22 Dec
2007
22 Dec
'07
10:41 p.m.
Hi
data (Ord a) => BST a = Empty | BST (BST a) a (BST a)
Experience has taught me to _never_ put class contexts on data definitions. Now you can't write something as simple as "Empty" - you have to give it a class context. This is just plain annoying. I would accept this pain if it meant I could write: insert :: a -> BST a -> BST a and have the Ord silently inserted - but you can't. You still have to write the Ord a => explicitly. As a result, I see no advantage to adding the class constraint, and plenty of disadvantages. If there are some advantages to this context I would be interested to know what they are. Thanks Neil