ghc-8.4.4: The GHC API

Safe HaskellNone
LanguageHaskell2010

DataCon

Contents

Synopsis

Main data types

data DataCon Source #

A data constructor

Instances
Eq DataCon Source # 
Instance details

Defined in DataCon

Methods

(==) :: DataCon -> DataCon -> Bool #

(/=) :: DataCon -> DataCon -> Bool #

Data DataCon Source # 
Instance details

Defined in 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 :: (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 #

OutputableBndr DataCon Source # 
Instance details

Defined in DataCon

Outputable DataCon Source # 
Instance details

Defined in DataCon

Uniquable DataCon Source # 
Instance details

Defined in DataCon

NamedThing DataCon Source # 
Instance details

Defined in DataCon

data DataConRep Source #

Data Constructor Representation

data SrcStrictness Source #

Source Strictness

What strictness annotation the user wrote

Constructors

SrcLazy

Lazy, ie '~'

SrcStrict

Strict, ie !

NoSrcStrict

no strictness annotation

Instances
Eq SrcStrictness Source # 
Instance details

Defined in DataCon

Data SrcStrictness Source # 
Instance details

Defined in DataCon

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 :: (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 #

Outputable SrcStrictness Source # 
Instance details

Defined in DataCon

Binary SrcStrictness Source # 
Instance details

Defined in DataCon

data SrcUnpackedness Source #

Source Unpackedness

What unpackedness the user requested

Constructors

SrcUnpack

{--} specified

SrcNoUnpack

{--} specified

NoSrcUnpack

no unpack pragma

Instances
Eq SrcUnpackedness Source # 
Instance details

Defined in DataCon

Data SrcUnpackedness Source # 
Instance details

Defined in DataCon

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 :: (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 #

Outputable SrcUnpackedness Source # 
Instance details

Defined in DataCon

Binary SrcUnpackedness Source # 
Instance details

Defined in DataCon

data HsSrcBang Source #

Haskell Source Bang

Bangs on data constructor arguments as the user wrote them in the source code.

(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)

Instances
Data HsSrcBang Source # 
Instance details

Defined in 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 :: (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 Source # 
Instance details

Defined in DataCon

data HsImplBang Source #

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

Strict but not unpacked field

HsUnpack (Maybe Coercion)

Strict and unpacked field co :: arg-ty ~ product-ty HsBang

Instances
Data HsImplBang Source # 
Instance details

Defined in 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 :: (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 Source # 
Instance details

Defined in DataCon

type ConTag = Int Source #

Constructor Tag

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

Equality specs

data EqSpec Source #

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

Instances
Outputable EqSpec Source # 
Instance details

Defined in DataCon

substEqSpec :: TCvSubst -> EqSpec -> EqSpec Source #

Substitute in an EqSpec. Precondition: if the LHS of the EqSpec is mapped in the substitution, it is mapped to a type variable, not a full type.

filterEqSpec :: [EqSpec] -> [TyVar] -> [TyVar] Source #

Filter out any TyVars mentioned in an EqSpec.

Field labels

data FieldLbl a Source #

Fields in an algebraic record type

Constructors

FieldLabel 

Fields

Instances
Functor FieldLbl Source # 
Instance details

Defined in FieldLabel

Methods

fmap :: (a -> b) -> FieldLbl a -> FieldLbl b #

(<$) :: a -> FieldLbl b -> FieldLbl a #

Foldable FieldLbl Source # 
Instance details

Defined in FieldLabel

Methods

fold :: Monoid m => FieldLbl m -> m #

foldMap :: Monoid m => (a -> m) -> FieldLbl a -> m #

foldr :: (a -> b -> b) -> b -> FieldLbl a -> b #

foldr' :: (a -> b -> b) -> b -> FieldLbl a -> b #

foldl :: (b -> a -> b) -> b -> FieldLbl a -> b #

foldl' :: (b -> a -> b) -> b -> FieldLbl a -> b #

foldr1 :: (a -> a -> a) -> FieldLbl a -> a #

foldl1 :: (a -> a -> a) -> FieldLbl a -> a #

toList :: FieldLbl a -> [a] #

null :: FieldLbl a -> Bool #

length :: FieldLbl a -> Int #

elem :: Eq a => a -> FieldLbl a -> Bool #

maximum :: Ord a => FieldLbl a -> a #

minimum :: Ord a => FieldLbl a -> a #

sum :: Num a => FieldLbl a -> a #

product :: Num a => FieldLbl a -> a #

Traversable FieldLbl Source # 
Instance details

Defined in FieldLabel

Methods

traverse :: Applicative f => (a -> f b) -> FieldLbl a -> f (FieldLbl b) #

sequenceA :: Applicative f => FieldLbl (f a) -> f (FieldLbl a) #

mapM :: Monad m => (a -> m b) -> FieldLbl a -> m (FieldLbl b) #

sequence :: Monad m => FieldLbl (m a) -> m (FieldLbl a) #

Eq a => Eq (FieldLbl a) Source # 
Instance details

Defined in FieldLabel

Methods

(==) :: FieldLbl a -> FieldLbl a -> Bool #

(/=) :: FieldLbl a -> FieldLbl a -> Bool #

Data a => Data (FieldLbl a) Source # 
Instance details

Defined in FieldLabel

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FieldLbl a -> c (FieldLbl a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FieldLbl a) #

toConstr :: FieldLbl a -> Constr #

dataTypeOf :: FieldLbl a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FieldLbl a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FieldLbl a)) #

gmapT :: (forall b. Data b => b -> b) -> FieldLbl a -> FieldLbl a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FieldLbl a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FieldLbl a -> r #

gmapQ :: (forall d. Data d => d -> u) -> FieldLbl a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FieldLbl a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FieldLbl a -> m (FieldLbl a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLbl a -> m (FieldLbl a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FieldLbl a -> m (FieldLbl a) #

Outputable a => Outputable (FieldLbl a) Source # 
Instance details

Defined in FieldLabel

Binary a => Binary (FieldLbl a) Source # 
Instance details

Defined in FieldLabel

type FieldLabelString = FastString Source #

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

Type construction

mkDataCon Source #

Arguments

:: Name 
-> Bool

Is the constructor declared infix?

-> TyConRepName

TyConRepName for the promoted TyCon

-> [HsSrcBang]

Strictness/unpack annotations, from user

-> [FieldLabel]

Field labels for the constructor, if it is a record, otherwise empty

-> [TyVar]

Universals.

-> [TyVar]

Existentials.

-> [TyVarBinder]

User-written TyVarBinders. These must be Inferred/Specified. See Note [TyVarBinders in DataCons]

-> [EqSpec]

GADT equalities

-> ThetaType

Theta-type occuring before the arguments proper

-> [Type]

Original argument types

-> Type

Original result type

-> RuntimeRepInfo

See comments on RuntimeRepInfo

-> TyCon

Representation type constructor

-> 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

buildAlgTyCon Source #

Arguments

:: Name 
-> [TyVar]

Kind variables and type variables

-> [Role] 
-> Maybe CType 
-> ThetaType

Stupid theta

-> AlgTyConRhs 
-> Bool

True = was declared in GADT syntax

-> AlgTyConFlav 
-> TyCon 

buildSynTyCon Source #

Arguments

:: Name 
-> [TyConBinder] 
-> Kind

result kind

-> [Role] 
-> Type 
-> TyCon 

fIRST_TAG :: ConTag Source #

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

Type deconstruction

dataConRepType :: DataCon -> Type Source #

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

dataConSig :: DataCon -> ([TyVar], ThetaType, [Type], Type) Source #

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

1) The result of dataConUnivAndExTyVars,

2) All the ThetaTypes relating to the DataCon (coercion, dictionary, implicit parameter - whatever)

3) The type arguments to the constructor

4) The original result type of the DataCon

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

Instantiate the universal tyvars of a data con, returning the instantiated existentials, constraints, and args

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

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

1) The result of dataConUnivTyVars

2) The result of dataConExTyVars

3) The GADT equalities

4) The result of dataConDictTheta

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

6) The original result type of the DataCon

dataConName :: DataCon -> Name Source #

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

dataConIdentity :: DataCon -> [Word8] Source #

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 Source #

The tag used for ordering DataCons

dataConTyCon :: DataCon -> TyCon Source #

The type constructor that we are building via this data constructor

dataConOrigTyCon :: DataCon -> TyCon Source #

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.

dataConUserType :: DataCon -> Type Source #

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.

dataConUnivTyVars :: DataCon -> [TyVar] Source #

The universally-quantified type variables of the constructor

dataConExTyVars :: DataCon -> [TyVar] Source #

The existentially-quantified type variables of the constructor

dataConUnivAndExTyVars :: DataCon -> [TyVar] Source #

Both the universal and existential type variables of the constructor

dataConUserTyVars :: DataCon -> [TyVar] Source #

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

dataConUserTyVarBinders :: DataCon -> [TyVarBinder] Source #

TyVarBinders for the type variables of the constructor, in the order the user wrote them

dataConEqSpec :: DataCon -> [EqSpec] Source #

Equalities derived from the result type of the data constructor, as written by the programmer in any GADT declaration. This includes *all* GADT-like equalities, including those written in by hand by the programmer.

dataConTheta :: DataCon -> ThetaType Source #

The *full* constraints on the constructor type.

dataConStupidTheta :: DataCon -> ThetaType Source #

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

data Eq a => T a = ...

dataConInstArgTys Source #

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

-> [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 -> [Type] Source #

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

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

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

dataConRepArgTys :: DataCon -> [Type] Source #

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

dataConFieldLabels :: DataCon -> [FieldLabel] Source #

The labels for the fields of this particular DataCon

dataConFieldType :: DataCon -> FieldLabelString -> Type Source #

Extract the type for any given labelled field of the DataCon

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

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] Source #

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 Source #

Source-level arity of the data constructor

dataConRepArity :: DataCon -> Arity Source #

Gives the number of actual fields in the representation of the data constructor. This may be more than appear in the source code; the extra ones are the existentially quantified dictionaries

dataConIsInfix :: DataCon -> Bool Source #

Should the DataCon be presented infix?

dataConWorkId :: DataCon -> Id Source #

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 Source #

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 Source #

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] Source #

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

dataConRepStrictness :: DataCon -> [StrictnessMark] Source #

Give the demands on the arguments of a Core constructor application (Con dc args)

splitDataProductType_maybe Source #

Arguments

:: Type

A product type, perhaps

-> Maybe (TyCon, [Type], DataCon, [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 type that is all of:

  • Concrete (i.e. constructors visible)
  • Single-constructor
  • Not existentially quantified

Whether the type is a data type or a newtype

Predicates on DataCons

isNullarySrcDataCon :: DataCon -> Bool Source #

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

isNullaryRepDataCon :: DataCon -> Bool Source #

Return whether there are any argument types for this DataCons runtime representation type See Note [DataCon arities]

isVanillaDataCon :: DataCon -> Bool Source #

Vanilla DataCons are those that are nice boring Haskell 98 constructors

dataConUserTyVarsArePermuted :: DataCon -> Bool Source #

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 dataConUserTyVarsArePermuted is only called at most once during a data constructor's lifetime.

eqHsBang :: HsImplBang -> HsImplBang -> Bool Source #

Compare strictness annotations

specialPromotedDc :: DataCon -> Bool Source #

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

isLegacyPromotableDataCon :: DataCon -> Bool Source #

Was this datacon promotable before GHC 8.0? That is, is it promotable without -XTypeInType

isLegacyPromotableTyCon :: TyCon -> Bool Source #

Was this tycon promotable before GHC 8.0? That is, is it promotable without -XTypeInType

Promotion related functions