summaryrefslogtreecommitdiff
path: root/testsuite/tests/impredicative/Compose.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/impredicative/Compose.hs')
-rw-r--r--testsuite/tests/impredicative/Compose.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/impredicative/Compose.hs b/testsuite/tests/impredicative/Compose.hs
new file mode 100644
index 0000000000..f3d3a10b28
--- /dev/null
+++ b/testsuite/tests/impredicative/Compose.hs
@@ -0,0 +1,26 @@
+{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags -XEmptyDataDecls -XGADTs #-}
+
+-- #1118
+
+module Compose where
+
+data Z
+data S n
+
+data List n a where
+ Nil :: List Z a
+ (:-) :: a -> List n a -> List (S n) a
+
+data Hold a = Hold (forall m . a m -> a (S m))
+
+compose' :: List n (Hold a) -> a (S Z) -> a (S n)
+compose' Nil x = x
+compose' ((Hold f) :- fs) x = f (compose' fs x)
+
+compose :: List n (forall m . a m -> a (S m)) -> a (S Z) -> a (S n)
+compose Nil x = x
+compose (f :- fs) x = f (compose fs x)
+
+composeS :: [forall m . a m -> a m] -> a n -> a n
+composeS [] x = x
+composeS (f:fs) x = f (composeS fs x)