Module

Resource.Unsafe

Implementation of the bracket/handler/resource pattern

This module provides the underlying implementation of the pattern. It is possible to leak resources if you know some tricks about how to do it. Use these values with caution.

#Resource

newtype Resource a

The abstraction over safe resource management.

Any values embeded in this data type will be safely acquired before use, and released after they're done being used. Will also release the resources in the face of exceptions.

Constructors

Instances

#new

new :: forall a. Aff a -> (a -> Aff Unit) -> Resource a

A fairly safe way to construct a Resource _.

This function can be easier to use sometimes than the continuation-based approach.

Relies on the underlying Aff _ behavior of bracketing for safety.

#new'

new' :: forall a. (forall b. (a -> Aff b) -> Aff b) -> Resource a

An alternative way to construct a Resource _.

This is a synonym for the Resource constructor.

#run

run :: Resource ~> Aff

Runs the Resource _.

This can potentially leak the resource as it's unrestricted what the final value is and could be the resource itself.

#with

with :: forall a b. Resource a -> (a -> Aff b) -> Aff b

Runs the Resource _ while passing the acquired resource to a callback.

This is an abstraction of the [handler][] pattern.

This can potentially leak the resource as it's unrestricted what the final value is and could be the resource itself.

Modules