【问题标题】:Is there any method to get the information of a module in Haskell?有什么方法可以获取 Haskell 中模块的信息吗?
【发布时间】:2019-01-11 18:37:47
【问题描述】:
module FAM where

我不知道 FAM 是做什么的。所以我想得到一些关于它的信息。

通过:t:i,我们将分别得到变量的类型和实例的信息。有什么方法可以获取模块的信息吗?

【问题讨论】:

  • 尝试:浏览 FAM
  • 我收到了一条错误消息Could not find module ‘FAM’ It is not a module in the current program, or in any known package. 我也尝试了:browse Data。并且也遇到了同样的错误。
  • 这个 FAM 模块在哪里?它是一个独立的文件吗?在阴谋集团的包裹中?我会尝试编译它并首先加载 GHCi。我也会尝试生成黑线鳕文档。
  • 来自我的lecture

标签: haskell module


【解决方案1】:

模块没有类型,它只是导出声明。如果您想查看它导出的声明(以不同于单击已有链接的方式),请在 GHCi 中加载该模块并浏览它。

例如,我将您的 FAM 模块保存在我的 tmp 目录中,以便我可以在 GHCi 中加载它:

% ghci /tmp/FAM.hs
GHCi, version 8.4.1: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/tommd/.ghci
[1 of 1] Compiling FAM              ( /tmp/FAM.hs, interpreted )
Ok, one module loaded.
*FAM>

现在我可以通过浏览请求模块导出的声明,或者将模块保留为隐式 (:browse) 或指定我感兴趣的模块 (:browse FAM),这在加载多个模块时很有用.例如:

*FAM> :browse FAM
fmap_List :: (a -> b) -> [a] -> [b]
fmap_Maybe :: (a -> b) -> Maybe a -> Maybe b
fmap_Either :: (a -> b) -> Either e a -> Either e b
data BinTree a = BTNil | BTNode a (BinTree a) (BinTree a)
map2_List :: (a -> b -> c) -> [a] -> [b] -> [c]
map2_Maybe :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c
map2_Either ::
  (a -> b -> c) -> Either e a -> Either e b -> Either e c
ap_List :: [a -> b] -> [a] -> [b]
map2_Listv2 :: (a -> b -> c) -> [a] -> [b] -> [c]
map3_List :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
addRecip :: Double -> Double -> Maybe Double
bind_Maybe :: Maybe a -> (a -> Maybe b) -> Maybe b
bind_Either :: Either e a -> (a -> Either e b) -> Either e b
bind_List :: [a] -> (a -> [b]) -> [b]
data IntranetRecord = I Integer String
data BBRecord = B Integer String
data MarkUsRecord = M String String
myJoin :: [IntranetRecord] -> [BBRecord] -> [MarkUsRecord]
myJoin2 :: [IntranetRecord] -> [BBRecord] -> [MarkUsRecord]
foldM :: Monad m => (b -> a -> m b) -> b -> [a] -> m b
newtype State s a = StateOf (s -> (s, a))
deState :: State s a -> s -> (s, a)
put :: s -> State s ()
get :: State s s
statefulSum :: [Integer] -> State Integer Integer
toyCheck :: IO Bool
class Monad f => MonadToyCheck (f :: * -> *) where
  toyGetChar :: f Char
  {-# MINIMAL toyGetChar #-}
toyCheck2 :: MonadToyCheck f => f Bool
realProgram :: IO Bool
newtype Feeder a = F (String -> (String, a))
unF :: Feeder a -> String -> (String, a)
testToyChecker2 :: String -> Bool

从这里您可以检查模块导出的类型、类和函数。

【讨论】:

    猜你喜欢
    • 2013-03-26
    • 1970-01-01
    • 2013-10-25
    • 2021-01-27
    • 2019-10-06
    • 2020-08-17
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    相关资源
    最近更新 更多