首页 > 解决方案 > 有什么方法可以获取 Haskell 中模块的信息吗?

问题描述

module FAM where

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

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

标签: haskellmodule

解决方案


模块没有类型,它只是导出声明。如果您想查看它导出的声明(以不同于单击已有链接的方式),则在 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

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


推荐阅读