GHC.Core.DataCon

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

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.DataCon

Contents

- Main data types
  - Equality specs
  - Field labels
  - Type construction
  - Type deconstruction
  - Predicates on DataCons
  - Promotion related functions
- Orphan instances

Synopsis

- data DataCon
- data DataConRep
  - = NoDataConRep
  - | DCR {
    - dcr_wrap_id :: Id
    - dcr_boxer :: DataConBoxer
    - dcr_arg_tys :: [Scaled Type]
    }
- data SrcStrictness
  - = SrcLazy
  - | SrcStrict
  - | NoSrcStrict
- data SrcUnpackedness
  - = SrcUnpack
  - | SrcNoUnpack
  - | NoSrcUnpack
- data HsSrcBang = HsSrcBang SourceText SrcUnpackedness SrcStrictness
- data HsImplBang
  - = HsLazy
  - | HsStrict Bool
  - | HsUnpack (Maybe Coercion)
- data StrictnessMark
  - = MarkedStrict
  - | NotMarkedStrict
- type ConTag = Int
- type DataConEnv a = UniqFM DataCon a
- data EqSpec
- mkEqSpec :: TyVar -> Type -> EqSpec
- eqSpecTyVar :: EqSpec -> TyVar
- eqSpecType :: EqSpec -> Type
- eqSpecPair :: EqSpec -> (TyVar, Type)
- eqSpecPreds :: [EqSpec] -> ThetaType
- data FieldLabel = FieldLabel {
  - flHasDuplicateRecordFields :: DuplicateRecordFields
  - flHasFieldSelector :: FieldSelectors
  - flSelector :: Name
  }
- flLabel :: FieldLabel -> FieldLabelString
- data FieldLabelString
- mkDataCon :: Name -> Bool -> TyConRepName -> [HsSrcBang] -> [HsImplBang] -> [StrictnessMark] -> [FieldLabel] -> [TyVar] -> [TyCoVar] -> ConcreteTyVars -> [TyVarBinder] -> [EqSpec] -> KnotTied ThetaType -> [KnotTied (Scaled Type)] -> KnotTied Type -> PromDataConInfo -> KnotTied TyCon -> ConTag -> ThetaType -> Id -> DataConRep -> DataCon
- fIRST_TAG :: ConTag
- dataConRepType :: DataCon -> Type
- dataConInstSig :: DataCon -> [Type] -> ([TyCoVar], ThetaType, [Type])
- dataConFullSig :: DataCon -> ([TyVar], [TyCoVar], [EqSpec], ThetaType, [Scaled Type], Type)
- dataConName :: DataCon -> Name
- dataConIdentity :: DataCon -> ByteString
- dataConTag :: DataCon -> ConTag
- dataConTagZ :: DataCon -> ConTagZ
- dataConTyCon :: DataCon -> TyCon
- dataConOrigTyCon :: DataCon -> TyCon
- dataConWrapperType :: DataCon -> Type
- dataConNonlinearType :: DataCon -> Type
- dataConDisplayType :: Bool -> DataCon -> Type
- dataConUnivTyVars :: DataCon -> [TyVar]
- dataConExTyCoVars :: DataCon -> [TyCoVar]
- dataConUnivAndExTyCoVars :: DataCon -> [TyCoVar]
- dataConConcreteTyVars :: DataCon -> ConcreteTyVars
- dataConUserTyVars :: DataCon -> [TyVar]
- dataConUserTyVarBinders :: DataCon -> [TyVarBinder]
- dataConTheta :: DataCon -> ThetaType
- dataConStupidTheta :: DataCon -> ThetaType
- dataConOtherTheta :: DataCon -> ThetaType
- dataConInstArgTys :: DataCon -> [Type] -> [Scaled Type]
- dataConOrigArgTys :: DataCon -> [Scaled Type]
- dataConOrigResTy :: DataCon -> Type
- dataConInstOrigArgTys :: DataCon -> [Type] -> [Scaled Type]
- dataConRepArgTys :: DataCon -> [Scaled Type]
- dataConResRepTyArgs :: DataCon -> [Type]
- dataConInstUnivs :: DataCon -> [Type] -> [Type]
- dataConFieldLabels :: DataCon -> [FieldLabel]
- dataConFieldType :: DataCon -> FieldLabelString -> Type
- dataConFieldType_maybe :: DataCon -> FieldLabelString -> Maybe (FieldLabel, Type)
- dataConSrcBangs :: DataCon -> [HsSrcBang]
- dataConSourceArity :: DataCon -> Arity
- dataConVisArity :: DataCon -> VisArity
- dataConRepArity :: DataCon -> Arity
- dataConIsInfix :: DataCon -> Bool
- dataConWorkId :: DataCon -> Id
- dataConWrapId :: DataCon -> Id
- dataConWrapId_maybe :: DataCon -> Maybe Id
- dataConImplicitTyThings :: DataCon -> [TyThing]
- dataConRepStrictness :: DataCon -> [StrictnessMark]
- dataConImplBangs :: DataCon -> [HsImplBang]
- dataConBoxer :: DataCon -> Maybe DataConBoxer
- splitDataProductType_maybe :: Type -> Maybe (TyCon, [Type], DataCon, [Scaled Type])
- isNullarySrcDataCon :: DataCon -> Bool
- isNullaryRepDataCon :: DataCon -> Bool
- isLazyDataConRep :: DataCon -> Bool
- isTupleDataCon :: DataCon -> Bool
- isBoxedTupleDataCon :: DataCon -> Bool
- isUnboxedTupleDataCon :: DataCon -> Bool
- isUnboxedSumDataCon :: DataCon -> Bool
- isCovertGadtDataCon :: DataCon -> Bool
- isUnaryClassDataCon :: DataCon -> Bool
- isVanillaDataCon :: DataCon -> Bool
- isNewDataCon :: DataCon -> Bool
- isTypeDataCon :: DataCon -> Bool
- classDataCon :: Class -> DataCon
- dataConCannotMatch :: [Type] -> DataCon -> Bool
- dataConUserTyVarBindersNeedWrapper :: DataCon -> Bool
- checkDataConTyVars :: DataCon -> Bool
- isBanged :: HsImplBang -> Bool
- isUnpacked :: HsImplBang -> Bool
- isMarkedStrict :: StrictnessMark -> Bool
- cbvFromStrictMark :: StrictnessMark -> CbvMark
- eqHsBang :: HsImplBang -> HsImplBang -> Bool
- isSrcStrict :: SrcStrictness -> Bool
- isSrcUnpacked :: SrcUnpackedness -> Bool
- specialPromotedDc :: DataCon -> Bool
- promoteDataCon :: DataCon -> TyCon

# Main data types

data DataCon #

A data constructor

#### Instances

Instances details

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

data DataConRep #

Data Constructor Representation See Note [Data constructor workers and wrappers]

Constructors

NoDataConRep |
DCR |
Fields dcr_wrap_id :: Id dcr_boxer :: DataConBoxer dcr_arg_tys :: [Scaled Type]

data SrcStrictness #

Source Strictness

What strictness annotation the user wrote

Constructors

SrcLazy | Lazy, ie `~`
SrcStrict | Strict, ie `!`
NoSrcStrict | no strictness annotation

#### Instances

Instances details

NFData SrcStrictness # |
Instance details Defined in GHC.Core.DataCon Methods rnf :: SrcStrictness -> () #
Data SrcStrictness # |
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) -> SrcStrictness -> c SrcStrictness # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcStrictness # toConstr :: SrcStrictness -> Constr # dataTypeOf :: SrcStrictness -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcStrictness) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcStrictness) # gmapT :: (forall b. Data b => b -> b) -> SrcStrictness -> SrcStrictness # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcStrictness -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcStrictness -> r # gmapQ :: (forall d. Data d => d -> u) -> SrcStrictness -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcStrictness -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcStrictness -> m SrcStrictness # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcStrictness -> m SrcStrictness # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcStrictness -> m SrcStrictness #
Binary SrcStrictness # |
Instance details Defined in GHC.Core.DataCon Methods put_ :: WriteBinHandle -> SrcStrictness -> IO () # put :: WriteBinHandle -> SrcStrictness -> IO (Bin SrcStrictness) # get :: ReadBinHandle -> IO SrcStrictness #
Outputable SrcStrictness # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: SrcStrictness -> SDoc #
Eq SrcStrictness # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: SrcStrictness -> SrcStrictness -> Bool # (/=) :: SrcStrictness -> SrcStrictness -> Bool #

data SrcUnpackedness #

Source Unpackedness

What unpackedness the user requested

Constructors

SrcUnpack | {-# UNPACK #-} specified
SrcNoUnpack | {-# NOUNPACK #-} specified
NoSrcUnpack | no unpack pragma

#### Instances

Instances details

NFData SrcUnpackedness # |
Instance details Defined in GHC.Core.DataCon Methods rnf :: SrcUnpackedness -> () #
Data SrcUnpackedness # |
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) -> SrcUnpackedness -> c SrcUnpackedness # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcUnpackedness # toConstr :: SrcUnpackedness -> Constr # dataTypeOf :: SrcUnpackedness -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcUnpackedness) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcUnpackedness) # gmapT :: (forall b. Data b => b -> b) -> SrcUnpackedness -> SrcUnpackedness # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcUnpackedness -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcUnpackedness -> r # gmapQ :: (forall d. Data d => d -> u) -> SrcUnpackedness -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcUnpackedness -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcUnpackedness -> m SrcUnpackedness # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcUnpackedness -> m SrcUnpackedness # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcUnpackedness -> m SrcUnpackedness #
Binary SrcUnpackedness # |
Instance details Defined in GHC.Core.DataCon Methods put_ :: WriteBinHandle -> SrcUnpackedness -> IO () # put :: WriteBinHandle -> SrcUnpackedness -> IO (Bin SrcUnpackedness) # get :: ReadBinHandle -> IO SrcUnpackedness #
Outputable SrcUnpackedness # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: SrcUnpackedness -> SDoc #
Eq SrcUnpackedness # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: SrcUnpackedness -> SrcUnpackedness -> Bool # (/=) :: SrcUnpackedness -> SrcUnpackedness -> Bool #

data HsSrcBang #

Haskell Source Bang

Bangs on data constructor arguments as written by the user, including the source code for exact-printing.

`(HsSrcBang _ SrcUnpack SrcLazy)` and `(HsSrcBang _ SrcUnpack NoSrcStrict)` (without StrictData) makes no sense, we emit a warning (in checkValidDataCon) and treat it like `(HsSrcBang _ NoSrcUnpack SrcLazy)`

In the AST, the `SourceText` is hidden inside the extension point `XConDeclField`.

Constructors

HsSrcBang SourceText SrcUnpackedness SrcStrictness |

#### Instances

Instances details

Data HsSrcBang # |
Instance details Defined in GHC.Core.DataCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsSrcBang -> c HsSrcBang # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsSrcBang # toConstr :: HsSrcBang -> Constr # dataTypeOf :: HsSrcBang -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsSrcBang) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsSrcBang) # gmapT :: (forall b. Data b => b -> b) -> HsSrcBang -> HsSrcBang # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsSrcBang -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsSrcBang -> r # gmapQ :: (forall d. Data d => d -> u) -> HsSrcBang -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsSrcBang -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsSrcBang -> m HsSrcBang # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsSrcBang -> m HsSrcBang # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsSrcBang -> m HsSrcBang #
Outputable HsSrcBang # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: HsSrcBang -> SDoc #

data HsImplBang #

Haskell Implementation Bang

Bangs of data constructor arguments as generated by the compiler after consulting HsSrcBang, flags, etc.

Constructors

HsLazy | Lazy field, or one with an unlifted type
HsStrict Bool | Strict but not unpacked field True = we could have unpacked, but opted not to because of -O0. See Note [Detecting useless UNPACK pragmas]
HsUnpack (Maybe Coercion) | Strict and unpacked field co :: arg-ty ~ product-ty HsBang

#### Instances

Instances details

Data HsImplBang # |
Instance details Defined in GHC.Core.DataCon Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsImplBang -> c HsImplBang # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsImplBang # toConstr :: HsImplBang -> Constr # dataTypeOf :: HsImplBang -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsImplBang) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsImplBang) # gmapT :: (forall b. Data b => b -> b) -> HsImplBang -> HsImplBang # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsImplBang -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsImplBang -> r # gmapQ :: (forall d. Data d => d -> u) -> HsImplBang -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsImplBang -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsImplBang -> m HsImplBang # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsImplBang -> m HsImplBang # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsImplBang -> m HsImplBang #
Outputable HsImplBang # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: HsImplBang -> SDoc #

data StrictnessMark #

Constructors

MarkedStrict |
NotMarkedStrict |

#### Instances

Instances details

Binary StrictnessMark # |
Instance details Defined in GHC.Core.DataCon Methods put_ :: WriteBinHandle -> StrictnessMark -> IO () # put :: WriteBinHandle -> StrictnessMark -> IO (Bin StrictnessMark) # get :: ReadBinHandle -> IO StrictnessMark #
Outputable StrictnessMark # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: StrictnessMark -> SDoc #
Eq StrictnessMark # |
Instance details Defined in GHC.Core.DataCon Methods (==) :: StrictnessMark -> StrictnessMark -> Bool # (/=) :: StrictnessMark -> StrictnessMark -> Bool #

type ConTag = Int #

A *one-index* constructor tag

Type of the tags associated with each constructor possibility or superclass selector

type DataConEnv a = UniqFM DataCon a #

## Equality specs

data EqSpec #

An `EqSpec` is a tyvar/type pair representing an equality made in rejigging a GADT constructor

#### Instances

Instances details

Outputable EqSpec # |
Instance details Defined in GHC.Core.DataCon Methods ppr :: EqSpec -> SDoc #

mkEqSpec :: TyVar -> Type -> EqSpec #

Make a non-dependent `EqSpec`

eqSpecTyVar :: EqSpec -> TyVar #

eqSpecType :: EqSpec -> Type #

eqSpecPair :: EqSpec -> (TyVar, Type) #

eqSpecPreds :: [EqSpec] -> ThetaType #

## Field labels

data FieldLabel #

Fields in an algebraic record type; see Note [FieldLabel].

Constructors

FieldLabel |
Fields flHasDuplicateRecordFields :: DuplicateRecordFields Was `DuplicateRecordFields` on in the defining module for this datatype? flHasFieldSelector :: FieldSelectors Was `FieldSelectors` enabled in the defining module for this datatype? See Note [NoFieldSelectors] in GHC.Rename.Env flSelector :: Name The `Name` of the selector function, which uniquely identifies the field label.

#### Instances

Instances details

NFData FieldLabel # |
Instance details Defined in GHC.Types.Name Methods rnf :: FieldLabel -> () #
Data FieldLabel # |
Instance details Defined in GHC.Types.FieldLabel Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FieldLabel -> c FieldLabel # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FieldLabel # toConstr :: FieldLabel -> Constr # dataTypeOf :: FieldLabel -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FieldLabel) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldLabel) # gmapT :: (forall b. Data b => b -> b) -> FieldLabel -> FieldLabel # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FieldLabel -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FieldLabel -> r # gmapQ :: (forall d. Data d => d -> u) -> FieldLabel -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FieldLabel -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FieldLabel -> m FieldLabel # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLabel -> m FieldLabel # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLabel -> m FieldLabel #
HasOccName FieldLabel # |
Instance details Defined in GHC.Types.FieldLabel Methods occName :: FieldLabel -> OccName #
Binary Name => Binary FieldLabel # | We need the `Binary Name` constraint here even though there is an instance defined in GHC.Types.Name, because the we have a SOURCE import, so the instance is not in scope. And the instance cannot be added to Name.hs-boot because GHC.Utils.Binary itself depends on GHC.Types.Name.
Instance details Defined in GHC.Types.FieldLabel Methods put_ :: WriteBinHandle -> FieldLabel -> IO () # put :: WriteBinHandle -> FieldLabel -> IO (Bin FieldLabel) # get :: ReadBinHandle -> IO FieldLabel #
Outputable FieldLabel # |
Instance details Defined in GHC.Types.FieldLabel Methods ppr :: FieldLabel -> SDoc #
Eq FieldLabel # |
Instance details Defined in GHC.Types.FieldLabel Methods (==) :: FieldLabel -> FieldLabel -> Bool # (/=) :: FieldLabel -> FieldLabel -> Bool #

flLabel :: FieldLabel -> FieldLabelString #

User-visible label of a field.

data FieldLabelString #

Field labels are just represented as strings; they are not necessarily unique (even within a module)

#### Instances

Instances details

NFData FieldLabelString # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods rnf :: FieldLabelString -> () #
Data FieldLabelString # |
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) -> FieldLabelString -> c FieldLabelString # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FieldLabelString # toConstr :: FieldLabelString -> Constr # dataTypeOf :: FieldLabelString -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FieldLabelString) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldLabelString) # gmapT :: (forall b. Data b => b -> b) -> FieldLabelString -> FieldLabelString # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FieldLabelString -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FieldLabelString -> r # gmapQ :: (forall d. Data d => d -> u) -> FieldLabelString -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FieldLabelString -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FieldLabelString -> m FieldLabelString # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLabelString -> m FieldLabelString # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLabelString -> m FieldLabelString #
Uniquable FieldLabelString # |
Instance details Defined in GHC.Types.FieldLabel Methods getUnique :: FieldLabelString -> Unique #
Outputable FieldLabelString # |
Instance details Defined in GHC.Types.FieldLabel Methods ppr :: FieldLabelString -> SDoc #
Eq FieldLabelString # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: FieldLabelString -> FieldLabelString -> Bool # (/=) :: FieldLabelString -> FieldLabelString -> Bool #
type Anno FieldLabelString # |
Instance details Defined in GHC.Hs.Expr type Anno FieldLabelString = SrcSpanAnnN

## Type construction

mkDataCon #

Arguments

:: Name |
-> Bool | Is the constructor declared infix?
-> TyConRepName | TyConRepName for the promoted TyCon
-> [HsSrcBang] | Strictness/unpack annotations, from user
-> [HsImplBang] | Strictness/unpack annotations, as inferred by the compiler
-> [StrictnessMark] | Strictness marks for the DataCon worker's fields in Core
-> [FieldLabel] | Field labels for the constructor, if it is a record, otherwise empty
-> [TyVar] | Universals.
-> [TyCoVar] | Existentials.
-> ConcreteTyVars | TyVars which must be instantiated with concrete types
-> [TyVarBinder] | User-written `TyVarBinder`s
-> [EqSpec] | GADT equalities
-> KnotTied ThetaType | Theta-type occurring before the arguments proper
-> [KnotTied (Scaled Type)] | Original argument types
-> KnotTied Type | Original result type
-> PromDataConInfo | See comments on `PromDataConInfo`
-> KnotTied TyCon | Representation type constructor
-> ConTag | Constructor tag
-> ThetaType | The "stupid theta", context of the data declaration e.g. `data Eq a => T a ...`
-> Id | Worker Id
-> DataConRep | Representation
-> DataCon |

Build a new data constructor

fIRST_TAG :: ConTag #

Tags are allocated from here for real constructors or for superclass selectors

## Type deconstruction

dataConRepType :: DataCon -> Type #

The representation type of the data constructor, i.e. the sort type that will represent values of this type at runtime

dataConInstSig :: DataCon -> [Type] -> ([TyCoVar], ThetaType, [Type]) #

Instantiate the universal tyvars of a data con, returning ( instantiated existentials , instantiated constraints including dependent GADT equalities which are *also* listed in the instantiated existentials , instantiated args)

dataConFullSig :: DataCon -> ([TyVar], [TyCoVar], [EqSpec], ThetaType, [Scaled Type], Type) #

The "full signature" of the `DataCon` returns, in order:

1) The result of `dataConUnivTyVars`

2) The result of `dataConExTyCoVars`

3) The non-dependent GADT equalities. Dependent GADT equalities are implied by coercion variables in return value (2).

4) The other constraints of the data constructor type, excluding GADT equalities

5) The original argument types to the `DataCon` (i.e. before any change of the representation of the type) with linearity annotations

6) The original result type of the `DataCon`

dataConName :: DataCon -> Name #

The `Name` of the `DataCon`, giving it a unique, rooted identification

dataConIdentity :: DataCon -> ByteString #

The string `package:module.name` identifying a constructor, which is attached to its info table and used by the GHCi debugger and the heap profiler

dataConTag :: DataCon -> ConTag #

The tag used for ordering `DataCon`s

dataConTagZ :: DataCon -> ConTagZ #

dataConTyCon :: DataCon -> TyCon #

The type constructor that we are building via this data constructor

dataConOrigTyCon :: DataCon -> TyCon #

The original type constructor used in the definition of this data constructor. In case of a data family instance, that will be the family type constructor.

dataConWrapperType :: DataCon -> Type #

The user-declared type of the data constructor in the nice-to-read form:

    T :: forall a b. a -> b -> T [a]

rather than:

    T :: forall a c. forall b. (c~[a]) => a -> b -> T c

The type variables are quantified in the order that the user wrote them. See `Note [DataCon user type variable binders]`.

NB: If the constructor is part of a data instance, the result type mentions the family tycon, not the internal one.

dataConNonlinearType :: DataCon -> Type #

dataConDisplayType :: Bool -> DataCon -> Type #

dataConUnivTyVars :: DataCon -> [TyVar] #

The universally-quantified type variables of the constructor

dataConExTyCoVars :: DataCon -> [TyCoVar] #

The existentially-quantified type/coercion variables of the constructor including dependent (kind-) GADT equalities

dataConUnivAndExTyCoVars :: DataCon -> [TyCoVar] #

Both the universal and existential type/coercion variables of the constructor

dataConConcreteTyVars :: DataCon -> ConcreteTyVars #

Which type variables of this data constructor that must be instantiated to concrete types? For example: the RuntimeRep variables of unboxed tuples and unboxed sums.

See Note [Representation-polymorphism checking built-ins] in GHC.Tc.Utils.Concrete

dataConUserTyVars :: DataCon -> [TyVar] #

The type variables of the constructor, in the order the user wrote them

dataConUserTyVarBinders :: DataCon -> [TyVarBinder] #

`TyVarBinder`s for the type variables of the constructor, in the order the user wrote them

dataConTheta :: DataCon -> ThetaType #

The *full* constraints on the constructor type, including dependent GADT equalities.

dataConStupidTheta :: DataCon -> ThetaType #

The "stupid theta" of the `DataCon`, such as `data Eq a` in:

    data Eq a => T a = ...

See `Note [The stupid context]`.

dataConOtherTheta :: DataCon -> ThetaType #

Returns constraints in the wrapper type, other than those in the dataConEqSpec

dataConInstArgTys #

Arguments

:: DataCon | A datacon with no existentials or equality constraints However, it can have a dcTheta (notably it can be a class dictionary, with superclasses)
-> [Type] | Instantiated at these types
-> [Scaled Type] |

Finds the instantiated types of the arguments required to construct a `DataCon` representation NB: these INCLUDE any dictionary args but EXCLUDE the data-declaration context, which is discarded It's all post-flattening etc; this is a representation type

dataConOrigArgTys :: DataCon -> [Scaled Type] #

Returns the argument types of the wrapper, excluding all dictionary arguments and without substituting for any type variables

dataConOrigResTy :: DataCon -> Type #

dataConInstOrigArgTys :: DataCon -> [Type] -> [Scaled Type] #

Returns just the instantiated value argument types of a `DataCon`, (excluding dictionary args)

dataConRepArgTys :: DataCon -> [Scaled Type] #

Returns the arg types of the worker, including *all* non-dependent evidence, after any flattening has been done and without substituting for any type variables

dataConResRepTyArgs :: DataCon -> [Type] #

Were the type variables of the data con written in a different order than the regular order (universal tyvars followed by existential tyvars)?

This is not a cheap test, so we minimize its use in GHC as much as possible. Currently, its only call site in the GHC codebase is in `mkDataConRep` in MkId, and so `dataConUserTyVarsNeedWrapper` is only called at most once during a data constructor's lifetime.

dataConInstUnivs :: DataCon -> [Type] -> [Type] #

Given a data constructor `dc` with n universally quantified type variables `a_{1}`, `a_{2}`, ..., `a_{n}`, and given a list of argument types `dc_args` of length m where m <= n, then:

    dataConInstUnivs dc dc_args

Will return:

    [dc_arg_{1}, dc_arg_{2}, ..., dc_arg_{m}, a_{m+1}, ..., a_{n}]

That is, return the list of universal type variables with `a_{1}`, `a_{2}`, ..., `a_{m}` instantiated with `dc_arg_{1}`, `dc_arg_{2}`, ..., `dc_arg_{m}`. It is possible for `m` to be less than `n`, in which case the remaining `n - m` elements will simply be universal type variables (with their kinds possibly instantiated).

Examples:

- Given the data constructor `D :: forall a b. Foo a b` and `dc_args` `[Int, Bool]`, then `dataConInstUnivs D dc_args` will return `[Int, Bool]`.
- Given the data constructor `D :: forall a b. Foo a b` and `dc_args` `[Int]`, then @`dataConInstUnivs D dc_args` will return `[Int, b]`.
- Given the data constructor `E :: forall k (a :: k). Bar k a` and `dc_args` `[Type]`, then @`dataConInstUnivs D dc_args` will return `[Type, (a :: Type)]`.

This is primarily used in `GHC.Tc.Deriv.*` in service of instantiating data constructors' field types. See `Note [Instantiating field types in stock deriving]` for a notable example of this.

dataConFieldLabels :: DataCon -> [FieldLabel] #

The labels for the fields of this particular `DataCon`

dataConFieldType :: DataCon -> FieldLabelString -> Type #

Extract the type for any given labelled field of the `DataCon`

dataConFieldType_maybe :: DataCon -> FieldLabelString -> Maybe (FieldLabel, Type) #

Extract the label and type for any given labelled field of the `DataCon`, or return `Nothing` if the field does not belong to it

dataConSrcBangs :: DataCon -> [HsSrcBang] #

Strictness/unpack annotations, from user; or, for imported DataCons, from the interface file The list is in one-to-one correspondence with the arity of the `DataCon`

dataConSourceArity :: DataCon -> Arity #

Number of value arguments of the data constructor

dataConVisArity :: DataCon -> VisArity #

Number of visible arguments of the data constructor

dataConRepArity :: DataCon -> Arity #

Gives the number of value arguments (including zero-width coercions) stored by the given `DataCon`'s worker in its Core representation. This may differ from the number of arguments that appear in the source code; see also Note [DataCon arities]

dataConIsInfix :: DataCon -> Bool #

Should the `DataCon` be presented infix?

dataConWorkId :: DataCon -> Id #

Get the Id of the `DataCon` worker: a function that is the "actual" constructor and has no top level binding in the program. The type may be different from the obvious one written in the source program. Panics if there is no such `Id` for this `DataCon`

dataConWrapId :: DataCon -> Id #

Returns an Id which looks like the Haskell-source constructor by using the wrapper if it exists (see `dataConWrapId_maybe`) and failing over to the worker (see `dataConWorkId`)

dataConWrapId_maybe :: DataCon -> Maybe Id #

Get the Id of the `DataCon` wrapper: a function that wraps the "actual" constructor so it has the type visible in the source program: c.f. `dataConWorkId`. Returns Nothing if there is no wrapper, which occurs for an algebraic data constructor and also for a newtype (whose constructor is inlined compulsorily)

dataConImplicitTyThings :: DataCon -> [TyThing] #

Find all the `Id`s implicitly brought into scope by the data constructor. Currently, the union of the `dataConWorkId` and the `dataConWrapId`

dataConRepStrictness :: DataCon -> [StrictnessMark] #

Give the demands on the runtime arguments of a Core DataCon worker application. The length of the list matches `dataConRepArgTys` (e.g., the number of runtime arguments).

dataConImplBangs :: DataCon -> [HsImplBang] #

dataConBoxer :: DataCon -> Maybe DataConBoxer #

splitDataProductType_maybe #

Arguments

:: Type | A product type, perhaps
-> Maybe (TyCon, [Type], DataCon, [Scaled Type]) |

Extract the type constructor, type argument, data constructor and it's representation argument types from a type if it is a product type.

Precisely, we return `Just` for any data type that is all of:

- Concrete (i.e. constructors visible)
- Single-constructor
- ... which has no existentials

Whether the type is a `data` type or a `newtype`.

## Predicates on DataCons

isNullarySrcDataCon :: DataCon -> Bool #

Return whether there are any argument types for this `DataCon`s original source type See Note [DataCon arities]

isNullaryRepDataCon :: DataCon -> Bool #

Return whether this `DataCon`'s worker, in its Core representation, takes any value arguments.

In particular, remember that we include coercion arguments in the arity of the Core representation of the `DataCon` -- both lifted and unlifted coercions, despite the latter having zero-width runtime representation.

See also Note [DataCon arities].

isLazyDataConRep :: DataCon -> Bool #

True == All fields are lazy

isTupleDataCon :: DataCon -> Bool #

isBoxedTupleDataCon :: DataCon -> Bool #

isUnboxedTupleDataCon :: DataCon -> Bool #

isUnboxedSumDataCon :: DataCon -> Bool #

isCovertGadtDataCon :: DataCon -> Bool #

isUnaryClassDataCon :: DataCon -> Bool #

isVanillaDataCon :: DataCon -> Bool #

Vanilla `DataCon`s are those that are nice boring Haskell 98 constructors

isNewDataCon :: DataCon -> Bool #

Is this the `DataCon` of a newtype?

isTypeDataCon :: DataCon -> Bool #

Is this data constructor in a "type data" declaration? See Note [Type data declarations] in GHC.Rename.Module.

classDataCon :: Class -> DataCon #

dataConCannotMatch :: [Type] -> DataCon -> Bool #

dataConUserTyVarBindersNeedWrapper :: DataCon -> Bool #

checkDataConTyVars :: DataCon -> Bool #

isBanged :: HsImplBang -> Bool #

isUnpacked :: HsImplBang -> Bool #

isMarkedStrict :: StrictnessMark -> Bool #

cbvFromStrictMark :: StrictnessMark -> CbvMark #

eqHsBang :: HsImplBang -> HsImplBang -> Bool #

Compare strictness annotations

isSrcStrict :: SrcStrictness -> Bool #

isSrcUnpacked :: SrcUnpackedness -> Bool #

specialPromotedDc :: DataCon -> Bool #

Should this DataCon be allowed in a type even without -XDataKinds? Currently, only Lifted & Unlifted

## Promotion related functions

promoteDataCon :: DataCon -> TyCon #

# Orphan instances

NFData SrcStrictness # |
Instance details Methods rnf :: SrcStrictness -> () #
NFData SrcUnpackedness # |
Instance details Methods rnf :: SrcUnpackedness -> () #
Binary SrcStrictness # |
Instance details Methods put_ :: WriteBinHandle -> SrcStrictness -> IO () # put :: WriteBinHandle -> SrcStrictness -> IO (Bin SrcStrictness) # get :: ReadBinHandle -> IO SrcStrictness #
Binary SrcUnpackedness # |
Instance details Methods put_ :: WriteBinHandle -> SrcUnpackedness -> IO () # put :: WriteBinHandle -> SrcUnpackedness -> IO (Bin SrcUnpackedness) # get :: ReadBinHandle -> IO SrcUnpackedness #
Outputable SrcStrictness # |
Instance details Methods ppr :: SrcStrictness -> SDoc #
Outputable SrcUnpackedness # |
Instance details Methods ppr :: SrcUnpackedness -> SDoc #