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

TheatreDev.Terminal.Actor

Synopsis

Documentation

data Actor message Source #

Controls of an actor, which processes the messages of type message.

Abstraction over the message channel, thread-forking and killing.

Instances

Instances details
Contravariant Actor Source # 
Instance details

Defined in TheatreDev.Terminal.Actor

Methods

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

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

Decidable Actor Source # 
Instance details

Defined in TheatreDev.Terminal.Actor

Methods

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

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

Divisible Actor Source # 
Instance details

Defined in TheatreDev.Terminal.Actor

Methods

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

conquer :: Actor a #

Monoid (Actor message) Source # 
Instance details

Defined in TheatreDev.Terminal.Actor

Methods

mempty :: Actor message #

mappend :: Actor message -> Actor message -> Actor message #

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

Semigroup (Actor message) Source # 
Instance details

Defined in TheatreDev.Terminal.Actor

Methods

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

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

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

Manipulation

adaptToList :: Actor message -> Actor [message] Source #

Adapt the actor to be able to receive lists of messages.

Acquisition

spawnStatelessGranular Source #

Arguments

:: (message -> IO ())

Interpreter of a message.

-> IO ()

Clean up when killed.

-> IO (Actor message)

Fork a thread to run the handler daemon on and produce a handle to control it.

Given an interpreter of messages, fork a thread to run the handler daemon on and produce a handle to control that actor.

Killing that actor will make it process all the messages in the queue first. All the messages sent to it after killing won't be processed.

spawnStatefulGranular :: state -> (state -> message -> IO state) -> (state -> IO ()) -> IO (Actor message) Source #

Actor with memory.

Threads a persistent state thru its iterations.

Given an interpreter of messages and initial state generator, forks a thread to run the computation on and produces a handle to address that actor.

Killing that actor will make it process all the messages in the queue first. All the messages sent to it after killing won't be processed.

spawnStatefulBatched :: state -> (state -> NonEmpty message -> IO state) -> (state -> IO ()) -> IO (Actor message) Source #

Control

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

Send a message to the actor.

kill :: Actor message -> IO () Source #

Kill the actor.

wait :: Actor message -> IO () Source #

Wait for the actor to die due to error or being killed.