when loading the following code, hugs escaped and reported that

ERROR "cal24.hs":10 - Instance of Integral (Ratio Integer) required for definition of Main.eval

I don't know why and how to solve it, anyone help me?

data ETree = Add ETree ETree
           | Sub ETree ETree
           | Mul ETree ETree
           | Div ETree ETree
           | Node Integer
           deriving Show

eval :: ETree->Maybe Rational
eval (Node x)    = Just (fromInteger x)
eval (Add t1 t2) = do { x<-eval t1; y<-eval t2;
                        if x>=y then return (x+y) else Nothing }
eval (Sub t1 t2) = do { x<-eval t1; y<-eval t2; return (x-y) }
eval (Mul t1 t2) = do { x<-eval t1; y<-eval t2;
                        if x>=y then return (x*y) else Nothing }
eval (Div t1 t2) = do { x<-eval t1; y<-eval t2;
                        if y/=0 then return (x `div` y) else Nothing }

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to