summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc088.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/tc088.hs')
-rw-r--r--testsuite/tests/typecheck/should_compile/tc088.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/tc088.hs b/testsuite/tests/typecheck/should_compile/tc088.hs
new file mode 100644
index 0000000000..05faeae482
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/tc088.hs
@@ -0,0 +1,19 @@
+-- Check that "->" is an instance of Eval
+
+module ShouldSucceed where
+
+instance Show (a->b)
+
+instance (Eq b) => Eq (a -> b) where
+ (==) f g = error "attempt to compare functions"
+
+ -- Since Eval is a superclass of Num this fails
+ -- unless -> is an instance of Eval
+instance (Num b) => Num (a -> b) where
+ f + g = \a -> f a + g a
+ f - g = \a -> f a - g a
+ f * g = \a -> f a * g a
+ negate f = \a -> negate (f a)
+ abs f = \a -> abs (f a)
+ signum f = \a -> signum (f a)
+ fromInteger n = \a -> fromInteger n