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