[project @ 1999-06-09 09:35:54 by simonpj]
[ghc-hetmet.git] / ghc / tests / programs / fun_insts / Main.hs
1 -- !!! Defines functions as an instance of Num
2
3 module Main where
4
5 instance (Eq a, Eq b) => Eq (a->b)
6  
7
8 instance Show (a->b) where
9   show f = "<<function>>"
10
11 instance (Num a, Num b) => Num (a->b) where
12     f + g    = \x -> f x + g x
13     negate f = \x -> - (f x)
14     f * g    = \x -> f x * g x
15     fromInteger n = \x -> fromInteger n
16
17 ss :: Float -> Float
18 cc :: Float -> Float
19 tt :: Float -> Float
20
21 ss = sin * sin
22 cc = cos * cos
23 tt = ss + cc
24 -- sin**2 + cos**2 = 1
25
26 main = putStrLn ((show (tt 0.4))++ "  "++(show (tt 1.652)))