{-# 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} {gf} asserts tag a
. ( Generic a, Rep a ~ D1 cd gf
, GFoldMapNonSum tag gf
, ApplyGCAsserts asserts gf)
=> a -> GenericFoldMapM tag
genericFoldMapNonSum :: forall {k} {cd :: Meta} {gf :: Type -> Type}
(asserts :: [GCAssert]) (tag :: k) a.
(Generic a, Rep a ~ D1 cd gf, GFoldMapNonSum tag gf,
ApplyGCAsserts asserts gf) =>
a -> GenericFoldMapM tag
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 (gf Any -> GenericFoldMapM tag)
-> (a -> gf Any) -> a -> GenericFoldMapM tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 D cd gf Any -> gf Any
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
unM1 (M1 D cd gf Any -> gf Any) -> (a -> M1 D cd gf Any) -> a -> gf Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> M1 D cd gf Any
a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from
genericFoldMapSum
:: forall {cd} {gf} opts asserts tag a
. ( Generic a, Rep a ~ D1 cd gf
, GFoldMapSum opts tag gf
, ApplyGCAsserts asserts gf)
=> (String -> GenericFoldMapM tag)
-> a -> GenericFoldMapM tag
genericFoldMapSum :: forall {k} {cd :: Meta} {gf :: Type -> Type} (opts :: SumOpts)
(asserts :: [GCAssert]) (tag :: k) a.
(Generic a, Rep a ~ D1 cd gf, GFoldMapSum opts tag gf,
ApplyGCAsserts asserts gf) =>
(String -> GenericFoldMapM tag) -> a -> GenericFoldMapM tag
genericFoldMapSum String -> GenericFoldMapM tag
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 -> GenericFoldMapM tag
f (gf Any -> GenericFoldMapM tag)
-> (a -> gf Any) -> a -> GenericFoldMapM tag
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 D cd gf Any -> gf Any
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
unM1 (M1 D cd gf Any -> gf Any) -> (a -> M1 D cd gf Any) -> a -> gf Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> M1 D cd gf Any
a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from
genericFoldMapSumConsByte
:: forall tag a
. (Generic a, GFoldMapSumConsByte tag (Rep a))
=> (Word8 -> GenericFoldMapM tag)
-> a -> GenericFoldMapM tag
genericFoldMapSumConsByte :: forall {k} (tag :: k) a.
(Generic a, GFoldMapSumConsByte tag (Rep a)) =>
(Word8 -> GenericFoldMapM tag) -> a -> GenericFoldMapM tag
genericFoldMapSumConsByte Word8 -> GenericFoldMapM tag
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 -> GenericFoldMapM tag
f (Rep a Any -> GenericFoldMapM tag)
-> (a -> Rep a Any) -> a -> GenericFoldMapM tag
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