GHC.Core.TyCon

ghc-9.14.0.20251028: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Core.TyCon

Contents

- Main TyCon data types
- TyConBinder
  - Field labels
  - Constructing TyCons
  - Predicates on TyCons
  - Extracting information out of TyCons
  - Manipulating TyCons
  - Predicated on TyConFlavours
- Runtime type representation
- Primitive representations of Types

Synopsis

- data TyCon
- data AlgTyConRhs
  - = AbstractTyCon
  - | DataTyCon {
    - data_cons :: [DataCon]
    - data_cons_size :: Int
    - is_enum :: Bool
    - is_type_data :: Bool
    - data_fixed_lev :: Bool
    }
  - | TupleTyCon {
    - data_con :: DataCon
    - tup_sort :: TupleSort
    }
  - | SumTyCon {
    - data_cons :: [DataCon]
    - data_cons_size :: Int
    }
  - | NewTyCon {
    - data_con :: DataCon
    - nt_rhs :: Type
    - nt_etad_rhs :: ([TyVar], Type)
    - nt_co :: CoAxiom Unbranched
    - nt_fixed_rep :: Bool
    }
  - | UnaryClassTyCon {
    - data_con :: DataCon
    }
- visibleDataCons :: AlgTyConRhs -> [DataCon]
- data AlgTyConFlav
  - = VanillaAlgTyCon TyConRepName
  - | UnboxedSumTyCon
  - | ClassTyCon Class TyConRepName
  - | DataFamInstTyCon (CoAxiom Unbranched) TyCon [Type]
- isNoParent :: AlgTyConFlav -> Bool
- data FamTyConFlav
  - = DataFamilyTyCon TyConRepName
  - | OpenSynFamilyTyCon
  - | ClosedSynFamilyTyCon (Maybe (CoAxiom Branched))
  - | AbstractClosedSynFamilyTyCon
  - | BuiltInSynFamTyCon BuiltInSynFamily
- data Role
  - = Nominal
  - | Representational
  - | Phantom
- data Injectivity
  - = NotInjective
  - | Injective [Bool]
- data PromDataConInfo
  - = NoPromInfo
  - | RuntimeRep ([Type] -> [PrimRep])
  - | VecCount Int
  - | VecElem PrimElemRep
  - | Levity Levity
- data TyConFlavour tc
  - = ClassFlavour
  - | TupleFlavour Boxity
  - | SumFlavour
  - | DataTypeFlavour
  - | NewtypeFlavour
  - | AbstractTypeFlavour
  - | OpenFamilyFlavour TypeOrData (Maybe tc)
  - | ClosedTypeFamilyFlavour
  - | TypeSynonymFlavour
  - | BuiltInTypeFlavour
  - | PromotedDataConFlavour
- type TyConBinder = VarBndr TyVar TyConBndrVis
- data TyConBndrVis
  - = NamedTCB ForAllTyFlag
  - | AnonTCB
- mkNamedTyConBinder :: ForAllTyFlag -> TyVar -> TyConBinder
- mkNamedTyConBinders :: ForAllTyFlag -> [TyVar] -> [TyConBinder]
- mkRequiredTyConBinder :: TyCoVarSet -> TyVar -> TyConBinder
- mkAnonTyConBinder :: TyVar -> TyConBinder
- mkAnonTyConBinders :: [TyVar] -> [TyConBinder]
- tyConBinderForAllTyFlag :: VarBndr a TyConBndrVis -> ForAllTyFlag
- tyConBndrVisForAllTyFlag :: TyConBndrVis -> ForAllTyFlag
- isNamedTyConBinder :: TyConBinder -> Bool
- isVisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool
- isInvisSpecTyConBinder :: VarBndr tv TyConBndrVis -> Bool
- isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool
- isInferredTyConBinder :: VarBndr var TyConBndrVis -> Bool
- isVisibleTcbVis :: TyConBndrVis -> Bool
- isInvisSpecTcbVis :: TyConBndrVis -> Bool
- tyConFieldLabels :: TyCon -> [FieldLabel]
- lookupTyConFieldLabel :: FieldLabelString -> TyCon -> Maybe FieldLabel
- mkAlgTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> Maybe CType -> [PredType] -> AlgTyConRhs -> AlgTyConFlav -> Bool -> TyCon
- mkClassTyCon :: Name -> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon
- mkPrimTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> TyCon
- mkTupleTyCon :: Name -> [TyConBinder] -> Kind -> DataCon -> TupleSort -> AlgTyConFlav -> TyCon
- mkSumTyCon :: Name -> [TyConBinder] -> Kind -> [DataCon] -> AlgTyConFlav -> TyCon
- mkDataTyConRhs :: [DataCon] -> AlgTyConRhs
- mkLevPolyDataTyConRhs :: Bool -> Bool -> [DataCon] -> AlgTyConRhs
- mkSynonymTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> Type -> Bool -> Bool -> Bool -> Bool -> TyCon
- mkFamilyTyCon :: Name -> [TyConBinder] -> Kind -> Maybe Name -> FamTyConFlav -> Maybe Class -> Injectivity -> TyCon
- mkPromotedDataCon :: DataCon -> Name -> TyConRepName -> [TyConBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon
- mkTcTyCon :: Name -> [TyConBinder] -> Kind -> [(Name, TcTyVar)] -> Bool -> TyConFlavour TyCon -> TyCon
- noTcTyConScopedTyVars :: [(Name, TcTyVar)]
- isAlgTyCon :: TyCon -> Bool
- isVanillaAlgTyCon :: TyCon -> Bool
- isClassTyCon :: TyCon -> Bool
- isUnaryClassTyCon :: TyCon -> Bool
- isUnaryClassTyCon_maybe :: TyCon -> Maybe (Class, DataCon)
- isFamInstTyCon :: TyCon -> Bool
- isPrimTyCon :: TyCon -> Bool
- isTupleTyCon :: TyCon -> Bool
- isUnboxedTupleTyCon :: TyCon -> Bool
- isBoxedTupleTyCon :: TyCon -> Bool
- isUnboxedSumTyCon :: TyCon -> Bool
- isPromotedTupleTyCon :: TyCon -> Bool
- isLiftedAlgTyCon :: TyCon -> Bool
- isTypeSynonymTyCon :: TyCon -> Bool
- tyConMustBeSaturated :: TyCon -> Bool
- isPromotedDataCon :: TyCon -> Bool
- isPromotedDataCon_maybe :: TyCon -> Maybe DataCon
- isDataKindsPromotedDataCon :: TyCon -> Bool
- isKindTyCon :: TyCon -> Bool
- isKindName :: Name -> Bool
- isLiftedTypeKindTyConName :: Name -> Bool
- isTauTyCon :: TyCon -> Bool
- isFamFreeTyCon :: TyCon -> Bool
- isForgetfulSynTyCon :: TyCon -> Bool
- isBoxedDataTyCon :: TyCon -> Bool
- isTypeDataTyCon :: TyCon -> Bool
- isEnumerationTyCon :: TyCon -> Bool
- isNewTyCon :: TyCon -> Bool
- isAbstractTyCon :: TyCon -> Bool
- isFamilyTyCon :: TyCon -> Bool
- isOpenFamilyTyCon :: TyCon -> Bool
- isTypeFamilyTyCon :: TyCon -> Bool
- isDataFamilyTyCon :: TyCon -> Bool
- isOpenTypeFamilyTyCon :: TyCon -> Bool
- isClosedSynFamilyTyConWithAxiom_maybe :: TyCon -> Maybe (CoAxiom Branched)
- tyConInjectivityInfo :: TyCon -> Injectivity
- isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily
- isGadtSyntaxTyCon :: TyCon -> Bool
- isInjectiveTyCon :: TyCon -> Role -> Bool
- isGenerativeTyCon :: TyCon -> Role -> Bool
- isTyConAssoc :: TyCon -> Bool
- tyConAssoc_maybe :: TyCon -> Maybe TyCon
- tyConFlavourAssoc_maybe :: TyConFlavour tc -> Maybe tc
- isImplicitTyCon :: TyCon -> Bool
- isTyConWithSrcDataCons :: TyCon -> Bool
- isTcTyCon :: TyCon -> Bool
- setTcTyConKind :: TyCon -> Kind -> TyCon
- tcHasFixedRuntimeRep :: TyCon -> Bool
- isConcreteTyCon :: TyCon -> Bool
- isValidDTT2TyCon :: TyCon -> Bool
- tyConName :: TyCon -> Name
- tyConSkolem :: TyCon -> Bool
- tyConKind :: TyCon -> Kind
- tyConUnique :: TyCon -> Unique
- tyConTyVars :: TyCon -> [TyVar]
- tyConVisibleTyVars :: TyCon -> [TyVar]
- tyConCType_maybe :: TyCon -> Maybe CType
- tyConDataCons :: TyCon -> [DataCon]
- tyConDataCons_maybe :: TyCon -> Maybe [DataCon]
- tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon
- tyConSingleDataCon :: TyCon -> DataCon
- tyConFamilySize :: TyCon -> Int
- tyConStupidTheta :: TyCon -> [PredType]
- tyConArity :: TyCon -> Arity
- tyConNullaryTy :: TyCon -> Type
- mkTyConTy :: TyCon -> Type
- tyConRoles :: TyCon -> [Role]
- tyConFlavour :: TyCon -> TyConFlavour TyCon
- tyConTuple_maybe :: TyCon -> Maybe TupleSort
- tyConClass_maybe :: TyCon -> Maybe Class
- tyConATs :: TyCon -> [TyCon]
- tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type])
- tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched)
- tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched)
- tyConFamilyResVar_maybe :: TyCon -> Maybe Name
- synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type)
- synTyConRhs_maybe :: TyCon -> Maybe Type
- famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav
- algTyConRhs :: TyCon -> AlgTyConRhs
- newTyConRhs :: TyCon -> ([TyVar], Type)
- newTyConEtadArity :: TyCon -> Int
- newTyConEtadRhs :: TyCon -> ([TyVar], Type)
- unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)
- unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)
- newTyConDataCon_maybe :: TyCon -> Maybe DataCon
- algTcFields :: TyConDetails -> FieldLabelEnv
- tyConPromDataConInfo :: TyCon -> PromDataConInfo
- tyConBinders :: TyCon -> [TyConBinder]
- tyConResKind :: TyCon -> Kind
- tyConInvisTVBinders :: [TyConBinder] -> [InvisTVBinder]
- tcTyConScopedTyVars :: TyCon -> [(Name, TcTyVar)]
- isMonoTcTyCon :: TyCon -> Bool
- tyConHasClosedResKind :: TyCon -> Bool
- mkTyConTagMap :: TyCon -> NameEnv ConTag
- data ExpandSynResult tyco
  - = NoExpansion
  - | ExpandsSyn [(TyVar, tyco)] Type [tyco]
- expandSynTyCon_maybe :: TyCon -> [tyco] -> ExpandSynResult tyco
- newTyConCo :: TyCon -> CoAxiom Unbranched
- newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched)
- pprPromotionQuote :: TyCon -> SDoc
- mkTyConKind :: [TyConBinder] -> Kind -> Kind
- tcFlavourIsOpen :: TyConFlavour tc -> Bool
- type TyConRepName = Name
- tyConRepName_maybe :: TyCon -> Maybe TyConRepName
- mkPrelTyConRepName :: Name -> TyConRepName
- tyConRepModOcc :: Module -> OccName -> (Module, OccName)
- data PrimRep
  - = BoxedRep !(Maybe Levity)
  - | Int8Rep
  - | Int16Rep
  - | Int32Rep
  - | Int64Rep
  - | IntRep
  - | Word8Rep
  - | Word16Rep
  - | Word32Rep
  - | Word64Rep
  - | WordRep
  - | AddrRep
  - | FloatRep
  - | DoubleRep
  - | VecRep Int PrimElemRep
- data PrimElemRep
  - = Int8ElemRep
  - | Int16ElemRep
  - | Int32ElemRep
  - | Int64ElemRep
  - | Word8ElemRep
  - | Word16ElemRep
  - | Word32ElemRep
  - | Word64ElemRep
  - | FloatElemRep
  - | DoubleElemRep
- data Levity
  - = Lifted
  - | Unlifted
- data PrimOrVoidRep
  - = VoidRep
  - | NVRep PrimRep
- primElemRepToPrimRep :: PrimElemRep -> PrimRep
- isGcPtrRep :: PrimRep -> Bool
- primRepSizeB :: Platform -> PrimRep -> Int
- primRepSizeW64_B :: PrimRep -> Int
- primElemRepSizeB :: Platform -> PrimElemRep -> Int
- primElemRepSizeW64_B :: PrimElemRep -> Int
- primRepIsFloat :: PrimRep -> Maybe Bool
- primRepsCompatible :: Platform -> [PrimRep] -> [PrimRep] -> Bool
- primRepCompatible :: Platform -> PrimRep -> PrimRep -> Bool
- primRepIsWord :: PrimRep -> Bool
- primRepIsInt :: PrimRep -> Bool

# Main TyCon data types

data TyCon Source #

TyCons represent type constructors. Type constructors are introduced by things such as:

1) Data declarations: `data Foo = ...` creates the `Foo` type constructor of kind `Type`

2) Type synonyms: `type Foo = ...` creates the `Foo` type constructor

3) Newtypes: `newtype Foo a = MkFoo ...` creates the `Foo` type constructor of kind `Type -> Type`

4) Class declarations: `class Foo where` creates the `Foo` type constructor of kind `Constraint`

This data type also encodes a number of primitive, built in type constructors such as those for function and tuple types.

If you edit this type, you may need to update the GHC formalism See Note [GHC Formalism] in GHC.Core.Lint

#### Instances

Instances details

NamedThing TyCon Source # |
Instance details Defined in GHC.Core.TyCon Methods getOccName :: TyCon -> OccName Source # getName :: TyCon -> Name Source #
Uniquable TyCon Source # |
Instance details Defined in GHC.Core.TyCon Methods getUnique :: TyCon -> Unique Source #
Outputable TyCon Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: TyCon -> SDoc Source #
Eq TyCon Source # |
Instance details Defined in GHC.Core.TyCon Methods (==) :: TyCon -> TyCon -> Bool Source # (/=) :: TyCon -> TyCon -> Bool Source #
Data TyCon Source # |
Instance details Defined in GHC.Core.TyCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyCon -> c TyCon Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyCon Source # toConstr :: TyCon -> Constr Source # dataTypeOf :: TyCon -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyCon) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyCon) Source # gmapT :: (forall b. Data b => b -> b) -> TyCon -> TyCon Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyCon -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyCon -> r Source # gmapQ :: (forall d. Data d => d -> u) -> TyCon -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyCon -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCon -> m TyCon Source #

data AlgTyConRhs Source #

Represents right-hand-sides of `TyCon`s for algebraic types

Constructors

AbstractTyCon | Says that we know nothing about this data type, except that it's represented by a pointer. Used when we export a data type abstractly into an .hi file.
DataTyCon | Information about those `TyCon`s derived from a `data` declaration. This includes data types with no constructors at all.
- Fields data_cons :: [DataCon] The data type constructors; can be empty if the user declares the type to have no constructors INVARIANT: Kept in order of increasing `DataCon` tag (see the tag assignment in mkTyConTagMap) data_cons_size :: Int Cached value: length data_cons is_enum :: Bool Cached value: is this an enumeration type? See Note [Enumeration types] is_type_data :: Bool data_fixed_lev :: Bool `True` if the data type constructor has a known, fixed levity when fully applied to its arguments, False otherwise. This can only be `False` with UnliftedDatatypes, e.g.
      data A :: TYPE (BoxedRep l) where { MkA :: Int -> A }
This boolean is cached to make it cheaper to check for levity and representation-polymorphism in tcHasFixedRuntimeRep.
TupleTyCon |
Fields data_con :: DataCon The unique constructor for the `newtype`. It has no existentials tup_sort :: TupleSort Is this a boxed, unboxed or constraint tuple?
SumTyCon | An unboxed sum type.
Fields data_cons :: [DataCon] The data type constructors; can be empty if the user declares the type to have no constructors INVARIANT: Kept in order of increasing `DataCon` tag (see the tag assignment in mkTyConTagMap) data_cons_size :: Int Cached value: length data_cons
NewTyCon | Information about those `TyCon`s derived from a `newtype` declaration
- Fields data_con :: DataCon The unique constructor for the `newtype`. It has no existentials nt_rhs :: Type Cached value: the argument type of the constructor, which is just the representation type of the `TyCon` (remember that `newtype`s do not exist at runtime so need a different representation type). The free `TyVar`s of this type are the `tyConTyVars` from the corresponding `TyCon` nt_etad_rhs :: ([TyVar], Type) Same as the `nt_rhs`, but this time eta-reduced. Hence the list of `TyVar`s in this field may be shorter than the declared arity of the `TyCon`. nt_co :: CoAxiom Unbranched nt_fixed_rep :: Bool `True` if the newtype has a known, fixed representation when fully applied to its arguments, `False` otherwise. This can only ever be `False` with UnliftedNewtypes. Example:
      newtype N (a :: TYPE r) = MkN a
Invariant: nt_fixed_rep nt = tcHasFixedRuntimeRep (nt_rhs nt) This boolean is cached to make it cheaper to check if a variable binding is representation-polymorphic in tcHasFixedRuntimeRep.
UnaryClassTyCon |
Fields data_con :: DataCon The unique constructor for the `newtype`. It has no existentials

visibleDataCons :: AlgTyConRhs -> [DataCon] Source #

Extract those `DataCon`s that we are able to learn about. Note that visibility in this sense does not correspond to visibility in the context of any particular user program!

data AlgTyConFlav Source #

Describes the flavour of an algebraic type constructor. For classes and data families, this flavour includes a reference to the parent `TyCon`.

Constructors

VanillaAlgTyCon TyConRepName | An ordinary algebraic type constructor. This includes unlifted and representation-polymorphic datatypes and newtypes and unboxed tuples, but NOT unboxed sums; see UnboxedSumTyCon.
UnboxedSumTyCon | An unboxed sum type constructor. This is distinct from VanillaAlgTyCon because we currently don't allow unboxed sums to be Typeable since there are too many of them. See #13276.
ClassTyCon Class TyConRepName | Type constructors representing a class dictionary. See Note [ATyCon for classes] in GHC.Types.TyThing INVARIANT: the algTcRhs is never NewTyCon; it could be TupleTyCon, DataTyCon, UnaryClassTyCon
DataFamInstTyCon (CoAxiom Unbranched) TyCon [Type] | Type constructors representing an *instance* of a *data* family. Parameters: 1) The type family in question 2) Instance types; free variables are the `tyConTyVars` of the current `TyCon` (not the family one). INVARIANT: the number of types matches the arity of the family `TyCon` 3) A `CoTyCon` identifying the representation type with the type instance family

#### Instances

Instances details

Outputable AlgTyConFlav Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: AlgTyConFlav -> SDoc Source #

isNoParent :: AlgTyConFlav -> Bool Source #

data FamTyConFlav Source #

Information pertaining to the expansion of a type synonym (`type`)

Constructors

DataFamilyTyCon TyConRepName | Represents an open type family without a fixed right hand side. Additional instances can appear at any time. These are introduced by either a top level declaration:
    data family T a :: Type
Or an associated data type declaration, within a class declaration:
    class C a b where
      data T b :: Type
OpenSynFamilyTyCon | An open type synonym family e.g. `type family F x y :: Type -> Type`
ClosedSynFamilyTyCon (Maybe (CoAxiom Branched)) | A closed type synonym family e.g. `type family F x where { F Int = Bool }`
AbstractClosedSynFamilyTyCon | A closed type synonym family declared in an hs-boot file with type family F a where ..
BuiltInSynFamTyCon BuiltInSynFamily | Built-in type family used by the TypeNats solver

#### Instances

Instances details

Outputable FamTyConFlav Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: FamTyConFlav -> SDoc Source #

data Role Source #

See Note [Roles] in GHC.Core.Coercion

Order of constructors matters: the Ord instance coincides with the *super*typing relation on roles.

Constructors

Nominal |
Representational |
Phantom |

#### Instances

Instances details

NFData Role Source # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods rnf :: Role -> () Source #
Binary Role Source # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods put_ :: WriteBinHandle -> Role -> IO () Source # put :: WriteBinHandle -> Role -> IO (Bin Role) Source # get :: ReadBinHandle -> IO Role Source #
Outputable Role Source # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods ppr :: Role -> SDoc Source #
Eq Role Source # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: Role -> Role -> Bool Source # (/=) :: Role -> Role -> Bool Source #
Ord Role Source # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods compare :: Role -> Role -> Ordering Source # (<) :: Role -> Role -> Bool Source # (<=) :: Role -> Role -> Bool Source # (>) :: Role -> Role -> Bool Source # (>=) :: Role -> Role -> Bool Source # max :: Role -> Role -> Role Source # min :: Role -> Role -> Role Source #
Data Role Source # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Role -> c Role Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Role Source # toConstr :: Role -> Constr Source # dataTypeOf :: Role -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Role) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Role) Source # gmapT :: (forall b. Data b => b -> b) -> Role -> Role Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Role -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Role -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Role -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Role -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Role -> m Role Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Role -> m Role Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Role -> m Role Source #
type Anno (Maybe Role) Source # |
Instance details Defined in GHC.Hs.Decls type Anno (Maybe Role) = EpAnnCO

data Injectivity Source #

Constructors

NotInjective |
Injective [Bool] |

#### Instances

Instances details

NFData Injectivity Source # |
Instance details Defined in GHC.Core.TyCon Methods rnf :: Injectivity -> () Source #
Binary Injectivity Source # |
Instance details Defined in GHC.Core.TyCon Methods put_ :: WriteBinHandle -> Injectivity -> IO () Source # put :: WriteBinHandle -> Injectivity -> IO (Bin Injectivity) Source # get :: ReadBinHandle -> IO Injectivity Source #
Eq Injectivity Source # |
Instance details Defined in GHC.Core.TyCon Methods (==) :: Injectivity -> Injectivity -> Bool Source # (/=) :: Injectivity -> Injectivity -> Bool Source #

data PromDataConInfo Source #

Some promoted datacons signify extra info relevant to GHC. For example, the `IntRep` constructor of `RuntimeRep` corresponds to the `IntRep` constructor of `PrimRep`. This data structure allows us to store this information right in the `TyCon`. The other approach would be to look up things like `RuntimeRep`'s `PrimRep` by known-key every time. See also Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType

Constructors

NoPromInfo | an ordinary promoted data con
RuntimeRep ([Type] -> [PrimRep]) | A constructor of `RuntimeRep`. The argument to the function should be the list of arguments to the promoted datacon.
VecCount Int | A constructor of `VecCount`
VecElem PrimElemRep | A constructor of `VecElem`
Levity Levity | A constructor of `Levity`

data TyConFlavour tc Source #

Paints a picture of what a `TyCon` represents, in broad strokes. This is used towards more informative error messages.

Constructors

ClassFlavour |
TupleFlavour Boxity |
SumFlavour |
DataTypeFlavour |
NewtypeFlavour |
AbstractTypeFlavour |
OpenFamilyFlavour TypeOrData (Maybe tc) |
ClosedTypeFamilyFlavour |
TypeSynonymFlavour |
BuiltInTypeFlavour | e.g., the `(->)` `TyCon`.
PromotedDataConFlavour |

#### Instances

Instances details

Functor TyConFlavour Source # |
Instance details Defined in GHC.Types.Basic Methods fmap :: (a -> b) -> TyConFlavour a -> TyConFlavour b Source # (<$) :: a -> TyConFlavour b -> TyConFlavour a Source #
Outputable (TyConFlavour tc) Source # |
Instance details Defined in GHC.Types.Basic Methods ppr :: TyConFlavour tc -> SDoc Source #
Eq tc => Eq (TyConFlavour tc) Source # |
Instance details Defined in GHC.Types.Basic Methods (==) :: TyConFlavour tc -> TyConFlavour tc -> Bool Source # (/=) :: TyConFlavour tc -> TyConFlavour tc -> Bool Source #
Data tc => Data (TyConFlavour tc) Source # |
Instance details Defined in GHC.Types.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyConFlavour tc -> c (TyConFlavour tc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TyConFlavour tc) Source # toConstr :: TyConFlavour tc -> Constr Source # dataTypeOf :: TyConFlavour tc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TyConFlavour tc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TyConFlavour tc)) Source # gmapT :: (forall b. Data b => b -> b) -> TyConFlavour tc -> TyConFlavour tc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConFlavour tc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyConFlavour tc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> TyConFlavour tc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyConFlavour tc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyConFlavour tc -> m (TyConFlavour tc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyConFlavour tc -> m (TyConFlavour tc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyConFlavour tc -> m (TyConFlavour tc) Source #

# TyConBinder

type TyConBinder = VarBndr TyVar TyConBndrVis Source #

data TyConBndrVis Source #

Constructors

NamedTCB ForAllTyFlag | A named, forall-bound variable (invisible or not)
AnonTCB | an ordinary, visible type argument

#### Instances

Instances details

NFData TyConBndrVis Source # |
Instance details Defined in GHC.Core.TyCon Methods rnf :: TyConBndrVis -> () Source #
Binary TyConBndrVis Source # |
Instance details Defined in GHC.Core.TyCon Methods put_ :: WriteBinHandle -> TyConBndrVis -> IO () Source # put :: WriteBinHandle -> TyConBndrVis -> IO (Bin TyConBndrVis) Source # get :: ReadBinHandle -> IO TyConBndrVis Source #
Outputable TyConBndrVis Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: TyConBndrVis -> SDoc Source #
OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: VarBndr tv TyConBndrVis -> SDoc Source #

mkNamedTyConBinder :: ForAllTyFlag -> TyVar -> TyConBinder Source #

mkNamedTyConBinders :: ForAllTyFlag -> [TyVar] -> [TyConBinder] Source #

mkRequiredTyConBinder :: TyCoVarSet -> TyVar -> TyConBinder Source #

Make a Required TyConBinder. It chooses between NamedTCB and AnonTCB based on whether the tv is mentioned in the dependent set

mkAnonTyConBinder :: TyVar -> TyConBinder Source #

mkAnonTyConBinders :: [TyVar] -> [TyConBinder] Source #

tyConBinderForAllTyFlag :: VarBndr a TyConBndrVis -> ForAllTyFlag Source #

tyConBndrVisForAllTyFlag :: TyConBndrVis -> ForAllTyFlag Source #

isNamedTyConBinder :: TyConBinder -> Bool Source #

isVisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool Source #

isInvisSpecTyConBinder :: VarBndr tv TyConBndrVis -> Bool Source #

isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool Source #

isInferredTyConBinder :: VarBndr var TyConBndrVis -> Bool Source #

isVisibleTcbVis :: TyConBndrVis -> Bool Source #

isInvisSpecTcbVis :: TyConBndrVis -> Bool Source #

## Field labels

tyConFieldLabels :: TyCon -> [FieldLabel] Source #

The labels for the fields of this particular `TyCon`

lookupTyConFieldLabel :: FieldLabelString -> TyCon -> Maybe FieldLabel Source #

Look up a field label belonging to this `TyCon`

## Constructing TyCons

mkAlgTyCon Source #

Arguments

:: Name |
-> [TyConBinder] | Binders of the `TyCon`
-> Kind | Result kind
-> [Role] | The roles for each TyVar
-> Maybe CType | The C type this type corresponds to when using the CAPI FFI
-> [PredType] | Stupid theta: see `algTcStupidTheta`
-> AlgTyConRhs | Information about data constructors
-> AlgTyConFlav | What flavour is it? (e.g. vanilla, type family)
-> Bool | Was the `TyCon` declared with GADT syntax?
-> TyCon |

This is the making of an algebraic `TyCon`.

mkClassTyCon :: Name -> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon Source #

Simpler specialization of `mkAlgTyCon` for classes

mkPrimTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | result kind Must answer `True` to `isFixedRuntimeRepKind` (i.e., no representation polymorphism). (If you need a representation-polymorphic PrimTyCon, change tcHasFixedRuntimeRep, marshalablePrimTyCon, reifyTyCon for PrimTyCons.)
-> [Role] |
-> TyCon |

Create an primitive `TyCon`, such as `Int#`, `Type` or `RealWorld` Primitive TyCons are marshalable iff not lifted. If you'd like to change this, modify marshalablePrimTyCon.

mkTupleTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | Result kind of the `TyCon`
-> DataCon |
-> TupleSort | Whether the tuple is boxed or unboxed
-> AlgTyConFlav |
-> TyCon |

mkSumTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | Kind of the resulting `TyCon`
-> [DataCon] |
-> AlgTyConFlav |
-> TyCon |

mkDataTyConRhs :: [DataCon] -> AlgTyConRhs Source #

Create an `AlgTyConRhs` from the data constructors.

Use `mkLevPolyDataConRhs` if the datatype can be levity-polymorphic or if it comes from a "data type" declaration

mkLevPolyDataTyConRhs Source #

Arguments

:: Bool | whether the `DataCon` has a fixed levity
-> Bool | True if this is a "type data" declaration See Note [Type data declarations] in GHC.Rename.Module
-> [DataCon] |
-> AlgTyConRhs |

Create an `AlgTyConRhs` from the data constructors, for a potentially levity-polymorphic datatype (with `UnliftedDatatypes`).

mkSynonymTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | result kind
-> [Role] |
-> Type |
-> Bool |
-> Bool |
-> Bool |
-> Bool |
-> TyCon |

Create a type synonym `TyCon`

mkFamilyTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | result kind
-> Maybe Name |
-> FamTyConFlav |
-> Maybe Class |
-> Injectivity |
-> TyCon |

Create a type family `TyCon`

mkPromotedDataCon :: DataCon -> Name -> TyConRepName -> [TyConBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon Source #

Create a promoted data constructor `TyCon` Somewhat dodgily, we give it the same Name as the data constructor itself; when we pretty-print the TyCon we add a quote; see the Outputable TyCon instance

mkTcTyCon Source #

Arguments

:: Name |
-> [TyConBinder] |
-> Kind | result kind only
-> [(Name, TcTyVar)] | Scoped type variables;
-> Bool | Is this TcTyCon generalised already?
-> TyConFlavour TyCon | What sort of `TyCon` this represents
-> TyCon |

Makes a tycon suitable for use during type-checking. It stores a variety of details about the definition of the TyCon, but no right-hand side. It lives only during the type-checking of a mutually-recursive group of tycons; it is then zonked to a proper TyCon in zonkTcTyCon. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.TyCl

noTcTyConScopedTyVars :: [(Name, TcTyVar)] Source #

No scoped type variables (to be used with mkTcTyCon).

## Predicates on TyCons

isAlgTyCon :: TyCon -> Bool Source #

Returns `True` if the supplied `TyCon` resulted from either a `data` or `newtype` declaration

isVanillaAlgTyCon :: TyCon -> Bool Source #

Returns `True` for vanilla AlgTyCons -- that is, those created with a `data` or `newtype` declaration.

isClassTyCon :: TyCon -> Bool Source #

Is this `TyCon` that for a class instance?

isUnaryClassTyCon :: TyCon -> Bool Source #

isUnaryClassTyCon_maybe :: TyCon -> Maybe (Class, DataCon) Source #

isFamInstTyCon :: TyCon -> Bool Source #

Is this `TyCon` that for a data family instance?

isPrimTyCon :: TyCon -> Bool Source #

Does this `TyCon` represent something that cannot be defined in Haskell?

isTupleTyCon :: TyCon -> Bool Source #

Does this `TyCon` represent a tuple?

NB: when compiling `Data.Tuple`, the tycons won't reply `True` to `isTupleTyCon`, because they are built as `AlgTyCons`. However they get spat into the interface file as tuple tycons, so I don't think it matters.

isUnboxedTupleTyCon :: TyCon -> Bool Source #

Is this the `TyCon` for an unboxed tuple?

isBoxedTupleTyCon :: TyCon -> Bool Source #

Is this the `TyCon` for a boxed tuple?

isUnboxedSumTyCon :: TyCon -> Bool Source #

Is this the `TyCon` for an unboxed sum?

isPromotedTupleTyCon :: TyCon -> Bool Source #

Is this the `TyCon` for a promoted tuple?

isLiftedAlgTyCon :: TyCon -> Bool Source #

isTypeSynonymTyCon :: TyCon -> Bool Source #

Is this a `TyCon` representing a regular H98 type synonym (`type`)?

tyConMustBeSaturated :: TyCon -> Bool Source #

True iff we can decompose (T a b c) into ((T a b) c) I.e. is it injective and generative w.r.t nominal equality? That is, if (T a b) ~N d e f, is it always the case that (T ~N d), (a ~N e) and (b ~N f)? Specifically NOT true of synonyms (open and otherwise)

It'd be unusual to call tyConMustBeSaturated on a regular H98 type synonym, because you should probably have expanded it first But regardless, it's not decomposable

isPromotedDataCon :: TyCon -> Bool Source #

Is this a PromotedDataCon?

isPromotedDataCon_maybe :: TyCon -> Maybe DataCon Source #

Retrieves the promoted DataCon if this is a PromotedDataCon;

isDataKindsPromotedDataCon :: TyCon -> Bool Source #

This function identifies PromotedDataCon's from data constructors in `data T = K1 | K2`, promoted by -XDataKinds. These type constructors are printed with a tick mark 'K1 and 'K2, and similarly have a tick mark added to their OccName's.

In contrast, constructors in `type data T = K1 | K2` are printed and represented with their original undecorated names. See Note [Type data declarations] in GHC.Rename.Module

isKindTyCon :: TyCon -> Bool Source #

Is this `TyCon` really meant for use at the kind level? That is, should it be permitted without `DataKinds`?

isKindName :: Name -> Bool Source #

This is `Name` really meant for use at the kind level? That is, should it be permitted wihout `DataKinds`?

isLiftedTypeKindTyConName :: Name -> Bool Source #

isTauTyCon :: TyCon -> Bool Source #

isFamFreeTyCon :: TyCon -> Bool Source #

Is this tycon neither a type family nor a synonym that expands to a type family?

isForgetfulSynTyCon :: TyCon -> Bool Source #

Is this a forgetful type synonym? If this is a type synonym whose RHS does not mention one (or more) of its bound variables, returns True. Thus, False means that all bound variables appear on the RHS; True may not mean anything, as the test to set this flag is conservative.

See Note [Forgetful type synonyms]

isBoxedDataTyCon :: TyCon -> Bool Source #

Returns `True` for data types that are definitely represented by heap-allocated constructors. These are scrutinised by Core-level `case` expressions, and they get info tables allocated for them.

Generally, the function will be true for all `data` types and false for newtype unboxed tuples unboxed sums type family type data `TyCon`s. But it is not guaranteed to return `True` in all cases that it could.

NB: for a data type family, only the instance `TyCon`s get an info table. The family declaration `TyCon` does not

isTypeDataTyCon :: TyCon -> Bool Source #

Was this `TyCon` declared as "type data"? See Note [Type data declarations] in GHC.Rename.Module.

isEnumerationTyCon :: TyCon -> Bool Source #

Is this an algebraic `TyCon` which is just an enumeration of values?

isNewTyCon :: TyCon -> Bool Source #

Is this `TyCon` that for a `newtype`

isAbstractTyCon :: TyCon -> Bool Source #

Test if the `TyCon` is algebraic but abstract (invisible data constructors)

isFamilyTyCon :: TyCon -> Bool Source #

Is this a `TyCon`, synonym or otherwise, that defines a family?

isOpenFamilyTyCon :: TyCon -> Bool Source #

Is this a `TyCon`, synonym or otherwise, that defines a family with instances?

isTypeFamilyTyCon :: TyCon -> Bool Source #

Is this a type family `TyCon` (whether open or closed)?

isDataFamilyTyCon :: TyCon -> Bool Source #

Is this a data family `TyCon`?

isOpenTypeFamilyTyCon :: TyCon -> Bool Source #

Is this an open type family TyCon?

isClosedSynFamilyTyConWithAxiom_maybe :: TyCon -> Maybe (CoAxiom Branched) Source #

Is this a non-empty closed type family? Returns `Nothing` for abstract or empty closed families.

tyConInjectivityInfo :: TyCon -> Injectivity Source #

``tyConInjectivityInfo` tc` returns ``Injective` is` if `tc` is an injective tycon (where `is` states for which `tyConBinders` `tc` is injective), or `NotInjective` otherwise.

isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily Source #

isGadtSyntaxTyCon :: TyCon -> Bool Source #

Is this an algebraic `TyCon` declared with the GADT syntax?

isInjectiveTyCon :: TyCon -> Role -> Bool Source #

`isInjectiveTyCon` is true of `TyCon`s for which this property holds (where r is the role passed in): If (T a1 b1 c1) ~r (T a2 b2 c2), then (a1 ~r1 a2), (b1 ~r2 b2), and (c1 ~r3 c2) (where r1, r2, and r3, are the roles given by tyConRolesX tc r) See also Note [Decomposing TyConApp equalities] in GHC.Tc.Solver.Equality

isGenerativeTyCon :: TyCon -> Role -> Bool Source #

`isGenerativeTyCon` is true of `TyCon`s for which this property holds (where r is the role passed in): If (T tys ~r t), then (t's head ~r T). See also Note [Decomposing TyConApp equalities] in GHC.Tc.Solver.Equality

NB: at Nominal role, isGenerativeTyCon is simple: isGenerativeTyCon tc Nominal = not (isTypeFamilyTyCon tc || isSynonymTyCon tc)

isTyConAssoc :: TyCon -> Bool Source #

Is this TyCon for an associated type?

tyConAssoc_maybe :: TyCon -> Maybe TyCon Source #

Get the enclosing class TyCon (if there is one) for the given TyCon.

tyConFlavourAssoc_maybe :: TyConFlavour tc -> Maybe tc Source #

Get the enclosing class TyCon (if there is one) for the given TyConFlavour

isImplicitTyCon :: TyCon -> Bool Source #

Identifies implicit tycons that, in particular, do not go into interface files (because they are implicitly reconstructed when the interface is read).

Note that:

- Associated families are implicit, as they are re-constructed from the class declaration in which they reside, and
- Family instances are not implicit as they represent the instance body (similar to a `dfun` does that for a class instance).
- Tuples are implicit iff they have a wired-in name (namely: boxed and unboxed tuples are wired-in and implicit, but constraint tuples are not)

isTyConWithSrcDataCons :: TyCon -> Bool Source #

Check if the tycon actually refers to a proper `data` or `newtype` with user defined constructors rather than one from a class or other construction.

isTcTyCon :: TyCon -> Bool Source #

Is this a TcTyCon? (That is, one only used during type-checking?)

setTcTyConKind :: TyCon -> Kind -> TyCon Source #

tcHasFixedRuntimeRep :: TyCon -> Bool Source #

Does this `TyCon` have a syntactically fixed RuntimeRep when fully applied, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete?

False is safe. True means we're sure. Does only a quick check, based on the TyCon's category.

See Note [Representation-polymorphic TyCons]

isConcreteTyCon :: TyCon -> Bool Source #

Is this `TyCon` concrete? More specifically, if `tys` are all concrete, is (T tys) concrete? (for synonyms this requires us to look at the RHS) Used for representation polymorphism checks. See Note [Concrete types] in GHC.Tc.Utils.Concrete

isValidDTT2TyCon :: TyCon -> Bool Source #

Returns `True` if a boxed type headed by the given `TyCon` satisfies condition DTT2 of Note [DataToTag overview] in GHC.Tc.Instance.Class

## Extracting information out of TyCons

tyConName :: TyCon -> Name Source #

Name of the constructor

tyConSkolem :: TyCon -> Bool Source #

Returns whether or not this `TyCon` is definite, or a hole that may be filled in at some later point. See Note [Skolem abstract data]

tyConKind :: TyCon -> Kind Source #

Kind of this TyCon

tyConUnique :: TyCon -> Unique Source #

A Unique of this TyCon. Invariant: identical to Unique of Name stored in tyConName field.

tyConTyVars :: TyCon -> [TyVar] Source #

TyVar binders

tyConVisibleTyVars :: TyCon -> [TyVar] Source #

tyConCType_maybe :: TyCon -> Maybe CType Source #

tyConDataCons :: TyCon -> [DataCon] Source #

As `tyConDataCons_maybe`, but returns the empty list of constructors if no constructors could be found

tyConDataCons_maybe :: TyCon -> Maybe [DataCon] Source #

Determine the `DataCon`s originating from the given `TyCon`, if the `TyCon` is the sort that can have any constructors (note: this does not include abstract algebraic types)

tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon Source #

If the given `TyCon` has a single data constructor, i.e. it is a `data` type with one alternative, a tuple type or a `newtype` then that constructor is returned. If the `TyCon` has more than one constructor, or represents a primitive or function type constructor then `Nothing` is returned.

tyConSingleDataCon :: TyCon -> DataCon Source #

Like `tyConSingleDataCon_maybe`, but panics if `Nothing`.

tyConFamilySize :: TyCon -> Int Source #

Determine the number of value constructors a `TyCon` has. Panics if the `TyCon` is not algebraic or a tuple

tyConStupidTheta :: TyCon -> [PredType] Source #

Find the "stupid theta" of the `TyCon`. A "stupid theta" is the context to the left of an algebraic type declaration, e.g. `Eq a` in the declaration `data Eq a => T a ...`. See `Note [The stupid context]` in GHC.Core.DataCon.

tyConArity :: TyCon -> Arity Source #

Arity

tyConNullaryTy :: TyCon -> Type Source #

A pre-allocated `TyConApp tycon []`

mkTyConTy :: TyCon -> Type Source #

(mkTyConTy tc) returns (TyConApp tc []) but arranges to share that TyConApp among all calls See Note [Sharing nullary TyConApps] So it's just an alias for tyConNullaryTy!

tyConRoles :: TyCon -> [Role] Source #

The role for each type variable This list has length = tyConArity See also Note [TyCon Role signatures]

tyConFlavour :: TyCon -> TyConFlavour TyCon Source #

tyConTuple_maybe :: TyCon -> Maybe TupleSort Source #

tyConClass_maybe :: TyCon -> Maybe Class Source #

If this `TyCon` is that for a class instance, return the class it is for. Otherwise returns `Nothing`

tyConATs :: TyCon -> [TyCon] Source #

Return the associated types of the `TyCon`, if any

tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type]) Source #

If this `TyCon` is that of a data family instance, return the family in question and the instance types. Otherwise, return `Nothing`

tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched) Source #

tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched) Source #

If this `TyCon` is that of a data family instance, return a `TyCon` which represents a coercion identifying the representation type with the type instance family. Otherwise, return `Nothing`

tyConFamilyResVar_maybe :: TyCon -> Maybe Name Source #

Extract type variable naming the result of injective type family

synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) Source #

Extract the `TyVar`s bound by a vanilla type synonym and the corresponding (unsubstituted) right hand side.

synTyConRhs_maybe :: TyCon -> Maybe Type Source #

Extract the information pertaining to the right hand side of a type synonym (`type`) declaration.

famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav Source #

Extract the flavour of a type family (with all the extra information that it carries)

algTyConRhs :: TyCon -> AlgTyConRhs Source #

Extract an `AlgTyConRhs` with information about data constructors from an algebraic or tuple `TyCon`. Panics for any other sort of `TyCon`

newTyConRhs :: TyCon -> ([TyVar], Type) Source #

Extract the bound type variables and type expansion of a type synonym `TyCon`. Panics if the `TyCon` is not a synonym

newTyConEtadArity :: TyCon -> Int Source #

The number of type parameters that need to be passed to a newtype to resolve it. May be less than in the definition if it can be eta-contracted.

newTyConEtadRhs :: TyCon -> ([TyVar], Type) Source #

Extract the bound type variables and type expansion of an eta-contracted type synonym `TyCon`. Panics if the `TyCon` is not a synonym

unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) Source #

Take a `TyCon` apart into the `TyVar`s it scopes over, the `Type` it expands into, and (possibly) a coercion from the representation type to the `newtype`. Returns `Nothing` if this is not possible.

unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) Source #

newTyConDataCon_maybe :: TyCon -> Maybe DataCon Source #

algTcFields :: TyConDetails -> FieldLabelEnv Source #

Maps a label to information about the field

tyConPromDataConInfo :: TyCon -> PromDataConInfo Source #

Extract any `RuntimeRepInfo` from this TyCon

tyConBinders :: TyCon -> [TyConBinder] Source #

Full binders

tyConResKind :: TyCon -> Kind Source #

Result kind

tyConInvisTVBinders :: [TyConBinder] -> [InvisTVBinder] Source #

tcTyConScopedTyVars :: TyCon -> [(Name, TcTyVar)] Source #

isMonoTcTyCon :: TyCon -> Bool Source #

tyConHasClosedResKind :: TyCon -> Bool Source #

mkTyConTagMap :: TyCon -> NameEnv ConTag Source #

## Manipulating TyCons

data ExpandSynResult tyco Source #

Constructors

NoExpansion |
ExpandsSyn [(TyVar, tyco)] Type [tyco] |

expandSynTyCon_maybe Source #

Arguments

:: TyCon |
-> [tyco] | Arguments to `TyCon`
-> ExpandSynResult tyco | Returns a `TyVar` substitution, the body type of the synonym (not yet substituted) and any arguments remaining from the application ^ Expand a type synonym application Return Nothing if the TyCon is not a synonym, or if not enough arguments are supplied

newTyConCo :: TyCon -> CoAxiom Unbranched Source #

newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched) Source #

Extracts the `newtype` coercion from such a `TyCon`, which can be used to construct something with the `newtype`s type from its representation type (right hand side). If the supplied `TyCon` is not a `newtype`, returns `Nothing`

pprPromotionQuote :: TyCon -> SDoc Source #

mkTyConKind :: [TyConBinder] -> Kind -> Kind Source #

## Predicated on TyConFlavours

tcFlavourIsOpen :: TyConFlavour tc -> Bool Source #

Is this flavour of `TyCon` an open type family or a data family?

# Runtime type representation

type TyConRepName = Name Source #

tyConRepName_maybe :: TyCon -> Maybe TyConRepName Source #

mkPrelTyConRepName :: Name -> TyConRepName Source #

Make a `Name` for the `Typeable` representation of the given wired-in type

tyConRepModOcc :: Module -> OccName -> (Module, OccName) Source #

The name (and defining module) for the Typeable representation (TyCon) of a type constructor.

See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable.

# Primitive representations of Types

data PrimRep Source #

A `PrimRep` is an abstraction of a non-void type. (Use `PrimRepOrVoidRep` if you want void types too.) It contains information that the code generator needs in order to pass arguments, return results, and store values of this type. See also Note [RuntimeRep and PrimRep] in GHC.Types.RepType and Note [VoidRep] in GHC.Types.RepType.

Constructors

BoxedRep !(Maybe Levity) | Boxed, heap value
Int8Rep | Signed, 8-bit value
Int16Rep | Signed, 16-bit value
Int32Rep | Signed, 32-bit value
Int64Rep | Signed, 64 bit value
IntRep | Signed, word-sized value
Word8Rep | Unsigned, 8 bit value
Word16Rep | Unsigned, 16 bit value
Word32Rep | Unsigned, 32 bit value
Word64Rep | Unsigned, 64 bit value
WordRep | Unsigned, word-sized value
AddrRep | A pointer, but not to a Haskell value (use `BoxedRep`)
FloatRep |
DoubleRep |
VecRep Int PrimElemRep | A vector

#### Instances

Instances details

Binary PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods put_ :: WriteBinHandle -> PrimRep -> IO () Source # put :: WriteBinHandle -> PrimRep -> IO (Bin PrimRep) Source # get :: ReadBinHandle -> IO PrimRep Source #
Outputable PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: PrimRep -> SDoc Source #
Eq PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods (==) :: PrimRep -> PrimRep -> Bool Source # (/=) :: PrimRep -> PrimRep -> Bool Source #
Ord PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods compare :: PrimRep -> PrimRep -> Ordering Source # (<) :: PrimRep -> PrimRep -> Bool Source # (<=) :: PrimRep -> PrimRep -> Bool Source # (>) :: PrimRep -> PrimRep -> Bool Source # (>=) :: PrimRep -> PrimRep -> Bool Source # max :: PrimRep -> PrimRep -> PrimRep Source # min :: PrimRep -> PrimRep -> PrimRep Source #
Data PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PrimRep -> c PrimRep Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PrimRep Source # toConstr :: PrimRep -> Constr Source # dataTypeOf :: PrimRep -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PrimRep) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PrimRep) Source # gmapT :: (forall b. Data b => b -> b) -> PrimRep -> PrimRep Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PrimRep -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PrimRep -> r Source # gmapQ :: (forall d. Data d => d -> u) -> PrimRep -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> PrimRep -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PrimRep -> m PrimRep Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimRep -> m PrimRep Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimRep -> m PrimRep Source #
Show PrimRep Source # |
Instance details Defined in GHC.Core.TyCon Methods showsPrec :: Int -> PrimRep -> ShowS Source # show :: PrimRep -> String Source # showList :: [PrimRep] -> ShowS Source #

data PrimElemRep Source #

Constructors

Int8ElemRep |
Int16ElemRep |
Int32ElemRep |
Int64ElemRep |
Word8ElemRep |
Word16ElemRep |
Word32ElemRep |
Word64ElemRep |
FloatElemRep |
DoubleElemRep |

#### Instances

Instances details

Binary PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods put_ :: WriteBinHandle -> PrimElemRep -> IO () Source # put :: WriteBinHandle -> PrimElemRep -> IO (Bin PrimElemRep) Source # get :: ReadBinHandle -> IO PrimElemRep Source #
Outputable PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods ppr :: PrimElemRep -> SDoc Source #
Eq PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods (==) :: PrimElemRep -> PrimElemRep -> Bool Source # (/=) :: PrimElemRep -> PrimElemRep -> Bool Source #
Ord PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods compare :: PrimElemRep -> PrimElemRep -> Ordering Source # (<) :: PrimElemRep -> PrimElemRep -> Bool Source # (<=) :: PrimElemRep -> PrimElemRep -> Bool Source # (>) :: PrimElemRep -> PrimElemRep -> Bool Source # (>=) :: PrimElemRep -> PrimElemRep -> Bool Source # max :: PrimElemRep -> PrimElemRep -> PrimElemRep Source # min :: PrimElemRep -> PrimElemRep -> PrimElemRep Source #
Data PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PrimElemRep -> c PrimElemRep Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PrimElemRep Source # toConstr :: PrimElemRep -> Constr Source # dataTypeOf :: PrimElemRep -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PrimElemRep) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PrimElemRep) Source # gmapT :: (forall b. Data b => b -> b) -> PrimElemRep -> PrimElemRep Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PrimElemRep -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PrimElemRep -> r Source # gmapQ :: (forall d. Data d => d -> u) -> PrimElemRep -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> PrimElemRep -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PrimElemRep -> m PrimElemRep Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimElemRep -> m PrimElemRep Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimElemRep -> m PrimElemRep Source #
Enum PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods succ :: PrimElemRep -> PrimElemRep Source # pred :: PrimElemRep -> PrimElemRep Source # toEnum :: Int -> PrimElemRep Source # fromEnum :: PrimElemRep -> Int Source # enumFrom :: PrimElemRep -> [PrimElemRep] Source # enumFromThen :: PrimElemRep -> PrimElemRep -> [PrimElemRep] Source # enumFromTo :: PrimElemRep -> PrimElemRep -> [PrimElemRep] Source # enumFromThenTo :: PrimElemRep -> PrimElemRep -> PrimElemRep -> [PrimElemRep] Source #
Show PrimElemRep Source # |
Instance details Defined in GHC.Core.TyCon Methods showsPrec :: Int -> PrimElemRep -> ShowS Source # show :: PrimElemRep -> String Source # showList :: [PrimElemRep] -> ShowS Source #

data Levity Source #

Constructors

Lifted |
Unlifted |

#### Instances

Instances details

Binary Levity Source # |
Instance details Defined in GHC.Types.Basic Methods put_ :: WriteBinHandle -> Levity -> IO () Source # put :: WriteBinHandle -> Levity -> IO (Bin Levity) Source # get :: ReadBinHandle -> IO Levity Source #
Outputable Levity Source # |
Instance details Defined in GHC.Types.Basic Methods ppr :: Levity -> SDoc Source #
Eq Levity Source # |
Instance details Defined in GHC.Types.Basic Methods (==) :: Levity -> Levity -> Bool Source # (/=) :: Levity -> Levity -> Bool Source #
Ord Levity Source # |
Instance details Defined in GHC.Types.Basic Methods compare :: Levity -> Levity -> Ordering Source # (<) :: Levity -> Levity -> Bool Source # (<=) :: Levity -> Levity -> Bool Source # (>) :: Levity -> Levity -> Bool Source # (>=) :: Levity -> Levity -> Bool Source # max :: Levity -> Levity -> Levity Source # min :: Levity -> Levity -> Levity Source #
Data Levity Source # |
Instance details Defined in GHC.Types.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Levity -> c Levity Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Levity Source # toConstr :: Levity -> Constr Source # dataTypeOf :: Levity -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Levity) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Levity) Source # gmapT :: (forall b. Data b => b -> b) -> Levity -> Levity Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Levity -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Levity -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Levity -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Levity -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Levity -> m Levity Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Levity -> m Levity Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Levity -> m Levity Source #
Show Levity Source # |
Instance details Defined in GHC.Types.Basic Methods showsPrec :: Int -> Levity -> ShowS Source # show :: Levity -> String Source # showList :: [Levity] -> ShowS Source #

data PrimOrVoidRep Source #

Constructors

VoidRep |
NVRep PrimRep |

#### Instances

Instances details

Eq PrimOrVoidRep Source # |
Instance details Defined in GHC.Core.TyCon Methods (==) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source # (/=) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source #
Ord PrimOrVoidRep Source # |
Instance details Defined in GHC.Core.TyCon Methods compare :: PrimOrVoidRep -> PrimOrVoidRep -> Ordering Source # (<) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source # (<=) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source # (>) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source # (>=) :: PrimOrVoidRep -> PrimOrVoidRep -> Bool Source # max :: PrimOrVoidRep -> PrimOrVoidRep -> PrimOrVoidRep Source # min :: PrimOrVoidRep -> PrimOrVoidRep -> PrimOrVoidRep Source #
Data PrimOrVoidRep Source # |
Instance details Defined in GHC.Core.TyCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PrimOrVoidRep -> c PrimOrVoidRep Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PrimOrVoidRep Source # toConstr :: PrimOrVoidRep -> Constr Source # dataTypeOf :: PrimOrVoidRep -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PrimOrVoidRep) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PrimOrVoidRep) Source # gmapT :: (forall b. Data b => b -> b) -> PrimOrVoidRep -> PrimOrVoidRep Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PrimOrVoidRep -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PrimOrVoidRep -> r Source # gmapQ :: (forall d. Data d => d -> u) -> PrimOrVoidRep -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> PrimOrVoidRep -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PrimOrVoidRep -> m PrimOrVoidRep Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimOrVoidRep -> m PrimOrVoidRep Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PrimOrVoidRep -> m PrimOrVoidRep Source #
Show PrimOrVoidRep Source # |
Instance details Defined in GHC.Core.TyCon Methods showsPrec :: Int -> PrimOrVoidRep -> ShowS Source # show :: PrimOrVoidRep -> String Source # showList :: [PrimOrVoidRep] -> ShowS Source #

primElemRepToPrimRep :: PrimElemRep -> PrimRep Source #

isGcPtrRep :: PrimRep -> Bool Source #

primRepSizeB :: Platform -> PrimRep -> Int Source #

The size of a `PrimRep` in bytes.

This applies also when used in a constructor, where we allow packing the fields. For instance, in `data Foo = Foo Float# Float#` the two fields will take only 8 bytes, which for 64-bit arch will be equal to 1 word. See also mkVirtHeapOffsetsWithPadding for details of how data fields are laid out.

primRepSizeW64_B :: PrimRep -> Int Source #

Like primRepSizeB but assumes pointers/words are 8 words wide.

This can be useful to compute the size of a rep as if we were compiling for a 64bit platform.

primElemRepSizeB :: Platform -> PrimElemRep -> Int Source #

primElemRepSizeW64_B :: PrimElemRep -> Int Source #

Like primElemRepSizeB but assumes pointers/words are 8 words wide.

This can be useful to compute the size of a rep as if we were compiling for a 64bit platform.

primRepIsFloat :: PrimRep -> Maybe Bool Source #

Return if Rep stands for floating type, returns Nothing for vector types.

primRepsCompatible :: Platform -> [PrimRep] -> [PrimRep] -> Bool Source #

primRepCompatible :: Platform -> PrimRep -> PrimRep -> Bool Source #

primRepIsWord :: PrimRep -> Bool Source #

primRepIsInt :: PrimRep -> Bool Source #