summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/TF_GADT.hs
blob: cdb397c60334e125359e5c32a99702c158a73316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE GADTs, TypeFamilies #-}

module TF_GADT where

-- Check that type families can be declared in GADT syntax
-- and indeed *be* GADTs

data family T a

data instance T [a] where
  T1 :: a -> T [a]


data instance T (Maybe a) where
  T3 :: Int -> T (Maybe Int)
  T4 :: a -> b -> T (Maybe (a,b))


f :: a -> T (Maybe a) -> T (Maybe a)
f x (T3 i) = T3 x
f x (T4 p q) = T4 p (snd x)