Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- mkMap :: ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec]
- mkMapWithOpts :: Options -> ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec]
- defaultOptions :: Options
- type ClassName = Name
- type InputTypeName = Name
- type OutputWrapperName = Name
- data family Some (c :: * -> Constraint)
- data Options = Options {
- maxDepth :: Int
- verbose :: Bool
- witnessGenerator :: ExpQ
- witnessTypeName :: Name
Documentation
mkMap :: ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec] Source #
When used as a declaration splice, this function will create three declarations:
- A data instance
Some
ClassName with a single constructor SomeClassName - A value named mapOfClassName, which has type
Map
TypeRep
InputType ->Some
Class
- A helper function getSomeClassName with signature
TypeRep
-> InputType ->Maybe
(Some
Class)
The four arguments to this function are:
- A TypeRep indicating what monomorphic type we should try to decode
- The name of the type that is the argument to the decoder function. Often ''ByteString or ''Aeson.Value.
- The name of a monad type with an instance of MonadFail that the functional expression uses to wrap the return value. Often ''Maybe.
- A quasiquoted expression for a function that takes an argument of the type named by (2) and has a polymorphic return type wrapped in the monad (3).
For example, for JSON the call generally be:
$(mkMap ''MyClass ''Value ''Result [|fromJSON|])
mkMapWithOpts :: Options -> ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec] Source #
type InputTypeName = Name Source #
type OutputWrapperName = Name Source #
data family Some (c :: * -> Constraint) Source #
Options | |
|