module Polysemy.Conc.Race where
import Polysemy.Time (TimeUnit)
import qualified Polysemy.Conc.Effect.Race as Race
import Polysemy.Conc.Effect.Race (Race)
race_ ::
Member Race r =>
Sem r a ->
Sem r a ->
Sem r a
race_ :: forall (r :: [(* -> *) -> * -> *]) a.
Member Race r =>
Sem r a -> Sem r a -> Sem r a
race_ Sem r a
ml Sem r a
mr =
Either a a -> a
forall a. Either a a -> a
unify (Either a a -> a) -> Sem r (Either a a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sem r a -> Sem r a -> Sem r (Either a a)
forall a b (r :: [(* -> *) -> * -> *]).
Member Race r =>
Sem r a -> Sem r b -> Sem r (Either a b)
Race.race Sem r a
ml Sem r a
mr
{-# inline race_ #-}
timeout_ ::
TimeUnit u =>
Member Race r =>
Sem r a ->
u ->
Sem r a ->
Sem r a
timeout_ :: forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
Sem r a -> u -> Sem r a -> Sem r a
timeout_ Sem r a
err u
interval Sem r a
ma =
Either a a -> a
forall a. Either a a -> a
unify (Either a a -> a) -> Sem r (Either a a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sem r a -> u -> Sem r a -> Sem r (Either a a)
forall a b u (r :: [(* -> *) -> * -> *]).
(TimeUnit u, Member Race r) =>
Sem r a -> u -> Sem r b -> Sem r (Either a b)
Race.timeout Sem r a
err u
interval Sem r a
ma
{-# inline timeout_ #-}
timeoutAs ::
TimeUnit u =>
Member Race r =>
a ->
u ->
Sem r b ->
Sem r (Either a b)
timeoutAs :: forall u (r :: [(* -> *) -> * -> *]) a b.
(TimeUnit u, Member Race r) =>
a -> u -> Sem r b -> Sem r (Either a b)
timeoutAs a
err =
Sem r a -> u -> Sem r b -> Sem r (Either a b)
forall a b u (r :: [(* -> *) -> * -> *]).
(TimeUnit u, Member Race r) =>
Sem r a -> u -> Sem r b -> Sem r (Either a b)
Race.timeout (a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
err)
{-# inline timeoutAs #-}
timeoutAs_ ::
TimeUnit u =>
Member Race r =>
a ->
u ->
Sem r a ->
Sem r a
timeoutAs_ :: forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
a -> u -> Sem r a -> Sem r a
timeoutAs_ a
err =
Sem r a -> u -> Sem r a -> Sem r a
forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
Sem r a -> u -> Sem r a -> Sem r a
timeout_ (a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
err)
{-# inline timeoutAs_ #-}
timeoutU ::
TimeUnit u =>
Member Race r =>
u ->
Sem r () ->
Sem r ()
timeoutU :: forall u (r :: [(* -> *) -> * -> *]).
(TimeUnit u, Member Race r) =>
u -> Sem r () -> Sem r ()
timeoutU =
Sem r () -> u -> Sem r () -> Sem r ()
forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
Sem r a -> u -> Sem r a -> Sem r a
timeout_ Sem r ()
forall (f :: * -> *). Applicative f => f ()
unit
{-# inline timeoutU #-}
timeoutMaybe ::
TimeUnit u =>
Member Race r =>
u ->
Sem r a ->
Sem r (Maybe a)
timeoutMaybe :: forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
u -> Sem r a -> Sem r (Maybe a)
timeoutMaybe u
u Sem r a
ma =
Maybe a -> u -> Sem r (Maybe a) -> Sem r (Maybe a)
forall u (r :: [(* -> *) -> * -> *]) a.
(TimeUnit u, Member Race r) =>
a -> u -> Sem r a -> Sem r a
timeoutAs_ Maybe a
forall a. Maybe a
Nothing u
u (a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> Sem r a -> Sem r (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sem r a
ma)
{-# inline timeoutMaybe #-}