diff options
Diffstat (limited to 'testsuite/tests/boxy/Compose.hs')
-rw-r--r-- | testsuite/tests/boxy/Compose.hs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/boxy/Compose.hs b/testsuite/tests/boxy/Compose.hs new file mode 100644 index 0000000000..0caa84cbe1 --- /dev/null +++ b/testsuite/tests/boxy/Compose.hs @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags -XEmptyDataDecls -XGADTs #-} + +-- Trac #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) |