Normalized information about newtypes and data types.
DatatypeInfo contains two fields, datatypeVars and datatypeInstTypes, which encode information about the argument types. The simplest explanation is that datatypeVars contains all the type variables bound by the data type constructor, while datatypeInstTypes contains the type arguments to the data type constructor. To be more precise:
For ADTs declared with
dataandnewtype, it will likely be the case that datatypeVars and datatypeInstTypes coincide. For instance, givennewtype Id a = MkId a, in the DatatypeInfo forIdwe would havedatatypeVars = [KindedTV a () StarT]and.datatypeInstVars= [SigT (VarT a) StarT]
ADTs that leverage PolyKinds may have more datatypeVars than
datatypeInstTypes. For instance, given data Proxy (a :: k) = MkProxy,
in the DatatypeInfo for Proxy we would have
datatypeVars = [KindedTV k () StarT, KindedTV a () (VarT k)]
(since there are two variables, k and a), whereas
datatypeInstTypes = [SigT (VarT a) (VarT k)], since there is
only one explicit type argument to Proxy.
The same outcome would occur if Proxy were declared using
TypeAbstractions, i.e., if it were declared as
data Proxy @k (a :: k) = MkProxy. The datatypeInstTypes would not
include a separate type for @k.
For
data instances andnewtype instances of data families, datatypeVars and datatypeInstTypes can be quite different. Here is an example to illustrate the difference:
data family F a b
data instance F (Maybe c) (f x) = MkF c (f x)
Then in the DatatypeInfo for F's data instance, we would have:
datatypeVars = [ KindedTV c () StarT
, KindedTV f () StarT
, KindedTV x () StarT ]
datatypeInstTypes = [ AppT (ConT ''Maybe) (VarT c)
, AppT (VarT f) (VarT x) ]
Constructors
DatatypeInfodatatypeContext :: CxtData type context (deprecated)
datatypeName :: NameType constructor
datatypeVars :: [TyVarBndrUnit]Type parameters
datatypeInstTypes :: [Type]Argument types
datatypeVariant :: DatatypeVariantExtra information
datatypeReturnKind :: KindReturn Kind of the type.
If normalization is unable to determine the return kind, then this is conservatively set to
StarT.datatypeCons :: [ConstructorInfo]Normalize constructor information
Instances5Eq, Data, Show, Generic, Rep
Eq DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.DatatypeData DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.DatatypeShow DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.DatatypeGeneric DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatypetype Rep DatatypeInfo = D1 ('MetaDataDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype"DatatypeInfo"
"Language.Haskell.TH.Datatype"
"th-abstraction-0.7.1.0-9nhRcaWTplFG28ILsuLy29"
'False) (C1 ('MetaCons"DatatypeInfo"
'PrefixI 'True) ((S1 ('MetaSel ('Just"datatypeContext"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cxt) :*: (S1 ('MetaSel ('Just"datatypeName"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: S1 ('MetaSel ('Just"datatypeVars"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TyVarBndrUnit]))) :*: ((S1 ('MetaSel ('Just"datatypeInstTypes"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Type]) :*: S1 ('MetaSel ('Just"datatypeVariant"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatatypeVariant)) :*: (S1 ('MetaSel ('Just"datatypeReturnKind"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Kind) :*: S1 ('MetaSel ('Just"datatypeCons"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ConstructorInfo])))))