[Haskell-cafe] definition of data

Adrian Neumann aneumann at inf.fu-berlin.de
Thu Jan 1 02:37:30 EST 2009


You need some type constructor:

data Tree a = Leaf a | Branch (Tree a) (Tree a)

Am 01.01.2009 um 08:32 schrieb Max.cs:

> hi all, I want to define a data type Tree a that can either be  a   
> or Branch (Tree a) (Tree a)?
>
> I tried
>
> data Tree a = a | Branch (Tree a) (Tree a) deriving Show
>
> but it seems not accpetable in haskell ?
>
> any way I could achieve this ?
>
> Thanks
>
> max
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: Signierter Teil der Nachricht
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090101/f8acc911/PGP.bin


More information about the Haskell-Cafe mailing list