[project @ 1999-01-23 18:07:42 by sof]
[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 (Num a, Num b) => Num (a->b) where
9     f + g    = \x -> f x + g x
10     negate f = \x -> - (f x)
11     f * g    = \x -> f x * g x
12     fromInteger n = \x -> fromInteger n
13
14 ss :: Float -> Float
15 cc :: Float -> Float
16 tt :: Float -> Float
17
18 ss = sin * sin
19 cc = cos * cos
20 tt = ss + cc
21 -- sin**2 + cos**2 = 1
22
23 main = putStrLn ((show (tt 0.4))++ "  "++(show (tt 1.652)))