generic-data-0.7.0.0: Deriving instances with GHC.Generics and related utilities

Safe HaskellSafe
LanguageHaskell2010

Generic.Data.Internal.Meta

Contents

Description

Type metadata accessors

Type names, constructor names...

Synopsis

Documentation

gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #

Name of the first data constructor in a type as a string.

gdatatypeName @(Maybe AnyType) = "Maybe"

gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #

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

gmoduleName @(Maybe AnyType) = "GHC.Base"

gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #

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

gpackageName @(Maybe AnyType) = "base"

gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool Source #

True if the first type constructor is a newtype.

fromDatatype :: forall d r. Datatype d => (M1 D d Proxy () -> r) -> r Source #

class GDatatype f where Source #

Generic representations that contain datatype metadata.

gconName :: forall a. Constructors a => a -> String Source #

Name of the first constructor in a value.

gconName (Just 0) = "Just"

gconFixity :: forall a. Constructors a => a -> Fixity Source #

The fixity of the first constructor.

gconFixity (Just 0) = Prefix
gconFixity ([] :*: id) = Infix RightAssociative 6

gconIsRecord :: forall a. Constructors a => a -> Bool Source #

True if the constructor is a record.

gconIsRecord (Just 0) = False
gconIsRecord (Sum 0) = True
-- newtype Sum a = Sum { getSum :: a }

gconNum :: forall a. Constructors a => Int Source #

Number of constructors.

gconNum @(Maybe AnyType) = 2

gconIndex :: forall a. Constructors a => a -> Int Source #

Index of a constructor.

gconIndex Nothing = 0
gconIndex (Just "test") = 1

newtype ConId a Source #

An opaque identifier for a constructor.

Constructors

ConId Int 
Instances
Eq (ConId a) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

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

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

Ord (ConId a) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

compare :: ConId a -> ConId a -> Ordering #

(<) :: ConId a -> ConId a -> Bool #

(<=) :: ConId a -> ConId a -> Bool #

(>) :: ConId a -> ConId a -> Bool #

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

max :: ConId a -> ConId a -> ConId a #

min :: ConId a -> ConId a -> ConId a #

conId :: forall a. Constructors a => a -> ConId a Source #

Identifier of a constructor.

conIdToInt :: forall a. ConId a -> Int Source #

Index of a constructor, given its identifier. See also gconIndex.

conIdToString :: forall a. Constructors a => ConId a -> String Source #

Name of a constructor. See also gconName.

conIdEnum :: forall a. Constructors a => [ConId a] Source #

All constructor identifiers.

gconNum @a = length (conIdEnum @a)

conIdMin :: forall a. Constructors a => ConId a Source #

This must not be called on an empty type.

conIdMax :: forall a. Constructors a => ConId a Source #

This must not be called on an empty type.

class (Generic a, GConstructors (Rep a)) => Constructors a Source #

Constraint synonym for Generic and GConstructors.

Instances
(Generic a, GConstructors (Rep a)) => Constructors a Source # 
Instance details

Defined in Generic.Data.Internal.Meta

newtype GConId r Source #

Constructors

GConId Int 
Instances
Eq (GConId r) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

(==) :: GConId r -> GConId r -> Bool #

(/=) :: GConId r -> GConId r -> Bool #

Ord (GConId r) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

compare :: GConId r -> GConId r -> Ordering #

(<) :: GConId r -> GConId r -> Bool #

(<=) :: GConId r -> GConId r -> Bool #

(>) :: GConId r -> GConId r -> Bool #

(>=) :: GConId r -> GConId r -> Bool #

max :: GConId r -> GConId r -> GConId r #

min :: GConId r -> GConId r -> GConId r #

toConId :: forall a. Generic a => GConId (Rep a) -> ConId a Source #

fromConId :: forall a. Generic a => ConId a -> GConId (Rep a) Source #

gConIdMin :: forall r. GConstructors r => GConId r Source #

gConIdMax :: forall r. GConstructors r => GConId r Source #

class GConstructors r where Source #

Generic representations that contain constructor metadata.

Instances
(GConstructors f, GConstructors g) => GConstructors (f :+: g :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

gConIdToString :: GConId (f :+: g) -> String Source #

gConId :: (f :+: g) p -> GConId (f :+: g) Source #

gConNum :: Int Source #

gConFixity :: (f :+: g) p -> Fixity Source #

gConIsRecord :: (f :+: g) p -> Bool Source #

Constructor c => GConstructors (M1 C c f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

gConIdToString :: GConId (M1 C c f) -> String Source #

gConId :: M1 C c f p -> GConId (M1 C c f) Source #

gConNum :: Int Source #

gConFixity :: M1 C c f p -> Fixity Source #

gConIsRecord :: M1 C c f p -> Bool Source #

GConstructors f => GConstructors (M1 D c f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

Methods

gConIdToString :: GConId (M1 D c f) -> String Source #

gConId :: M1 D c f p -> GConId (M1 D c f) Source #

gConNum :: Int Source #

gConFixity :: M1 D c f p -> Fixity Source #

gConIsRecord :: M1 D c f p -> Bool Source #

Type families

type family MetaOf (f :: * -> *) :: Meta where ... Source #

Meta field of the M1 type constructor.

Equations

MetaOf (M1 i d f) = d 

type family MetaDataName (m :: Meta) :: Symbol where ... Source #

Name of the data type (MetaData).

Equations

MetaDataName (MetaData n _m _p _nt) = n 

type family MetaDataModule (m :: Meta) :: Symbol where ... Source #

Name of the module where the data type is defined (MetaData)

Equations

MetaDataModule (MetaData _n m _p _nt) = m 

type family MetaDataPackage (m :: Meta) :: Symbol where ... Source #

Name of the package where the data type is defined (MetaData)

Equations

MetaDataPackage (MetaData _n _m p _nt) = p 

type family MetaDataNewtype (m :: Meta) :: Bool where ... Source #

True if the data type is a newtype (MetaData).

Equations

MetaDataNewtype (MetaData _n _m _p nt) = nt 

type family MetaConsName (m :: Meta) :: Symbol where ... Source #

Name of the constructor (MetaCons).

Equations

MetaConsName (MetaCons n _f _s) = n 

type family MetaConsFixity (m :: Meta) :: FixityI where ... Source #

Fixity of the constructor (MetaCons).

Equations

MetaConsFixity (MetaCons _n f s) = f 

type family MetaConsRecord (m :: Meta) :: Bool where ... Source #

True for a record constructor (MetaCons).

Equations

MetaConsRecord (MetaCons _n _f s) = s 

type family MetaSelNameM (m :: Meta) :: Maybe Symbol where ... Source #

Just the name of the record field, if it is one (MetaSel).

Equations

MetaSelNameM (MetaSel mn _su _ss _ds) = mn 

type family MetaSelName (m :: Meta) :: Symbol where ... Source #

Name of the record field; undefined for non-record fields (MetaSel).

Equations

MetaSelName (MetaSel (Just n) _su _ss _ds) = n 

type family MetaSelUnpack (m :: Meta) :: SourceUnpackedness where ... Source #

Unpackedness annotation of a field (MetaSel).

Equations

MetaSelUnpack (MetaSel _mn su _ss _ds) = su 

type family MetaSelSourceStrictness (m :: Meta) :: SourceStrictness where ... Source #

Strictness annotation of a field (MetaSel).

Equations

MetaSelSourceStrictness (MetaSel _mn _su ss _ds) = ss 

type family MetaSelStrictness (m :: Meta) :: DecidedStrictness where ... Source #

Inferred strictness of a field (MetaSel).

Equations

MetaSelStrictness (MetaSel _mn _su _ss ds) = ds 

type DummyMeta = MetaData "" "" "" False Source #

A placeholder for Meta values.

type family UnM1 (f :: k -> *) :: k -> * Source #

Remove an M1 type constructor.

Instances
type UnM1 (M1 i c f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Internal.Meta

type UnM1 (M1 i c f :: k -> Type) = f