summaryrefslogtreecommitdiff
path: root/testsuite/tests/gadt/tdpe.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/gadt/tdpe.hs')
-rw-r--r--testsuite/tests/gadt/tdpe.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/tdpe.hs b/testsuite/tests/gadt/tdpe.hs
new file mode 100644
index 0000000000..58a4b85094
--- /dev/null
+++ b/testsuite/tests/gadt/tdpe.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE GADTs #-}
+
+module Tdpe where
+
+data Type t where
+ TBase :: Type Base
+ TFun :: Type a -> Type b -> Type (a -> b)
+
+b :: Type Base
+b = TBase
+
+newtype Base = In { out :: Term Base }
+
+data Term t where
+ App :: Term (a->b) -> Term a -> Term b
+ Fun :: (Term a -> Term b) -> Term (a->b)
+
+reify :: Type t -> t -> Term t
+reify (TBase) v = out v
+reify (TFun a b) v = Fun (\x -> reify b (v (reflect a x)))
+
+reflect :: Type t -> Term t -> t
+reflect (TBase) e = In e
+reflect (TFun a b) e = \x -> reflect b (App e (reify a x))