theatre-dev-0.1.1.1: Minimalistic actor library experiments
Safe HaskellSafe-Inferred
LanguageHaskell2010

TheatreDev.Perpetual

Description

Exploration of perpetual actors. I.e., those that exist for the whole duration of the app.

This limitation provides for simpler API and most apps are expected not to need more.

Synopsis

Documentation

data Actor msg Source #

Actor, which processes the messages of type msg.

Provides abstraction over the communication channel and threads.

Instances

Instances details
Contravariant Actor Source #

Maps the input message to a different type.

Instance details

Defined in TheatreDev.Perpetual

Methods

contramap :: (a' -> a) -> Actor a -> Actor a' #

(>$) :: b -> Actor b -> Actor a #

Decidable Actor Source #

Provides a choice between alternative actors to process the message.

Instance details

Defined in TheatreDev.Perpetual

Methods

lose :: (a -> Void) -> Actor a #

choose :: (a -> Either b c) -> Actor b -> Actor c -> Actor a #

Divisible Actor Source #

Splits the message between actors.

Instance details

Defined in TheatreDev.Perpetual

Methods

divide :: (a -> (b, c)) -> Actor b -> Actor c -> Actor a #

conquer :: Actor a #

Monoid (Actor msg) Source #

Provides an identity for merging the actors, which does nothing.

Instance details

Defined in TheatreDev.Perpetual

Methods

mempty :: Actor msg #

mappend :: Actor msg -> Actor msg -> Actor msg #

mconcat :: [Actor msg] -> Actor msg #

Semigroup (Actor msg) Source #

Distributes the message across the merged actors.

Instance details

Defined in TheatreDev.Perpetual

Methods

(<>) :: Actor msg -> Actor msg -> Actor msg #

sconcat :: NonEmpty (Actor msg) -> Actor msg #

stimes :: Integral b => b -> Actor msg -> Actor msg #

spawnStateless Source #

Arguments

:: (msg -> IO ())

Process the next message. Must not throw any exceptions.

-> IO (Actor msg)

Action forking a thread to run the actor loop and producing a handle for sending messages to it.

spawnStateful Source #

Arguments

:: state

Initial state.

-> (state -> msg -> IO state)

Process the next message updating the state. The IO action must not throw any exceptions.

-> IO (Actor msg)

Action forking a thread to run the actor loop and producing a handle for sending messages to it.

tell :: Actor msg -> msg -> IO () Source #

Schedule a message for the actor to process after the ones already scheduled.