{-# LANGUAGE
AllowAmbiguousTypes,
ConstraintKinds,
EmptyCase,
FlexibleContexts,
FlexibleInstances,
MultiParamTypeClasses,
QuantifiedConstraints,
RankNTypes,
ScopedTypeVariables,
TypeApplications,
TypeOperators,
UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-}
module Generic.Functor.Internal where
import ApNormalize
import Control.Applicative (liftA2)
import Data.Bifoldable (Bifoldable(..))
import Data.Bifunctor (Bifunctor(..))
import Data.Coerce (coerce, Coercible)
import Data.Functor.Identity (Identity(..))
import Data.Functor.Const (Const(..))
import Data.Monoid (Endo(..))
import GHC.Generics hiding (S)
import Generic.Functor.Internal.Implicit
gfmap :: forall f a b. GFunctor f => (a -> b) -> (f a -> f b)
gfmap :: (a -> b) -> f a -> f b
gfmap a -> b
f = (GFunctorRep a b f => f a -> f b)
-> GFunctorRep a b f => f a -> f b
forall (c :: Constraint) r. (c => r) -> c => r
with @(GFunctorRep a b f) (Rep (f b) () -> f b
forall a x. Generic a => Rep a x -> a
to (Rep (f b) () -> f b) -> (f a -> Rep (f b) ()) -> f a -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent (a -> b) -> Rep (f a) () -> Rep (f b) ()
forall arr (f :: * -> *) (g :: * -> *).
GMap1 arr f g =>
arr -> f () -> g ()
gmapRep ((a -> b) -> Default Incoherent (a -> b)
forall arr. arr -> Default Incoherent arr
defaultIncoherent a -> b
f) (Rep (f a) () -> Rep (f b) ())
-> (f a -> Rep (f a) ()) -> f a -> Rep (f b) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> Rep (f a) ()
forall a x. Generic a => a -> Rep a x
from)
gsolomap :: forall a b x y. (Generic x, Generic y, GSolomap a b x y) => (a -> b) -> (x -> y)
gsolomap :: (a -> b) -> x -> y
gsolomap a -> b
f = Rep y () -> y
forall a x. Generic a => Rep a x -> a
to (Rep y () -> y) -> (x -> Rep y ()) -> x -> y
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent (a -> b) -> Rep x () -> Rep y ()
forall arr (f :: * -> *) (g :: * -> *).
GMap1 arr f g =>
arr -> f () -> g ()
gmapRep ((a -> b) -> Default Incoherent (a -> b)
forall arr. arr -> Default Incoherent arr
defaultIncoherent a -> b
f) (Rep x () -> Rep y ()) -> (x -> Rep x ()) -> x -> Rep y ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. x -> Rep x ()
forall a x. Generic a => a -> Rep a x
from
solomap :: forall a b x y. Solomap a b x y => (a -> b) -> (x -> y)
solomap :: (a -> b) -> x -> y
solomap a -> b
f = (a -> b) -> x -> y
forall arr x y. Multimap arr x y => arr -> x -> y
multimap a -> b
f
gmultimap :: forall arr x y. (Generic x, Generic y, GMultimap arr x y) => arr -> (x -> y)
gmultimap :: arr -> x -> y
gmultimap arr
f = Rep y () -> y
forall a x. Generic a => Rep a x -> a
to (Rep y () -> y) -> (x -> Rep y ()) -> x -> y
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent arr -> Rep x () -> Rep y ()
forall arr (f :: * -> *) (g :: * -> *).
GMap1 arr f g =>
arr -> f () -> g ()
gmapRep (arr -> Default Incoherent arr
forall arr. arr -> Default Incoherent arr
defaultIncoherent arr
f) (Rep x () -> Rep y ()) -> (x -> Rep x ()) -> x -> Rep y ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. x -> Rep x ()
forall a x. Generic a => a -> Rep a x
from
multimap :: forall arr x y. Multimap arr x y => arr -> (x -> y)
multimap :: arr -> x -> y
multimap arr
f = Default Incoherent arr -> x -> y
forall arr x y. MultimapI arr x y => arr -> x -> y
multimapI (arr -> Default Incoherent arr
forall arr. arr -> Default Incoherent arr
defaultIncoherent arr
f)
gbimap :: forall f a b c d. GBimap f => (a -> b) -> (c -> d) -> f a c -> f b d
gbimap :: (a -> b) -> (c -> d) -> f a c -> f b d
gbimap a -> b
f c -> d
g = (GBimapRep a b c d f => f a c -> f b d)
-> GBimapRep a b c d f => f a c -> f b d
forall (c :: Constraint) r. (c => r) -> c => r
with @(GBimapRep a b c d f) (Rep (f b d) () -> f b d
forall a x. Generic a => Rep a x -> a
to (Rep (f b d) () -> f b d)
-> (f a c -> Rep (f b d) ()) -> f a c -> f b d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent ((a -> b) :+ (c -> d))
-> Rep (f a c) () -> Rep (f b d) ()
forall arr (f :: * -> *) (g :: * -> *).
GMap1 arr f g =>
arr -> f () -> g ()
gmapRep (((a -> b) :+ (c -> d)) -> Default Incoherent ((a -> b) :+ (c -> d))
forall arr. arr -> Default Incoherent arr
defaultIncoherent (a -> b
f (a -> b) -> (c -> d) -> (a -> b) :+ (c -> d)
forall a b. a -> b -> a :+ b
:+ c -> d
g)) (Rep (f a c) () -> Rep (f b d) ())
-> (f a c -> Rep (f a c) ()) -> f a c -> Rep (f b d) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a c -> Rep (f a c) ()
forall a x. Generic a => a -> Rep a x
from)
gfirst :: forall f a b c. GFirst f => (a -> b) -> f a c -> f b c
gfirst :: (a -> b) -> f a c -> f b c
gfirst a -> b
f = (GFirstRep a b c f => f a c -> f b c)
-> GFirstRep a b c f => f a c -> f b c
forall (c :: Constraint) r. (c => r) -> c => r
with @(GFirstRep a b c f) (Rep (f b c) () -> f b c
forall a x. Generic a => Rep a x -> a
to (Rep (f b c) () -> f b c)
-> (f a c -> Rep (f b c) ()) -> f a c -> f b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent (a -> b) -> Rep (f a c) () -> Rep (f b c) ()
forall arr (f :: * -> *) (g :: * -> *).
GMap1 arr f g =>
arr -> f () -> g ()
gmapRep ((a -> b) -> Default Incoherent (a -> b)
forall arr. arr -> Default Incoherent arr
defaultIncoherent a -> b
f) (Rep (f a c) () -> Rep (f b c) ())
-> (f a c -> Rep (f a c) ()) -> f a c -> Rep (f b c) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a c -> Rep (f a c) ()
forall a x. Generic a => a -> Rep a x
from)
gsecond :: forall f a c d. GSecond f => (c -> d) -> f a c -> f a d
gsecond :: (c -> d) -> f a c -> f a d
gsecond = (c -> d) -> f a c -> f a d
forall (f :: * -> *) a b. GFunctor f => (a -> b) -> f a -> f b
gfmap
gfoldMap :: forall t m a. (GFoldMap m t, Monoid m) => (a -> m) -> t a -> m
gfoldMap :: (a -> m) -> t a -> m
gfoldMap a -> m
f =
(GFoldMapRep a a m t => t a -> m)
-> GFoldMapRep a a m t => t a -> m
forall (c :: Constraint) r. (c => r) -> c => r
with @(GFoldMapRep a a m t) (Default Incoherent (Fold m a a) -> Rep (t a) () -> m
forall m arr (f :: * -> *).
(GFoldMap1 m arr f f, Monoid m) =>
arr -> f () -> m
gfoldMapRep (Fold m a a -> Default Incoherent (Fold m a a)
forall arr. arr -> Default Incoherent arr
defaultIncoherent ((a -> m) -> Fold m a a
forall m x y. (x -> m) -> Fold m x y
Fold @m @a @a a -> m
f)) (Rep (t a) () -> m) -> (t a -> Rep (t a) ()) -> t a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t a -> Rep (t a) ()
forall a x. Generic a => a -> Rep a x
from)
gbifoldMap :: forall t m a b. (GBifoldMap m t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m
gbifoldMap :: (a -> m) -> (b -> m) -> t a b -> m
gbifoldMap a -> m
f b -> m
g =
(GBifoldMapRep a a b b m t => t a b -> m)
-> GBifoldMapRep a a b b m t => t a b -> m
forall (c :: Constraint) r. (c => r) -> c => r
with @(GBifoldMapRep a a b b m t) (Default Incoherent (Fold m a a :+ Fold m b b)
-> Rep (t a b) () -> m
forall m arr (f :: * -> *).
(GFoldMap1 m arr f f, Monoid m) =>
arr -> f () -> m
gfoldMapRep ((Fold m a a :+ Fold m b b)
-> Default Incoherent (Fold m a a :+ Fold m b b)
forall arr. arr -> Default Incoherent arr
defaultIncoherent ((a -> m) -> Fold m a a
forall m x y. (x -> m) -> Fold m x y
Fold @m @a @a a -> m
f Fold m a a -> Fold m b b -> Fold m a a :+ Fold m b b
forall a b. a -> b -> a :+ b
:+ (b -> m) -> Fold m b b
forall m x y. (x -> m) -> Fold m x y
Fold @m @b @b b -> m
g)) (Rep (t a b) () -> m) -> (t a b -> Rep (t a b) ()) -> t a b -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t a b -> Rep (t a b) ()
forall a x. Generic a => a -> Rep a x
from)
gtraverse :: forall t f a b. (GTraverse f t, Applicative f) => (a -> f b) -> t a -> f (t b)
gtraverse :: (a -> f b) -> t a -> f (t b)
gtraverse a -> f b
f = (GTraverseRep a b f t => t a -> f (t b))
-> GTraverseRep a b f t => t a -> f (t b)
forall (c :: Constraint) r. (c => r) -> c => r
with @(GTraverseRep a b f t) (Aps f (t b) -> f (t b)
forall (f :: * -> *) a. Applicative f => Aps f a -> f a
lowerAps (Aps f (t b) -> f (t b)) -> (t a -> Aps f (t b)) -> t a -> f (t b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Rep (t b) () -> t b) -> Aps f (Rep (t b) ()) -> Aps f (t b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (t b) () -> t b
forall a x. Generic a => Rep a x -> a
to (Aps f (Rep (t b) ()) -> Aps f (t b))
-> (t a -> Aps f (Rep (t b) ())) -> t a -> Aps f (t b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent (a -> f b)
-> Rep (t a) () -> Aps f (Rep (t b) ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GTraverse1 m arr f g =>
arr -> f () -> Aps m (g ())
gtraverseRep ((a -> f b) -> Default Incoherent (a -> f b)
forall arr. arr -> Default Incoherent arr
defaultIncoherent a -> f b
f) (Rep (t a) () -> Aps f (Rep (t b) ()))
-> (t a -> Rep (t a) ()) -> t a -> Aps f (Rep (t b) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t a -> Rep (t a) ()
forall a x. Generic a => a -> Rep a x
from)
gbitraverse :: forall t f a b c d. (GBitraverse f t, Applicative f) => (a -> f b) -> (c -> f d) -> t a c -> f (t b d)
gbitraverse :: (a -> f b) -> (c -> f d) -> t a c -> f (t b d)
gbitraverse a -> f b
f c -> f d
g =
(GBitraverseRep a b c d f t => t a c -> f (t b d))
-> GBitraverseRep a b c d f t => t a c -> f (t b d)
forall (c :: Constraint) r. (c => r) -> c => r
with @(GBitraverseRep a b c d f t) (Aps f (t b d) -> f (t b d)
forall (f :: * -> *) a. Applicative f => Aps f a -> f a
lowerAps (Aps f (t b d) -> f (t b d))
-> (t a c -> Aps f (t b d)) -> t a c -> f (t b d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Rep (t b d) () -> t b d)
-> Aps f (Rep (t b d) ()) -> Aps f (t b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep (t b d) () -> t b d
forall a x. Generic a => Rep a x -> a
to (Aps f (Rep (t b d) ()) -> Aps f (t b d))
-> (t a c -> Aps f (Rep (t b d) ())) -> t a c -> Aps f (t b d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Default Incoherent ((a -> f b) :+ (c -> f d))
-> Rep (t a c) () -> Aps f (Rep (t b d) ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GTraverse1 m arr f g =>
arr -> f () -> Aps m (g ())
gtraverseRep (((a -> f b) :+ (c -> f d))
-> Default Incoherent ((a -> f b) :+ (c -> f d))
forall arr. arr -> Default Incoherent arr
defaultIncoherent (a -> f b
f (a -> f b) -> (c -> f d) -> (a -> f b) :+ (c -> f d)
forall a b. a -> b -> a :+ b
:+ c -> f d
g)) (Rep (t a c) () -> Aps f (Rep (t b d) ()))
-> (t a c -> Rep (t a c) ()) -> t a c -> Aps f (Rep (t b d) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t a c -> Rep (t a c) ()
forall a x. Generic a => a -> Rep a x
from)
with :: forall c r. (c => r) -> (c => r)
with :: (c => r) -> c => r
with c => r
x = r
c => r
x
class (forall a. Generic (f a), forall a b. GFunctorRep a b f) => GFunctor f
instance (forall a. Generic (f a), forall a b. GFunctorRep a b f) => GFunctor f
class GMap1 (Default Incoherent (a -> b)) (Rep (f a)) (Rep (f b)) => GFunctorRep a b f
instance GMap1 (Default Incoherent (a -> b)) (Rep (f a)) (Rep (f b)) => GFunctorRep a b f
class (forall a c. Generic (f a c), forall a b c d. GBimapRep a b c d f) => GBimap f
instance (forall a c. Generic (f a c), forall a b c d. GBimapRep a b c d f) => GBimap f
class GMap1 (Default Incoherent ((a -> b) :+ (c -> d))) (Rep (f a c)) (Rep (f b d)) => GBimapRep a b c d f
instance GMap1 (Default Incoherent ((a -> b) :+ (c -> d))) (Rep (f a c)) (Rep (f b d)) => GBimapRep a b c d f
class (forall a c. Generic (f a c), forall a b c. GFirstRep a b c f) => GFirst f
instance (forall a c. Generic (f a c), forall a b c. GFirstRep a b c f) => GFirst f
class GMap1 (Default Incoherent (a -> b)) (Rep (f a c)) (Rep (f b c)) => GFirstRep a b c f
instance GMap1 (Default Incoherent (a -> b)) (Rep (f a c)) (Rep (f b c)) => GFirstRep a b c f
class (forall a c. Generic (f a c), forall a c d. GFunctorRep c d (f a)) => GSecond f
instance (forall a c. Generic (f a c), forall a c d. GFunctorRep c d (f a)) => GSecond f
class (GBimap f, GFirst f, GSecond f) => GBifunctor f
instance (GBimap f, GFirst f, GSecond f) => GBifunctor f
class (forall a. Generic (t a), forall a b. GTraverseRep a b f t) => GTraverse f t
instance (forall a. Generic (t a), forall a b. GTraverseRep a b f t) => GTraverse f t
class GTraverse1 f (Default Incoherent (a -> f b)) (Rep (t a)) (Rep (t b)) => GTraverseRep a b f t
instance GTraverse1 f (Default Incoherent (a -> f b)) (Rep (t a)) (Rep (t b)) => GTraverseRep a b f t
class (forall f. Applicative f => GBitraverse f t) => GTraversable t
instance (forall f. Applicative f => GBitraverse f t) => GTraversable t
class (forall a b. Generic (t a b), forall a b c d. GBitraverseRep a b c d f t) => GBitraverse f t
instance (forall a b. Generic (t a b), forall a b c d. GBitraverseRep a b c d f t) => GBitraverse f t
class GTraverse1 f (Default Incoherent ((a -> f b) :+ (c -> f d))) (Rep (t a c)) (Rep (t b d)) => GBitraverseRep a b c d f t
instance GTraverse1 f (Default Incoherent ((a -> f b) :+ (c -> f d))) (Rep (t a c)) (Rep (t b d)) => GBitraverseRep a b c d f t
class (forall f. Applicative f => GBitraverse f t) => GBitraversable t
instance (forall f. Applicative f => GBitraverse f t) => GBitraversable t
class (forall a. Generic (t a), forall a b. GFoldMapRep a b m t) => GFoldMap m t
instance (forall a. Generic (t a), forall a b. GFoldMapRep a b m t) => GFoldMap m t
class GFoldMap1 m (Default Incoherent (Fold m a b)) (Rep (t a)) (Rep (t b)) => GFoldMapRep a b m t
instance GFoldMap1 m (Default Incoherent (Fold m a b)) (Rep (t a)) (Rep (t b)) => GFoldMapRep a b m t
class (forall m. Monoid m => GFoldMap m t) => GFoldable t
instance (forall m. Monoid m => GFoldMap m t) => GFoldable t
class (forall a b. Generic (t a b), forall a b c d. GBifoldMapRep a b c d m t) => GBifoldMap m t
instance (forall a b. Generic (t a b), forall a b c d. GBifoldMapRep a b c d m t) => GBifoldMap m t
class GFoldMap1 m (Default Incoherent (Fold m a b :+ Fold m c d)) (Rep (t a c)) (Rep (t b d)) => GBifoldMapRep a b c d m t
instance GFoldMap1 m (Default Incoherent (Fold m a b :+ Fold m c d)) (Rep (t a c)) (Rep (t b d)) => GBifoldMapRep a b c d m t
class (forall m. Monoid m => GBifoldMap m t) => GBifoldable t
instance (forall m. Monoid m => GBifoldMap m t) => GBifoldable t
class GMultimap (a -> b) x y => GSolomap a b x y
instance GMultimap (a -> b) x y => GSolomap a b x y
class Multimap (a -> b) x y => Solomap a b x y
instance Multimap (a -> b) x y => Solomap a b x y
class GMap1 (Default Incoherent arr) (Rep x) (Rep y) => GMultimap arr x y
instance GMap1 (Default Incoherent arr) (Rep x) (Rep y) => GMultimap arr x y
class MultimapI (Default Incoherent arr) x y => Multimap arr x y
instance MultimapI (Default Incoherent arr) x y => Multimap arr x y
newtype GenericFunctor f a = GenericFunctor (f a)
instance GFunctor f => Functor (GenericFunctor f) where
fmap :: (a -> b) -> GenericFunctor f a -> GenericFunctor f b
fmap = ((a -> b) -> f a -> f b)
-> (a -> b) -> GenericFunctor f a -> GenericFunctor f b
forall s t r. Coercible s t => (r -> s) -> r -> t
coerce1 (forall a b. GFunctor f => (a -> b) -> f a -> f b
forall (f :: * -> *) a b. GFunctor f => (a -> b) -> f a -> f b
gfmap @f)
instance GFoldable f => Foldable (GenericFunctor f) where
foldMap :: (a -> m) -> GenericFunctor f a -> m
foldMap = ((a -> m) -> f a -> m) -> (a -> m) -> GenericFunctor f a -> m
forall t u am m. Coercible t u => (am -> t -> m) -> am -> u -> m
coerceFoldMap (forall m a. (GFoldMap m f, Monoid m) => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(GFoldMap m t, Monoid m) =>
(a -> m) -> t a -> m
gfoldMap @f)
newtype GenericBifunctor f a b = GenericBifunctor (f a b)
instance GBifunctor f => Bifunctor (GenericBifunctor f) where
bimap :: (a -> b)
-> (c -> d) -> GenericBifunctor f a c -> GenericBifunctor f b d
bimap = ((a -> b) -> (c -> d) -> f a c -> f b d)
-> (a -> b)
-> (c -> d)
-> GenericBifunctor f a c
-> GenericBifunctor f b d
forall t u r s. Coercible t u => (r -> s -> t) -> r -> s -> u
coerce2 (forall a b c d. GBimap f => (a -> b) -> (c -> d) -> f a c -> f b d
forall (f :: * -> * -> *) a b c d.
GBimap f =>
(a -> b) -> (c -> d) -> f a c -> f b d
gbimap @f)
first :: (a -> b) -> GenericBifunctor f a c -> GenericBifunctor f b c
first = ((a -> b) -> f a c -> f b c)
-> (a -> b) -> GenericBifunctor f a c -> GenericBifunctor f b c
forall w v (f :: * -> * -> *) b d (g :: * -> * -> *) r.
(Coercible w v, Coercible (f b d) (g b d)) =>
(r -> w -> f b d) -> r -> v -> g b d
coerce3 (forall a b c. GFirst f => (a -> b) -> f a c -> f b c
forall (f :: * -> * -> *) a b c.
GFirst f =>
(a -> b) -> f a c -> f b c
gfirst @f)
second :: (b -> c) -> GenericBifunctor f a b -> GenericBifunctor f a c
second = ((b -> c) -> f a b -> f a c)
-> (b -> c) -> GenericBifunctor f a b -> GenericBifunctor f a c
forall w v (f :: * -> * -> *) b d (g :: * -> * -> *) r.
(Coercible w v, Coercible (f b d) (g b d)) =>
(r -> w -> f b d) -> r -> v -> g b d
coerce3 (forall a c d. GSecond f => (c -> d) -> f a c -> f a d
forall (f :: * -> * -> *) a c d.
GSecond f =>
(c -> d) -> f a c -> f a d
gsecond @f)
instance GBifoldable f => Bifoldable (GenericBifunctor f) where
bifoldMap :: (a -> m) -> (b -> m) -> GenericBifunctor f a b -> m
bifoldMap = ((a -> m) -> (b -> m) -> f a b -> m)
-> (a -> m) -> (b -> m) -> GenericBifunctor f a b -> m
forall t u am bm m.
Coercible t u =>
(am -> bm -> t -> m) -> am -> bm -> u -> m
coerceBifoldMap (forall m a b.
(GBifoldMap m f, Monoid m) =>
(a -> m) -> (b -> m) -> f a b -> m
forall (t :: * -> * -> *) m a b.
(GBifoldMap m t, Monoid m) =>
(a -> m) -> (b -> m) -> t a b -> m
gbifoldMap @f)
coerce1 :: Coercible s t => (r -> s) -> (r -> t)
coerce1 :: (r -> s) -> r -> t
coerce1 = (r -> s) -> r -> t
coerce
coerce2 :: Coercible t u => (r -> s -> t) -> (r -> s -> u)
coerce2 :: (r -> s -> t) -> r -> s -> u
coerce2 = (r -> s -> t) -> r -> s -> u
coerce
coerce3 :: (Coercible w v, Coercible (f b d) (g b d)) => (r -> w -> f b d) -> (r -> v -> g b d)
coerce3 :: (r -> w -> f b d) -> r -> v -> g b d
coerce3 = (r -> w -> f b d) -> r -> v -> g b d
coerce
coerceFoldMap :: Coercible t u => (am -> t -> m) -> (am -> u -> m)
coerceFoldMap :: (am -> t -> m) -> am -> u -> m
coerceFoldMap = (am -> t -> m) -> am -> u -> m
coerce
coerceBifoldMap :: Coercible t u => (am -> bm -> t -> m) -> (am -> bm -> u -> m)
coerceBifoldMap :: (am -> bm -> t -> m) -> am -> bm -> u -> m
coerceBifoldMap = (am -> bm -> t -> m) -> am -> bm -> u -> m
coerce
class GMultimapK m arr f g where
gmultimapK :: arr -> f () -> m (g ())
instance MultimapI arr x y => GMultimapK Identity arr (K1 i x) (K1 i' y) where
gmultimapK :: arr -> K1 i x () -> Identity (K1 i' y ())
gmultimapK = (arr -> x -> y) -> arr -> K1 i x () -> Identity (K1 i' y ())
coerce (MultimapI arr x y => arr -> x -> y
forall arr x y. MultimapI arr x y => arr -> x -> y
multimapI @arr @x @y)
class GMultimapK Identity arr f g => GMap1 arr f g
instance GMultimapK Identity arr f g => GMap1 arr f g
gmapRep :: GMap1 arr f g => arr -> f () -> g ()
gmapRep :: arr -> f () -> g ()
gmapRep arr
f f ()
x = Identity (g ()) -> g ()
forall a. Identity a -> a
runIdentity (arr -> f () -> Identity (g ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f ()
x)
instance (Multifold_ m arr x y, Monoid m) => GMultimapK (Const (EndoM m)) arr (K1 i x) (K1 i' y) where
gmultimapK :: arr -> K1 i x () -> Const (EndoM m) (K1 i' y ())
gmultimapK arr
f (K1 x
x) = y -> K1 i' y ()
forall k i c (p :: k). c -> K1 i c p
K1 (y -> K1 i' y ())
-> Const (EndoM m) y -> Const (EndoM m) (K1 i' y ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fold m x y -> x -> Const (EndoM m) y
forall m x y. Monoid m => Fold m x y -> x -> Const (EndoM m) y
foldToConst (arr -> Fold m x y
forall m arr x y. Multifold_ m arr x y => arr -> Fold m x y
multifold_ arr
f) x
x
instance {-# INCOHERENT #-} GMultimapK (Const (EndoM m)) arr (K1 i x) (K1 i x) where
gmultimapK :: arr -> K1 i x () -> Const (EndoM m) (K1 i x ())
gmultimapK arr
_ (K1 x
_) = EndoM m -> Const (EndoM m) (K1 i x ())
forall k a (b :: k). a -> Const a b
Const ((Maybe m -> Maybe m) -> EndoM m
forall a. (a -> a) -> Endo a
Endo Maybe m -> Maybe m
forall a. a -> a
id)
type EndoM m = Endo (Maybe m)
unEndoM :: Monoid m => EndoM m -> m
unEndoM :: EndoM m -> m
unEndoM (Endo Maybe m -> Maybe m
f) = case Maybe m -> Maybe m
f Maybe m
forall a. Maybe a
Nothing of
Maybe m
Nothing -> m
forall a. Monoid a => a
mempty
Just m
y -> m
y
liftEndoM :: Monoid m => m -> EndoM m
liftEndoM :: m -> EndoM m
liftEndoM m
y = (Maybe m -> Maybe m) -> EndoM m
forall a. (a -> a) -> Endo a
Endo (m -> Maybe m
forall a. a -> Maybe a
Just (m -> Maybe m) -> (Maybe m -> m) -> Maybe m -> Maybe m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe m -> m
app)
where
app :: Maybe m -> m
app Maybe m
Nothing = m
y
app (Just m
y') = m
y m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` m
y'
foldToConst :: Monoid m => Fold m x y -> x -> Const (EndoM m) y
foldToConst :: Fold m x y -> x -> Const (EndoM m) y
foldToConst (Fold x -> m
f) x
x = EndoM m -> Const (EndoM m) y
forall k a (b :: k). a -> Const a b
Const (m -> EndoM m
forall m. Monoid m => m -> EndoM m
liftEndoM (x -> m
f x
x))
class GMultimapK (Const (EndoM m)) arr f g => GFoldMap1 m arr f g
instance GMultimapK (Const (EndoM m)) arr f g => GFoldMap1 m arr f g
gfoldMapRep :: forall m arr f. (GFoldMap1 m arr f f, Monoid m) => arr -> f () -> m
gfoldMapRep :: arr -> f () -> m
gfoldMapRep arr
f f ()
x = EndoM m -> m
forall m. Monoid m => EndoM m -> m
unEndoM (Const (EndoM m) (f ()) -> EndoM m
forall a k (b :: k). Const a b -> a
getConst (arr -> f () -> Const (EndoM m) (f ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f ()
x :: Const (EndoM m) (f ())))
instance (Multitraverse m arr x y) => GMultimapK (Aps m) arr (K1 i x) (K1 i' y) where
gmultimapK :: arr -> K1 i x () -> Aps m (K1 i' y ())
gmultimapK arr
f (K1 x
x) = y -> K1 i' y ()
forall k i c (p :: k). c -> K1 i c p
K1 (y -> K1 i' y ()) -> m y -> Aps m (K1 i' y ())
forall a b (f :: * -> *). (a -> b) -> f a -> Aps f b
<$>^ arr -> x -> m y
forall (f :: * -> *) arr x y.
Multitraverse f arr x y =>
arr -> x -> f y
multitraverse arr
f x
x
class GMultimapK (Aps m) arr f g => GTraverse1 m arr f g
instance GMultimapK (Aps m) arr f g => GTraverse1 m arr f g
gtraverseRep :: GTraverse1 m arr f g => arr -> f () -> Aps m (g ())
gtraverseRep :: arr -> f () -> Aps m (g ())
gtraverseRep = arr -> f () -> Aps m (g ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK
instance (GMultimapK m arr f g, Functor m) => GMultimapK m arr (M1 i c f) (M1 i' c' g) where
gmultimapK :: arr -> M1 i c f () -> m (M1 i' c' g ())
gmultimapK arr
f (M1 f ()
x) = g () -> M1 i' c' g ()
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (g () -> M1 i' c' g ()) -> m (g ()) -> m (M1 i' c' g ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> arr -> f () -> m (g ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f ()
x
instance
(GMultimapK m arr f1 g1, GMultimapK m arr f2 g2, Applicative m) =>
GMultimapK m arr (f1 :+: f2) (g1 :+: g2)
where
gmultimapK :: arr -> (:+:) f1 f2 () -> m ((:+:) g1 g2 ())
gmultimapK arr
f (L1 f1 ()
x) = g1 () -> (:+:) g1 g2 ()
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 (g1 () -> (:+:) g1 g2 ()) -> m (g1 ()) -> m ((:+:) g1 g2 ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> arr -> f1 () -> m (g1 ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f1 ()
x
gmultimapK arr
f (R1 f2 ()
y) = g2 () -> (:+:) g1 g2 ()
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 (g2 () -> (:+:) g1 g2 ()) -> m (g2 ()) -> m ((:+:) g1 g2 ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> arr -> f2 () -> m (g2 ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f2 ()
y
instance
(GMultimapK m arr f1 g1, GMultimapK m arr f2 g2, Applicative m) =>
GMultimapK m arr (f1 :*: f2) (g1 :*: g2)
where
gmultimapK :: arr -> (:*:) f1 f2 () -> m ((:*:) g1 g2 ())
gmultimapK arr
f (f1 ()
x :*: f2 ()
y) = (g1 () -> g2 () -> (:*:) g1 g2 ())
-> m (g1 ()) -> m (g2 ()) -> m ((:*:) g1 g2 ())
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 g1 () -> g2 () -> (:*:) g1 g2 ()
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (arr -> f1 () -> m (g1 ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f1 ()
x) (arr -> f2 () -> m (g2 ())
forall (m :: * -> *) arr (f :: * -> *) (g :: * -> *).
GMultimapK m arr f g =>
arr -> f () -> m (g ())
gmultimapK arr
f f2 ()
y)
instance Applicative m => GMultimapK m arr U1 U1 where
gmultimapK :: arr -> U1 () -> m (U1 ())
gmultimapK arr
_ U1 ()
U1 = U1 () -> m (U1 ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 ()
forall k (p :: k). U1 p
U1
instance GMultimapK m arr V1 V1 where
gmultimapK :: arr -> V1 () -> m (V1 ())
gmultimapK arr
_ V1 ()
v = case V1 ()
v of