Module

Control.Monad.Resource

#register

register :: forall m. MonadResource m => Aff Unit -> m ReleaseKey

Register some release action to run in the cleanup phase, returning the ReleaseKey for the action.

#acquire

acquire :: forall m a. MonadResource m => Aff a -> (a -> Aff Unit) -> m (Tuple ReleaseKey a)

Given logic to acquire and free a resource a, this will: acquire the resource, register the release action, and return the resource and the action's ReleaseKey

#deregister

deregister :: forall m. MonadResource m => ReleaseKey -> m Unit

Remove the release action associated with the key.

#release

release :: forall m. MonadResource m => ReleaseKey -> m Unit

Trigger the release action for the ReleaseKey if it is registered.

#release'

release' :: forall m. MonadResource m => ReleaseKey -> m Boolean

Trigger the release action for the ReleaseKey if it is registered. Returns true if the key was found, false otherwise.

#isRegistered

isRegistered :: forall m. MonadResource m => ReleaseKey -> m Boolean

Returns true if the given ReleaseKey is registered in the current ResourceT, and false otherwise.

#isReleased

isReleased :: forall m. MonadResource m => ReleaseKey -> m Boolean

Returns true if the given ReleaseKey is not registered in the current ResourceT, and true otherwise.

#fork

fork :: forall a m. MonadResource m => Resource a -> m (Fiber a)

#forkAff

forkAff :: forall a m. MonadResource m => Aff a -> m (Fiber a)

#supervise

supervise :: forall a. Resource a -> Resource a

Re-exports from Control.Monad.Resource.Class

Re-exports from Control.Monad.Resource.Internal.Registry

#ReleaseKey

Re-exports from Control.Monad.Resource.Trans

#ResourceT

newtype ResourceT (m :: Type -> Type) a

The resource cleanup monad transformer.

This monad transformer extends the base monad with a mutable registry for tracking resource cleanup actions. At the end of evaluation all remaining cleanup actions are executed.

Instances

#Resource

type Resource = ResourceT Aff

The Resource monad is a synonym for ResourceT Aff.

#runResourceT

runResourceT :: forall m a b. (m a -> Aff b) -> ResourceT m a -> Aff b

Run a computation in the ResourceT monad, while changing it to Aff to ensure the cleanup will run safely.

#runResource

runResource :: forall a. Resource a -> Aff a

Run an Aff computation in the ResourceT monad.

#mapResourceT

mapResourceT :: forall m m' a b. (m a -> m' b) -> ResourceT m a -> ResourceT m' b

Change the type of the result in a ResourceT monad action.

Modules