How can I view the definition of a function in Haskell/GHCi?

前端 未结 3 1706
清酒与你
清酒与你 2021-02-01 00:57

I\'m using Haskell 2010.1.0.0.1 with GHC 6. Typing :t at the GHCi prompt followed by the name of a function shows us the type of the function. Is there a way to vie

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 01:12

    I don't think so. You can use :i for a little bit more information (more useful for infix operators and data constructions, etc.), but not the definition:

    ghci> :i repeat
    repeat :: a -> [a]       -- Defined in GHC.List
    

    You can use hoogle to quickly find the documentation for a standard library function, which on the right has a link to go to the source. It's still a few clicks away though.

提交回复
热议问题