GHC.Core.TyCo.Compare

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

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.TyCo.Compare

Contents

- Type comparison
- Visiblity comparision

Description

Type equality and comparison

Synopsis

- eqType :: Type -> Type -> Bool
- eqTypeX :: RnEnv2 -> Type -> Type -> Bool
- eqTypes :: [Type] -> [Type] -> Bool
- nonDetCmpType :: Type -> Type -> Ordering
- nonDetCmpTypes :: [Type] -> [Type] -> Ordering
- nonDetCmpTypeX :: RnEnv2 -> Type -> Type -> Ordering
- nonDetCmpTypesX :: RnEnv2 -> [Type] -> [Type] -> Ordering
- nonDetCmpTc :: TyCon -> TyCon -> Ordering
- eqVarBndrs :: RnEnv2 -> [Var] -> [Var] -> Maybe RnEnv2
- pickyEqType :: Type -> Type -> Bool
- tcEqType :: HasDebugCallStack => Type -> Type -> Bool
- tcEqKind :: HasDebugCallStack => Kind -> Kind -> Bool
- tcEqTypeNoKindCheck :: Type -> Type -> Bool
- tcEqTypeVis :: Type -> Type -> Bool
- tcEqTyConApps :: TyCon -> [Type] -> TyCon -> [Type] -> Bool
- eqForAllVis :: ForAllTyFlag -> ForAllTyFlag -> Bool
- cmpForAllVis :: ForAllTyFlag -> ForAllTyFlag -> Ordering

# Type comparison

eqType :: Type -> Type -> Bool #

Type equality on source types. Does not look through `newtypes`, `PredType`s or type families, but it does look through type synonyms. This first checks that the kinds of the types are equal and then checks whether the types are equal, ignoring casts and coercions. (The kind check is a recursive call, but since all kinds have type `Type`, there is no need to check the types of kinds.) See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep.

eqTypeX :: RnEnv2 -> Type -> Type -> Bool #

Compare types with respect to a (presumably) non-empty `RnEnv2`.

eqTypes :: [Type] -> [Type] -> Bool #

Type equality on lists of types, looking through type synonyms but not newtypes.

nonDetCmpType :: Type -> Type -> Ordering #

nonDetCmpTypes :: [Type] -> [Type] -> Ordering #

nonDetCmpTypeX :: RnEnv2 -> Type -> Type -> Ordering #

nonDetCmpTypesX :: RnEnv2 -> [Type] -> [Type] -> Ordering #

nonDetCmpTc :: TyCon -> TyCon -> Ordering #

Compare two `TyCon`s. See Note [nonDetCmpType nondeterminism]

eqVarBndrs :: RnEnv2 -> [Var] -> [Var] -> Maybe RnEnv2 #

pickyEqType :: Type -> Type -> Bool #

Like `pickyEqTypeVis`, but returns a Bool for convenience

tcEqType :: HasDebugCallStack => Type -> Type -> Bool #

tcEqType implements typechecker equality It behaves just like eqType, but is implemented differently (for now)

tcEqKind :: HasDebugCallStack => Kind -> Kind -> Bool #

tcEqTypeNoKindCheck :: Type -> Type -> Bool #

Just like `tcEqType`, but will return True for types of different kinds as long as their non-coercion structure is identical.

tcEqTypeVis :: Type -> Type -> Bool #

Like `tcEqType`, but returns True if the visible part of the types are equal, even if they are really unequal (in the invisible bits)

tcEqTyConApps :: TyCon -> [Type] -> TyCon -> [Type] -> Bool #

Check whether two TyConApps are the same; if the number of arguments are different, just checks the common prefix of arguments.

# Visiblity comparision

eqForAllVis :: ForAllTyFlag -> ForAllTyFlag -> Bool #

Do these denote the same level of visibility? `Required` arguments are visible, others are not. So this function equates `Specified` and `Inferred`. Used for printing.

cmpForAllVis :: ForAllTyFlag -> ForAllTyFlag -> Ordering #

Do these denote the same level of visibility? `Required` arguments are visible, others are not. So this function equates `Specified` and `Inferred`. Used for printing.