Difference between revisions of "Type signature"

From HaskellWiki
Jump to: navigation, search
(short explanation)
 
(more links)
Line 3: Line 3:
 
inc :: Num a => a -> a
 
inc :: Num a => a -> a
 
</haskell>
 
</haskell>
that tells, what is the type of a variable.
+
that tells, what is the [[type]] of a [[variable]].
 
In the example <hask>inc</hask> is the variable and <hask>Num a => a -> a</hask> is its type,
 
In the example <hask>inc</hask> is the variable and <hask>Num a => a -> a</hask> is its type,
namely a function type.
+
namely a [[function]] type.
   
 
It is considered [[Type signatures as good style|good style]] to add a type signature to every [[top-level variable]].
 
It is considered [[Type signatures as good style|good style]] to add a type signature to every [[top-level variable]].

Revision as of 00:16, 30 December 2010

A type signature is a line like

inc :: Num a => a -> a

that tells, what is the type of a variable. In the example inc is the variable and Num a => a -> a is its type, namely a function type.

It is considered good style to add a type signature to every top-level variable.

References