Copyright | Copyright 2022 Shea Levy. |
---|---|
License | Apache-2.0 |
Maintainer | shea@shealevy.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This design and implementation is heavily based on ResourceT
from resourcet,
including some code copied verbatim and then generalized appropriately. resourcet
is Copyright (c)2011, Michael Snoyman
, and licensed under the BSD 3-clause license
available at LICENSE.resourcet.
Synopsis
- newtype NoContinuationResourceT m a = NoContinuationResourceT {
- unNoContinuationResourceT :: ReaderT (MutVar (PrimState m) (NoContinuationReleaseMap m)) m a
- data StupidlyManyResources = StupidlyManyResources
- data NoContinuationReleaseMap m = NoContinuationReleaseMap {
- nextKey :: !Key
- releaseActions :: !(IntMap (GeneralReleaseType (WithException m) () -> m ()))
- data NoContinuationReleaseKey m = NoContinuationReleaseKey {}
Documentation
newtype NoContinuationResourceT m a Source #
A MonadTrans
former turning any PrimMonad
that is a MonadWith
into a MonadAllocate
Note that the MonadAllocate
instance is only valid if the underlying monad satisfies the "no continuation"
condition, i.e. that if execution of a computation exits a given lexical scope we are guaranteed that either
all of the actions within that scope have executed or the entire monadic computation has been terminated.
The most common factors violating "no continuation" are call/cc and exception catching. A monad which allows exception throwing but not catching is not thereby disqualified, as any thrown exception will of necessity propagate until it terminates the entire monadic computation.
In conjunction with the PrimMonad
requirement, this essentially means the base of m
must be an ST
and
there must be no ContT
in the stack.
NoContinuationResourceT | |
|
Instances
data StupidlyManyResources Source #
Caller tried to allocate more than maxBound :: Int
resources in a single NoContinuationResourceT
scope.
Instances
data NoContinuationReleaseMap m Source #
Internal state for NoContinuationResourceT
NoContinuationReleaseMap | |
|
data NoContinuationReleaseKey m Source #
Handle to run a release action early in NoContinuationResourceT