{-# LANGUAGE AllowAmbiguousTypes #-}
module Generic.Data.Function.FoldMap
( GenericFoldMap(..)
, genericFoldMapNonSum, GFoldMapNonSum
, genericFoldMapSum, GFoldMapSum
, genericFoldMapSumConsByte, GFoldMapSumConsByte
) where
import GHC.Generics
import Generic.Data.Rep.Assert
import Generic.Data.Function.FoldMap.NonSum
import Generic.Data.Function.FoldMap.Sum
import Generic.Data.Function.FoldMap.Constructor
import Generic.Data.Function.FoldMap.SumConsByte
import Data.Word ( Word8 )
genericFoldMapNonSum
:: forall {cd} {f} asserts tag {m} a
. ( Generic a, Rep a ~ D1 cd f
, m ~ GenericFoldMapM tag
, GFoldMapNonSum tag f
, ApplyGCAsserts asserts f)
=> a -> m
genericFoldMapNonSum :: forall {k} {cd :: Meta} {f :: Type -> Type} (asserts :: [GCAssert])
(tag :: k) {m} a.
(Generic a, Rep a ~ D1 cd f, m ~ GenericFoldMapM tag,
GFoldMapNonSum tag f, ApplyGCAsserts asserts f) =>
a -> m
genericFoldMapNonSum = forall (tag :: k) (f :: Type -> Type) p.
GFoldMapNonSum tag f =>
f p -> GenericFoldMapM tag
forall {k} {k1} (tag :: k) (f :: k1 -> Type) (p :: k1).
GFoldMapNonSum tag f =>
f p -> GenericFoldMapM tag
gFoldMapNonSum @tag (f Any -> m) -> (a -> f Any) -> a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 D cd f Any -> f Any
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
unM1 (M1 D cd f Any -> f Any) -> (a -> M1 D cd f Any) -> a -> f Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> M1 D cd f Any
a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from
genericFoldMapSum
:: forall {cd} {f} opts asserts tag {m} a
. ( Generic a, Rep a ~ D1 cd f
, m ~ GenericFoldMapM tag
, GFoldMapSum opts tag f
, ApplyGCAsserts asserts f)
=> (String -> m)
-> a -> m
genericFoldMapSum :: forall {k} {cd :: Meta} {f :: Type -> Type} (opts :: SumOpts)
(asserts :: [GCAssert]) (tag :: k) {m} a.
(Generic a, Rep a ~ D1 cd f, m ~ GenericFoldMapM tag,
GFoldMapSum opts tag f, ApplyGCAsserts asserts f) =>
(String -> m) -> a -> m
genericFoldMapSum String -> m
f = forall {k} {k1} (opts :: SumOpts) (tag :: k) (f :: k1 -> Type)
(p :: k1).
GFoldMapSum opts tag f =>
(String -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
forall (opts :: SumOpts) (tag :: k) (f :: Type -> Type) p.
GFoldMapSum opts tag f =>
(String -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
gFoldMapSum @opts @tag String -> m
String -> GenericFoldMapM tag
f (f Any -> m) -> (a -> f Any) -> a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 D cd f Any -> f Any
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
unM1 (M1 D cd f Any -> f Any) -> (a -> M1 D cd f Any) -> a -> f Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> M1 D cd f Any
a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from
genericFoldMapSumConsByte
:: forall tag {m} a
. (m ~ GenericFoldMapM tag, Generic a, GFoldMapSumConsByte tag (Rep a))
=> (Word8 -> m)
-> a -> m
genericFoldMapSumConsByte :: forall {k} (tag :: k) {m} a.
(m ~ GenericFoldMapM tag, Generic a,
GFoldMapSumConsByte tag (Rep a)) =>
(Word8 -> m) -> a -> m
genericFoldMapSumConsByte Word8 -> m
f = forall (tag :: k) (f :: Type -> Type) p.
GFoldMapSumConsByte tag f =>
(Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
forall {k} {k1} (tag :: k) (f :: k1 -> Type) (p :: k1).
GFoldMapSumConsByte tag f =>
(Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
gFoldMapSumConsByte @tag Word8 -> m
Word8 -> GenericFoldMapM tag
f (Rep a Any -> m) -> (a -> Rep a Any) -> a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from