summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc084.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/tc084.hs')
-rw-r--r--testsuite/tests/typecheck/should_compile/tc084.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/tc084.hs b/testsuite/tests/typecheck/should_compile/tc084.hs
new file mode 100644
index 0000000000..597a296f90
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/tc084.hs
@@ -0,0 +1,23 @@
+{- This program shows up a bug in the handling of
+ the monomorphism restriction in an earlier version of
+ ghc. With ghc 0.18 and before, f gets a type with
+ an unbound type variable, which shows up in the
+ interface file. Reason: it was being monomorphised.
+
+ Simon PJ
+-}
+
+module ShouldSucceed where
+
+
+g :: Num a => Bool -> a -> b -> a
+g b x y = if b then x+x else x-x
+
+-- Everything is ok if this signature is put in
+-- but the program should be perfectly legal without it.
+-- f :: Num a => a -> b -> a
+f = g True
+
+h y x = f (x::Int) y
+ -- This use of f binds the overloaded monomorphic
+ -- type to Int