{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE Safe #-}
module Data.Semigroup.Traversable
( Traversable1(..)
, traverse1Maybe
, gtraverse1
, gsequence1
, foldMap1Default
) where
import Control.Applicative
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
#endif
import Data.Semigroup.Traversable.Class
import Data.Functor.Bind.Class
import GHC.Generics
foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m
foldMap1Default :: forall (f :: * -> *) m a.
(Traversable1 f, Semigroup m) =>
(a -> m) -> f a -> m
foldMap1Default a -> m
f = Const m (f Any) -> m
forall {k} a (b :: k). Const a b -> a
getConst (Const m (f Any) -> m) -> (f a -> Const m (f Any)) -> f a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Const m Any) -> f a -> Const m (f Any)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b. Apply f => (a -> f b) -> f a -> f (f b)
traverse1 (m -> Const m Any
forall {k} a (b :: k). a -> Const a b
Const (m -> Const m Any) -> (a -> m) -> a -> Const m Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m
f)
gtraverse1 ::
(Traversable1 (Rep1 t), Apply f, Generic1 t) =>
(a -> f b) ->
t a ->
f (t b)
gtraverse1 :: forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 (Rep1 t), Apply f, Generic1 t) =>
(a -> f b) -> t a -> f (t b)
gtraverse1 a -> f b
f t a
x = Rep1 t b -> t b
forall a. Rep1 t a -> t a
forall k (f :: k -> *) (a :: k). Generic1 f => Rep1 f a -> f a
to1 (Rep1 t b -> t b) -> f (Rep1 t b) -> f (t b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Rep1 t a -> f (Rep1 t b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> Rep1 t a -> f (Rep1 t b)
traverse1 a -> f b
f (t a -> Rep1 t a
forall a. t a -> Rep1 t a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1 t a
x)
gsequence1 ::
(Traversable1 (Rep1 t), Apply f, Generic1 t) =>
t (f b) ->
f (t b)
gsequence1 :: forall (t :: * -> *) (f :: * -> *) b.
(Traversable1 (Rep1 t), Apply f, Generic1 t) =>
t (f b) -> f (t b)
gsequence1 = (Rep1 t b -> t b) -> f (Rep1 t b) -> f (t b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Rep1 t b -> t b
forall a. Rep1 t a -> t a
forall k (f :: k -> *) (a :: k). Generic1 f => Rep1 f a -> f a
to1 (f (Rep1 t b) -> f (t b))
-> (t (f b) -> f (Rep1 t b)) -> t (f b) -> f (t b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep1 t (f b) -> f (Rep1 t b)
forall (t :: * -> *) (f :: * -> *) b.
(Traversable1 t, Apply f) =>
t (f b) -> f (t b)
forall (f :: * -> *) b. Apply f => Rep1 t (f b) -> f (Rep1 t b)
sequence1 (Rep1 t (f b) -> f (Rep1 t b))
-> (t (f b) -> Rep1 t (f b)) -> t (f b) -> f (Rep1 t b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t (f b) -> Rep1 t (f b)
forall a. t a -> Rep1 t a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1