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

Bluefin.IO

Synopsis

Documentation

You can run IO operations inside Eff.

Handle

data IOE (e :: Effects) #

Handle that allows you to run IO operations

Instances

Instances details
e :> es => MonadBaseControl IO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Associated Types

type StM (EffReader (IOE e) es) a #

Methods

liftBaseWith :: (RunInBase (EffReader (IOE e) es) IO -> IO a) -> EffReader (IOE e) es a #

restoreM :: StM (EffReader (IOE e) es) a -> EffReader (IOE e) es a #

e :> es => MonadBase IO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

liftBase :: IO α -> EffReader (IOE e) es α #

e :> es => MonadIO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

liftIO :: IO a -> EffReader (IOE e) es a #

e :> es => MonadUnliftIO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

withRunInIO :: ((forall a. EffReader (IOE e) es a -> IO a) -> IO b) -> EffReader (IOE e) es b #

type StM (EffReader (IOE e) es) a 
Instance details

Defined in Bluefin.Internal

type StM (EffReader (IOE e) es) a = a

Handlers

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!

Effectful operations

effIO #

Arguments

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

͘

Run an IO operation in Eff

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

IO type classes

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!

withEffToIO #

Arguments

:: forall (e2 :: Effects) (es :: Effects) a. e2 :> es 
=> ((forall r. (forall (e1 :: Effects). IOE e1 -> Eff (e1 :& es) r) -> IO r) -> IO a)

Continuation with the unlifting function in scope.

-> IOE e2 
-> Eff es a 

EffReader

data EffReader r (es :: Effects) a #

Because doing IO operations inside Eff requires a value-level argument we can't give IO-related instances to Eff directly. Instead we wrap it in EffReader.

Instances

Instances details
e :> es => MonadBaseControl IO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Associated Types

type StM (EffReader (IOE e) es) a #

Methods

liftBaseWith :: (RunInBase (EffReader (IOE e) es) IO -> IO a) -> EffReader (IOE e) es a #

restoreM :: StM (EffReader (IOE e) es) a -> EffReader (IOE e) es a #

e :> es => MonadBase IO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

liftBase :: IO α -> EffReader (IOE e) es α #

e :> es => MonadFail (EffReader (Exception String e) es) 
Instance details

Defined in Bluefin.Internal

Methods

fail :: String -> EffReader (Exception String e) es a #

e :> es => MonadIO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

liftIO :: IO a -> EffReader (IOE e) es a #

Applicative (EffReader r es) 
Instance details

Defined in Bluefin.Internal

Methods

pure :: a -> EffReader r es a #

(<*>) :: EffReader r es (a -> b) -> EffReader r es a -> EffReader r es b #

liftA2 :: (a -> b -> c) -> EffReader r es a -> EffReader r es b -> EffReader r es c #

(*>) :: EffReader r es a -> EffReader r es b -> EffReader r es b #

(<*) :: EffReader r es a -> EffReader r es b -> EffReader r es a #

Functor (EffReader r es) 
Instance details

Defined in Bluefin.Internal

Methods

fmap :: (a -> b) -> EffReader r es a -> EffReader r es b #

(<$) :: a -> EffReader r es b -> EffReader r es a #

Monad (EffReader r es) 
Instance details

Defined in Bluefin.Internal

Methods

(>>=) :: EffReader r es a -> (a -> EffReader r es b) -> EffReader r es b #

(>>) :: EffReader r es a -> EffReader r es b -> EffReader r es b #

return :: a -> EffReader r es a #

e :> es => MonadUnliftIO (EffReader (IOE e) es) 
Instance details

Defined in Bluefin.Internal

Methods

withRunInIO :: ((forall a. EffReader (IOE e) es a -> IO a) -> IO b) -> EffReader (IOE e) es b #

type StM (EffReader (IOE e) es) a 
Instance details

Defined in Bluefin.Internal

type StM (EffReader (IOE e) es) a = a

effReader :: forall r (es :: Effects) a. (r -> Eff es a) -> EffReader r es a #

runEffReader :: forall r (es :: Effects) a. r -> EffReader r es a -> Eff es a #