Generics.SOP.Metadata

generics-sop-0.2.5.0: Generic Programming using True Sums of Products

Safe Haskell | None
Language | Haskell2010

Generics.SOP.Metadata

Contents

- re-exports

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

- 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
- 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
- constructorName :: ConstructorInfo xs -> ConstructorName
- data FieldInfo :: * -> * where
  - FieldInfo :: FieldName -> FieldInfo a
- fieldName :: FieldInfo a -> FieldName
- type DatatypeName = String
- type ModuleName = String
- type ConstructorName = String
- type FieldName = String
- type Fixity = Int
- data Associativity :: *
  - = LeftAssociative
  - | RightAssociative
  - | NotAssociative

# Documentation

data DatatypeInfo :: [[*]] -> * where #

Metadata for a datatype.

A value of type ``DatatypeInfo` c` contains the information about a datatype that is not contained in ``Code` c`. This information consists primarily of the names of the datatype, its constructors, and possibly its record selectors.

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) # |
Methods (==) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool # (/=) :: DatatypeInfo xs -> DatatypeInfo xs -> Bool #
(All [*] (Compose * [*] Eq ConstructorInfo) xs, All [*] (Compose * [*] Ord ConstructorInfo) xs) => Ord (DatatypeInfo xs) # |
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) # |
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: 0.2.3.0

datatypeName :: DatatypeInfo xss -> DatatypeName #

The name of a datatype (or newtype).

Since: 0.2.3.0

constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss #

The constructor info for a datatype (or newtype).

Since: 0.2.3.0

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

All * (Compose * * Eq FieldInfo) xs => Eq (ConstructorInfo xs) # |
Methods (==) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool # (/=) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool #
(All * (Compose * * Eq FieldInfo) xs, All * (Compose * * Ord FieldInfo) xs) => Ord (ConstructorInfo xs) # |
Methods compare :: ConstructorInfo xs -> ConstructorInfo xs -> Ordering # (<) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool # (<=) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool # (>) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool # (>=) :: ConstructorInfo xs -> ConstructorInfo xs -> Bool # max :: ConstructorInfo xs -> ConstructorInfo xs -> ConstructorInfo xs # min :: ConstructorInfo xs -> ConstructorInfo xs -> ConstructorInfo xs #
All * (Compose * * Show FieldInfo) xs => Show (ConstructorInfo xs) # |
Methods showsPrec :: Int -> ConstructorInfo xs -> ShowS # show :: ConstructorInfo xs -> String # showList :: [ConstructorInfo xs] -> ShowS #

constructorName :: ConstructorInfo xs -> ConstructorName #

The name of a constructor.

Since: 0.2.3.0

data FieldInfo :: * -> * where #

For records, this functor maps the component to its selector name.

Constructors

FieldInfo :: FieldName -> FieldInfo a |

Instances

Functor FieldInfo # |
Methods fmap :: (a -> b) -> FieldInfo a -> FieldInfo b # (<$) :: a -> FieldInfo b -> FieldInfo a #
Eq (FieldInfo a) # |
Methods (==) :: FieldInfo a -> FieldInfo a -> Bool # (/=) :: FieldInfo a -> FieldInfo a -> Bool #
Ord (FieldInfo a) # |
Methods compare :: FieldInfo a -> FieldInfo a -> Ordering # (<) :: FieldInfo a -> FieldInfo a -> Bool # (<=) :: FieldInfo a -> FieldInfo a -> Bool # (>) :: FieldInfo a -> FieldInfo a -> Bool # (>=) :: FieldInfo a -> FieldInfo a -> Bool # max :: FieldInfo a -> FieldInfo a -> FieldInfo a # min :: FieldInfo a -> FieldInfo a -> FieldInfo a #
Show (FieldInfo a) # |
Methods showsPrec :: Int -> FieldInfo a -> ShowS # show :: FieldInfo a -> String # showList :: [FieldInfo a] -> ShowS #

fieldName :: FieldInfo a -> FieldName #

The name of a field.

Since: 0.2.3.0

type DatatypeName = String #

The name of a datatype.

type ModuleName = String #

The name of a module.

type ConstructorName = String #

The name of a data constructor.

type FieldName = String #

The name of a field / record selector.

type Fixity = Int #

The fixity of an infix constructor.

# re-exports

data Associativity :: * #

Datatype to represent the associativity of a constructor

Constructors

LeftAssociative |
RightAssociative |
NotAssociative |

Instances

Bounded Associativity |
Methods minBound :: Associativity # maxBound :: Associativity #
Enum Associativity |
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 |
Methods (==) :: Associativity -> Associativity -> Bool # (/=) :: Associativity -> Associativity -> Bool #
Data Associativity |
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 |
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 |
Methods readsPrec :: Int -> ReadS Associativity # readList :: ReadS [Associativity] # readPrec :: ReadPrec Associativity # readListPrec :: ReadPrec [Associativity] #
Show Associativity |
Methods showsPrec :: Int -> Associativity -> ShowS # show :: Associativity -> String # showList :: [Associativity] -> ShowS #
Ix Associativity |
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 |
Associated Types type Rep Associativity :: * -> * # Methods from :: Associativity -> Rep Associativity x # to :: Rep Associativity x -> Associativity #
SingI Associativity LeftAssociative |
Methods sing :: Sing LeftAssociative a
SingI Associativity RightAssociative |
Methods sing :: Sing RightAssociative a
SingI Associativity NotAssociative |
Methods sing :: Sing NotAssociative a
SingKind Associativity (KProxy Associativity) |
Associated Types type DemoteRep (KProxy Associativity) (kparam :: KProxy (KProxy Associativity)) :: * Methods fromSing :: Sing (KProxy Associativity) a -> DemoteRep (KProxy Associativity) kparam
type Rep Associativity |
type Rep Associativity = D1 (MetaData "Associativity" "GHC.Generics" "base" False) ((:+:) (C1 (MetaCons "LeftAssociative" PrefixI False) U1) ((:+:) (C1 (MetaCons "RightAssociative" PrefixI False) U1) (C1 (MetaCons "NotAssociative" PrefixI False) U1)))
data Sing Associativity |
data Sing Associativity where SLeftAssociative :: Sing Associativity LeftAssociative SRightAssociative :: Sing Associativity RightAssociative SNotAssociative :: Sing Associativity NotAssociative
type DemoteRep Associativity (KProxy Associativity) |
type DemoteRep Associativity (KProxy Associativity) = Associativity