[Haskell-beginners] docstring equivalent

Stephen Tetley stephen.tetley at gmail.com
Tue Jun 29 02:48:21 EDT 2010


Hello Prad

The info command will give you details of a function - its type
signature and the module where it is defined, its fixity if it is an
infix function:

Prelude> :info length
length :: [a] -> Int    -- Defined in GHC.List

The shorthand is :i

Prelude> :i (>>=)
class Monad m where
  (>>=) :: m a -> (a -> m b) -> m b
  ...
        -- Defined in GHC.Base
infixl 1 >>=

For constructors, info will tell you which data type the constructor
belongs to and the module where it is defined:

Prelude> :i Just
data Maybe a = ... | Just a     -- Defined in Data.Maybe


There is no mechanism like docstring in Haskell though - the
information displayed by the info command is not customizable.

Best wishes

Stephen


More information about the Beginners mailing list