summaryrefslogtreecommitdiff
path: root/testsuite/tests/boxy/Base1.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/boxy/Base1.hs')
-rw-r--r--testsuite/tests/boxy/Base1.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/boxy/Base1.hs b/testsuite/tests/boxy/Base1.hs
new file mode 100644
index 0000000000..88e7e80f17
--- /dev/null
+++ b/testsuite/tests/boxy/Base1.hs
@@ -0,0 +1,30 @@
+{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags #-}
+
+module Base1 where
+-- basic examples of impredicative instantiation of variables
+
+data MEither a b = MLeft a
+ | MRight b
+ | MEmpty
+
+type Sid = forall a. a -> a
+
+-- no need for impredicativity
+test0 = MRight id
+
+-- requires impredicativity
+test1 :: Sid -> MEither Sid b
+test1 fid = MLeft fid
+
+test2 :: MEither b Sid -> Maybe (Sid,Sid)
+test2 m = case (test1 id) of
+ MLeft x -> case m of
+ MRight y -> Just (x,y)
+ _ -> Nothing
+ _ -> Nothing
+
+test3 :: MEither a b -> b
+test3 (MRight x) = x
+
+test4 = test3 (test1 id)
+