Kind

ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Kind

Contents

- Main data type
  - Deconstructing Kinds
  - Predicates on Kinds
  - Functions on variables

Synopsis

- type SuperKind = Type
- type Kind = Type
- typeKind :: Type -> Kind
- anyKind :: Kind
- liftedTypeKind :: Kind
- unliftedTypeKind :: Kind
- openTypeKind :: Kind
- constraintKind :: Kind
- mkArrowKind :: Kind -> Kind -> Kind
- mkArrowKinds :: [Kind] -> Kind -> Kind
- anyKindTyCon :: TyCon
- liftedTypeKindTyCon :: TyCon
- openTypeKindTyCon :: TyCon
- unliftedTypeKindTyCon :: TyCon
- constraintKindTyCon :: TyCon
- superKind :: Kind
- superKindTyCon :: TyCon
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- kindAppResult :: SDoc -> Kind -> [Type] -> Kind
- synTyConResKind :: TyCon -> Kind
- splitKindFunTys :: Kind -> ([Kind], Kind)
- splitKindFunTysN :: Int -> Kind -> ([Kind], Kind)
- splitKindFunTy_maybe :: Kind -> Maybe (Kind, Kind)
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- isOpenTypeKind :: Kind -> Bool
- isConstraintKind :: Kind -> Bool
- isConstraintOrLiftedKind :: Kind -> Bool
- returnsConstraintKind :: Kind -> Bool
- isKind :: Kind -> Bool
- isKindVar :: Var -> Bool
- isSuperKind :: Type -> Bool
- isSuperKindTyCon :: TyCon -> Bool
- isLiftedTypeKindCon :: TyCon -> Bool
- isConstraintKindCon :: TyCon -> Bool
- isAnyKind :: Kind -> Bool
- isAnyKindCon :: TyCon -> Bool
- okArrowArgKind :: Kind -> Bool
- okArrowResultKind :: Kind -> Bool
- isSubOpenTypeKind :: Kind -> Bool
- isSubOpenTypeKindKey :: Unique -> Bool
- isSubKind :: Kind -> Kind -> Bool
- isSubKindCon :: TyCon -> TyCon -> Bool
- tcIsSubKind :: Kind -> Kind -> Bool
- tcIsSubKindCon :: TyCon -> TyCon -> Bool
- defaultKind :: Kind -> Kind
- defaultKind_maybe :: Kind -> Maybe Kind
- kiVarsOfKind :: Kind -> VarSet
- kiVarsOfKinds :: [Kind] -> VarSet

# Main data type

type SuperKind = Type

"Super kinds", used to help encode `Kind`s as types. Invariant: a super kind is always of this form:

    TyConApp SuperKindTyCon ...

type Kind = Type

The key type representing kinds in the compiler. Invariant: a kind is always in one of these forms:

    FunTy k1 k2
    TyConApp PrimTyCon [...]
    TyVar kv   -- (during inference only)
    ForAll ... -- (for top-level coercions)

typeKind :: Type -> Kind

anyKind :: Kind

See Type for details of the distinction between these `Kind`s

liftedTypeKind :: Kind

See Type for details of the distinction between these `Kind`s

unliftedTypeKind :: Kind

See Type for details of the distinction between these `Kind`s

openTypeKind :: Kind

See Type for details of the distinction between these `Kind`s

constraintKind :: Kind

See Type for details of the distinction between these `Kind`s

mkArrowKind :: Kind -> Kind -> Kind

Given two kinds `k1` and `k2`, creates the `Kind` `k1 -> k2`

mkArrowKinds :: [Kind] -> Kind -> Kind

Iterated application of `mkArrowKind`

anyKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

liftedTypeKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

openTypeKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

unliftedTypeKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

constraintKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

superKind :: Kind

See Type for details of the distinction between these `Kind`s

superKindTyCon :: TyCon

See Type for details of the distinction between the `Kind` `TyCon`s

pprKind :: Kind -> SDoc

pprParendKind :: Kind -> SDoc

## Deconstructing Kinds

kindAppResult :: SDoc -> Kind -> [Type] -> Kind

synTyConResKind :: TyCon -> Kind

Find the result `Kind` of a type synonym, after applying it to its `arity` number of type variables Actually this function works fine on data types too, but they'd always return `*`, so we never need to ask

splitKindFunTys :: Kind -> ([Kind], Kind)

Essentially `splitFunTys` on kinds

splitKindFunTysN :: Int -> Kind -> ([Kind], Kind)

Essentially `splitFunTysN` on kinds

splitKindFunTy_maybe :: Kind -> Maybe (Kind, Kind)

## Predicates on Kinds

isLiftedTypeKind :: Kind -> Bool

isUnliftedTypeKind :: Kind -> Bool

See Type for details of the distinction between these `Kind`s

isOpenTypeKind :: Kind -> Bool

See Type for details of the distinction between these `Kind`s

isConstraintKind :: Kind -> Bool

See Type for details of the distinction between these `Kind`s

isConstraintOrLiftedKind :: Kind -> Bool

See Type for details of the distinction between these `Kind`s

returnsConstraintKind :: Kind -> Bool

isKind :: Kind -> Bool

Is this a kind (i.e. a type-of-types)?

isKindVar :: Var -> Bool

isSuperKind :: Type -> Bool

Is this a super-kind (i.e. a type-of-kinds)?

isSuperKindTyCon :: TyCon -> Bool

isLiftedTypeKindCon :: TyCon -> Bool

isConstraintKindCon :: TyCon -> Bool

isAnyKind :: Kind -> Bool

See Type for details of the distinction between these `Kind`s

isAnyKindCon :: TyCon -> Bool

okArrowArgKind :: Kind -> Bool

okArrowResultKind :: Kind -> Bool

isSubOpenTypeKind :: Kind -> Bool

True of any sub-kind of OpenTypeKind

isSubOpenTypeKindKey :: Unique -> Bool

isSubKind :: Kind -> Kind -> Bool

`k1 `isSubKind` k2` checks that `k1` <: `k2` Sub-kinding is extremely simple and does not look under arrrows or type constructors

isSubKindCon :: TyCon -> TyCon -> Bool

`kc1 `isSubKindCon` kc2` checks that `kc1` <: `kc2`

tcIsSubKind :: Kind -> Kind -> Bool

tcIsSubKindCon :: TyCon -> TyCon -> Bool

defaultKind :: Kind -> Kind

defaultKind_maybe :: Kind -> Maybe Kind

Used when generalising: default OpenKind and ArgKind to *. See Type for more information on what that means

## Functions on variables

kiVarsOfKind :: Kind -> VarSet

kiVarsOfKinds :: [Kind] -> VarSet