| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Bluefin.Eff
Synopsis
- data Eff (es :: Effects) a
- runPureEff :: (forall (es :: Effects). Eff es a) -> a
- runEff_ :: (forall (e :: Effects). IOE e -> Eff e a) -> IO a
- runEff :: (forall (e :: Effects) (es :: Effects). IOE e -> Eff (e :& es) a) -> IO a
- bracket :: forall (es :: Effects) a b. Eff es a -> (a -> Eff es ()) -> (a -> Eff es b) -> Eff es b
- withMonadIO :: forall (e :: Effects) (es :: Effects) r. e :> es => IOE e -> (forall (m :: Type -> Type). MonadIO m => m r) -> Eff es r
- withMonadFail :: forall (e :: Effects) (es :: Effects) r. e :> es => Exception String e -> (forall (m :: Type -> Type). MonadFail m => m r) -> Eff es r
- data Effects
- class (es1 :: Effects) :> (es2 :: Effects)
- type (:&) = 'Union
Eff monad
Run an Eff
runPureEff :: (forall (es :: Effects). Eff es a) -> a #
Run an Eff that doesn't contain any unhandled effects.
Resource management
Arguments
| :: forall (es :: Effects) a b. Eff es a | Acquire the resource |
| -> (a -> Eff es ()) | Release the resource |
| -> (a -> Eff es b) | Run the body |
| -> Eff es b |
bracket acquire release body: acquire a resource, perform the
body with it, and release the resource even if body threw an
exception. This is essentially the same as
Control.Exception., whose
documentation you can inspect for further details.bracket
bracket has a very general type that does not require es to
contain an exception or IO effect. The reason that this is safe is:
- While
bracketdoes catch exceptions, this is unobservable, since the exception is re-thrown; the cleanup action happens unconditionally; and no part of it gets access to the thrown exception. Effitself is able to guarantee that any exceptions thrown in the body will be actually thrown beforebracketexits. This is inherited from the fact thatEffis a wrapper aroundIO.
While it is usually the case that the cleanup action will in fact
want to use IO effects, this is not universally true, see the
polymorphicBracket example for an example.
Type classes
See Bluefin.Eff.IO for the most direct way of doing I/O in
Bluefin. If you really want to use MonadIO you can use
withMonadIO.
Effect tracking
Instances
| Handle (ConstEffect r :: Effects -> Type) | |
Defined in Bluefin.Internal Methods mapHandle :: forall (e :: Effects) (es :: Effects). e :> es => ConstEffect r e -> ConstEffect r es # | |
class (es1 :: Effects) :> (es2 :: Effects) #
Effect subset constraint
Instances
| e :> e | A set of effects |
Defined in Bluefin.Internal | |
| e :> (e :& es) |
|
Defined in Bluefin.Internal | |
| e :> es => e :> (x :& es) | If |
Defined in Bluefin.Internal | |