Am 05.04.2012 um 08:42 schrieb Brandon Allbery: > On Thu, Apr 5, 2012 at 01:53, Sutherland, Julian > <julian.sutherlan...@imperial.ac.uk> wrote: > data Tree = Node Left Right | Leaf > > Could be converted to a struct in C/C++: > > struct Tree { > struct Tree* left; > struct Tree* right; > }; > > Shouldn't this actually be a tagged union? Not that they exist as such in > C/C++, but are easy enough to emulate (minus the extra type checking that > real tagged unions such as even Pascal gives you):
Not necessarily. The above type is equivalent to type Tree = Maybe (Left, Right) (modulo strictness, of course) and the C/C++ convention is to represent Nothing by a NULL pointer. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe