cabal-version: 3.0
name: general-allocate
version: 0.2.0.0
license: Apache-2.0
license-file: LICENSE
author: Shea Levy
maintainer: shea@shealevy.com
copyright: Coypright 2022 Shea Levy.
category: Control, Exceptions
extra-source-files: CHANGELOG.md
tested-with: GHC == { 9.2.4 }
synopsis: Exception-safe resource management in more monads
description:
Write monad-generic resource-safe code that can be instantiated in both
IO and pure contexts.
[exceptions](https://hackage.haskell.org/package/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](https://hackage.haskell.org/package/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.
bug-reports: https://github.com/shlevy/general-allocate/issues
source-repository head
type: git
location: https://github.com/shlevy/general-allocate
library
exposed-modules:
Control.Monad.Allocate
Control.Monad.NoContinuation.Resource
Control.Monad.NoContinuation.Resource.Internal
Control.Monad.With
Data.GeneralAllocate
Data.Exceptable
build-depends:
, base ^>= { 4.14, 4.16, 4.17 }
, containers ^>= { 0.6 }
, mtl ^>= { 2.2, 2.3 }
, primitive ^>= { 0.7 }
, resourcet ^>= { 1.3 }
, safe-exceptions ^>= { 0.1 }
, transformers ^>= { 0.5, 0.6 }
-- At transformers >= 0.6, remove the Monad (t m) constraint on MonadAllocate AllocateViaLift
hs-source-dirs: src
default-language: Haskell2010