Module
Control.Monad.Fork.Class
- Package
- purescript-fork
- Repository
- slamdata/purescript-fork
#MonadFork Source
class (Monad m, Functor f) <= MonadFork f m | m -> f where
Represents Monads which can be forked asynchronously.
Laws:
-- Unjoined suspension is a no-op
suspend a1 *> suspend a2 = suspend a2
-- Suspend/join is identity
suspend >=> join = id
-- Fork/join is identity
fork >=> join = id
-- Join is idempotent
join t *> join t = join t
Members
Instances
#MonadKill Source
class (MonadFork f m, MonadThrow e m) <= MonadKill e f m | m -> e f where
Represents Monads which can be killed after being forked.
Laws:
-- Killed suspension is an exception
suspend a >>= \f -> kill e f *> join f = throwError e
-- Suspend/kill is unit
suspend a >>= kill e = pure unit
Members
Instances
#MonadBracket Source
class (MonadKill e f m, MonadError e m) <= MonadBracket e f m | m -> e f where
Represents Monads which support cleanup in the presence of async exceptions.
Laws:
bracket a k \_ -> pure r
= uninterruptible (a >>= k (Completed r))
-- Release failed
bracket a k \_ -> throwError e
= uninterruptible (a >>= k (Failed e) *> throwError e)
-- Release killed
fork (bracket a k \_ -> never) >>= \f -> kill e f *> void (try (join f))
= uninterruptible (a >>= k (Killed e))
Members
bracket :: forall a r. m r -> (BracketCondition e a -> r -> m Unit) -> (r -> m a) -> m a
uninterruptible :: forall a. m a -> m a
never :: forall a. m a
Instances
MonadBracket Error Fiber Aff
(MonadBracket e f m) => MonadBracket e f (ReaderT r m)
- Modules
- Control.
Monad. Fork. Class