bluefin-0.0.0.0
Safe HaskellNone
LanguageHaskell2010

Bluefin.Eff

Synopsis

Eff monad

data Eff (es :: Effects) a Source #

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 Source #

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

runEff Source #

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!

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 Source #

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 Source #

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

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

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 Source #

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

Union of effects