Hi Patrick,
I'm afraid that you've run into a problem that often catches newcomers
to Haskell. It isn't a bug in Hugs, but perhaps it should go in the FAQ.
There are a few typos in your code, but we don't actually need anything
more than the datatype to begin to understand what is going on:
| data Btree a = Null |
| Node a (Btree a ) (Btree a )
| deriving ( Eq , Show )
So now suppose that we try to print the Null binary tree in Hugs using
the derived Show, or that we try to compare Null with Null, using the
derived Eq. In each case we get an error message:
Main> Null
ERROR: Cannot find "show" function for:
*** Expression : Null
*** Of type : Btree a
Main> Null == Null
ERROR: Unresolved overloading
*** Type : Eq a => Bool
*** Expression : Null == Null
Main>
In general, of course, to print or compare Btree values, we need to
know how to print or compare their component types. In the case of
Null values, we can see that this information is not needed, but the
type system can't tell this because it doesn't distinguish Null from
any other values of the Btree type. In effect, the above error
messages are Hugs' way of saying "I know that you're using a value
of type Btree a, but I don't know which type you want me to use for a."
The way to fix this is to give Hugs the extra information that it
requires---by using a type annotation, for example:
Main> Null :: Btree ()
Null
Main> Null == (Null :: Btree ())
True
Main>
Fortunately, this kind of problem doesn't happen too often in
practice: for example, if one of the Null trees above is replaced
by a non-empty tree, then Hugs will see the elements that are stored
in the tree, and infer the desired type automatically.
Hope this helps,
Mark