Using Trees
and defining a new "Eq
" I'm getting an "Ambiguous class occurrence 'Eq' *** Could refer to: Hugs.Prelude.Eq Main.Eq".
I'm aware that I'm trying to add a new definition for the existing Eq-Class of the prelude, but I don't want to use import prelude hiding (Eq), because my new equality is using the "==" for numerical types. The Operator is called "=+", because it is not a real equality (which I think is already 'loaded' via deriving), but only a structural one.
data Tree = Nil | Node Int Tree Tree deriving (Eq, Ord, Show)
instance Eq Tree where
Nil =+ Nil = true
(Node a tl1 tr1) =+ (Node b tl2 tr2) = (a==b) && (tl1==tl2) && (tl1==tl2)
I'd be thankful for any suggestions.