module TheatreDev.Wait where

import TheatreDev.Prelude

type Wait = STM (Maybe SomeException)

both :: Wait -> Wait -> Wait
both :: Wait -> Wait -> Wait
both Wait
left Wait
right =
  forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) Wait
left Wait
right

all :: [Wait] -> Wait
all :: [Wait] -> Wait
all [Wait]
waits =
  forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Wait]
waits