generic-data-functions-0.5.1: Familiar functions lifted to generic data types
Safe HaskellSafe-Inferred
LanguageGHC2021

Generic.Data.Function.FoldMap.Sum

Description

foldMap for sum types where constructors are encoded by mapping the constructor name.

Note that constructor names are unique per type. So as long as your mapping function similarly outputs unique values of your monoid for each constructor, you should be able to "reverse" the process (e.g. for generic traverse).

Synopsis

Documentation

class GFoldMapSum tag gf where Source #

Methods

gFoldMapSum :: (String -> GenericFoldMapM tag) -> gf p -> GenericFoldMapM tag Source #

Instances

Instances details
GFoldMapSum (tag :: k1) (V1 :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> V1 p -> GenericFoldMapM tag Source #

GFoldMapCSum tag (l :+: r) => GFoldMapSum (tag :: k1) (l :+: r :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> (l :+: r) p -> GenericFoldMapM tag Source #

GFoldMapCSum tag (C1 c gf) => GFoldMapSum (tag :: k1) (C1 c gf :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> C1 c gf p -> GenericFoldMapM tag Source #

GFoldMapSum tag gf => GFoldMapSum (tag :: k1) (D1 c gf :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> D1 c gf p -> GenericFoldMapM tag Source #

class GFoldMapCSum tag gf where Source #

Sum type handler prefixing constructor contents with their mapped constructor name via a provided String -> m.

TODO rename

Methods

gFoldMapCSum :: (String -> GenericFoldMapM tag) -> gf p -> GenericFoldMapM tag Source #

Instances

Instances details
(GFoldMapCSum tag l, GFoldMapCSum tag r) => GFoldMapCSum (tag :: k1) (l :+: r :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapCSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> (l :+: r) p -> GenericFoldMapM tag Source #

(Semigroup (GenericFoldMapM tag), Constructor c, GFoldMapC tag gf) => GFoldMapCSum (tag :: k1) (C1 c gf :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

gFoldMapCSum :: forall (p :: k10). (String -> GenericFoldMapM tag) -> C1 c gf p -> GenericFoldMapM tag Source #