"Justin Bailey" <[EMAIL PROTECTED]> writes: > I'm reading Chris Okasaki's "Purely Functional Data Structures", and some > of his Haskell is confusing me. He defines the type Color and RedBlackSet > as: > > data Color = R | B > data RedBlackSet a = E | T Color (RedBlackSet a) a (RedBlackSet a) > > and then later he defines a function insertSet: > > insertSet x s = T B a y b > where ins E = T R E x E > ... > T _ a y b = ins s > > What I don't understand is his use of the "T" constructor, both at > > insertSet x s = T B a y b
Here it creates a new RedBlackSet > and in the where statement: > > T _ a y b = ins s Here it's a pattern match. So if ins s returns (T x a' y' b'), then a = a'; y = y'; b = b' are used in the expresion covered by the where clause. -- Jón Fairbairn [EMAIL PROTECTED] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe