| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Stock.Generic
Description
Generic / Generic1 synthesizers: Rep as a balanced :+: / :*: tree.
Synopsis
- reshape1Ftys :: GenEnv -> Maybe [Type] -> TyVar -> Type -> [Type] -> [Type]
- rewriteRep :: GenEnv -> RewriteEnv -> [Ct] -> [Type] -> TcPluginM TcPluginRewriteResult
- rewriteRep1 :: GenEnv -> RewriteEnv -> [Ct] -> [Type] -> TcPluginM TcPluginRewriteResult
- synthGeneric :: GenEnv -> Type -> Type -> Coercion -> [ConInfo] -> TcPluginM EvTerm
- synthGeneric1 :: GenEnv -> Class -> CtLoc -> Type -> Type -> TcPluginM (Maybe (EvTerm, [Ct]))
Documentation
reshape1Ftys :: GenEnv -> Maybe [Type] -> TyVar -> Type -> [Type] -> [Type] Source #
Field types with Override1 modifiers applied: an h a field whose config
names a modifier m becomes m a (so its Rep1 leaf is Rec1 m); all other
fields are unchanged. Used by both rewriteRep1 (the Rep1 type) and
synthGeneric1 (the from1/to1 values), keeping them in lock-step.
rewriteRep :: GenEnv -> RewriteEnv -> [Ct] -> [Type] -> TcPluginM TcPluginRewriteResult Source #
rewriteRep1 :: GenEnv -> RewriteEnv -> [Ct] -> [Type] -> TcPluginM TcPluginRewriteResult Source #
Rewrite Rep1 (Stock1 F) to the parameter-aware structure (Par1/Rec1/
Rec0 leaves under the M1 metadata). No rewrite if any field is an
unsupported shape (composition etc.).
synthGeneric :: GenEnv -> Type -> Type -> Coercion -> [ConInfo] -> TcPluginM EvTerm Source #
The structural Rep for a whole datatype: a single constructor is just its
product repStruct; several constructors form a balanced :+: tree of
their product structs (mirroring GHC's foldBal).
cons carries each constructor's modifier field types (ciFields) and the
per-cell coercions (ciFieldCos, realFieldType ~R modifierType; Refl
without an Override). The Rep leaves use the modifier types (matching
rewriteRep); from coerces the real field into the leaf, to coerces
back before rebuilding. Refl everywhere ⇒ byte-identical Core to plain.
synthGeneric1 :: GenEnv -> Class -> CtLoc -> Type -> Type -> TcPluginM (Maybe (EvTerm, [Ct])) Source #
Synthesize Generic1 (Stock1 F): like synthGeneric but the field
representation is parameter-aware — the last type variable a becomes
Par1, g a becomes Rec1 g, a constant becomes Rec0 (see rep1Field).
from1/to1 wrap/unwrap each field through the corresponding newtype.
Nothing for shapes rep1Field rejects (e.g. composition f (g a)).