yet another very simple overlapping instance example

2003-06-25 Thread Razvan Musaloiu-E.
Hi! Can somebody explain to me why ghc/hugs fails to compile the following Haskell program? As long as MyInt is not an instance of Num the compilations should succed... but it don't. :-( Why? $ cat multi.hs data MyInt = MyInt Int deriving Show class Op_plus a b where plus :: a - b - Int

Re: yet another very simple overlapping instance example

2003-06-25 Thread Razvan Musaloiu-E.
Hi! Koen Claessen wrote: | instance (Num a) = Op_plus a MyInt where | i `plus` (MyInt b) = i + b Remember that b is of type Int, but you also say that i is of any Num type. This clashes, since + requires both if its arguments to hve the same types. You are right! I did't notice that error.

Re: yet another very simple overlapping instance example

2003-06-25 Thread Razvan Musaloiu-E.
Hi! Keith Wansbrough wrote: instance Op_plus MyInt MyInt where instance (Num a) = Op_plus a MyInt where instance (Num a) = Op_plus MyInt a where [..] Overlapping instance declarations: multi.hs:9: Op_plus a MyInt multi.hs:12: Op_plus MyInt a Failed, modules loaded: none. The GHC manual talks