{-# LANGUAGE StandaloneKindSignatures #-}
module Wire.Sem.Concurrency where
import Data.Kind (Type)
import Imports
import Polysemy
data ConcurrencySafety = Safe | Unsafe
type Concurrency :: ConcurrencySafety -> (Type -> Type) -> Type -> Type
data Concurrency (safe :: ConcurrencySafety) m a where
UnsafePooledMapConcurrentlyN ::
(Foldable t) =>
Int ->
(a -> m b) ->
t a ->
Concurrency safe m [b]
UnsafePooledMapConcurrentlyN_ ::
(Foldable t) =>
Int ->
(a -> m b) ->
t a ->
Concurrency safe m ()
unsafePooledMapConcurrentlyN ::
forall r t a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int ->
(a -> Sem r b) ->
t a ->
Sem r [b]
unsafePooledMapConcurrentlyN :: forall (r :: EffectRow) (t :: * -> *) a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int -> (a -> Sem r b) -> t a -> Sem r [b]
unsafePooledMapConcurrentlyN Int
n a -> Sem r b
f t a
as =
Concurrency 'Unsafe (Sem r) [b] -> Sem r [b]
forall (e :: Effect) (r :: EffectRow) a.
Member e r =>
e (Sem r) a -> Sem r a
send
( Int -> (a -> Sem r b) -> t a -> Concurrency 'Unsafe (Sem r) [b]
forall (t :: * -> *) a (m :: * -> *) b (safe :: ConcurrencySafety).
Foldable t =>
Int -> (a -> m b) -> t a -> Concurrency safe m [b]
UnsafePooledMapConcurrentlyN Int
n a -> Sem r b
f t a
as ::
Concurrency 'Unsafe (Sem r) [b]
)
{-# INLINEABLE unsafePooledMapConcurrentlyN #-}
unsafePooledMapConcurrentlyN_ ::
forall r t a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int ->
(a -> Sem r b) ->
t a ->
Sem r ()
unsafePooledMapConcurrentlyN_ :: forall (r :: EffectRow) (t :: * -> *) a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int -> (a -> Sem r b) -> t a -> Sem r ()
unsafePooledMapConcurrentlyN_ Int
n a -> Sem r b
f t a
as =
Concurrency 'Unsafe (Sem r) () -> Sem r ()
forall (e :: Effect) (r :: EffectRow) a.
Member e r =>
e (Sem r) a -> Sem r a
send
(Int -> (a -> Sem r b) -> t a -> Concurrency 'Unsafe (Sem r) ()
forall (t :: * -> *) a (m :: * -> *) b (safe :: ConcurrencySafety).
Foldable t =>
Int -> (a -> m b) -> t a -> Concurrency safe m ()
UnsafePooledMapConcurrentlyN_ Int
n a -> Sem r b
f t a
as :: Concurrency 'Unsafe (Sem r) ())
{-# INLINEABLE unsafePooledMapConcurrentlyN_ #-}
unsafePooledForConcurrentlyN ::
forall r t a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int ->
t a ->
(a -> Sem r b) ->
Sem r [b]
unsafePooledForConcurrentlyN :: forall (r :: EffectRow) (t :: * -> *) a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int -> t a -> (a -> Sem r b) -> Sem r [b]
unsafePooledForConcurrentlyN Int
n t a
as a -> Sem r b
f =
Concurrency 'Unsafe (Sem r) [b] -> Sem r [b]
forall (e :: Effect) (r :: EffectRow) a.
Member e r =>
e (Sem r) a -> Sem r a
send
(Int -> (a -> Sem r b) -> t a -> Concurrency 'Unsafe (Sem r) [b]
forall (t :: * -> *) a (m :: * -> *) b (safe :: ConcurrencySafety).
Foldable t =>
Int -> (a -> m b) -> t a -> Concurrency safe m [b]
UnsafePooledMapConcurrentlyN Int
n a -> Sem r b
f t a
as :: Concurrency 'Unsafe (Sem r) [b])
{-# INLINEABLE unsafePooledForConcurrentlyN #-}
unsafePooledForConcurrentlyN_ ::
forall r t a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int ->
t a ->
(a -> Sem r b) ->
Sem r ()
unsafePooledForConcurrentlyN_ :: forall (r :: EffectRow) (t :: * -> *) a b.
(Member (Concurrency 'Unsafe) r, Foldable t) =>
Int -> t a -> (a -> Sem r b) -> Sem r ()
unsafePooledForConcurrentlyN_ Int
n t a
as a -> Sem r b
f =
Concurrency 'Unsafe (Sem r) () -> Sem r ()
forall (e :: Effect) (r :: EffectRow) a.
Member e r =>
e (Sem r) a -> Sem r a
send
(Int -> (a -> Sem r b) -> t a -> Concurrency 'Unsafe (Sem r) ()
forall (t :: * -> *) a (m :: * -> *) b (safe :: ConcurrencySafety).
Foldable t =>
Int -> (a -> m b) -> t a -> Concurrency safe m ()
UnsafePooledMapConcurrentlyN_ Int
n a -> Sem r b
f t a
as :: Concurrency 'Unsafe (Sem r) ())
{-# INLINEABLE unsafePooledForConcurrentlyN_ #-}