| 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 :: * -> * where
- data ConstructorInfo :: [*] -> * 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 :: [[*]] -> * 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 #
The name of a data constructor.
type ModuleName = String #
The name of a module.
type DatatypeName = String #
The name of a datatype.
data FieldInfo :: * -> * where #
For records, this functor maps the component to its selector name.
Instances
| Functor FieldInfo # | |
| Eq (FieldInfo a) # | |
| Ord (FieldInfo a) # | |
Defined in Generics.SOP.Metadata | |
| Show (FieldInfo a) # | |
data ConstructorInfo :: [*] -> * where #
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 :: [[*]] -> * where #
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) # | |
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) # | |
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) # | |
Defined in Generics.SOP.Metadata Methods showsPrec :: Int -> DatatypeInfo xs -> ShowS # show :: DatatypeInfo xs -> String # showList :: [DatatypeInfo xs] -> ShowS # | |
moduleName :: DatatypeInfo xss -> ModuleName #
The module name where a datatype is defined.
Since: generics-sop-0.2.3.0
datatypeName :: DatatypeInfo xss -> DatatypeName #
The name of a datatype (or newtype).
Since: generics-sop-0.2.3.0
constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss #
The constructor info for a datatype (or newtype).
Since: generics-sop-0.2.3.0
constructorName :: ConstructorInfo xs -> ConstructorName #
The name of a constructor.
Since: generics-sop-0.2.3.0
re-exports
data Associativity #
Datatype to represent the associativity of a constructor
Constructors
| LeftAssociative | |
| RightAssociative | |
| NotAssociative |