Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data TyThing
- tyThingCategory :: TyThing -> String
- pprTyThingCategory :: TyThing -> SDoc
- pprShortTyThing :: TyThing -> SDoc
- data Type
- = TyVarTy Var
- | AppTy Type Type
- | TyConApp TyCon [KindOrType]
- | ForAllTy !TyCoVarBinder Type
- | FunTy { }
- | LitTy TyLit
- | CastTy Type KindCoercion
- | CoercionTy Coercion
- data TyLit
- type KindOrType = Type
- type Kind = Type
- type KnotTied ty = ty
- type PredType = Type
- type ThetaType = [PredType]
- data ArgFlag
- data AnonArgFlag
- data ForallVisFlag
- data Coercion
- = Refl Type
- | GRefl Role Type MCoercionN
- | TyConAppCo Role TyCon [Coercion]
- | AppCo Coercion CoercionN
- | ForAllCo TyCoVar KindCoercion Coercion
- | FunCo Role Coercion Coercion
- | CoVarCo CoVar
- | AxiomInstCo (CoAxiom Branched) BranchIndex [Coercion]
- | AxiomRuleCo CoAxiomRule [Coercion]
- | UnivCo UnivCoProvenance Role Type Type
- | SymCo Coercion
- | TransCo Coercion Coercion
- | NthCo Role Int Coercion
- | LRCo LeftOrRight CoercionN
- | InstCo Coercion CoercionN
- | KindCo Coercion
- | SubCo CoercionN
- | HoleCo CoercionHole
- data UnivCoProvenance
- data CoercionHole = CoercionHole {}
- coHoleCoVar :: CoercionHole -> CoVar
- setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole
- type CoercionN = Coercion
- type CoercionR = Coercion
- type CoercionP = Coercion
- type KindCoercion = CoercionN
- data MCoercion
- type MCoercionR = MCoercion
- type MCoercionN = MCoercion
- mkTyConTy :: TyCon -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyCoVarTy :: TyCoVar -> Type
- mkTyCoVarTys :: [TyCoVar] -> [Type]
- mkFunTy :: AnonArgFlag -> Type -> Type -> Type
- mkVisFunTy :: Type -> Type -> Type
- mkInvisFunTy :: Type -> Type -> Type
- mkVisFunTys :: [Type] -> Type -> Type
- mkInvisFunTys :: [Type] -> Type -> Type
- mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
- mkForAllTys :: [TyCoVarBinder] -> Type -> Type
- mkPiTy :: TyCoBinder -> Type -> Type
- mkPiTys :: [TyCoBinder] -> Type -> Type
- data TyCoBinder
- type TyCoVarBinder = VarBndr TyCoVar ArgFlag
- type TyBinder = TyCoBinder
- binderVar :: VarBndr tv argf -> tv
- binderVars :: [VarBndr tv argf] -> [tv]
- binderType :: VarBndr TyCoVar argf -> Type
- binderArgFlag :: VarBndr tv argf -> argf
- delBinderVar :: VarSet -> TyCoVarBinder -> VarSet
- isInvisibleArgFlag :: ArgFlag -> Bool
- isVisibleArgFlag :: ArgFlag -> Bool
- isInvisibleBinder :: TyCoBinder -> Bool
- isVisibleBinder :: TyCoBinder -> Bool
- isTyBinder :: TyCoBinder -> Bool
- isNamedBinder :: TyCoBinder -> Bool
- pickLR :: LeftOrRight -> (a, a) -> a
- typeSize :: Type -> Int
- coercionSize :: Coercion -> Int
- provSize :: UnivCoProvenance -> Int
Documentation
tyThingCategory :: TyThing -> String Source #
pprTyThingCategory :: TyThing -> SDoc Source #
pprShortTyThing :: TyThing -> SDoc Source #
Types
TyVarTy Var | Vanilla type or kind variable (*never* a coercion variable) |
AppTy Type Type | Type application to something other than a 1) Function: must not be a 2) Argument type |
TyConApp TyCon [KindOrType] | Application of a 1) Type constructor being applied to. 2) Type arguments. Might not have enough type arguments here to saturate the constructor. Even type synonyms are not necessarily saturated; for example unsaturated type synonyms can appear as the right hand side of a type synonym. |
ForAllTy !TyCoVarBinder Type | A Π type. |
FunTy | t1 -> t2 Very common, so an important special case See Note [Function types] |
LitTy TyLit | Type literals are similar to type constructors. |
CastTy Type KindCoercion | A kind cast. The coercion is always nominal. INVARIANT: The cast is never refl. INVARIANT: The Type is not a CastTy (use TransCo instead) See Note Respecting definitional equality and (EQ3) |
CoercionTy Coercion | Injection of a Coercion into a type This should only ever be used in the RHS of an AppTy, in the list of a TyConApp, when applying a promoted GADT data constructor |
Instances
Data Type Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type # dataTypeOf :: Type -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) # gmapT :: (forall b. Data b => b -> b) -> Type -> Type # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r # gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type # | |
Outputable Type Source # | |
Instances
Eq TyLit Source # | |
Data TyLit Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyLit -> c TyLit # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyLit # dataTypeOf :: TyLit -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyLit) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyLit) # gmapT :: (forall b. Data b => b -> b) -> TyLit -> TyLit # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyLit -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyLit -> r # gmapQ :: (forall d. Data d => d -> u) -> TyLit -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyLit -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyLit -> m TyLit # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyLit -> m TyLit # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyLit -> m TyLit # | |
Ord TyLit Source # | |
Outputable TyLit Source # | |
type KindOrType = Type Source #
The key representation of types within the compiler
type KnotTied ty = ty Source #
A type labeled KnotTied
might have knot-tied tycons in it. See
Note [Type checking recursive type and class declarations] in
TcTyClsDecls
A type of the form p
of constraint kind represents a value whose type is
the Haskell predicate p
, where a predicate is what occurs before
the =>
in a Haskell type.
We use PredType
as documentation to mark those types that we guarantee to
have this kind.
It can be expanded into its representation, but:
- The type checker must treat it as opaque
- The rest of the compiler treats it as transparent
Consider these examples:
f :: (Eq a) => a -> Int g :: (?x :: Int -> Int) => a -> Int h :: (r\l) => {r} => {l::Int | r}
Here the Eq a
and ?x :: Int -> Int
and rl
are all called "predicates"
Argument Flag
Is something required to appear in source Haskell (Required
),
permitted by request (Specified
) (visible type application), or
prohibited entirely from appearing in source Haskell (Inferred
)?
See Note [VarBndrs, TyCoVarBinders, TyConBinders, and visibility] in TyCoRep
Instances
Eq ArgFlag Source # | |
Data ArgFlag Source # | |
Defined in Var gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ArgFlag -> c ArgFlag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ArgFlag # toConstr :: ArgFlag -> Constr # dataTypeOf :: ArgFlag -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ArgFlag) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArgFlag) # gmapT :: (forall b. Data b => b -> b) -> ArgFlag -> ArgFlag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r # gmapQ :: (forall d. Data d => d -> u) -> ArgFlag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ArgFlag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag # | |
Ord ArgFlag Source # | |
Outputable ArgFlag Source # | |
Binary ArgFlag Source # | |
Outputable tv => Outputable (VarBndr tv ArgFlag) Source # | |
data AnonArgFlag Source #
The non-dependent version of ArgFlag
.
VisArg | Used for |
InvisArg | Used for |
Instances
data ForallVisFlag Source #
Is a forall
invisible (e.g., forall a b. {...}
, with a dot) or visible
(e.g., forall a b -> {...}
, with an arrow)?
ForallVis | A visible |
ForallInvis | An invisible |
Instances
Coercions
A Coercion
is concrete evidence of the equality/convertibility
of two types.
Refl Type | |
GRefl Role Type MCoercionN | |
TyConAppCo Role TyCon [Coercion] | |
AppCo Coercion CoercionN | |
ForAllCo TyCoVar KindCoercion Coercion | |
FunCo Role Coercion Coercion | |
CoVarCo CoVar | |
AxiomInstCo (CoAxiom Branched) BranchIndex [Coercion] | |
AxiomRuleCo CoAxiomRule [Coercion] | |
UnivCo UnivCoProvenance Role Type Type | |
SymCo Coercion | |
TransCo Coercion Coercion | |
NthCo Role Int Coercion | |
LRCo LeftOrRight CoercionN | |
InstCo Coercion CoercionN | |
KindCo Coercion | |
SubCo CoercionN | |
HoleCo CoercionHole | See Note [Coercion holes] Only present during typechecking |
Instances
Data Coercion Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Coercion -> c Coercion # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Coercion # toConstr :: Coercion -> Constr # dataTypeOf :: Coercion -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Coercion) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Coercion) # gmapT :: (forall b. Data b => b -> b) -> Coercion -> Coercion # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Coercion -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Coercion -> r # gmapQ :: (forall d. Data d => d -> u) -> Coercion -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Coercion -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Coercion -> m Coercion # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Coercion -> m Coercion # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Coercion -> m Coercion # | |
Outputable Coercion Source # | |
data UnivCoProvenance Source #
For simplicity, we have just one UnivCo that represents a coercion from
some type to some other type, with (in general) no restrictions on the
type. The UnivCoProvenance specifies more exactly what the coercion really
is and why a program should (or shouldn't!) trust the coercion.
It is reasonable to consider each constructor of UnivCoProvenance
as a totally independent coercion form; their only commonality is
that they don't tell you what types they coercion between. (That info
is in the UnivCo
constructor of Coercion
.
UnsafeCoerceProv | From |
PhantomProv KindCoercion | See Note [Phantom coercions]. Only in Phantom roled coercions |
ProofIrrelProv KindCoercion | From the fact that any two coercions are considered equivalent. See Note [ProofIrrelProv]. Can be used in Nominal or Representational coercions |
PluginProv String | From a plugin, which asserts that this coercion is sound. The string is for the use of the plugin. |
Instances
Data UnivCoProvenance Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnivCoProvenance -> c UnivCoProvenance # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnivCoProvenance # toConstr :: UnivCoProvenance -> Constr # dataTypeOf :: UnivCoProvenance -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UnivCoProvenance) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnivCoProvenance) # gmapT :: (forall b. Data b => b -> b) -> UnivCoProvenance -> UnivCoProvenance # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnivCoProvenance -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnivCoProvenance -> r # gmapQ :: (forall d. Data d => d -> u) -> UnivCoProvenance -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnivCoProvenance -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnivCoProvenance -> m UnivCoProvenance # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnivCoProvenance -> m UnivCoProvenance # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnivCoProvenance -> m UnivCoProvenance # | |
Outputable UnivCoProvenance Source # | |
data CoercionHole Source #
A coercion to be filled in by the type-checker. See Note [Coercion holes]
Instances
Data CoercionHole Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CoercionHole -> c CoercionHole # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CoercionHole # toConstr :: CoercionHole -> Constr # dataTypeOf :: CoercionHole -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CoercionHole) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CoercionHole) # gmapT :: (forall b. Data b => b -> b) -> CoercionHole -> CoercionHole # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CoercionHole -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CoercionHole -> r # gmapQ :: (forall d. Data d => d -> u) -> CoercionHole -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CoercionHole -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CoercionHole -> m CoercionHole # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CoercionHole -> m CoercionHole # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CoercionHole -> m CoercionHole # | |
Outputable CoercionHole Source # | |
coHoleCoVar :: CoercionHole -> CoVar Source #
setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole Source #
type KindCoercion = CoercionN Source #
A semantically more meaningful type to represent what may or may not be a
useful Coercion
.
Instances
Data MCoercion Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MCoercion -> c MCoercion # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MCoercion # toConstr :: MCoercion -> Constr # dataTypeOf :: MCoercion -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MCoercion) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MCoercion) # gmapT :: (forall b. Data b => b -> b) -> MCoercion -> MCoercion # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MCoercion -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MCoercion -> r # gmapQ :: (forall d. Data d => d -> u) -> MCoercion -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MCoercion -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MCoercion -> m MCoercion # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MCoercion -> m MCoercion # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MCoercion -> m MCoercion # | |
Outputable MCoercion Source # | |
type MCoercionR = MCoercion Source #
type MCoercionN = MCoercion Source #
Functions over types
mkTyConTy :: TyCon -> Type Source #
Create the plain type constructor type which has been applied to no type arguments at all.
mkTyVarTys :: [TyVar] -> [Type] Source #
mkTyCoVarTy :: TyCoVar -> Type Source #
mkTyCoVarTys :: [TyCoVar] -> [Type] Source #
mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type Source #
Like mkTyCoForAllTy
, but does not check the occurrence of the binder
See Note [Unused coercion variable in ForAllTy]
mkForAllTys :: [TyCoVarBinder] -> Type -> Type Source #
Wraps foralls over the type using the provided TyCoVar
s from left to right
Functions over binders
data TyCoBinder Source #
A TyCoBinder
represents an argument to a function. TyCoBinders can be
dependent (Named
) or nondependent (Anon
). They may also be visible or
not. See Note [TyCoBinders]
Instances
Data TyCoBinder Source # | |
Defined in TyCoRep gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyCoBinder -> c TyCoBinder # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyCoBinder # toConstr :: TyCoBinder -> Constr # dataTypeOf :: TyCoBinder -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyCoBinder) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyCoBinder) # gmapT :: (forall b. Data b => b -> b) -> TyCoBinder -> TyCoBinder # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r # gmapQ :: (forall d. Data d => d -> u) -> TyCoBinder -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyCoBinder -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder # | |
Outputable TyCoBinder Source # | |
type TyCoVarBinder = VarBndr TyCoVar ArgFlag Source #
Variable Binder
A TyCoVarBinder
is the binder of a ForAllTy
It's convenient to define this synonym here rather its natural
home in TyCoRep, because it's used in DataCon.hs-boot
A TyVarBinder
is a binder with only TyVar
type TyBinder = TyCoBinder Source #
TyBinder
is like TyCoBinder
, but there can only be TyVarBinder
in the Named
field.
binderVars :: [VarBndr tv argf] -> [tv] Source #
binderArgFlag :: VarBndr tv argf -> argf Source #
delBinderVar :: VarSet -> TyCoVarBinder -> VarSet Source #
Remove the binder's variable from the set, if the binder has a variable.
isInvisibleArgFlag :: ArgFlag -> Bool Source #
Does this ArgFlag
classify an argument that is not written in Haskell?
isVisibleArgFlag :: ArgFlag -> Bool Source #
Does this ArgFlag
classify an argument that is written in Haskell?
isInvisibleBinder :: TyCoBinder -> Bool Source #
Does this binder bind an invisible argument?
isVisibleBinder :: TyCoBinder -> Bool Source #
Does this binder bind a visible argument?
isTyBinder :: TyCoBinder -> Bool Source #
If its a named binder, is the binder a tyvar? Returns True for nondependent binder. This check that we're really returning a *Ty*Binder (as opposed to a coercion binder). That way, if/when we allow coercion quantification in more places, we'll know we missed updating some function.
isNamedBinder :: TyCoBinder -> Bool Source #
Functions over coercions
pickLR :: LeftOrRight -> (a, a) -> a Source #
Sizes
coercionSize :: Coercion -> Int Source #
provSize :: UnivCoProvenance -> Int Source #