extensible-effects-concurrent-0.3.0.0: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Process.Interactive

Synopsis

Documentation

data SchedulerVar r Source #

This module provides support for executing Process actions from IO.

One use case is interacting with processes from the REPL, e.g.:

>>> import Control.Eff.Concurrent.Process.SingleThreadedScheduler (defaultMain)
>>> import Data.Dynamic
>>> import Data.Maybe
>>> s <- forkInteractiveScheduler Control.Eff.Concurrent.Process.SingleThreadedScheduler.defaultMain
>>> fooPid <- submit s (spawn (forever (receiveMessage SP >>= (logMsg . fromMaybe "Huh!??" . fromDynamic))))
>>> fooPid
<0.1.0>
>>> submit s (sendMessageAs SP fooPid "test")
test
>>> submit s (sendShutdown SP fooPid)

Since: 0.3.0.0

forkInteractiveScheduler :: forall r. SetMember Lift (Lift IO) r => (Eff (Process r ': r) () -> IO ()) -> IO (SchedulerVar r) Source #

Fork a scheduler with a process that communicates with it via MVar, which is also the reason for the Lift IO constraint.

killInteractiveScheduler :: SchedulerVar r -> IO () Source #

Exit the schedulder immediately using an asynchronous exception.

submit :: forall r a. SetMember Lift (Lift IO) r => SchedulerVar r -> Eff (Process r ': r) a -> IO a Source #

Send a Process effect to the main process of a scheduler, this blocks until the effect is executed.

submitPrint :: forall r a. (Show a, SetMember Lift (Lift IO) r) => SchedulerVar r -> Eff (Process r ': r) a -> IO () Source #

Send a Process effect to the main process of a scheduler, this blocks until the effect is executed, then the result is printed by the thread, that runs the process 0 in the scheduler.

submitCast :: forall o r. (SetMember Lift (Lift IO) r, Typeable o) => SchedulerVar r -> Server o -> Api o Asynchronous -> IO () Source #

Combination of submit and cast.

submitCall :: forall o q r. (SetMember Lift (Lift IO) r, Typeable o, Typeable q) => SchedulerVar r -> Server o -> Api o (Synchronous q) -> IO q Source #

Combination of submit and cast.