generic-data-functions-0.3.0: 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 (opts :: SumOpts) tag f where Source #

Methods

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

Instances

Instances details
GFoldMapSum opts (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 (C1 c f) => GFoldMapSum 'AllowSingletonSum (tag :: k1) (C1 c f :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

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

GFoldMapSum 'SumOnly (tag :: k1) (C1 c f :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

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

GFoldMapCSum tag (l :+: r) => GFoldMapSum opts (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 #

class GFoldMapCSum tag f 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) -> f 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 f) => GFoldMapCSum (tag :: k1) (C1 c f :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.Function.FoldMap.Sum

Methods

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