Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- acquire :: Acquire a -> IO a
- acquireAndUse :: Acquire env -> Use env err res -> IO (Either err res)
- useAcquired :: env -> Use env err res -> IO (Either err res)
- newtype Acquire env = Acquire (IO (env, IO ()))
- startAndStop :: IO a -> (a -> IO ()) -> Acquire a
- newtype Use env err res = Use (ReaderT env (ExceptT err IO) res)
- mapEnv :: (b -> a) -> Use a err res -> Use b err res
- mapErr :: (a -> b) -> Use env a res -> Use env b res
- mapEnvAndErr :: (envB -> envA) -> (errA -> errB) -> Use envA errA res -> Use envB errB res
IO
acquireAndUse :: Acquire env -> Use env err res -> IO (Either err res) Source #
Execute an action, which uses a resource, having a resource provider.
useAcquired :: env -> Use env err res -> IO (Either err res) Source #
Run use on an acquired environment.
Acquire
Resource provider. Abstracts over resource acquisition and releasing.
Composes well, allowing you to merge multiple providers into one.
Implementation of http://www.haskellforall.com/2013/06/the-resource-applicative.html
Construct Acquire
by specifying a resource initializer and finalizer actions.
Use
newtype Use env err res Source #
Resource handler, which has a notion of pure errors.
Instances
MonadError err (Use env err) Source # | |
Defined in Acquire throwError :: err -> Use env err a # catchError :: Use env err a -> (err -> Use env err a) -> Use env err a # | |
MonadReader env (Use env err) Source # | |
Bifunctor (Use env) Source # | |
MonadIO (Use env err) Source # | |
Monoid err => Alternative (Use env err) Source # | |
Applicative (Use env err) Source # | |
Defined in Acquire | |
Functor (Use env err) Source # | |
Monad (Use env err) Source # | |
Monoid err => MonadPlus (Use env err) Source # | |
mapEnv :: (b -> a) -> Use a err res -> Use b err res Source #
Map the environment of a resource handler.
mapEnvAndErr :: (envB -> envA) -> (errA -> errB) -> Use envA errA res -> Use envB errB res Source #
Map both the environment and the error of a resource handler.