GADT.hs 465 Bytes
Newer Older
1 2 3 4 5
data Empty
data NonEmpty

data SafeList x y where
     Nil :: SafeList x Empty
mnislaih's avatar
mnislaih committed
6 7
     Cons:: Eq x => x -> SafeList x y  -> SafeList x NonEmpty
     One :: Eq x => x -> SafeList x Empty -> SafeList x NonEmpty
8 9 10 11

safeHead :: SafeList x NonEmpty -> x
safeHead (Cons x _) = x

12
foo = Cons (3 :: Int) (Cons 6 (Cons 9 Nil))
13 14


mnislaih's avatar
mnislaih committed
15 16 17 18
data Dict x where
        DictN :: Num x => x -> Dict x
        DictE :: Eq x =>  x -> Dict x

19
data Exist where
20
        Exist :: forall a. a -> Exist