summaryrefslogtreecommitdiff
path: root/testsuite/tests/impredicative/Base1.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/impredicative/Base1.hs')
-rw-r--r--testsuite/tests/impredicative/Base1.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/impredicative/Base1.hs b/testsuite/tests/impredicative/Base1.hs
new file mode 100644
index 0000000000..5e3b377ee2
--- /dev/null
+++ b/testsuite/tests/impredicative/Base1.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE ImpredicativeTypes #-}
+
+-- Sept 16: now failing, because I've further reduced the scop
+-- of impredicative types
+
+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)
+