Is it possible to get Haskell Documentation from Terminal or from ghci?
In Ruby I usually do
ri thefunc
In Perl I usually do
perldoc -f thefunc
Or I can get interactive help in Python.
How to do this kind of thing in Haskell? For example, if I want to get Documentation about [] or : on Terminal?
Update
I found this related thread, but I’m not sure if :i is the answer :-/ or is it?
*Main> :i []
data [] a = [] | a : [a] -- Defined in GHC.Types
instance (Eq a) => Eq [a] -- Defined in GHC.Base
instance Monad [] -- Defined in GHC.Base
instance Functor [] -- Defined in GHC.Base
instance (Ord a) => Ord [a] -- Defined in GHC.Base
instance (Read a) => Read [a] -- Defined in GHC.Read
instance (Show a) => Show [a] -- Defined in GHC.Show
What you want is called Hoogle. It’s actually quite a bit cooler than most command-line doc tools, as it can look up functions by name or by type, and is pretty clever at working out types that are compatible but not exactly what you specified (e.g. you might search for
a -> [a]and it will figure out that you might want a function with the type(Monad m) => a -> m a, the type you searched for is the same thing with the typeclass filled in).