{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Trustworthy #-}
module Grisette.Lib.Data.Traversable
(
mrgTraverse,
mrgSequenceA,
mrgFor,
mrgMapM,
mrgForM,
mrgSequence,
)
where
import Grisette.Core.Control.Monad.Union
import Grisette.Core.Data.Class.Mergeable
import Grisette.Core.Data.Class.SimpleMergeable
mrgTraverse ::
forall a b t f.
( Mergeable b,
Mergeable1 t,
MonadUnion f,
Traversable t
) =>
(a -> f b) ->
t a ->
f (t b)
mrgTraverse :: forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgTraverse a -> f b
f = forall (u :: * -> *) a.
UnionLike u =>
MergingStrategy a -> u a -> u a
mergeWithStrategy forall a (u :: * -> *).
(Mergeable a, Mergeable1 u) =>
MergingStrategy (u a)
rootStrategy1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (u :: * -> *) a. (UnionLike u, Mergeable a) => u a -> u a
merge forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
f)
{-# INLINE mrgTraverse #-}
mrgSequenceA ::
forall a t f.
( Mergeable a,
Mergeable1 t,
MonadUnion f,
Traversable t
) =>
t (f a) ->
f (t a)
mrgSequenceA :: forall a (t :: * -> *) (f :: * -> *).
(Mergeable a, Mergeable1 t, MonadUnion f, Traversable t) =>
t (f a) -> f (t a)
mrgSequenceA = forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgTraverse forall a. a -> a
id
{-# INLINE mrgSequenceA #-}
mrgMapM ::
forall a b t f.
( Mergeable b,
Mergeable1 t,
MonadUnion f,
Traversable t
) =>
(a -> f b) ->
t a ->
f (t b)
mrgMapM :: forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgMapM = forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgTraverse
{-# INLINE mrgMapM #-}
mrgSequence ::
forall a t f.
( Mergeable a,
Mergeable1 t,
MonadUnion f,
Traversable t
) =>
t (f a) ->
f (t a)
mrgSequence :: forall a (t :: * -> *) (f :: * -> *).
(Mergeable a, Mergeable1 t, MonadUnion f, Traversable t) =>
t (f a) -> f (t a)
mrgSequence = forall a (t :: * -> *) (f :: * -> *).
(Mergeable a, Mergeable1 t, MonadUnion f, Traversable t) =>
t (f a) -> f (t a)
mrgSequenceA
{-# INLINE mrgSequence #-}
mrgFor ::
( Mergeable b,
Mergeable1 t,
Traversable t,
MonadUnion m
) =>
t a ->
(a -> m b) ->
m (t b)
mrgFor :: forall b (t :: * -> *) (m :: * -> *) a.
(Mergeable b, Mergeable1 t, Traversable t, MonadUnion m) =>
t a -> (a -> m b) -> m (t b)
mrgFor = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgTraverse
{-# INLINE mrgFor #-}
mrgForM ::
( Mergeable b,
Mergeable1 t,
Traversable t,
MonadUnion m
) =>
t a ->
(a -> m b) ->
m (t b)
mrgForM :: forall b (t :: * -> *) (m :: * -> *) a.
(Mergeable b, Mergeable1 t, Traversable t, MonadUnion m) =>
t a -> (a -> m b) -> m (t b)
mrgForM = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b (t :: * -> *) (f :: * -> *).
(Mergeable b, Mergeable1 t, MonadUnion f, Traversable t) =>
(a -> f b) -> t a -> f (t b)
mrgMapM
{-# INLINE mrgForM #-}