Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- isLabel :: TyLit -> Type -> Exp -> Dec
- constructorIsLabel :: TyLit -> Type -> [Type] -> Exp -> Dec
- newtypeConstructorIsLabel :: TyLit -> Type -> Name -> Type -> Dec
- sumConstructorIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec
- enumConstructorIsLabel :: TyLit -> Type -> Name -> Dec
- tupleAdtConstructorIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec
- mapperIsLabel :: TyLit -> Type -> Type -> Exp -> Dec
- productMapperIsLabel :: TyLit -> Type -> Type -> Name -> Int -> Int -> Dec
- sumMapperIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec
- accessorIsLabel :: TyLit -> Type -> Type -> Exp -> Dec
- productAccessorIsLabel :: TyLit -> Type -> Type -> Name -> Int -> Int -> Dec
- sumAccessorIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec
- enumAccessorIsLabel :: TyLit -> Type -> Name -> Dec
- hasField :: TyLit -> Type -> Type -> [Clause] -> Dec
- enumHasField :: TyLit -> Type -> Name -> Dec
- sumHasField :: TyLit -> Type -> Name -> [Type] -> Dec
- productHasField :: TyLit -> Type -> Type -> Name -> Int -> Int -> Dec
IsLabel
Constructor
constructorIsLabel :: TyLit -> Type -> [Type] -> Exp -> Dec Source #
instance (a ~ Text) => IsLabel "error" (a -> Result)
tupleAdtConstructorIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec Source #
IsLabel
instance which converts tuple to ADT.
Mapper
:: TyLit | Field label. |
-> Type | Type of the product. |
-> Type | Type of the mapper function. |
-> Exp |
|
-> Dec |
|
Template of IsLabel
for instances mapping to mapper functions.
instance (mapper ~ (Text -> Text)) => IsLabel "name" (mapper -> Person -> Person)
:: TyLit | Field label. |
-> Type | Type of the product. |
-> Type | Type of the member we're focusing on. |
-> Name | Constructor name. |
-> Int | Total amount of members in the product. |
-> Int | Offset of the member we're focusing on. |
-> Dec |
|
Template of IsLabel
for instances mapping to mapper functions.
instance (mapper ~ (Text -> Text)) => IsLabel "name" (mapper -> Person -> Person)
:: TyLit | Field label. |
-> Type | Type of the product. |
-> Name | Constructor name. |
-> [Type] | Member types we're focusing on. |
-> Dec |
|
Template of IsLabel
for instances mapping to mapper functions.
instance (mapper ~ (Int -> Text -> (Int, Text))) => IsLabel "error" (mapper -> Result -> Result)
Accessor
accessorIsLabel :: TyLit -> Type -> Type -> Exp -> Dec Source #
Template of IsLabel
for instances mapping to accessor functions.
productAccessorIsLabel Source #
:: TyLit | Field label. |
-> Type | Type of the product. |
-> Type | Type of the member we're focusing on. |
-> Name | Constructor name. |
-> Int | Total amount of members in the product. |
-> Int | Offset of the member we're focusing on. |
-> Dec |
|
Instance of IsLabel
for a member of a product type.
sumAccessorIsLabel :: TyLit -> Type -> Name -> [Type] -> Dec Source #
instance (a ~ Maybe Text) => IsLabel "error" (Result -> a)
HasField
hasField :: TyLit -> Type -> Type -> [Clause] -> Dec Source #
The most general template for HasField
.
:: TyLit | Field label. |
-> Type | The ADT type. |
-> Name | Name of the constructor. |
-> [Type] | Member types of that constructor. |
-> Dec |
|
Instance of HasField
for a constructor of a sum ADT,
projecting it into a Maybe
tuple of its members.
Generates code of the following pattern:
instance HasField "fieldLabel" sumAdt (Maybe projectionType)
- When the amount of member types is 0,
projectionType
is()
. - When the amount of member types is 1, it is that member type.
- Otherwise it is a tuple of those members.