ghc-7.4.2: The GHC API

Safe Haskell | None

Kind

Contents

- Main data type
  - Deconstructing Kinds
  - Predicates on Kinds
  - Functions on variables
  - Promotion related functions

Synopsis

- type Kind = Type
- typeKind :: Type -> Kind
- anyKind :: Kind
- liftedTypeKind :: Kind
- unliftedTypeKind :: Kind
- openTypeKind :: Kind
- argTypeKind :: Kind
- ubxTupleKind :: Kind
- constraintKind :: Kind
- mkArrowKind :: Kind -> Kind -> Kind
- mkArrowKinds :: [Kind] -> Kind -> Kind
- anyKindTyCon :: TyCon
- liftedTypeKindTyCon :: TyCon
- openTypeKindTyCon :: TyCon
- unliftedTypeKindTyCon :: TyCon
- argTypeKindTyCon :: TyCon
- ubxTupleKindTyCon :: TyCon
- constraintKindTyCon :: TyCon
- tySuperKind :: SuperKind
- tySuperKindTyCon :: TyCon
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- kindFunResult :: Kind -> KindOrType -> Kind
- kindAppResult :: 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
- isUbxTupleKind :: Kind -> Bool
- isArgTypeKind :: Kind -> Bool
- isConstraintKind :: Kind -> Bool
- isConstraintOrLiftedKind :: Kind -> Bool
- isKind :: Kind -> Bool
- isSuperKind :: Type -> Bool
- noHashInKind :: Kind -> Bool
- isLiftedTypeKindCon :: TyCon -> Bool
- isConstraintKindCon :: TyCon -> Bool
- isAnyKind :: Kind -> Bool
- isAnyKindCon :: TyCon -> Bool
- isSubArgTypeKind :: Kind -> Bool
- tcIsSubArgTypeKind :: Kind -> Bool
- isSubOpenTypeKind :: Kind -> Bool
- tcIsSubOpenTypeKind :: Kind -> Bool
- isSubKind :: Kind -> Kind -> Bool
- tcIsSubKind :: Kind -> Kind -> Bool
- defaultKind :: Kind -> Kind
- isSubKindCon :: TyCon -> TyCon -> Bool
- tcIsSubKindCon :: TyCon -> TyCon -> Bool
- isSubOpenTypeKindCon :: TyCon -> Bool
- isKiVar :: TyVar -> Bool
- splitKiTyVars :: [TyVar] -> ([KindVar], [TyVar])
- partitionKiTyVars :: [TyVar] -> ([KindVar], [TyVar])
- kiVarsOfKind :: Kind -> VarSet
- kiVarsOfKinds :: [Kind] -> VarSet
- promoteType :: Type -> Kind
- isPromotableType :: Type -> Bool
- isPromotableKind :: Kind -> Maybe Int

# Main data type

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

argTypeKind :: Kind

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

ubxTupleKind :: 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

argTypeKindTyCon :: TyCon

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

ubxTupleKindTyCon :: 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

tySuperKind :: SuperKind

tySuperKindTyCon :: TyCon

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

pprKind :: Kind -> SDoc

pprParendKind :: Kind -> SDoc

## Deconstructing Kinds

kindFunResult :: Kind -> KindOrType -> Kind

Essentially `funResultTy` on kinds handling pi-types too

kindAppResult :: 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

isUbxTupleKind :: Kind -> Bool

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

isArgTypeKind :: 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

isKind :: Kind -> Bool

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

isSuperKind :: Type -> Bool

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

noHashInKind :: Kind -> Bool

isLiftedTypeKindCon :: TyCon -> Bool

isConstraintKindCon :: TyCon -> Bool

isAnyKind :: Kind -> Bool

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

isAnyKindCon :: TyCon -> Bool

isSubArgTypeKind :: Kind -> Bool

True of any sub-kind of ArgTypeKind

tcIsSubArgTypeKind :: Kind -> Bool

True of any sub-kind of ArgTypeKind

isSubOpenTypeKind :: Kind -> Bool

True of any sub-kind of OpenTypeKind

True of any sub-kind of OpenTypeKind

tcIsSubOpenTypeKind :: Kind -> Bool

True of any sub-kind of OpenTypeKind

isSubKind :: Kind -> Kind -> Bool

tcIsSubKind :: Kind -> Kind -> Bool

defaultKind :: Kind -> Kind

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

isSubKindCon :: TyCon -> TyCon -> Bool

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

tcIsSubKindCon :: TyCon -> TyCon -> Bool

isSubOpenTypeKindCon :: TyCon -> Bool

## Functions on variables

isKiVar :: TyVar -> Bool

splitKiTyVars :: [TyVar] -> ([KindVar], [TyVar])

partitionKiTyVars :: [TyVar] -> ([KindVar], [TyVar])

kiVarsOfKind :: Kind -> VarSet

kiVarsOfKinds :: [Kind] -> VarSet

## Promotion related functions

promoteType :: Type -> Kind

Promotes a type to a kind. Assumes the argument is promotable.

isPromotableType :: Type -> Bool

isPromotableKind :: Kind -> Maybe Int