summaryrefslogtreecommitdiff
path: root/testsuite/tests/programs/fun_insts/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/programs/fun_insts/Main.hs')
-rw-r--r--testsuite/tests/programs/fun_insts/Main.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/programs/fun_insts/Main.hs b/testsuite/tests/programs/fun_insts/Main.hs
new file mode 100644
index 0000000000..fece8c9c47
--- /dev/null
+++ b/testsuite/tests/programs/fun_insts/Main.hs
@@ -0,0 +1,26 @@
+-- !!! Defines functions as an instance of Num
+
+module Main where
+
+instance (Eq a, Eq b) => Eq (a->b)
+
+
+instance Show (a->b) where
+ show f = "<<function>>"
+
+instance (Num a, Num b) => Num (a->b) where
+ f + g = \x -> f x + g x
+ negate f = \x -> - (f x)
+ f * g = \x -> f x * g x
+ fromInteger n = \x -> fromInteger n
+
+ss :: Float -> Float
+cc :: Float -> Float
+tt :: Float -> Float
+
+ss = sin * sin
+cc = cos * cos
+tt = ss + cc
+-- sin**2 + cos**2 = 1
+
+main = putStrLn ((show (tt 0.4))++ " "++(show (tt 1.652)))