
11 Sep
2011
11 Sep
'11
12:21 p.m.
Hi, just for the sake of deepening my understanding of Haskell types, I'm looking for a way to define a data type, like list or tree, that takes arbitrary values as its content. In Java, I would write class Tree { Object node; Tree left; Tree right; } and that allows me to put Integers, Strings, or anything into the tree, since they all inherit from Object. How would I go about defining such a type in Haskell? I'm reading www.learnyouahasell.com and all of the examples use only a single type parameter as in data Tree a = Nil | Node a (Tree a) (Tree a) so you can't mix Integers and Strings for example. Alex