!      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ None%&'+,-03456;<=FKNQSTVhC\ Each process is identified by a single process id, that stays constant throughout the life cycle of a process. Also, message sending relies on these values to address messages to processes.Every function for   things needs proxy for the low-level effect list depending on the scheduler implementation. I don't know a smarter way yet to do this.Cons   onto a list of effects.Every   action returns it's actual result wrapped in this type. It will allow to signal errors as well as pass on normal results such as incoming messages. The process is required to exit.XThe process is required to exit from an error condition, that cannot be recovered from. :The process may resume to do work, using the given result. BThis indicates that the action did not complete, and maybe retried The process effect is the basis for message passing concurrency. This effect describes an interface for concurrent, communicating isolated processes identified uniquely by a process-id.Processes can raise exceptions that can be caught, exit gracefully or with an error, or be killed by other processes, with the option of ignoring the shutdown request.vProcess Scheduling is implemented in different modules. All scheduler implementations should follow some basic rules:fair scheduling sending a message does not blockreceiving a message does block*spawning a child blocks only a very momentJa newly spawned process shall be scheduled before the parent process after the spawnGwhen the first process exists, all process should be killed immediately Return the current  jStart a new process, the new process will execute an effect, the function will return immediately with a .aProcess exit, this is the same as if the function that was applied to a spawn function returned.8Exit the process due to an error, this cannot be caught.$Raise an error, that can be handled.VRequest that another a process exits. The targeted process is interrupted and gets a A, the target process may decide to ignore the shutdown requests.-Send a message to a process addressed by the . Sending a message should **always succeed** and return **immediately**, even if the destination process does not exist, or does not accept messages of the given type.Receive a message. This should block until an a message was received. The pure function may convert the incoming message into something, and the result is returned as ProcessMessage value. Another reason why this function returns, is if a process control message was sent to the process. This can only occur from inside the runtime system, aka the effect handler implementation. (Currently there is one in  .) Execute a  d action and resume the process, retry the action or exit the process when a shutdown was requested.gExecute a and action and resume the process, retry the action, shutdown the process or return an error. Return a  for a   effect.-Send a message to a process addressed by the . See .-Send a message to a process addressed by the . See .jStart a new process, the new process will execute an effect, the function will return immediately with a .#Block until a message was received.%Receive and cast the message to some  instance.ZEnter a loop to receive messages and pass them to a callback, until the function returns . Returns the  of the current process.Exit the process.Exit the process with an error."Thrown an error, can be caught by  . $Catch and handle an error raised by 3. Works independent of the handler implementation.!Like   it catches R, but instead of invoking a user provided handler, the result is wrapped into an .#  !1#1   !  None%&'+,-03456<FKNQSTVhY2'This is a tag-type that wraps around a  and holds an 8 index type.5This  data kindH is used to indicate at the type level if a specific constructor of an ApiT instance has a result for which some caller has to wait, or if it is asynchronous.65Blocking operation with a specific return type, e.g. ,('Synchronous (Either RentalError RentalId))7Non-blocking async operation8zThis data family defines an API, a communication interface description between to processes, where one process acts as a server and the other(s) as  client(s).PThe first parameter is usually a user defined phantom type that identifies the 8 instance.LThe second parameter specifies if a specific constructor of an (GADT-like) Api instance is 6;, i.e. returns a result and blocks the caller or if it is 7Example:  data BookShop deriving Typeable data instance Api BookShop r where RentBook :: BookId -> Api BookShop ('Synchronous (Either RentalError RentalId)) BringBack :: RentalId -> Api BookShop 'Asynchronous type BookId = Int type RentalId = Int type RentalError = String >Tag a  with an 8 type index to mark it a 2 process handling that API?Tag a  with an 8 type index to mark it a 2 process handling that API 2345678=>? 8567234=>?234567 None%&'+,-03456<FKNQSTVhZNone%&'+,-03456<FKNQSTVho@Instead of passing around a 2& value and passing to functions like B or C, a 2 can provided by a  effect, if there is only a  single server for a given 8I instance. This type alias is convenience to express that an effect has   and a reader for a 2.ASend an 8v request that has no return value and return as fast as possible. The type signature enforces that the corresponding 8 clause is 7 . Return True if the message was sent to the process. Note that this is totally not the same as that the request was successfully handled. If that is important, use C instead.BSend an 8v request that has no return value and return as fast as possible. The type signature enforces that the corresponding 8 clause is 7.CSend an 8: request and wait for the server to return a result value.3The type signature enforces that the corresponding 8 clause is 6.D"Run a reader effect that contains the one server handling a specific 8 instance.ELike C but take the 2 from the reader provided by D.FLike EG but also catch errors raised if e.g. the server crashed. By allowing  instances to contain the reply, application level errors can be combined with errors rising from inter process communication.GLike B but take the 2 from the reader provided by D.@ABCDEFGBACGEF@DNone%&'+,-03456<FKNQSTVhwH'Catch an exception and return it in an .I,Lift an IO action and catch all error using  then wrap the 6 using a given wrapper function and rethrow it using .J#Run an effect with exceptions like  and rethrow it as  using K,Lift an IO action and catch all errors with  with a pure handler.L,Lift an IO action and catch all errors with  with an effect handler.MCatch  thrown by an effect.HIJKLMHIJKLMNone%&'+,-03456<FKNQSTVhy NOPSQRTUVWXYZ PQRSTUWVNOZXYNOPQRS None%&'+,-03456<FKNQSTVh{Embeds a less-constrained 2 into a more-constrained one. Analogous to MTL's lift.None%&'+,-03456<FKNQSTVh[TAn exception that is used by the mechanism that chains together multiple different \2 allowing a single process to implement multiple 8s. This exception is thrown by j%. This exception can be caught with h, this way, several distinct \ can be tried until one fits or until the k is invoked.\$A record of callbacks requests to a server, serving a specific 8 family instance.^JA cast will not return a result directly. This is used for async methods._gA call is a blocking operation, the caller is blocked until this handler calls the reply continuation.`This callback is called with Nothing& if the process exits peacefully, or Just "error message..." if the process exits with an error. This function is responsible to exit the process if necessary. The default behavior is defined in d.aHReceive and process incoming requests until the process exits, using an \.Apply either the _, ^ or the ` callback to an incoming 7. Note, it is unlikely that this function must be used.bA default handler to use in _ in \. It will call  with a nice error message.cA default handler to use in ^ in \. It will call  with a nice error message.d9Exit the process either normally of the error message is Nothing or with  otherwise.ea two \?s at once. The first handler is used for termination handling.fa three \?s at once. The first handler is used for termination handling.g/The basic building block of the combination of \5s is this function, which can not only be passed to , but also throws an [ exception if jG failed, such that multiple invokation of this function for different \s can be tried, by using h. ~tryApiHandler px handlers1 message `catchUnhandled` tryApiHandler px handlers2 `catchUnhandled` tryApiHandler px handlers3hIf j! failes to cast the message to a  for a certain \ it throws an [ exception. That exception is caught by this function and the raw message is given to the handler function. This is the basis for chaining \s.iCatch [8s and terminate the process with an error, if necessary.jCast a $ value, and if that fails, throw an [ error.k0If an incoming message could not be casted to a  corresponding to an \ (e.g. with jO) one should use this function to exit the process with a corresponding error.[\]^_`abcdefghijka\]^_`bcdefg[hijk[\]^_`None%&'+,-03456;<=>?FKNQSTVh1Internal exception to **immediately** shutdown a l process created by x , other than u the message queue will not be flushed, not further messages will be logged, except for the optional final message.!Internal exception to shutdown a l process created by x. This exception is handled such that all message already en-queued are handled and then an optional final message is written.l&A log channel processes logs from the my effect by en-queuing them in a shared queue read from a seperate processes. A channel can contain log message filters.filter log messagesdiscard all log messages&send all log messages to a log processm9Logging effect type, parameterized by a log message type.oLog a message.p#Change, add or remove log messages. Requirements:[All log meta data for typical prod code can be added without changing much of the code5Add timestamp to a log messages of a sub-computation.Write some messages to a file.<Log something extra, e.g. runtime memory usage in load testsApproach: Install a callback that sneaks into to log message sending/receiving, to intercept the messages and execute some code and then return a new message.qFChange, add or remove log messages without side effects, faster than p. Requirements:5Tests run fast in unit tests so travis won't time outDrop debug logs Grep like log filteringApproach: Install a callback that sneaks into to log message sending/receiving, to intercept the messages and execute some code and then return a new message.rCapture the logs in a .sThrow away all log messages.tHandle m effects using  s.uSend the log messages to a l.v(Enqueue a log message into a log channelw Create a l* that will discard all messages sent via forwardLogstochannel or v.xPFork a new process, that applies a monadic action to all log messages sent via u or v.yFilter logs sent to a l using a predicate.zRun an action and close a l created by w, x or y afterwards using {. If a - was thrown, the log channel is killed with |!, and the exception is re-thrown.{$Close a log channel created by e.g. x. Message already enqueue are handled, as well as an optional final message. Subsequent log message will not be handled anymore. If the log channel must be closed immediately, use | instead.|Close a log channel quickly, without logging messages already in the queue. Subsequent logging requests will not be handled anymore. If the log channel must be closed without loosing any messages, use { instead.}Wrap l4 creation and destruction around a monad action in y manner. This function uses {M, so en-queued messages are flushed on exit. The resulting action in in the D monad, which is essentially a reader for the log handler function.xYSize of the log message input queue. If the queue is full, message are dropped silently. An IO action to log the messages Optional first message to log}YSize of the log message input queue. If the queue is full, message are dropped silently. Optional first message to log Optional last message to log An IO action that will use the lY, after the action returns (even because of an exception) the log channel is destroyed.M     lmnopqrstuvwxyz{|}mnopqrstluwxy{|z}vlmnNone%&'+,-03456<FKNQSTVhThe concrete list of (ects for running this pure scheduler on IO and with string logging. Execute a  8 in the current thread, all child processes spawned by P will be executed concurrently using a co-routine based, round-robin scheduler.A  for . Execute a   using  on top of  IO and m String effects. ! None%&'+,-03456;<=>?FKNQSTVh"1Information about a process, needed to implement MessagePassing and  , handlers. The message queue is backed by a # and contains  MessageQEntry values.$ Contains all "e elements, as well as the state needed to implement inter process communication. It contains also a l6 to which the logs of all processes are forwarded to.The concrete list of ;ects for this scheduler implementation. See HasSchedulerIOsAn alias for the constraints for the effects essential to this scheduler implementation, i.e. these effects allow ing new  es. See SchedulerIO@A sum-type with errors that can occur when scheduleing messages.No " was found for a j during internal processing. NOTE: This is **ONLY** caused by internal errors, probably by an incorrect MessagePassingq handler in this module. **Sending a message to a process ALWAYS succeeds!** Even if the process does not exist.A process called .A process called .A process exits.<An action was not performed while the scheduler was exiting.%A newtype wrapper around an & holding a $ state. This is needed by  and provided by  runScheduler.A  for jThis is the main entry point to running a message passing concurrency application. This function takes a   on top of the  effect and a l for concurrent logging.<Start the message passing concurrency system then execute a   on top of 0 effect. All logging is sent to standard output.<Start the message passing concurrency system then execute a   on top of 0 effect. All logging is sent to standard output. "'()*$+,-./012345%67None%&'+,-03456;<=FKNQSTVh 889:;<=>?@AB<=C;:89 None%&'+,-03456;<=>?FKNQSTVh An : that schedules the observations to an effectful callback.Internal state for manageobservers An existential wrapper around a 2 of an G. Needed to support different types of observers to observe the same  in a general fashion.An 8: index that supports registration and de-registration of s./Type of observations visible on this observable Return the 8 value for the cast_ that registeres an observer Return the 8 value for the cast_ that de-registeres an observerAn 80 index that support observation of the another 8 that is . Wrap the  and the  (i.e. the 2&) that caused the observation into a 8 value that the  understands.Send an  to an  Send the  Send the Send an  to .Keep track of registered .s Observers can be added and removed, and an 0 can be sent to all registerd observers at once.Add an  to the  managed by . Delete an  from the  managed by .Send an  to all  s in the  state.Start a new process for an ; that schedules all observations to an effectful callback.DEFGNone%&'+,-03456;<=>?FKNQSTVh 8HIJKLMNOPQRSTUVWXNYMLKJZHINone%&'+,-03456<FKNQSTVhc[\]^_`abc !"#$%&'()*+,-./0123456789:;<=>?@AABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijjklmnopqrstuvwxyz{|}~                      V i       !""#$%&'()*+,-./0123 4567 8 9:; 4 < = > 8 ? @ A B C D D E E F 9 GHIJKKLMNOPQ  R S TUVWXYZ[\]M^_`abcdefghijklmno