diff options
Diffstat (limited to 'testsuite/tests/indexed-types/should_compile/T2219.hs')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/T2219.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T2219.hs b/testsuite/tests/indexed-types/should_compile/T2219.hs new file mode 100644 index 0000000000..ea7d442f74 --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T2219.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TypeFamilies, GADTs, EmptyDataDecls, TypeOperators #-} + +module Test where + +data Zero +data Succ a + +data FZ +data FS fn + +data Fin n fn where + FZ :: Fin (Succ n) FZ + FS :: Fin n fn -> Fin (Succ n) (FS fn) + +data Nil +data a ::: b + +type family Lookup ts fn :: * +type instance Lookup (t ::: ts) FZ = t +type instance Lookup (t ::: ts) (FS fn) = Lookup ts fn + +data Tuple n ts where + Nil :: Tuple Zero Nil + (:::) :: t -> Tuple n ts -> Tuple (Succ n) (t ::: ts) + +proj :: Fin n fn -> Tuple n ts -> Lookup ts fn +proj FZ (v ::: _) = v +proj (FS fn) (_ ::: vs) = proj fn vs |