[project @ 1999-06-09 09:35:54 by simonpj]
[ghc-hetmet.git] / ghc / tests / typecheck / should_compile / tc088.hs
1 -- Check that "->" is an instance of Eval
2
3 module ShouldSucceed where
4
5 instance Show (a->b)
6
7 instance (Eq b) => Eq (a -> b) where
8         (==) f g = error "attempt to compare functions"
9
10         -- Since Eval is a superclass of Num this fails 
11         -- unless -> is an instance of Eval
12 instance (Num b) => Num (a -> b) where
13     f + g                     =  \a -> f a + g a
14     f - g                     =  \a -> f a - g a
15     f * g                     =  \a -> f a * g a
16     negate f                  =  \a -> negate (f a)
17     abs f                     =  \a -> abs (f a)
18     signum f                  =  \a -> signum (f a)
19     fromInteger n             =  \a -> fromInteger n
20     fromInt n                 =  \a -> fromInt n