Difference between revisions of "Cookbook/Compilers and interpreters"
< Cookbook
Jump to navigation
Jump to search
(first step to turn this page from an arbitrary tutorial to a cookbook chapter) |
|||
Line 10: | Line 10: | ||
Prelude> :t "Hello" |
Prelude> :t "Hello" |
||
"Hello" :: [Char] |
"Hello" :: [Char] |
||
− | </haskell> |
||
− | Haskell has the following types defined in the [[Prelude]]. |
||
− | <haskell> |
||
− | Int -- bounded, word-sized integers |
||
− | Integer -- unbounded integers |
||
− | Double -- floating point values |
||
− | Char -- characters |
||
− | String -- equivalent to [Char], strings are lists of characters |
||
− | () -- the unit type |
||
− | Bool -- booleans |
||
− | [a] -- lists |
||
− | (a,b) -- tuples / product types |
||
− | Either a b -- sum types |
||
− | Maybe a -- optional values |
||
</haskell> |
</haskell> |
Revision as of 08:11, 31 August 2009
GHC
GHCi
Checking Types
To check the type of an expression or function, use the command `:t'
Prelude> :t x
x :: Integer
Prelude> :t "Hello"
"Hello" :: [Char]