[Haskell-cafe] A Foldable binary search tree
brad.larsen at gmail.com
Sun Dec 23 10:38:17 EST 2007
On Sun, 23 Dec 2007 06:42:52 -0500, Neil Mitchell <ndmitchell at gmail.com>
> Hi Brad,
>> > 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.
>> With the class context in the BST definition, ghc gives no complaints
>> I evaluate "Empty":
> In some circumstances, you need to give a type sig. For example using
> Main> Empty
> ERROR - Cannot find "show" function for:
> *** Expression : Empty
> *** Of type : BST a
> I guess GHC has enough defaulting to display this anyway.
Sorry, forgot to mention that my BST derives Show.
> You'll also have the dreaded-evil-horrid monomorhpism restriction if you
> empty = Empty
More stuff for me to read about :-)
More information about the Haskell-Cafe