úÎ3™1½      -In the Actor Model, at each step an actor...  processes a single received message  may spawn new actors  may send 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 spawning a Behavior. Behaviors consist of  a composed $ that is executed when a message is received and  returns the Behavior for processing the next input. b1  b2 has the  of b2 begin where the abort  occured in b1, i.e. b2'0s first input will be the final input handed to  b1.  One can   a messages to a Mailbox where it will be processed  according to an actor' s defined  ! 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  Alternative# computation or exiting the actor.  yield = mzero AUseful to make defining a continuing Behavior more readable as a  " receive block", e.g.   pairUp out = Receive $ do  a <- received  receive $ do  b <- received  send out (b,a)  return (pairUp out)  Defined: 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 Like = but allows one to specify explicitly the channel from which J an actor should take its input. Useful for extending the library to work  over other channels. 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.  Useful for debugging  Behaviors. 'Fork an actor performing the specified . N.B. an actor  begins execution of its  headBehavior only after a mesage has been  received. See also . CFork a looping computation which starts immediately. Equivalent to  launching a  Behavior () and another " that sends an infinite stream of  ()s to the former's . >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 # 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  Alternative or " ; compositions when one wants to ignore the leftover input.  constB = Receive . return       $      !"#$$%&'(')*simple-actors-0.1.0Control.Concurrent.Actors"Control.Concurrent.Actors.BehaviorActionBehaviorReceive headActionMailbox<.|>yieldreceivereceived guardReceivedsend spawnReading runBehavior_ runBehaviorspawnspawn_printBputStrBsignalBconstBbaseGHC.Basereturntransformers-0.2.2.0Control.Monad.IO.ClassliftIOreaderT runActionactionrunBehaviorStep$fMonoidBehavior Control.MonadmplusMessagesoutChaninChan Data.MonoidMonoidmappend