Name of the first data constructor in a type as a string.
gdatatypeName @(Maybe Int)"Maybe"
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulegeneric-data-1.1.0.2Haskell2010
Type metadata accessors
Type names, constructor names...
This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time.
If something here seems useful, please report it or create a pull request to export it from an external module.
:set -XDataKinds -XTypeApplicationsimport Control.Applicative (ZipList)import Data.Monoid (Sum(..))
Name of the first data constructor in a type as a string.
gdatatypeName @(Maybe Int)"Maybe"
Name of the module where the first type constructor is defined.
gmoduleName @(ZipList Int)"Control.Applicative"
Name of the package where the first type constructor is defined.
gpackageName @(Maybe Int)"base"
True if the first type constructor is a newtype.
gisNewtype @[Int]FalsegisNewtype @(ZipList Int)True
Generic representations that contain datatype metadata.
Name of the first constructor in a value.
gconName (Just 0)"Just"
The fixity of the first constructor.
import GHC.Generics ((:*:)(..))gconFixity (Just 0)PrefixgconFixity ([] :*: id)Infix RightAssociative 6
True if the constructor is a record.
gconIsRecord (Just 0)FalsegconIsRecord (Sum 0) -- Note: newtype Sum a = Sum { getSum :: a }True
Number of constructors.
gconNum @(Maybe Int)2
Index of a constructor.
gconIndex Nothing0gconIndex (Just "test")1
Identifier of a constructor.
Index of a constructor, given its identifier. See also gconIndex.
Name of a constructor. See also gconName.
The first constructor. This must not be called on an empty type.
The last constructor. This must not be called on an empty type.
Get a ConId by name.
conIdNamed @"Nothing" :: ConId (Maybe Int)ConId 0conIdNamed @"Just" :: ConId (Maybe Int)ConId 1
Constraint synonym for Generic and GConstructors.
(Generic a, GConstructors (Rep a)) => Constructors aDefined in generic-data-1.1.0.2 · Generic.Data.Internal.MetaConstraint synonym for generic types a with a constructor named n.
(Generic a, KnownNat (ConIdNamed' n a)) => ConIdNamed n aDefined in generic-data-1.1.0.2 · Generic.Data.Internal.MetaGeneric representations that contain constructor metadata.
gConIdToString :: GConId r -> StringgConId :: r p -> GConId rgConNum :: IntgConFixity :: r p -> FixitygConIsRecord :: r p -> BoolGConstructors V1Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta(GConstructors f, GConstructors g) => GConstructors (f :+: g)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.MetaGConstructors f => GConstructors (M1 D c f)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.MetaConstructor c => GConstructors (M1 C c f)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Metatype family GConIdNamed' (n :: Symbol) (f :: k -> Type) (i :: Nat) (o :: Maybe Nat) :: Maybe Nat whereGConIdNamed' n (M1 D _c f) i r = GConIdNamed' n f i rGConIdNamed' n (f :+: g) i r = GConIdNamed' n f i (GConIdNamed' n g (i + NConstructors f) r)GConIdNamed' n (M1 C ('MetaCons n _f _s) _g) i _r = 'Just iGConIdNamed' n (M1 C ('MetaCons _n _f _s) _g) _i r = rGConIdNamed' _n V1 _i r = rConstraint that a generic type a is not empty.
Producing an error message otherwise.
The Symbol parameter fname is used only for error messages.
It is implied by the simpler constraint IsEmptyType a ~ 'False
NonEmptyType_ fname a => NonEmptyType fname aDefined in generic-data-1.1.0.2 · Generic.Data.Internal.MetaInternal definition of NonEmptyType.
It is implied by the simpler constraint IsEmptyType a ~ 'False.
:set -XTypeFamilies:{conIdMin' :: (Constructors a, IsEmptyType a ~ 'False) => ConId aconIdMin' = conIdMin:}
:{conIdMax' :: (Constructors a, IsEmptyType a ~ 'False) => ConId aconIdMax' = conIdMax:}
True if the generic type a is empty.
Internal definition of IsEmptyType.
Throw an error if the boolean b is true, meaning that the type a is empty.
Example:
ghci> data E deriving Generic
ghci> conIdMin :: ConId EError message:
The function 'conIdMin' cannot be used with the empty type EName of the data type (MetaData).
MetaDataName ('MetaData n _m _p _nt) = nName of the module where the data type is defined (MetaData)
MetaDataModule ('MetaData _n m _p _nt) = mName of the package where the data type is defined (MetaData)
MetaDataPackage ('MetaData _n _m p _nt) = pTrue if the data type is a newtype (MetaData).
MetaDataNewtype ('MetaData _n _m _p nt) = ntName of the constructor (MetaCons).
MetaConsName ('MetaCons n _f _s) = nFixity of the constructor (MetaCons).
MetaConsFixity ('MetaCons _n f s) = fTrue for a record constructor (MetaCons).
MetaConsRecord ('MetaCons _n _f s) = sJust the name of the record field, if it is one (MetaSel).
MetaSelNameM ('MetaSel mn _su _ss _ds) = mnName of the record field; undefined for non-record fields (MetaSel).
MetaSelName ('MetaSel ('Just n) _su _ss _ds) = nUnpackedness annotation of a field (MetaSel).
MetaSelUnpack ('MetaSel _mn su _ss _ds) = suStrictness annotation of a field (MetaSel).
MetaSelSourceStrictness ('MetaSel _mn _su ss _ds) = ssInferred strictness of a field (MetaSel).
MetaSelStrictness ('MetaSel _mn _su _ss ds) = dsA placeholder for Meta values.
Remove an M1 type constructor.