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

Stock.Traversable

Description

Traversable (Stock1 F), synthesized directly (DeriveTraversable-style Core), NOT by coercion. traverse's result f (t b) places the wrapper under an abstract applicative f (nominal role), so DerivingVia cannot coerce Traversable (Stock1 F) onto F — but the instance itself is perfectly definable and usable at the wrapper. Put it on your own type with the one-liner (which works with Override1 too):

instance Traversable F where
  traverse g = fmap unStock1 . traverse g . Stock1
Synopsis

Documentation

synthTraversable :: GenEnv -> Class -> CtLoc -> Type -> Type -> TcPluginM (Maybe (EvTerm, [Ct])) Source #

Synthesize Traversable (Stock1 F): per constructor, pure mkCon <*> f1 <*> … <*> fn where the parameter field uses the supplied g, a constant uses pure, and a sub-functor H a field uses traverse @H g (an Override1-reshaped functor traverses through the modifier, re-wrapped with pure coerce <*> _ — never a cast under the abstract f). Functor and Foldable superclasses come from their own synthesizers.