Personal tools

Cookbook/Compilers and interpreters

From HaskellWiki

< Cookbook(Difference between revisions)
Jump to: navigation, search
(GHCi)
Line 14: Line 14:
 
| :i
 
| :i
 
|<haskell>
 
|<haskell>
Prelude> :i length
+
Prelude> :i Maybe
length :: [a] -> Int -- Defined in GHC.List
+
data Maybe a = Nothing | Just a -- Defined in Data.Maybe
  +
instance (Eq a) => Eq (Maybe a) -- Defined in Data.Maybe
  +
instance Monad Maybe -- Defined in Data.Maybe
  +
instance Functor Maybe -- Defined in Data.Maybe
  +
instance (Ord a) => Ord (Maybe a) -- Defined in Data.Maybe
  +
instance (Read a) => Read (Maybe a) -- Defined in GHC.Read
  +
instance (Show a) => Show (Maybe a) -- Defined in GHC.Show
 
</haskell>
 
</haskell>
 
|-
 
|-

Revision as of 08:27, 31 August 2009

1 GHC

TODO

2 GHCi

Problem Solution Examples
checking definitions  :i
Prelude> :i Maybe
data Maybe a = Nothing | Just a         -- Defined in Data.Maybe
instance (Eq a) => Eq (Maybe a) -- Defined in Data.Maybe
instance Monad Maybe -- Defined in Data.Maybe
instance Functor Maybe -- Defined in Data.Maybe
instance (Ord a) => Ord (Maybe a) -- Defined in Data.Maybe
instance (Read a) => Read (Maybe a) -- Defined in GHC.Read
instance (Show a) => Show (Maybe a) -- Defined in GHC.Show
checking types  :t
Prelude> :t "Hello"
"Hello" :: [Char]

3 Hugs

TODO