| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Eff.Concurrent.Process.SingleThreadedScheduler
Description
A coroutine based, single threaded scheduler for Processes.
Synopsis
- scheduleM :: forall m r a. Monad m => (forall b. Eff r b -> m b) -> m () -> Eff (Processes r) a -> m (Either (Interrupt NoRecovery) a)
- scheduleMonadIOEff :: MonadIO (Eff r) => Eff (Processes r) a -> Eff r (Either (Interrupt NoRecovery) a)
- scheduleIOWithLogging :: HasCallStack => LogWriter IO -> Eff EffectsIo a -> IO (Either (Interrupt NoRecovery) a)
- schedulePure :: Eff (Processes '[Logs, LogWriterReader PureLogWriter]) a -> Either (Interrupt NoRecovery) a
- type PureEffects = Processes PureBaseEffects
- type PureSafeEffects = SafeProcesses PureBaseEffects
- type PureBaseEffects = '[Logs, LogWriterReader PureLogWriter]
- type HasPureBaseEffects e = (HasCallStack, PureBaseEffects <:: e)
- defaultMain :: HasCallStack => Eff EffectsIo () -> IO ()
- defaultMainWithLogWriter :: HasCallStack => LogWriter IO -> Eff EffectsIo () -> IO ()
- scheduleIO :: MonadIO m => (forall b. Eff r b -> Eff '[Lift m] b) -> Eff (Processes r) a -> m (Either (Interrupt NoRecovery) a)
- type EffectsIo = Processes BaseEffectsIo
- type SafeEffectsIo = SafeProcesses BaseEffectsIo
- type BaseEffectsIo = LoggingAndIo
- type HasBaseEffectsIo e = (HasCallStack, Lifted IO e, LoggingAndIo <:: e)
Documentation
Arguments
| :: Monad m | |
| => (forall b. Eff r b -> m b) | |
| -> m () | An that performs a yield w.r.t. the underlying effect
|
| -> Eff (Processes r) a | |
| -> m (Either (Interrupt NoRecovery) a) |
Handle the Process effect, as well as all lower effects using an effect handler function.
Execute the main Process and all the other processes spawned by it in the
current thread concurrently, using a co-routine based, round-robin
scheduler. If a process exits with eg.g exitNormally or exitWithError
or is killed by another process Left ... is returned.
Otherwise, the result will be wrapped in a Right.
Every time a process _yields_ the effects are evaluated down to the a value
of type m (Either String a).
If the evaluator function runs the action down e.g. IO this might improve
memory consumption, for long running services, with processes that loop
endlessly.
Since: 0.4.0.0
scheduleMonadIOEff :: MonadIO (Eff r) => Eff (Processes r) a -> Eff r (Either (Interrupt NoRecovery) a) Source #
scheduleIOWithLogging :: HasCallStack => LogWriter IO -> Eff EffectsIo a -> IO (Either (Interrupt NoRecovery) a) Source #
Run processes that have the Logs and the Lift effects.
The user must provide a log handler function.
Log messages are evaluated strict.
scheduleIOWithLogging ==scheduleIO.withLogging
Since: 0.4.0.0
schedulePure :: Eff (Processes '[Logs, LogWriterReader PureLogWriter]) a -> Either (Interrupt NoRecovery) a Source #
Like scheduleIO but pure. The yield effect is just return ().
schedulePure == runIdentity . scheduleM (Identity . run) (return ())
Since: 0.3.0.2
type PureEffects = Processes PureBaseEffects Source #
The effect list for Process effects in the single threaded pure scheduler.
See PureBaseEffects and Processes
Since: 0.25.0
type PureSafeEffects = SafeProcesses PureBaseEffects Source #
The effect list for Process effects in the single threaded pure scheduler.
This is like SafeProcesses, no Interrupts are present.
See PureBaseEffects and SafeProcesses
Since: 0.25.0
type PureBaseEffects = '[Logs, LogWriterReader PureLogWriter] Source #
The effect list for a pure, single threaded scheduler contains only
Logs and the LogWriterReader for PureLogWriter.
Since: 0.25.0
type HasPureBaseEffects e = (HasCallStack, PureBaseEffects <:: e) Source #
defaultMain :: HasCallStack => Eff EffectsIo () -> IO () Source #
Execute a Process using scheduleM on top of Lift IO.
All logging is written to the console using consoleLogWriter.
To use another LogWriter use defaultMainWithLogWriter instead.
defaultMainWithLogWriter :: HasCallStack => LogWriter IO -> Eff EffectsIo () -> IO () Source #
scheduleIO :: MonadIO m => (forall b. Eff r b -> Eff '[Lift m] b) -> Eff (Processes r) a -> m (Either (Interrupt NoRecovery) a) Source #
type EffectsIo = Processes BaseEffectsIo Source #
type SafeEffectsIo = SafeProcesses BaseEffectsIo Source #
The effect list for Process effects in the single threaded scheduler.
This is like SafeProcesses, no Interrupts are present.
See BaseEffectsIo.
Since: 0.25.0
type BaseEffectsIo = LoggingAndIo Source #
type HasBaseEffectsIo e = (HasCallStack, Lifted IO e, LoggingAndIo <:: e) Source #
Constraint for the existence of the underlying scheduler effects.
Since: 0.25.0