{-# LANGUAGE AllowAmbiguousTypes #-}
module Generic.Data.Function.FoldMap
( GenericFoldMap(..)
, genericFoldMapNonSum, GFoldMapNonSum
, genericFoldMapSum, GFoldMapSum
, genericFoldMapSumRaw
, genericFoldMapSumConsByte, GFoldMapSumConsByte
) where
import GHC.Generics
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 )
import Generic.Data.MetaParse.Cstr
import GHC.TypeLits ( symbolVal' )
genericFoldMapNonSum
:: forall tag a
. ( Generic a, GFoldMapNonSum tag (Rep a)
) => a -> GenericFoldMapM tag
genericFoldMapNonSum :: forall {k} (tag :: k) a.
(Generic a, GFoldMapNonSum tag (Rep a)) =>
a -> GenericFoldMapM tag
genericFoldMapNonSum = forall (tag :: k) (gf :: Type -> Type) p.
GFoldMapNonSum tag gf =>
gf p -> GenericFoldMapM tag
forall {k} {k1} (tag :: k) (gf :: k1 -> Type) (p :: k1).
GFoldMapNonSum tag gf =>
gf p -> GenericFoldMapM tag
gFoldMapNonSum @tag (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
genericFoldMapSum
:: forall tag sumtag a
. (Generic a, GFoldMapSum tag sumtag (Rep a))
=> ParseCstrTo sumtag (GenericFoldMapM tag)
-> a -> GenericFoldMapM tag
genericFoldMapSum :: forall {k} {k} (tag :: k) (sumtag :: k) a.
(Generic a, GFoldMapSum tag sumtag (Rep a)) =>
ParseCstrTo sumtag (GenericFoldMapM tag)
-> a -> GenericFoldMapM tag
genericFoldMapSum ParseCstrTo sumtag (GenericFoldMapM tag)
f = forall (tag :: k) (sumtag :: k) (gf :: Type -> Type) p.
GFoldMapSum tag sumtag gf =>
ParseCstrTo sumtag (GenericFoldMapM tag)
-> gf p -> GenericFoldMapM tag
forall {k} {k1} {k2} (tag :: k) (sumtag :: k1) (gf :: k2 -> Type)
(p :: k2).
GFoldMapSum tag sumtag gf =>
ParseCstrTo sumtag (GenericFoldMapM tag)
-> gf p -> GenericFoldMapM tag
gFoldMapSum @tag @sumtag Proxy# x -> GenericFoldMapM tag
ParseCstrTo sumtag (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
genericFoldMapSumRaw
:: forall tag a
. (Generic a, GFoldMapSum tag Raw (Rep a))
=> (String -> GenericFoldMapM tag)
-> a -> GenericFoldMapM tag
genericFoldMapSumRaw :: forall {k} (tag :: k) a.
(Generic a, GFoldMapSum tag Raw (Rep a)) =>
(String -> GenericFoldMapM tag) -> a -> GenericFoldMapM tag
genericFoldMapSumRaw String -> GenericFoldMapM tag
f = forall (tag :: k) sumtag (gf :: Type -> Type) p.
GFoldMapSum tag sumtag gf =>
ParseCstrTo sumtag (GenericFoldMapM tag)
-> gf p -> GenericFoldMapM tag
forall {k} {k1} {k2} (tag :: k) (sumtag :: k1) (gf :: k2 -> Type)
(p :: k2).
GFoldMapSum tag sumtag gf =>
ParseCstrTo sumtag (GenericFoldMapM tag)
-> gf p -> GenericFoldMapM tag
gFoldMapSum @tag @Raw (\Proxy# x
p -> String -> GenericFoldMapM tag
f (Proxy# x -> String
forall (n :: Symbol). KnownSymbol n => Proxy# n -> String
symbolVal' Proxy# x
Proxy# x
p)) (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
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