úÎTÚGĽ      !"#$%&'()*+,-./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 ËĚÍÎ ËĚĚ 8.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 Ö×$‰start or continue a workflow from a list of workflows in the IO monad with exception handling. The excepton is returned as a Left value &name of workflow in the workflow list Hinitial value (ever use the initial value even to restart the workflow) function to execute 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. 2 a version of /+ for workflows started wit no parameter by  4TReturn the reference to the last logged result , usually, the last result stored by !. > wiorkflow references can be accessed 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 5 are type safe at runtuime. 5SExecute an step but return a reference to the result instead of the result itself stepWFRef exp= ! exp >>= 46*Log a value and return a reference to it.  newWFRef x= ! $ return x >>= 47\Read the content of a Workflow reference. Note that its result is not in the Workflow monad 8OWrites 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 <- 5 expr  push "queue" r  back <- pop " queueback"  ... 9ALog 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 9 timeout ...  Just x -> do 9 $ 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 <  !"#$%&'()*+,-./0123456789:;<=<# $%!"46578*'():;=<93+-/,.201&  , !"#$%&'()+,-./2456789:;<= >?@ABăäCdspawn a list of independent workflows (the first argument) with a seed value (the second argument).  Their results are reduced by D or E DYwait for the results and apply the cond to produce a single output in the Workflow monad ĺE0select the outputs of the workflows produced by C 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. Fkspawn 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 GMsum the outputs of a list of workflows according with its monoid definition @ sumUp timeout actions = vote timeout actions (return . mconcat) >?@ABCDEFG CDEFG>BA@? >BA@??@ABCDEFG Ha queue reference ćçčéęëěíîIJcheck if the queue is empty KL;get the reference to new or existing queue trough its name M+empty the queue (factually, it is deleted) Nversion in the STM monad O9read the first element in the queue and delete it (pop)  Queue name the returned elems ďPversion in the STM monad Q Queue name the returned elems Rpush an element in the queue Sversion in the STM monad TJreturn the list of all elements in the queue. The queue remains unchanged Uversion in the STM monad V=return the first element in the queue that has the given key Wversion in the STM monad đKupdate the first element of the queue with a new element with the same key ńversion in the STM monad X:return the list of all elements in the queue and empty it Ya version in the STM monad ZNdelete all the elements of the queue that has the key of the parameter passed [verison in the STM monad HIJKLMNOPQRSTUVWXYZ[HLOPQMNTURSVWXYZ[IJKHIJKLMNOPQRSTUVWXYZ[ \a queue reference ňóôőö÷řůú]^check if the queue is empty _`;get the reference to new or existing queue trough its name a+empty the queue (factually, it is deleted) bversion in the STM monad c9read the first element in the queue and delete it (pop)  Queue name the returned elems űdversion in the STM monad e Queue name the returned elems fpush an element in the queue gversion in the STM monad hJreturn the list of all elements in the queue. The queue remains unchanged iversion in the STM monad j=return the first element in the queue that has the given key kversion in the STM monad üKupdate the first element of the queue with a new element with the same key ýversion in the STM monad l:return the list of all elements in the queue and empty it ma version in the STM monad nNdelete all the elements of the queue that has the key of the parameter passed overison in the STM monad \]^_`abcdefghijklmno\`cdeabhifgjklmno]^_\]^_`abcdefghijklmno 8p.return conditions from the invocation of start/restart primitives qrstumadapted 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. vGeneralized version of Ď wGeneralized version of Đ xGeneralized version of Ń ygPMonadTrans 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 z{|}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 $ action~Generalized 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 ‰start or continue a workflow from a list of workflows in the IO monad with exception handling. The excepton is returned as a Left value &name of workflow in the workflow list Hinitial value (ever use the initial value even to restart the workflow) function to execute 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  ‘TReturn the reference to the last logged result , usually, the last result stored by ƒ. > wiorkflow references can be accessed 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 pqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š8|{yzuvwx~…‚€†ptsrqƒ„}‘“’”•ˆ‰Š—˜š™–‹ŒŽ‡  +ptsrqqrstuvwxvwxyzz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š ›œžŸ   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:;<=>?@ABCDEFGHIJKLMNOPQNRSTUVWXYZ[\]^_`abcdefghijWXYZ[\]^_`abcdefghij !"#$%&'()*+,-./012356789;<=>?BDEFGHIJKLMNOPQNRSTUVklmnopqrstuvwxyz{|}~  € €  ‚ ƒ „ … † ‡ ˆ ˆ ‰ Š ‹ Œ  Ž Ž  ‘’$‘“%‘“&‘“”•–—˜™ š› šœ šžŸ ‘Ą˘Ł¤ĽŚ§§¨ŠŞŤŹ­­ŽŻ°ą˛łŠŞŤŹ­­ŽŻ°ą˛ł•–—˜™4žŸ Ł¤ĽŚ§§¨´Workflow-0.5.8.1Control.Workflow.TextControl.Workflow.BinaryControl.Workflow.Text.PatternsData.Persistent.Queue.TextData.Persistent.Queue.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 stepControlstartstartWFrestartWorkflows syncWritegetAll getWFKeys getWFHistory waitWFActive killThreadWF killThreadWF1killWFkillWF1delWF delWFHistory delWFHistory1delWF1clearRunningFlaggetWFRef 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