ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.Predicate

Synopsis

- data Pred
  - = ClassPred Class [Type]
  - | EqPred EqRel Type Type
  - | IrredPred PredType
  - | ForAllPred [TyVar] [PredType] PredType
- classifyPredType :: PredType -> Pred
- isPredTy :: HasDebugCallStack => Type -> Bool
- isEvVarType :: Type -> Bool
- data EqRel
  - = NomEq
  - | ReprEq
- eqRelRole :: EqRel -> Role
- isEqPrimPred :: PredType -> Bool
- isEqPred :: PredType -> Bool
- getEqPredTys :: PredType -> (Type, Type)
- getEqPredTys_maybe :: PredType -> Maybe (Role, Type, Type)
- getEqPredRole :: PredType -> Role
- predTypeEqRel :: PredType -> EqRel
- mkPrimEqPred :: Type -> Type -> Type
- mkReprPrimEqPred :: Type -> Type -> Type
- mkPrimEqPredRole :: Role -> Type -> Type -> PredType
- mkNomPrimEqPred :: Kind -> Type -> Type -> Type
- mkClassPred :: Class -> [Type] -> PredType
- isDictTy :: Type -> Bool
- typeDeterminesValue :: Type -> Bool
- isClassPred :: PredType -> Bool
- isEqualityClass :: Class -> Bool
- isCTupleClass :: Class -> Bool
- getClassPredTys :: HasDebugCallStack => PredType -> (Class, [Type])
- getClassPredTys_maybe :: PredType -> Maybe (Class, [Type])
- classMethodTy :: Id -> Type
- classMethodInstTy :: Id -> [Type] -> Type
- isIPLikePred :: Type -> Bool
- mentionsIP :: Type -> Class -> [Type] -> Bool
- isIPTyCon :: TyCon -> Bool
- isIPClass :: Class -> Bool
- isCallStackTy :: Type -> Bool
- isCallStackPred :: Class -> [Type] -> Maybe FastString
- isCallStackPredTy :: Type -> Bool
- isExceptionContextPred :: Class -> [Type] -> Maybe FastString
- isIPPred_maybe :: Class -> [Type] -> Maybe (Type, Type)
- type DictId = EvId
- isEvVar :: Var -> Bool
- isDictId :: Id -> Bool

# Documentation

data Pred #

A predicate in the solver. The solver tries to prove Wanted predicates from Given ones.

Constructors

ClassPred Class [Type] | A typeclass predicate.
EqPred EqRel Type Type | A type equality predicate.
IrredPred PredType | An irreducible predicate.
ForAllPred [TyVar] [PredType] PredType | A quantified predicate. See Note [Quantified constraints] in GHC.Tc.Solver.Solve

classifyPredType :: PredType -> Pred #

isPredTy :: HasDebugCallStack => Type -> Bool #

isEvVarType :: Type -> Bool #

data EqRel #

A choice of equality relation. This is separate from the type `Role` because `Phantom` does not define a (non-trivial) equality relation.

Constructors

NomEq |
ReprEq |

#### Instances

Instances details

Outputable EqRel # |
Instance details Defined in GHC.Core.Predicate Methods ppr :: EqRel -> SDoc #
Eq EqRel # |
Instance details Defined in GHC.Core.Predicate Methods (==) :: EqRel -> EqRel -> Bool # (/=) :: EqRel -> EqRel -> Bool #
Ord EqRel # |
Instance details Defined in GHC.Core.Predicate Methods compare :: EqRel -> EqRel -> Ordering # (<) :: EqRel -> EqRel -> Bool # (<=) :: EqRel -> EqRel -> Bool # (>) :: EqRel -> EqRel -> Bool # (>=) :: EqRel -> EqRel -> Bool # max :: EqRel -> EqRel -> EqRel # min :: EqRel -> EqRel -> EqRel #

eqRelRole :: EqRel -> Role #

isEqPrimPred :: PredType -> Bool #

isEqPred :: PredType -> Bool #

getEqPredTys :: PredType -> (Type, Type) #

getEqPredTys_maybe :: PredType -> Maybe (Role, Type, Type) #

getEqPredRole :: PredType -> Role #

predTypeEqRel :: PredType -> EqRel #

Get the equality relation relevant for a pred type.

mkPrimEqPred :: Type -> Type -> Type #

Creates a primitive nominal type equality predicate. t1 ~# t2 Invariant: the types are not Coercions

mkReprPrimEqPred :: Type -> Type -> Type #

Creates a primitive representational type equality predicate. t1 ~R# t2 Invariant: the types are not Coercions

mkPrimEqPredRole :: Role -> Type -> Type -> PredType #

Makes a lifted equality predicate at the given role

mkNomPrimEqPred :: Kind -> Type -> Type -> Type #

Creates a primitive nominal type equality predicate with an explicit (but homogeneous) kind: (~#) k k ty1 ty2

mkClassPred :: Class -> [Type] -> PredType #

isDictTy :: Type -> Bool #

typeDeterminesValue :: Type -> Bool #

isClassPred :: PredType -> Bool #

isEqualityClass :: Class -> Bool #

isCTupleClass :: Class -> Bool #

getClassPredTys :: HasDebugCallStack => PredType -> (Class, [Type]) #

getClassPredTys_maybe :: PredType -> Maybe (Class, [Type]) #

classMethodTy :: Id -> Type #

classMethodInstTy :: Id -> [Type] -> Type #

isIPLikePred :: Type -> Bool #

mentionsIP :: Type -> Class -> [Type] -> Bool #

isIPTyCon :: TyCon -> Bool #

isIPClass :: Class -> Bool #

isCallStackTy :: Type -> Bool #

Is a type a `CallStack`?

isCallStackPred :: Class -> [Type] -> Maybe FastString #

Is a `PredType` a `CallStack` implicit parameter?

If so, return the name of the parameter.

isCallStackPredTy :: Type -> Bool #

isExceptionContextPred :: Class -> [Type] -> Maybe FastString #

Is a `PredType` an `ExceptionContext` implicit parameter?

If so, return the name of the parameter.

isIPPred_maybe :: Class -> [Type] -> Maybe (Type, Type) #

Decomposes a predicate if it is an implicit parameter. Does not look in superclasses. See also [Local implicit parameters].

type DictId = EvId #

Dictionary Identifier

isEvVar :: Var -> Bool #

isDictId :: Id -> Bool #