Safe Haskell | None |
---|---|
Language | Haskell2010 |
- for :: Functor f => f a -> (a -> b) -> f b
- litStruct :: [ExpQ] -> ExpQ
- litStructPat :: [PatQ] -> PatQ
- caseMaybes :: [(Name, Name)] -> ExpQ -> ExpQ
- fromTyVarBndr :: TyVarBndr -> Type
- fromConstr :: Con -> (Name, [Type])
- tyVarName :: TyVarBndr -> Name
- promotedListT :: [TypeQ] -> TypeQ
- relevantTyVars :: [Con] -> [Name]
- makeRepresentable :: Name -> Q [Dec]
- makeRepresentableTuple :: Int -> Q Dec
Documentation
litStructPat :: [PatQ] -> PatQ Source #
fromTyVarBndr :: TyVarBndr -> Type Source #
promotedListT :: [TypeQ] -> TypeQ Source #
relevantTyVars :: [Con] -> [Name] Source #
makeRepresentable :: Name -> Q [Dec] Source #
Create a Representable
instance for a type.
The strategy used to marshal types depends on the shape of your type:
- If none of the constructor(s) have fields, the type is represented by a
Byte
where the n-th constructor (counting from 0) is marshalled to n - If the type has a single constructor with exactly one field, is is
represented by the
RepType
of it's field. (This is always the case fornewtypes
) - If the type has a single constructor with multiple fields, it is
represented by a
Struct
(consisting of the translated members) - In the general case with multiple constructors with varying numbers of
fields , the type is represented by a pair (2-element struct) of a
Byte
(tag) and aVariant
. The n-th constructor (counting from 0) is represented by the tag n and contents of theVariant
depends on the number of members: - For constructors without members, a single
Byte
with the value 0 is stored (The value of the Byte is ignored when unmarshalling) - For constructors with a single member, the translated member is stored as-is
- For constructors with multiple members, the translated members are stored in a
Struct
makeRepresentableTuple :: Int -> Q Dec Source #
Create a Representable
instance for a Tuple. The tuple will be
represented by a Struct
. Instances for Tuples up to length 20 are already
provided