bluefin-0.0.6.0: The Bluefin effect system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Bluefin.Eff

Synopsis

Eff monad

data Eff (es :: Effects) a #

Instances

Instances details
Applicative (Eff es) 
Instance details

Defined in Bluefin.Internal

Methods

pure :: a -> Eff es a #

(<*>) :: Eff es (a -> b) -> Eff es a -> Eff es b #

liftA2 :: (a -> b -> c) -> Eff es a -> Eff es b -> Eff es c #

(*>) :: Eff es a -> Eff es b -> Eff es b #

(<*) :: Eff es a -> Eff es b -> Eff es a #

Functor (Eff es) 
Instance details

Defined in Bluefin.Internal

Methods

fmap :: (a -> b) -> Eff es a -> Eff es b #

(<$) :: a -> Eff es b -> Eff es a #

Monad (Eff es) 
Instance details

Defined in Bluefin.Internal

Methods

(>>=) :: Eff es a -> (a -> Eff es b) -> Eff es b #

(>>) :: Eff es a -> Eff es b -> Eff es b #

return :: a -> Eff es a #

Run an Eff

runPureEff :: (forall (es :: Effects). Eff es a) -> a #

Run an Eff that doesn't contain any unhandled effects.

runEff #

Arguments

:: (forall (e :: Effects) (es :: Effects). IOE e -> Eff (e :& es) a) 
-> IO a

͘

Run an Eff whose only unhandled effect is IO.

>>> runEff $ \io -> do
      effIO io (putStrLn "Hello world!")
Hello, world!

Resource management

bracket :: forall (es :: Effects) a b. Eff es a -> (a -> Eff es ()) -> (a -> Eff es b) -> 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.bracket, whose documentation you can inspect for further details.

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.

withMonadIO #

Arguments

:: forall (e :: Effects) (es :: Effects) r. e :> es 
=> IOE e 
-> (forall (m :: Type -> Type). MonadIO m => m r)

MonadIO operation

-> Eff es r

MonadIO operation run in Eff

Run MonadIO operations in Eff.

>>> runEff $ \io -> withMonadIO io $ liftIO $ do
      putStrLn "Hello world!"
Hello, world!

withMonadFail #

Arguments

:: forall (e :: Effects) (es :: Effects) r. e :> es 
=> Exception String e

Exception to throw on fail

-> (forall (m :: Type -> Type). MonadFail m => m r)

MonadFail operation

-> Eff es r

MonadFail operation run in Eff

Run MonadFail operations in Eff.

>>> runPureEff $ try $ \e ->
      when (2 > 1) $
        withMonadFail e (fail "2 was bigger than 1")
Left "2 was bigger than 1"

Effect tracking

data Effects #

class (es1 :: Effects) :> (es2 :: Effects) #

Effect subset constraint

Instances

Instances details
e :> e

A set of effects e is a subset of itself

Instance details

Defined in Bluefin.Internal

e :> (e :& es)

e is a subset of a larger set e :& es

Instance details

Defined in Bluefin.Internal

e :> es => e :> (x :& es)

If e is subset of es then e is a subset of a larger set, x :& es

Instance details

Defined in Bluefin.Internal

type (:&) = 'Union infixr 9 #

type (:&) :: Effects -> Effects -> Effects

Union of effects