stock-0.1.0.0: Stock-style deriving via coercion, with no Generic
Safe HaskellNone
LanguageGHC2021

Stock.Applicative

Description

Pointwise Applicative via Stock1, for single-constructor (product) types — a faster Generically1: pure replicates into every field and (<*>) applies field-wise. Each field must be the parameter (applied directly), an Applicative functor of it (delegating to that functor), or a constant — which, Const-style (exactly as Generically1), is fine given a Monoid: pure fills it with mempty and (<*>)/liftA2 combine with (<>). (Any sum type is still rejected.) The Functor superclass dictionary comes from synthFunctor.

Synopsis

Documentation

data FldSpec Source #

How one field of the product is handled by pure/(<*>)/liftA2: it is the parameter; an Applicative functor m of it (with m's dict, and a Just h t ~R m t coercion builder when reshaped by an Override1, else Nothing); or a constant of type ft handled Const-style via its Monoid.

castInOv :: Maybe (Type -> Coercion) -> Type -> CoreExpr -> CoreExpr Source #

Coerce a field value into the modifier functor (h t ~R m t); identity when the field is not reshaped.

castBackOv :: Maybe (Type -> Coercion) -> Type -> CoreExpr -> CoreExpr Source #

Coerce a result back from the modifier functor to the real field type.