haskell - 有什么方法可以获取 Haskell 中模块的信息吗?
问题描述
module FAM where
我不知道 FAM 是做什么的。所以我想得到一些关于它的信息。
通过:t
和:i
,我们将分别得到变量的类型和实例的信息。有什么方法可以获取模块的信息吗?
解决方案
模块没有类型,它只是导出声明。如果您想查看它导出的声明(以不同于单击已有链接的方式),则在 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
从这里您可以检查模块导出的类型、类和函数。
推荐阅读
- python-3.x - 你如何使用 Selenium Python 并让它遍历网页中需要的每个选择标签,然后总是选择 [1] 或第一个选项?
- .net - 如何通过 API 获取 nuget 包元数据?
- c# - xamarin 表单条目的千位分隔符格式化程序
- c# - 如何让二维数组在 C# 中对齐?
- python - 如何用盐检查密码()?
- arrays - 动态数组中的删除操作
- javascript - 我将如何打开一个在打开时不聚焦的新窗口
- c# - 取消关闭窗口的任务。如何检测任务是否同步返回?
- html - 如何使用 PrimeNG 在标题中显示保存的过滤器?
- typo3-8.x - TYPO3 表 tx_realurl_pathcache 不存在