1 -- Check that "->" is an instance of Eval
3 module ShouldSucceed where
4 import Int( Num(fromInt) )
8 instance (Eq b) => Eq (a -> b) where
9 (==) f g = error "attempt to compare functions"
11 -- Since Eval is a superclass of Num this fails
12 -- unless -> is an instance of Eval
13 instance (Num b) => Num (a -> b) where
14 f + g = \a -> f a + g a
15 f - g = \a -> f a - g a
16 f * g = \a -> f a * g a
17 negate f = \a -> negate (f a)
18 abs f = \a -> abs (f a)
19 signum f = \a -> signum (f a)
20 fromInteger n = \a -> fromInteger n
21 fromInt n = \a -> fromInt n