1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | {-#LANGUAGE GADTs, DataKinds, PolyKinds, KindSignatures, StandaloneDeriving #-} data Natural = Zero | Succ Natural deriving (Show,Eq,Ord) data List el len where Nil :: List el Zero Cons :: el -> List el len -> List el (Succ len) deriving instance Show el => Show (List el len) class HasLength f where len :: f n -> Natural -- class HasLength (f :: Natural -> *) where len :: f n -> Natural instance HasLength (List el) where len Nil = Zero len (Cons _ xs) = Succ (len xs) -- If I use the narrow kind signature I get -- the opposite 'kind mismatch' with this of course: instance HasLength [] where len [] = Zero len (x:xs) = Succ (len xs) -- as it stands, ghc-7.6 infers -- > :k HasLength :: (k -> *) -> Constraint -- ghc-7.4 infers thus: -- *Main> :k HasLength -- HasLength :: (AnyK -> *) -> Constraint |
1:1: Error: Unused LANGUAGE pragma
Found:
{-# LANGUAGE GADTs, DataKinds, PolyKinds, KindSignatures,
StandaloneDeriving #-}
Why not:
{-# LANGUAGE GADTs, DataKinds, PolyKinds, StandaloneDeriving #-}