general-allocate: Exception-safe resource management in more monads

[ apache, control, exceptions, library ] [ Propose Tags ]

Write monad-generic resource-safe code that can be instantiated in both IO and pure contexts.

exceptions provides MonadMask, which generalizes the bracket pattern but only for monads that can catch exceptions (i.e., transformer stacks on top of IO or Either SomeException). resourcet provides MonadResource, which allows for arbitrarily interleaved allocations and releases of resources, but only for MonadUnliftIO. This module provides type-classes for both types of resource allocation which can be properly instantiated at more monads, through the expedient of weakening a requirement which doesn't matter in the cases where it's not met: In monads that can't catch exceptions, release actions will not be called in the case of an exception (asynchronous or otherwise), but in those same monads the entire monadic computation will be terminated by the same exception and so resource management has ended anyway.

See Control.Monad.With for scoped (bracket-style) resource management.

See Control.Monad.Allocate for arbitrary lifetime resource management.

See Data.GeneralAllocate to define values that can be used for allocation in either resource management style.

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.0.1, 0.2.1.0, 0.2.1.1, 0.2.1.2, 0.2.1.3, 0.2.1.4, 0.2.2.0, 0.2.3.0, 0.2.3.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <4.15 || >=4.16 && <4.20), containers (>=0.6 && <0.8), exceptions (>=0.10 && <0.11), mtl (>=2.2 && <2.4), primitive (>=0.7 && <0.10), resourcet (>=1.3 && <1.4), safe-exceptions (>=0.1 && <0.2), transformers (>=0.5 && <0.7) [details]
License Apache-2.0
Copyright Coypright 2022 Shea Levy.
Author Shea Levy
Maintainer shea@shealevy.com
Category Control, Exceptions
Bug tracker https://github.com/shlevy/general-allocate/issues
Source repo head: git clone https://github.com/shlevy/general-allocate
Uploaded by shlevy at 2024-01-13T03:35:06Z
Distributions NixOS:0.2.3.1
Reverse Dependencies 3 direct, 4 indirect [details]
Downloads 467 total (45 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-01-13 [all 1 reports]