[Haskell-cafe] AbstractDataType question

Sebastian Sylvan sebastian.sylvan at gmail.com
Sun Dec 12 13:46:42 EST 2004


On Sun, 12 Dec 2004 13:08:30 -0500, Jason Bailey <azrael at demonlords.net> wrote:
> 
> So in the wiki on AbstractDataType (
> http://haskell.org/hawiki/AbstractDataType )
> 
> it gives the following example:
> 
> data Tree a = Nil
>             | Node { left  :: Tree a,
>                      value :: a,
>                      right :: Tree a }
> 
> The part where I am confused is with the use of '{' and '}' my reference
> book is apparently out of date as it states that Haskell doesn't even
> use those characters :)
> 
> 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


/S
-- 
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862


More information about the Haskell-Cafe mailing list