2 From: Marc van Dongen <dongen@cs.ucc.ie>
3 Date: Sat, 31 May 1997 19:57:46 +0100 (BST)
5 panic! (the `impossible' happened):
8 Please report it as a compiler bug to glasgow-haskell-bugs@dcs.gla.ac.uk.
11 If the instance definition for (*) at the end of this toy module
12 is replaced by the definition that is commented, this all compiles
13 fine. Strange, because the two implementations are equivalent modulo
14 the theory {(*) = multiply}.
16 Remove the `multiply :: a -> a -> a' part, and it compiles without
20 SPJ note: the type signature on "multiply" should be
21 multiply :: Group a => a -> a -> a
25 module ShouldSucceed( Group, Ring ) where
27 import qualified Prelude( Ord(..), Eq(..), Num(..) )
28 import Prelude hiding( Ord(..), Eq(..), Num(..), MonadZero( zero ) )
31 compare :: a -> a -> Prelude.Ordering
32 fromInteger :: Integer -> a
40 -- class (Group a) => Ring a where
43 -- case (compare a zero) of
45 -- LT -> zero - ((*) (zero - a) b)
46 -- GT -> case compare a one of
48 -- _ -> b + ((*) (a - one) b)
50 class (Group a) => Ring a where
52 (*) a b = multiply a b
53 where multiply :: Group a => a -> a ->a
55 = case (compare a zero) of
57 LT -> zero - (multiply (zero - a) b)
58 GT -> case compare a one of
60 _ -> b + (multiply (a - one) b)