[project @ 2000-01-10 11:08:04 by simonmar]
[ghc-hetmet.git] / ghc / tests / typecheck / should_compile / tc088.hs
1 -- Check that "->" is an instance of Eval
2
3 module ShouldSucceed where
4 import Int( Num(fromInt) )
5
6 instance Show (a->b)
7
8 instance (Eq b) => Eq (a -> b) where
9         (==) f g = error "attempt to compare functions"
10
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