Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generics.SOP.Metadata
Contents
Description
Metadata about what a datatype looks like
In generics-sop
, the metadata is completely independent of the main
universe. Many generic functions will use this metadata, but other don't,
and yet others might need completely different metadata.
This module defines a datatype to represent standard metadata, i.e., names of the datatype, its constructors, and possibly its record selectors. Metadata descriptions are in general GADTs indexed by the code of the datatype they're associated with, so matching on the metadata will reveal information about the shape of the datatype.
Synopsis
- type Fixity = Int
- type FieldName = String
- type ConstructorName = String
- type ModuleName = String
- type DatatypeName = String
- data FieldInfo :: Type -> Type where
- data ConstructorInfo :: [Type] -> Type where
- Constructor :: SListI xs => ConstructorName -> ConstructorInfo xs
- Infix :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y]
- Record :: SListI xs => ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs
- data DatatypeInfo :: [[Type]] -> Type where
- ADT :: ModuleName -> DatatypeName -> NP ConstructorInfo xss -> DatatypeInfo xss
- Newtype :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]]
- moduleName :: DatatypeInfo xss -> ModuleName
- datatypeName :: DatatypeInfo xss -> DatatypeName
- constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss
- constructorName :: ConstructorInfo xs -> ConstructorName
- fieldName :: FieldInfo a -> FieldName
- data Associativity
Documentation
type ConstructorName = String Source #
The name of a data constructor.
type ModuleName = String Source #
The name of a module.
type DatatypeName = String Source #
The name of a datatype.
data FieldInfo :: Type -> Type where Source #
For records, this functor maps the component to its selector name.
Instances
Functor FieldInfo Source # | |
Eq (FieldInfo a) Source # | |
Ord (FieldInfo a) Source # | |
Defined in Generics.SOP.Metadata | |
Show (FieldInfo a) Source # | |
data ConstructorInfo :: [Type] -> Type where Source #
Metadata for a single constructors.
This is indexed by the product structure of the constructor components.
Constructors
Constructor :: SListI xs => ConstructorName -> ConstructorInfo xs | |
Infix :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y] | |
Record :: SListI xs => ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs |
Instances
data DatatypeInfo :: [[Type]] -> Type where Source #
Metadata for a datatype.
A value of type
contains the information about a datatype
that is not contained in DatatypeInfo
c
. This information consists
primarily of the names of the datatype, its constructors, and possibly its
record selectors.Code
c
The constructor indicates whether the datatype has been declared using newtype
or not.
Constructors
ADT :: ModuleName -> DatatypeName -> NP ConstructorInfo xss -> DatatypeInfo xss | |
Newtype :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]] |
Instances
All (Compose Eq ConstructorInfo) xs => Eq (DatatypeInfo xs) Source # | |
Defined in Generics.SOP.Metadata Methods (==) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool (/=) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool | |
(All (Compose Eq ConstructorInfo) xs, All (Compose Ord ConstructorInfo) xs) => Ord (DatatypeInfo xs) Source # | |
Defined in Generics.SOP.Metadata Methods compare :: DatatypeInfo xs -> DatatypeInfo xs -> Ordering (<) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool (<=) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool (>) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool (>=) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool max :: DatatypeInfo xs -> DatatypeInfo xs -> DatatypeInfo xs min :: DatatypeInfo xs -> DatatypeInfo xs -> DatatypeInfo xs | |
All (Compose Show ConstructorInfo) xs => Show (DatatypeInfo xs) Source # | |
Defined in Generics.SOP.Metadata Methods showsPrec :: Int -> DatatypeInfo xs -> ShowS show :: DatatypeInfo xs -> String showList :: [DatatypeInfo xs] -> ShowS |
moduleName :: DatatypeInfo xss -> ModuleName Source #
The module name where a datatype is defined.
Since: 0.2.3.0
datatypeName :: DatatypeInfo xss -> DatatypeName Source #
The name of a datatype (or newtype).
Since: 0.2.3.0
constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss Source #
The constructor info for a datatype (or newtype).
Since: 0.2.3.0
constructorName :: ConstructorInfo xs -> ConstructorName Source #
The name of a constructor.
Since: 0.2.3.0
re-exports
data Associativity #
Constructors
LeftAssociative | |
RightAssociative | |
NotAssociative |
Instances
Bounded Associativity | |
Defined in GHC.Generics | |
Enum Associativity | |
Defined in GHC.Generics Methods succ :: Associativity -> Associativity pred :: Associativity -> Associativity toEnum :: Int -> Associativity fromEnum :: Associativity -> Int enumFrom :: Associativity -> [Associativity] enumFromThen :: Associativity -> Associativity -> [Associativity] enumFromTo :: Associativity -> Associativity -> [Associativity] enumFromThenTo :: Associativity -> Associativity -> Associativity -> [Associativity] | |
Eq Associativity | |
Defined in GHC.Generics | |
Data Associativity | |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Associativity -> c Associativity gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Associativity toConstr :: Associativity -> Constr dataTypeOf :: Associativity -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Associativity) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Associativity) gmapT :: (forall b. Data b => b -> b) -> Associativity -> Associativity gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Associativity -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Associativity -> r gmapQ :: (forall d. Data d => d -> u) -> Associativity -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Associativity -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Associativity -> m Associativity | |
Ord Associativity | |
Defined in GHC.Generics Methods compare :: Associativity -> Associativity -> Ordering (<) :: Associativity -> Associativity -> Bool (<=) :: Associativity -> Associativity -> Bool (>) :: Associativity -> Associativity -> Bool (>=) :: Associativity -> Associativity -> Bool max :: Associativity -> Associativity -> Associativity min :: Associativity -> Associativity -> Associativity | |
Read Associativity | |
Defined in GHC.Generics Methods readsPrec :: Int -> ReadS Associativity readList :: ReadS [Associativity] readPrec :: ReadPrec Associativity readListPrec :: ReadPrec [Associativity] | |
Show Associativity | |
Defined in GHC.Generics Methods showsPrec :: Int -> Associativity -> ShowS show :: Associativity -> String showList :: [Associativity] -> ShowS | |
Ix Associativity | |
Defined in GHC.Generics Methods range :: (Associativity, Associativity) -> [Associativity] index :: (Associativity, Associativity) -> Associativity -> Int unsafeIndex :: (Associativity, Associativity) -> Associativity -> Int inRange :: (Associativity, Associativity) -> Associativity -> Bool rangeSize :: (Associativity, Associativity) -> Int unsafeRangeSize :: (Associativity, Associativity) -> Int | |
Generic Associativity | |
Defined in GHC.Generics Associated Types type Rep Associativity :: Type -> Type | |
SingKind Associativity | |
Defined in GHC.Generics Associated Types type DemoteRep Associativity :: Type Methods fromSing :: Sing a -> DemoteRep Associativity | |
HasDatatypeInfo Associativity Source # | |
Defined in Generics.SOP.Instances Associated Types type DatatypeInfoOf Associativity :: DatatypeInfo Source # Methods datatypeInfo :: proxy Associativity -> DatatypeInfo (Code Associativity) Source # | |
Generic Associativity Source # | |
Defined in Generics.SOP.Instances Associated Types type Code Associativity :: [[Type]] Source # Methods from :: Associativity -> Rep Associativity Source # to :: Rep Associativity -> Associativity Source # | |
SingI LeftAssociative | |
Defined in GHC.Generics Methods sing :: Sing LeftAssociative | |
SingI RightAssociative | |
Defined in GHC.Generics Methods sing :: Sing RightAssociative | |
SingI NotAssociative | |
Defined in GHC.Generics Methods sing :: Sing NotAssociative | |
type Rep Associativity | |
Defined in GHC.Generics type Rep Associativity = D1 (MetaData "Associativity" "GHC.Generics" "base" False) (C1 (MetaCons "LeftAssociative" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "RightAssociative" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "NotAssociative" PrefixI False) (U1 :: Type -> Type))) | |
type DemoteRep Associativity | |
Defined in GHC.Generics | |
data Sing (a :: Associativity) | |
Defined in GHC.Generics data Sing (a :: Associativity) where
| |
type DatatypeInfoOf Associativity Source # | |
Defined in Generics.SOP.Instances type DatatypeInfoOf Associativity = ADT "GHC.Generics" "Associativity" (Constructor "LeftAssociative" ': (Constructor "RightAssociative" ': (Constructor "NotAssociative" ': ([] :: [ConstructorInfo])))) | |
type Code Associativity Source # | |
Defined in Generics.SOP.Instances type Code Associativity = ([] :: [Type]) ': (([] :: [Type]) ': (([] :: [Type]) ': ([] :: [[Type]]))) |