[Haskell-cafe] AbstractDataType question

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun Dec 12 17:25:00 EST 2004


On Sun, Dec 12, 2004 at 07:46:42PM +0100, Sebastian Sylvan wrote:
> > Could someone point me to some documentation on whats being created here
> > and how its used?
> 
> It's basically a shorthand for writing accessor functions.
> 
> You could do something like:
> data Tree a = Nil | Node (Tree a) a (Tree a)
> left (Node l _ _) = l
> value (Node _ v _) = v
> right (Node _ _ r) = r

Record field labels can be also used in pattern matching and in
record update. Especially the latter is very useful. For more
information, see The Haskell 98 Report.

Best regards,
Tomasz


More information about the Haskell-Cafe mailing list