1{-# LANGUAGE RankNTypes #-} 2 3data Empty 4data NonEmpty 5 6data SafeList x y where 7 Nil :: SafeList x Empty 8 Cons:: Eq x => x -> SafeList x y -> SafeList x NonEmpty 9 One :: Eq x => x -> SafeList x Empty -> SafeList x NonEmpty 10 11safeHead :: SafeList x NonEmpty -> x 12safeHead (Cons x _) = x 13 14foo = Cons 3 (Cons 6 (Cons 9 Nil)) 15 16 17data Dict x where 18 DictN :: Num x => x -> Dict x 19 DictE :: Eq x => x -> Dict x 20 21data Exist where 22 Exist :: forall a. a -> Exist 23