module Top.Types.Kinds where
import Top.Types.Primitive
import Top.Types.Substitution
import Top.Types.Quantification
import Top.Types.Schemes
type Kind = Tp
type Kinds = [Kind]
type KindScheme = TpScheme
star :: Kind
star = TCon "*"
defaultToStar :: Kind -> Kind
defaultToStar kind =
let sub = listToSubstitution [ (i, star) | i <- ftv kind ]
in sub |-> kind
showKind :: Kind -> String
showKind kind =
let sub = listToSubstitution [ (i, TCon ('k':show i)) | i <- ftv kind ]
in show (sub |-> kind)
showKindScheme :: KindScheme -> String
showKindScheme scheme =
let sub = listToSubstitution
$ [ (i, TCon ('k':show j)) | (i, j) <- zip (quantifiers scheme) [1 :: Int ..] ]
++ [ (i, TCon ("_k"++show i)) | i <- ftv scheme ]
in show (sub |-> unquantify scheme)