| Copyright | Copyright 2022 Shea Levy. |
|---|---|
| License | Apache-2.0 |
| Maintainer | shea@shealevy.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Monad.NoContinuation.Resource
Description
This module defines a MonadTransformer, NoContinuationResourceT, which allows for
running MonadAllocate code in pure PrimMonads. This allows
for writing monad-generic resource-safe code and freely switching between
tResourceT on top of IO and the pure NoContinuationResourceT
on top of ST.
Synopsis
- data NoContinuationResourceT m a
- runNoContinuationResourceT :: (PrimMonad m, MonadWith m) => NoContinuationResourceT m a -> m a
- data StupidlyManyResources = StupidlyManyResources
Documentation
data NoContinuationResourceT m a Source #
A MonadTransformer 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.
Instances
runNoContinuationResourceT :: (PrimMonad m, MonadWith m) => NoContinuationResourceT m a -> m a Source #
Run a NoContinuationResourceT computation, freeing all resources before continuing.
data StupidlyManyResources Source #
Caller tried to allocate more than maxBound :: Int resources in a single NoContinuationResourceT scope.
Constructors
| StupidlyManyResources |
Instances
| Exception StupidlyManyResources Source # | |
| Show StupidlyManyResources Source # | |
Defined in Control.Monad.NoContinuation.Resource.Internal Methods showsPrec :: Int -> StupidlyManyResources -> ShowS # show :: StupidlyManyResources -> String # showList :: [StupidlyManyResources] -> ShowS # | |