Module

Control.Monad.Resource

Package
purescript-resourcet
Repository
robertdp/purescript-resourcet

#register Source

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 Source

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 Source

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

Remove the release action associated with the key.

#release Source

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

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

#release' Source

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 Source

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

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

#isReleased Source

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 Source

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

#forkAff Source

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

#supervise Source

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

Re-exports from Control.Monad.Resource.Class

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

#ReleaseKey Source

Re-exports from Control.Monad.Resource.Trans

#ResourceT Source

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 Source

type Resource = ResourceT Aff

The Resource monad is a synonym for ResourceT Aff.

#runResourceT Source

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 Source

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

Run an Aff computation in the ResourceT monad.

#mapResourceT Source

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.