HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulegeneric-data-1.1.0.2Haskell2010

Generic.Data.Internal.Meta

Type metadata accessors

Type names, constructor names...

Warning

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.

  • 8 types
  • 5 classes
  • 23 values
Example3 expressions
:set -XDataKinds -XTypeApplicationsimport Control.Applicative (ZipList)import Data.Monoid (Sum(..))
valuegmoduleName :: (Generic a, GDatatype (Rep a)) => String
#

Name of the module where the first type constructor is defined.

Example1 expression
gmoduleName @(ZipList Int)"Control.Applicative"
valuegisNewtype :: (Generic a, GDatatype (Rep a)) => Bool
#

True if the first type constructor is a newtype.

Example2 expressions
gisNewtype @[Int]FalsegisNewtype @(ZipList Int)True
valuegconName :: Constructors a => a -> String
#

Name of the first constructor in a value.

Example1 expression
gconName (Just 0)"Just"
valuegconFixity :: Constructors a => a -> Fixity
#

The fixity of the first constructor.

Example3 expressions
import GHC.Generics ((:*:)(..))gconFixity (Just 0)PrefixgconFixity ([] :*: id)Infix RightAssociative 6
valuegconIsRecord :: Constructors a => a -> Bool
#

True if the constructor is a record.

Example2 expressions
gconIsRecord (Just 0)FalsegconIsRecord (Sum 0)   -- Note:  newtype Sum a = Sum { getSum :: a }True
valuegconIndex :: Constructors a => a -> Int
#

Index of a constructor.

Example2 expressions
gconIndex Nothing0gconIndex (Just "test")1
newtypenewtype ConId (a :: k)
#

An opaque identifier for a constructor.

Constructors

Instances3Eq, Ord, Show
  • Eq (ConId a)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta
  • Ord (ConId a)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta
  • Show (ConId a)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta
valueconIdNamed :: ConIdNamed s a => ConId a
#

Get a ConId by name.

Example2 expressions
conIdNamed @"Nothing" :: ConId (Maybe Int)ConId 0conIdNamed @"Just"    :: ConId (Maybe Int)ConId 1

Constructor information on generic representations

newtypenewtype GConId (r :: k)
#

Constructors

Instances2Eq, Ord
  • Eq (GConId r)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta
  • Ord (GConId r)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta
classclass GConstructors (r :: k -> Type) where
#

Generic representations that contain constructor metadata.

Methods

Instances4GConstructors

Find a constructor tag by name

Check that a type is not empty

classclass NonEmptyType_ fname a => NonEmptyType (fname :: Symbol) a
#

Constraint 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

Instances1NonEmptyType
typetype NonEmptyType_ (fname :: Symbol) a = ErrorIfEmpty fname a (IsEmptyType a) ~ '()
#

Internal definition of NonEmptyType. It is implied by the simpler constraint IsEmptyType a ~ 'False.

Example2 expressions
:set -XTypeFamilies:{conIdMin' :: (Constructors a, IsEmptyType a ~ 'False) => ConId aconIdMin' = conIdMin:}
Example1 expression
:{conIdMax' :: (Constructors a, IsEmptyType a ~ 'False) => ConId aconIdMax' = conIdMax:}
familytype family ErrorIfEmpty (fname :: Symbol) a (b :: Bool) :: () where
#

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 E

Error message:

The function 'conIdMin' cannot be used with the empty type E

Equations

Type families

15 declarations
familytype family UnM1 (f :: k -> Type) :: k -> Type
#

Remove an M1 type constructor.

Instances1UnM1
  • type UnM1 (M1 i c f) = fDefined in generic-data-1.1.0.2 · Generic.Data.Internal.Meta