úÎLHü     None-In the Actor Model, at each step an actor...  processes a single  message  may  new actors  may  messages to other actors  s the  for processing the next message $These actions take place within the Action i monad, where i is the type * of the input message the actor receives. N.B.:C the MonadIO instance here is an abstraction leak. An example of a  good use of  might be to give an Action access to a source of  randomness. An actor is created by ing a Behavior. Behaviors consist of a  composed $ that is executed when a message is  and  returns the Behavior for processing the next input. b1  b2 has the  of b2 begin where the   occured in b1, i.e. b2'0s first input will be the final input handed to  b1.  !"#$%&'()*+, !"#$ !"#$%&'()*+,NoneIWe extend the actor model to support joining (or synchronizing) multiple  es to a single ' input type, using a new class with an > associated type. Functionality is best explained by example: Spawn an actor returning it's !, and send it its first message:  ! sumTuple :: Behavior (Int, Int)   do b <- spawn sumTuple  send b (4, 1)  ... But now we would like our sumTuple0 actor to receive each number from a different  concurrent actor:   do (b1, b2) <- spawn sumTuple - b3 <- spawn (multipliesBy2AndSendsTo b1)  send b3 2  send b2 1  ... GLastly spawn an actor that starts immediately on an infinite supply of ()s, # and supplies an endless stream of Ints to sumTuple  do (b1, b2) <- spawn sumTuple ! () <- spawn (sendsIntsTo b2)  send b1 4  ... One can  a messages to a Mailbox where it will be processed  according to an actor' s defined   type Joined (Mailbox a) = a Convert the input side of a  SplitChan to a Mailbox. Useful for D sending data out from an actor system via a channel created in IO. 4 contraProduct = contramap Left &&& contramap Right ' contraFanin f g = contramap (f ||| g) ( contraFanout f g = contramap (f &&& g)  Sequence two Behaviors. After the first s the second takes over, @ discarding the message the former was processing. See also the -  instance for Behavior. # b <.|> b' = b `mappend` constB b' IImmediately give up processing an input, perhaps relinquishing the input  to an .# computation or exiting the actor.  yield = mzero AUseful to make defining a continuing Behavior more readable as a  " receive block", e.g.  # pairUpAndSendTo mb = Receive $ do  a <- received  receive $ do  b <- received  send mb (b,a) % return (pairUpAndSendTo mb)  Defined as:  receive = return . Receive *Return the message received to start this  block. N.B the value 9 returned here does not change between calls in the same .  received = ask Return ' message matching predicate, otherwise . 8 guardReceived p = ask >>= \i-> guard (p i) >> return i FSend a message asynchronously to an actor receiving from Mailbox. See  also ( for converting other types of chans to .  send b = liftIO . writeChan b  A strict :  send' b a = a `seq` send b a Like 7 but supports chaining sends by returning the Mailbox. K Convenient for initializing an Actor with its first input after spawning,  e.g.  do mb <- 0 <-> spawn foo 'Fork an actor performing the specified . N.B. an actor  begins execution of its  headBehavior only after a message becomes H available to process; for sending an initial message to an actor right  after  ing it, (/) can be convenient. Run a  Behavior ()4 in the main thread, returning when the computation  exits. run a  in the IO monad, taking its "messages" from the list. >Prints all messages to STDOUT in the order they are received,  -ing  immediately after n inputs are printed. Like  but using putStr. Sends a ()) to the passed chan. This is useful with 0 for " signalling the end of some other . * signalB c = Receive (send c () >> yield) A Behavior= that discard its first input, returning the passed Behavior / for processing subsequent inputs. Useful with . or - 4 compositions when one wants to ignore the leftover  ed message.  constB = Receive . return 1  type Joined () = ()  Represents an endless supply of () s. Allows -ing  a  Behavior (), that starts immediately and loops until it  -s, e.g. 4 do () <- spawn startsImmediately -- :: Behavior () " 123456789:   ! 123456789:;      !"#$%&'()*+,-./012345676849:;<=>?@ABCDsimple-actors-0.4.0Control.Concurrent.Actors"Control.Concurrent.Actors.BehaviorreceivedspawnsendyieldActionBehaviorReceive headActionSourcesJoinedMailboxout coproductMbzipMb contraProduct contraFanin contraFanout<.|>receive guardReceivedsend'<-> runBehavior_ runBehaviorprintBputStrBsignalBconstBbaseGHC.Basereturntransformers-0.3.0.0Control.Monad.IO.ClassliftIO$fMonoidBehavior Control.MonadmplusreaderT runActionactionrunBehaviorStep$fArrowLoopAction$fArrowZeroAction$fArrowPlusAction$fArrowChoiceAction$fArrowApplyAction $fArrowAction$fCategoryAction$fContravariantBehavior Data.MonoidMonoidControl.Applicative Alternative<|>mappend $fSources() $fSources(,,)$fSources(,,,)$fSources(,,,,)$fSources(,,,,,)$fSources(,,,,,,) $fSources(,)$fSourcesMailbox$fNewSplitChanMailboxMessages$fSplitChanMailboxMessages