我可以从前奏中获得函数的来源:
lambdabot> src foldr
foldr f z [] = z
foldr f z (x:xs) = f x (foldr f z xs)
但我无法从其他模块获取源代码:
lambdabot> src flatten
Source not found. Maybe if you used more than just two fingers...
lambdabot> hoogle flatten
Data.Tree flatten :: Tree a -> [a]
Data.Graph flattenSCC :: SCC vertex -> [vertex]
Data.Graph flattenSCCs :: [SCC a] -> [a]
lambdabot> src Data.Tree flatten
Source not found. Just try something else.
lambdabot> src Data.Tree.flatten
Source not found. Have you considered trying to match wits with a rutabaga?
lambdabot> src Tree flatten
Source not found. And you call yourself a Rocket Scientist!
lambdabot> src Tree.flatten
Source not found. Just try something else.
我该怎么做?
答案 0 :(得分:2)
你真的不能这样做。 lambdabot使用一个充满name->源映射的硬连线文件;它不会以特别有原则的方式查找标识符的来源。
你可以做的最好的事情是ghci中的:i foo
以找出标识符来自哪个模块,然后查找该模块的来源(例如,使用Hoogle,通常链接到包含源链接的页面。)