| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Monad.Free.Foil.Binary.TH
Description
Derive the Binary instance a client's pattern (binder) type needs,
alongside the hand-written instances of Control.Monad.Free.Foil.Binary.
A pattern type is a GADT over two scope indices, so its instance cannot come from GHC.Generics. What the deriver writes is the shape one would write by hand: one tag byte per constructor in declaration order, then the fields in order. Decoding happens at the diagonal, with every scope index of a constructor instantiated to the same variable, which any chain of binder indices admits. A single coercion then moves the result to the requested indices. That coercion mints scope evidence, so a derived instance is part of the same trust boundary as the library's own. See the module documentation of Control.Monad.Free.Foil.Binary.
Synopsis
- deriveBinaryPattern :: Name -> Q [Dec]
Documentation
deriveBinaryPattern :: Name -> Q [Dec] Source #
writes
deriveBinaryPattern ''Patterninstance (Binary p1, …) => Binary (Pattern p1 … n l) for a pattern
type of kind … -> S -> S -> Type whose fields are parameters, name
binders, or nested patterns.
Since: 0.4.0