-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Template haskell utilities for helping with deserialization etc. of existential types -- -- instance-map provides Template Haskell functions that help go from -- serialized values with value-level type witnesses (i.e. TypeRep -- values) to existential types containing type-level evidence of -- membership in a type class. It is useful for dealing with serialized -- values when only membership in a certain class (and not the -- monomorphic type) is known at the site of deserialization. @package instance-map @version 0.1.0.0 module Type.InstanceMap.TH -- | When used as a declaration splice, this function will create three -- declarations: -- -- -- --
--   Map TypeRep InputType -> Some Class
--   
-- -- -- --
--   TypeRep -> InputType -> Maybe (Some Class)
--   
-- -- The four arguments to this function are: -- --
    --
  1. A TypeRep indicating what monomorphic type we should try to -- decode
  2. --
  3. The name of the type that is the argument to the decoder function. -- Often ''ByteString or ''Aeson.Value.
  4. --
  5. The name of a monad type with an instance of MonadFail that the -- functional expression uses to wrap the return value. Often -- ''Maybe.
  6. --
  7. 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).
  8. --
-- -- For example, for JSON the call generally be: -- --
--   $(mkMap ''MyClass ''Value ''Result [|fromJSON|])
--   
mkMap :: ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec] -- | Like mkMap but with user-provided Options mkMapWithOpts :: Options -> ClassName -> InputTypeName -> OutputWrapperName -> ExpQ -> Q [Dec] defaultOptions :: Options type ClassName = Name type InputTypeName = Name type OutputWrapperName = Name data Options Options :: Int -> Bool -> ExpQ -> Name -> Options -- | How deep to traverse the tree of instance contexts when attempting to -- find monomorphic types that are members of the class. Default is 2. -- -- For instance, if we have declarations like: -- --
--   data NumWithS n = NumWithS String n
--   instance (Num a) => Num (NumWithS a)
--   
-- -- with maxDepth set to 2, then NumWithS Int and NumWithS (NumWithS Int) -- would both be found but NumWithS (NumWithS (NumWithS Int)) would not -- be. [maxDepth] :: Options -> Int -- | Whether to produce lots of debugging output. Default False. [verbose] :: Options -> Bool [witnessGenerator] :: Options -> ExpQ [witnessTypeName] :: Options -> Name module Type.InstanceMap