úÎKÉ>Y       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ   Ą˘Ł¤ĽŚ§¨ŠŞ  Ą˘Ł¤ĽŚ§¨ŠŞ  Ą˘Ą˘Ł¤Ľ¤ĽŚ§¨ŠŞŠŞŤŹ­ŽŻ° ŤŹ­ŽŻą˛ł´°Ť­ŹŹ­ŽŻŻ° ľśˇ¸šşťź˝ž-use Data.TCache.syncCache to write the state 1number of seconds between saves when asyncronous size of the cache when async write state after every step żŔÁÂľśˇ¸šşťź˝ž żŔÁĂÄÂĹľľśžˇ¸šşťź˝ˇ¸šşťź˝ž   żŔÁŔÁ ĆÇ Rprint the state changes along the workflow, that is, all the intermediate results ĆÇČÉ ĆÇÇ 7.return conditions from the invocation of start/restart primitives madapted from MonadCatchIO-mtl. Workflow need to express serializable constraints about the returned values, Jso the usual class definitions for lifting IO functions are not suitable. Generalized version of Ę Generalized version of Ë Generalized version of Ě gPMonadTrans permits |to define a partial monad transformer. They are not defined for all kinds of data mbut the ones that have instances of certain classes.That is because in the lift instance code there are some Shidden use of these classes. This also may permit an accurate control of effects. 8An instance of MonadTrans is an instance of PMonadTrans fexecutes a computation inside of the workflow monad whatever the monad encapsulated in the workflow. 0 Warning: this computation is executed whenever ~ the workflow restarts, no matter if it has been already executed previously. This is useful for intializations or debugging. / To avoid re-execution when restarting use: ! $ unsafeIOtoWF... iTo perform IO actions in a workflow that encapsulates an IO monad, use step over the IO action directly:   ! $ action instead of  ! $ unsafeIOtoWF $ actionGeneralized version of Í ?start or restart an anonymous workflow inside another workflow A its state is deleted when finished and the result is stored in  the parent' s WF state. Ta version of exec1 that deletes its state after complete execution or thread killed *a version of exec with no seed parameter. 5start or continue a workflow with exception handling < | the workflow flags are updated even in case of exception  | WFerrors are raised as exceptions ÎĎ!rlifts a monadic computation to the WF monad, and provides transparent state loging and resuming of computation "Ipermits modification of the workflow state by the procedure being lifted L if the boolean value is True. This is used internally for control purposes Đ#9start or continue a workflow with no exception handling. F | the programmer has to handle inconsistencies in the workflow state  | using + or - in case of exception. #name thar identifies the workflow. workflow to execute Ginitial value (ever use the initial value for restarting the workflow) result of the computation ŃŇ$kre-start the non finished workflows in the list, for all the initial values that they may have been called %8The execution log is cached in memory using the package TCacheQ. This procedure defines the polcy for writing the cache into permanent storage. "For fast workflows, or when TCache`$ is used also for other purposes ,  Asynchronous is the best option  Asynchronous mode invokes Ó-. For more complex use of the syncronization  please use this Ó. (When interruptions are controlled, use  mode and include a call to Ô in the finalizaton code &Areturn all the steps of the workflow log. The values are dynamic /to get all the steps with result of type Int:  all <- &  let lfacts = mapMaybe  all :: [Int] '?return the list of object keys that are running for a workflow (=return the current state of the computation, in the IO monad )<kill the executing thread if not killed, but not its state.    # or $ will continue the workflow * a version of  KillThreadWF+ for workflows started wit no parameter by  +;kill the process (if running) and drop it from the list of R restart-able workflows. Its state history remains , so it can be inspected with   getWfHistory printWFHistory and so on , a version of KillWF+ for workflows started wit no parameter by  -[delete the WF from the running list and delete the workflow state from persistent storage. < Use it to perform cleanup if the process has been killed. . a version of -+ for workflows started wit no parameter by  /aReturn the the workflow reference to the last logged result , usually, the last result stored by !. V wiorkflow references can be can be accessed (to its content) outside of the workflow $ . They also can be (de)serialized. EWARNING getWFRef can produce casting errors when the type demanded - do not match the serialized data. Instead, Ő and 0 are type safe at runtuime. 0SExecute an step but return a reference to the result instead of the result itself stepWFRef exp= ! exp >>= /1*Log a value and return a reference to it.  newWFRef x= ! $ return x >>= /2\Read the content of a Workflow reference. Note that its result is not in the Workflow monad 3OWrites a new value en in the workflow reference, that is, in the workflow log. Z Why would you use this?. Don do that!. modifiying the content of the workflow log would d change the excution flow when the workflow restarts. This metod is used internally in the package K the best way to communicate with a workflow is trough a persistent queue: worflow= exec1 wf do  r <- 0 expr  push "queue" r  back <- pop " queueback"  ... 4ALog a message in the workflow history. I can be printed out with printWFhistory 3 The message is printed in the standard output too ÖnWait until a TCache object (with a certaing key) meet a certain condition (useful to check external actions ) _ NOTE if anoter process delete the object from te cache, then waitForData will no longuer work 4 inside the wokflow, it can be used by lifting it :  do  x < - step $ ..  y <- step $ waitForData ...  .. 2The condition that the retrieved object must meet Ba partially defined object for which keyResource can be extracted …return the retrieved object that meet the condition and has the given kwaitForData filter x= atomically $ waitForDataSTM filter x ×2The condition that the retrieved object must meet Ba partially defined object for which keyResource can be extracted Jreturn the retrieved object that meet the condition and has the given key 54observe the workflow log untiil a condition is met. 2The condition that the retrieved object must meet The workflow name 3the INITIAL value used in the workflow to start it (The first event that meet the condition 62The condition that the retrieved object must meet The workflow name 3The INITIAL value used in the workflow to start it (The first event that meet the condition 79Start the timeout and return the flag to be monitored by 8 n This timeout is persistent. This means that the time start to count from the first call to getTimeoutFlag on b no matter if the workflow is restarted. The time that the worlkflow has been stopped count also. 5 the wait time can exceed the time between failures. % when timeout is 0 means no timeout. Ř8VWait until a certain clock time has passed by monitoring its flag, in the STM monad. F This permits to compose timeouts with locks waiting for data using Ů iexample: wait for any respoinse from a Queue if no response is given in 5 minutes, it is returned True.   flag <- 7 $ 5 * 60  ap  )- 'step' . atomically $ readSomewhere >= return . Just Ů 8 flag >> return Nothing  case ap of  Nothing -> do 4 timeout ...  Just x -> do 4 $ received ++ show x ... ÚUWait until a certain clock time has passed by monitoring its flag, in the IO monad.  See 8 ŰÜ8An instance of MonadTrans is an instance of PMonadTrans Ý plift= step 9  !"#$%&'()*+,-./0123456789# $!"/1023&'(56874)+-*,.%  + !"#$%&'()*+,-./012345678 9:;<=Ţß>dspawn a list of independent workflows (the first argument) with a seed value (the second argument).  Their results are reduced by ? or @ ?Ywait for the results and apply the cond to produce a single output in the Workflow monad ŕ@0select the outputs of the workflows produced by > constrained within a timeout. P The check filter, can select , discard or finish the entire computation before E the timeout is reached. When the computation finalizes, it stop all ? the pending workflows and return the list of selected outputs V the timeout is in seconds and is no limited to Int values, so it can last for years. fThis is necessary for the modelization of real-life institutional cycles such are political elections  timeout of 0 means no timeout. Akspawn a list of workflows and reduces the results according with the comp parameter within a given timeout   vote timeout actions comp x= N split actions x >>= select timeout (const $ return Select) >>= comp BMsum the outputs of a list of workflows according with its monoid definition @ sumUp timeout actions = vote timeout actions (return . mconcat) 9:;<=>?@AB >?@AB9=<;: 9=<;::;<=>?@AB Ca queue reference áâăäĺćçčéDEcheck if the queue is empty FG;get the reference to new or existing queue trough its name H+empty the queue (factually, it is deleted) Iversion in the STM monad J9read the first element in the queue and delete it (pop)  Queue name the returned elems ęKversion in the STM monad L Queue name the returned elems Mpush an element in the queue Nversion in the STM monad OJreturn the list of all elements in the queue. The queue remains unchanged Pversion in the STM monad Q=return the first element in the queue that has the given key Rversion in the STM monad ëKupdate the first element of the queue with a new element with the same key ěversion in the STM monad S:return the list of all elements in the queue and empty it Ta version in the STM monad UNdelete all the elements of the queue that has the key of the parameter passed Vverison in the STM monad CDEFGHIJKLMNOPQRSTUVCGJKLHIOPMNQRSTUVDEFCDEFGHIJKLMNOPQRSTUV Wa queue reference íîďđńňóôőXYcheck if the queue is empty Z[;get the reference to new or existing queue trough its name \+empty the queue (factually, it is deleted) ]version in the STM monad ^9read the first element in the queue and delete it (pop)  Queue name the returned elems ö_version in the STM monad ` Queue name the returned elems apush an element in the queue bversion in the STM monad cJreturn the list of all elements in the queue. The queue remains unchanged dversion in the STM monad e=return the first element in the queue that has the given key fversion in the STM monad ÷Kupdate the first element of the queue with a new element with the same key řversion in the STM monad g:return the list of all elements in the queue and empty it ha version in the STM monad iNdelete all the elements of the queue that has the key of the parameter passed jverison in the STM monad WXYZ[\]^_`abcdefghijW[^_`\]cdabefghijXYZWXYZ[\]^_`abcdefghij 7k.return conditions from the invocation of start/restart primitives lmnopmadapted from MonadCatchIO-mtl. Workflow need to express serializable constraints about the returned values, Jso the usual class definitions for lifting IO functions are not suitable. qGeneralized version of Ę rGeneralized version of Ë sGeneralized version of Ě tgPMonadTrans permits |to define a partial monad transformer. They are not defined for all kinds of data mbut the ones that have instances of certain classes.That is because in the lift instance code there are some Shidden use of these classes. This also may permit an accurate control of effects. 8An instance of MonadTrans is an instance of PMonadTrans uvwxfexecutes a computation inside of the workflow monad whatever the monad encapsulated in the workflow. 0 Warning: this computation is executed whenever ~ the workflow restarts, no matter if it has been already executed previously. This is useful for intializations or debugging. / To avoid re-execution when restarting use: ~ $ unsafeIOtoWF... iTo perform IO actions in a workflow that encapsulates an IO monad, use step over the IO action directly:   ~ $ action instead of  ~ $ unsafeIOtoWF $ actionyGeneralized version of Í z?start or restart an anonymous workflow inside another workflow A its state is deleted when finished and the result is stored in  the parent' s WF state. {Ta version of exec1 that deletes its state after complete execution or thread killed |*a version of exec with no seed parameter. }5start or continue a workflow with exception handling < | the workflow flags are updated even in case of exception  | WFerrors are raised as exceptions ůú~rlifts a monadic computation to the WF monad, and provides transparent state loging and resuming of computation Ipermits modification of the workflow state by the procedure being lifted L if the boolean value is True. This is used internally for control purposes ű€9start or continue a workflow with no exception handling. F | the programmer has to handle inconsistencies in the workflow state  | using ˆ or Š in case of exception. #name thar identifies the workflow. workflow to execute Ginitial value (ever use the initial value for restarting the workflow) result of the computation üýkre-start the non finished workflows in the list, for all the initial values that they may have been called ‚8The execution log is cached in memory using the package TCacheQ. This procedure defines the polcy for writing the cache into permanent storage. "For fast workflows, or when TCache`$ is used also for other purposes ,  Asynchronous is the best option  Asynchronous mode invokes Ó-. For more complex use of the syncronization  please use this Ó. (When interruptions are controlled, use  mode and include a call to Ô in the finalizaton code ƒAreturn all the steps of the workflow log. The values are dynamic /to get all the steps with result of type Int:  all <- ƒ  let lfacts = mapMaybe  all :: [Int] „?return the list of object keys that are running for a workflow …=return the current state of the computation, in the IO monad †<kill the executing thread if not killed, but not its state.  } € or  will continue the workflow ‡ a version of  KillThreadWF+ for workflows started wit no parameter by | ˆ;kill the process (if running) and drop it from the list of R restart-able workflows. Its state history remains , so it can be inspected with   getWfHistory printWFHistory and so on ‰ a version of KillWF+ for workflows started wit no parameter by | Š[delete the WF from the running list and delete the workflow state from persistent storage. < Use it to perform cleanup if the process has been killed. ‹ a version of Š+ for workflows started wit no parameter by | ŒaReturn the the workflow reference to the last logged result , usually, the last result stored by ~. V wiorkflow references can be can be accessed (to its content) outside of the workflow $ . They also can be (de)serialized. EWARNING getWFRef can produce casting errors when the type demanded - do not match the serialized data. Instead, Ő and  are type safe at runtuime. SExecute an step but return a reference to the result instead of the result itself stepWFRef exp= ~ exp >>= ŒŽ*Log a value and return a reference to it.  newWFRef x= ~ $ return x >>= Œ\Read the content of a Workflow reference. Note that its result is not in the Workflow monad OWrites a new value en in the workflow reference, that is, in the workflow log. Z Why would you use this?. Don do that!. modifiying the content of the workflow log would d change the excution flow when the workflow restarts. This metod is used internally in the package K the best way to communicate with a workflow is trough a persistent queue: worflow= exec1 wf do  r <-  expr  push "queue" r  back <- pop " queueback"  ... ‘ALog a message in the workflow history. I can be printed out with printWFhistory 3 The message is printed in the standard output too ţnWait until a TCache object (with a certaing key) meet a certain condition (useful to check external actions ) _ NOTE if anoter process delete the object from te cache, then waitForData will no longuer work 4 inside the wokflow, it can be used by lifting it :  do  x < - step $ ..  y <- step $ waitForData ...  .. 2The condition that the retrieved object must meet Ba partially defined object for which keyResource can be extracted …return the retrieved object that meet the condition and has the given kwaitForData filter x= atomically $ waitForDataSTM filter x ˙2The condition that the retrieved object must meet Ba partially defined object for which keyResource can be extracted Jreturn the retrieved object that meet the condition and has the given key ’4observe the workflow log untiil a condition is met. 2The condition that the retrieved object must meet The workflow name 3the INITIAL value used in the workflow to start it (The first event that meet the condition “2The condition that the retrieved object must meet The workflow name 3The INITIAL value used in the workflow to start it (The first event that meet the condition ”9Start the timeout and return the flag to be monitored by • n This timeout is persistent. This means that the time start to count from the first call to getTimeoutFlag on b no matter if the workflow is restarted. The time that the worlkflow has been stopped count also. 5 the wait time can exceed the time between failures. % when timeout is 0 means no timeout. •VWait until a certain clock time has passed by monitoring its flag, in the STM monad. F This permits to compose timeouts with locks waiting for data using Ů iexample: wait for any respoinse from a Queue if no response is given in 5 minutes, it is returned True.   flag <- ” $ 5 * 60  ap  )- 'step' . atomically $ readSomewhere >= return . Just Ů • flag >> return Nothing  case ap of  Nothing -> do ‘ timeout ...  Just x -> do ‘ $ received ++ show x ... UWait until a certain clock time has passed by monitoring its flag, in the IO monad.  See • 8An instance of MonadTrans is an instance of PMonadTrans  plift= step 8 klmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•8wvtupqrsy€}{|zkonml~xŒŽƒ„…’“•”‘†ˆŠ‡‰‹‚  +konmllmnopqrsqrstuuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”• –—˜™š›dspawn a list of independent workflows (the first argument) with a seed value (the second argument).  Their results are reduced by œ or  œYwait for the results and apply the cond to produce a single output in the Workflow monad 0select the outputs of the workflows produced by › constrained within a timeout. P The check filter, can select , discard or finish the entire computation before E the timeout is reached. When the computation finalizes, it stop all ? the pending workflows and return the list of selected outputs V the timeout is in seconds and is no limited to Int values, so it can last for years. fThis is necessary for the modelization of real-life institutional cycles such are political elections  timeout of 0 means no timeout. žkspawn a list of workflows and reduces the results according with the comp parameter within a given timeout   vote timeout actions comp x= N split actions x >>= select timeout (const $ return Select) >>= comp ŸMsum the outputs of a list of workflows according with its monoid definition @ sumUp timeout actions = vote timeout actions (return . mconcat) –—˜™š›œžŸ ›œžŸ–š™˜— –š™˜——˜™š›œžŸ            !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLIMNOPQRSTUVWXYZ[\]^_`abcdeRSTUVWXYZ[\]^_`abcde !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLIMNOPQfghijklmnopqrstuvwxyz  { { | } ~  €  ‚ ƒ ƒ „ … † ‡ ˆ ‰ ‰ Š ‹Œ$ŒŽ%ŒŽ&ŒŽ‘’“” •– •— •˜™š›ŒœžŸ Ą˘˘Ł¤ĽŚ§¨¨ŠŞŤŹ­Ž¤ĽŚ§¨¨ŠŞŤŹ­Ž‘’“”™š›žŸ Ą˘˘ŁŻWorkflow-0.5.8.0Control.Workflow.TextControl.Workflow.Text.PatternsData.Persistent.Queue.TextData.Persistent.Queue.BinaryControl.Workflow.Binary Control.Workflow.Binary.PatternsControl.Workflow.GenSerializerControl.Workflow.IDynamicControl.Workflow.StatControl.Workflow.Text.TextDefsControl.Workflow.Binary.BinDefs TCache-0.9Data.TCache.DefaultPersistencedefPathkey Indexabletransformers-0.2.2.0Control.Monad.IO.ClassliftIOMonadIO safeFromIDynWFRefSyncMode SyncManual Asyncronous frecuency cacheSize Synchronous printHistoryWFErrors ExceptionTimeoutAlreadyRunningNotFound MonadCatchIOcatchblockunblock PMonadTransplift WorkflowListWorkflow unsafeIOtoWFthrowwfExecexec1dexec1execstep stepControlstartrestartWorkflows syncWritegetAll getWFKeys getWFHistory killThreadWF killThreadWF1killWFkillWF1delWFdelWF1getWFRef stepWFRefnewWFRef readWFRef writeWFReflogWFwaitFor waitForSTMgetTimeoutFlag waitUntilSTMSelect FinishSelect FinishDiscardDiscardsplitmergeselectvotesumUpRefQueue unreadSTMisEmpty isEmptySTMgetQRefflushflushSTMpoppopSTMpickpushpushSTMpickAll pickAllSTMpickElem pickElemSTMreadAll readAllSTM deleteElem deleteElemSTM DynSerializerserialM fromDynData RunSerializer runSerial runDeserialThreeSerializer TwoSerializer SerializerserialdeserialIDynTypeDLeftDRightIDynamicIDynfromIDyn errorfied dynPrefix dynPrefixSptoIDynStatwfNamestateindexrecoverversionstimeoutRunningWFstkeyWF tvSyncWritestat0 keyRunningPretty statPrefixwFRefStrbaseControl.Exception.BaseGHC.IOthrowIOmv getTempName stepControl1getStaterunWF Data.TCacheclearSyncCache syncCachenewDBRef waitForDatawaitForDataSTMgetTimeSeconds GHC.Conc.SyncorElse waitUntilwait$fPMonadTranstma$fPMonadTransWFmaActionWF readWFRef1QueueConstraintsSerialiserString serialStringdeserialStringQueuenameimpoutreadQRef updateElem updateElemSTM