| Safe Haskell | Safe-Inferred | 
|---|---|
| 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
- 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 -> POP StrictnessInfo xss -> DatatypeInfo xss
- Newtype :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]]
 
- data FieldInfo :: Type -> Type where
- type DatatypeName = String
- type ModuleName = String
- type ConstructorName = String
- type FieldName = String
- data StrictnessInfo :: Type -> Type where
- datatypeName :: DatatypeInfo xss -> DatatypeName
- moduleName :: DatatypeInfo xss -> ModuleName
- constructorName :: ConstructorInfo xs -> ConstructorName
- constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss
- fieldName :: FieldInfo a -> FieldName
- data Associativity
- data DecidedStrictness
- data SourceStrictness
- data SourceUnpackedness
Documentation
data ConstructorInfo :: [Type] -> Type where Source #
Metadata for a single constructor.
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 DatatypeInfo cCode c
The constructor indicates whether the datatype has been declared using newtype
 or not.
Constructors
| ADT :: ModuleName -> DatatypeName -> NP ConstructorInfo xss -> POP StrictnessInfo xss -> DatatypeInfo xss | |
| Newtype :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]] | 
Instances
data FieldInfo :: Type -> Type where Source #
For records, this functor maps the component to its selector name.
Instances
| Functor FieldInfo Source # | |
| Show (FieldInfo a) Source # | |
| Eq (FieldInfo a) Source # | |
| Ord (FieldInfo a) Source # | |
| Defined in Generics.SOP.Metadata | |
type DatatypeName = String Source #
The name of a datatype.
type ModuleName = String Source #
The name of a module.
type ConstructorName = String Source #
The name of a data constructor.
data StrictnessInfo :: Type -> Type where Source #
Metadata for strictness information of a field.
Indexed by the type of the field.
Since: 0.4.0.0
Constructors
| StrictnessInfo :: SourceUnpackedness -> SourceStrictness -> DecidedStrictness -> StrictnessInfo a | 
Instances
datatypeName :: DatatypeInfo xss -> DatatypeName Source #
The name of a datatype (or newtype).
Since: 0.2.3.0
moduleName :: DatatypeInfo xss -> ModuleName Source #
The module name where a datatype is defined.
Since: 0.2.3.0
constructorName :: ConstructorInfo xs -> ConstructorName Source #
The name of a constructor.
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
re-exports
data Associativity #
Datatype to represent the associativity of a constructor
Constructors
| LeftAssociative | |
| RightAssociative | |
| NotAssociative | 
Instances
data DecidedStrictness #
The strictness that GHC infers for a field during compilation. Whereas
 there are nine different combinations of SourceUnpackedness and
 SourceStrictness, the strictness that GHC decides will ultimately be one
 of lazy, strict, or unpacked. What GHC decides is affected both by what the
 user writes in the source code and by GHC flags. As an example, consider
 this data type:
data E = ExampleConstructor {-# UNPACK #-} !Int !Int Int
- If compiled without optimization or other language extensions, then the
   fields of ExampleConstructorwill haveDecidedStrict,DecidedStrict, andDecidedLazy, respectively.
- If compiled with -XStrictDataenabled, then the fields will haveDecidedStrict,DecidedStrict, andDecidedStrict, respectively.
- If compiled with -O2enabled, then the fields will haveDecidedUnpack,DecidedStrict, andDecidedLazy, respectively.
Since: base-4.9.0.0
Constructors
| DecidedLazy | |
| DecidedStrict | |
| DecidedUnpack | 
Instances
data SourceStrictness #
The strictness of a field as the user wrote it in the source code. For example, in the following data type:
data E = ExampleConstructor Int ~Int !Int
The fields of ExampleConstructor have NoSourceStrictness,
 SourceLazy, and SourceStrict, respectively.
Since: base-4.9.0.0
Constructors
| NoSourceStrictness | |
| SourceLazy | |
| SourceStrict | 
Instances
data SourceUnpackedness #
The unpackedness of a field as the user wrote it in the source code. For example, in the following data type:
data E = ExampleConstructor     Int
           {-# NOUNPACK #-} Int
           {-#   UNPACK #-} Int
The fields of ExampleConstructor have NoSourceUnpackedness,
 SourceNoUnpack, and SourceUnpack, respectively.
Since: base-4.9.0.0
Constructors
| NoSourceUnpackedness | |
| SourceNoUnpack | |
| SourceUnpack |