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

  • suspend :: forall a. m a -> m (f a)
  • fork :: forall a. m a -> m (f a)
  • join :: forall a. f a -> m a

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

#BracketCondition Source

data BracketCondition e a

Constructors

#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

Instances