ʝx      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwNone +246:FM#SReturn the unique name of a workflow with a parameter (executed with exec or start)+Pshow the state changes along the workflow, that is, all the intermediate results/default instances(  !"#$%&'()*+,-./0123$  !"#$%&xy'()*+,-( !"3# 2$%&1'()*0+,-/.    !"#$%&'()*+,-./0123None+2346:M+4AReturn conditions from the invocation of start/restart primitives;Adapted from the MonadCatchIO-mtl package. However, in this case it is needed to express serializable constraints about the returned values, so the usual class definitions for lifting IO functions are not suitable.<Generalized version of z=Generalized version of >Generalized version of ? PMonadTransS permits |to define a partial monad transformer. They are not defined for all kinds of data but the ones that have instances of certain classes.That is because in the lift instance code there are some hidden use of these classes. This also may permit an accurate control of effects. An instance of MonadTrans is an instance of PMonadTransCCExecutes a computation inside of the workflow monad whatever the monad encapsulated in the workflow. 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: J $ unsafeIOtoWF...hTo perform IO actions in a workflow that encapsulates an IO monad, use step over the IO action directly:  J $ action instead of  J $ unsafeIOtoWF $ actionDGeneralized version of {EStart or restart an anonymous workflow inside another workflow. Its state is deleted when finished and the result is stored in the parent's WF state.FSA version of exec1 that deletes its state after complete execution or thread killedG)A version of exec with no seed parameter.HrStart or continue a workflow with exception handling the workflow flags are updated even in case of exception WFerrors are raised as exceptionsIBexecutes a workflow, but does not mark it as finished even if the process ended. It this case, the workflow just will return the last result. If the workflow was gathering data from user questions for a configuration, then this primitive will store them in the log the first time, and can be retrieve it the next time.JLifts a monadic computation to the WF monad, and provides transparent state loging and resuming the computation Note: Side effect can be repeated at recovery time if the log was not complete before shut down see the integer sequence example, above.MSTrue if the workflow in recovery mode, reading the log to recover the process state|For debugging purposes. At recovery time, instead of returning the stored value from the log , stepDebug executes the computation fH as normally. . It permits the exact re-execution of a workflow processN"Start or continue a workflow . 4 and exceptions are returned as Left errP (even if they were triggered as exceptions). Other exceptions are returned as Left (Exception e) use [ or \# in case of error to clear the log.QWStart or continue a workflow from a list of workflows with exception handling. see N/ for details about exception and error handlingR#Re-start the non finished workflows in the list, for all the initial values that they may have been invoked. The list contain he identifiers of the workflows and the procedures to be called. All the workflows initiated with exec* or start* will be restarted with all possible seed values.S@Return all the steps of the workflow log. The values are dynamic1to get all the steps with result of type Int: all <- S let lfacts = mapMaybe  all :: [Int]TFReturn the keys of the workflows that are running with a given prefixU<Return the current state of the computation, in the IO monadVEDelete the history of a workflow. Be sure that this WF has finished.X$wait until the workflow is restartedY=Kill the executing thread if not killed, but not its state. H N or R will continue the workflowZ A version of  KillThreadWF+ for workflows started wit no parameter by G[Kill the process (if running) and drop it from the list of restart-able workflows. Its state history remains , so it can be inspected with  getWfHistory + and so on.<When the workflow has been called with no parameter, use: ()\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.<When the workflow has been called with no parameter, use: ()^=Log a value in the workflow log and return a reference to it.  newWFRef x= _ (return x) >>= return . fst_OExecute an step and return a reference to the result besides the result itself`[Read the content of a Workflow reference. Note that its result is not in the Workflow monadaaWrites a new value en in the workflow reference, that is, in the workflow log. Why would you use this?. Don't do that!. modifiying the content of the workflow log would change the excution flow when the workflow restarts. This metod is used internally in the package. The best way to communicate with a workflow is trough a persistent queue, using Data.Persistent.Collection: %worflow= exec1 "wf" do r <- _ expr push "queue" r back <- pop "queueback" ... bMoves the state of workflow with a seed value to become the state of other seed value This may be of interest when the entry value changes its key value but should not initiate a new workflow but continues with the current onecALog a message in the workflow history. I can be printed out with +3 The message is printed in the standard output too}mWait 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 longer work inside the wokflow, it can be used by lifting it : do x <- step $ .. y <- step $ waitForData ... ..d2Observe the workflow log until a condition is met.f9Start the timeout and return the flag to be monitored by g6 This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag no matter if the workflow is restarted. The time during which the worlkflow has been stopped count also. Thus, the wait time can exceed the time between failures. when timeout is 0 means no timeout.gWait until a certain clock time has passed by monitoring its flag, in the STM monad. This permits to compose timeouts with locks waiting for data using ~hexample: wait for any respoinse from a Queue if no response is given in 5 minutes, it is returned True.  flag <- f $ 5 * 60 ap <- J4 . atomically $ readSomewhere >>= return . Just ~ g; flag >> return Nothing case ap of Nothing -> do c# "timeout" ... Just x -> do c $ "received" ++ show x ... ZWait until a certain clock time has passed by monitoring its flag, in the IO monad. See ghReturn either the result of the STM conputation or Nothing in case of timeout. The computation can retry This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag no matter if the workflow is restarted. The time during which the worlkflow has been stopped count also. Thus, the wait time can exceed the time between failures. when timeout is 0 it means no timeout.iUExecutes a computation understanding that it is inside the workflow identified by . If f finish after time it genetates a 6 exception which may result in the end of the workflow if the programmer does not catch it. If the workflow is restarted after time2p has elapsed, the workflow will restart from the beginning. If not, it will restart after the last logged step.Usually  time2> timetime2=0 means time2 is infinite withKillTimeout :: CMC.MonadCatchIO m => String -> Int -> Integer -> m a -> m a withKillTimeout id time time2 f = do tid <- liftIO myThreadId tstart <- liftIO getTimeSeconds let final= liftIO $ do tnow <- getTimeSeconds let ref = getDBRef $ keyResource $ stat0{wfName=id} -- !> (keyResource $ stat0{wfName=id} ) when (time2 /=0) . atomically $ do s <- readDBRef ref  error ( "withKillTimeout: Workflow not found: "++ id) writeDBRef ref s{lastActive= tnow,timeout= Just (time2 - fromIntegral (tnow - tstart))} clearRunningFlag id let proc= do twatchdog <- liftIO $ case time of 0 -> return tid _ -> forkIO $ threadDelay (time * 1000000) >> throwTo tid Timeout r <- f liftIO $ killThread twatchdog return rproc  final7An instance of MonadTrans is an instance of PMonadTrans  plift= stepT456789:;<=>?@ABCDEFGHIJKLM|N"name that identifies the workflow.workflow to executeFinitial value (ever use the initial value for restarting the workflow)result of the computationOPQ%Name of workflow in the workflow listGInitial value (ever use the initial value even to restart the workflow)function to executeResult of the computationRSTUVWXYZ[\]^_`abc}1The condition that the retrieved object must meetAa partially defined object for which keyResource can be extractedIreturn the retrieved object that meet the condition and has the given key1The condition that the retrieved object must meetAa partially defined object for which keyResource can be extractedIreturn the retrieved object that meet the condition and has the given keyd1The condition that the retrieved object must meetThe workflow name2the INITIAL value used in the workflow to start it'The first event that meet the conditione1The condition that the retrieved object must meetThe workflow name&The INITIAL value used in the workflow'The first event that meet the conditionfghiF #+456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiFBA?@;<=>9:D #NHFGIEQR48765JKLC ^_`abXSTUdegfhic]Y[\ZVW+MPOG487659:;<=>?@ABCDEFGHIJKLM|NOPQRSTUVWXYZ[\]^_`abc}defghiNone +26:MjCto execute a computation every time it is invoked. A synonimous of CkCto execute one computation once . It executes at the first run onlylexecutes a computation with k and j statements a synonym of IjkljklkjljklNone +2346:M n<Select this output, kill all and return the selected outputso=Discard this output, kill all and return the selected outputspContinue the source processqDiscard the source outputrselect the source outputs%spawn a list of independent workflow actions with a seed value a The results are reduced by t or utXwait for the results and apply the cond to produce a single output in the Workflow monadu0select the outputs of the workflows produced by s constrained within a timeout. The check filter, can select , discard or finish the entire computation before the timeout is reached. When the computation finalizes, it kill all the pending workflows and return the list of selected outputs the timeout is in seconds and it is is in the workflow monad, so it is possible to restart the process if interrupted, so it can proceed for years.This is necessary for the modelization of real-life institutional cycles such are political elections A timeout of 0 means no timeout.vEspawn a list of workflows and reduces the results according with the comp! parameter within a given timeout l vote timeout actions comp x= split actions x >>= select timeout (const $ return Select) >>= comp wLsum the outputs of a list of workflows according with its monoid definition @ sumUp timeout actions = vote timeout actions (return . mconcat)mnopqrstuvw mnopqrstuvw stuvwmrqponmrqponstuvw           !"#$$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxtyz{|}~E Workflow-0.8.3Control.WorkflowControl.Workflow.StatControl.Workflow.ConfigurationControl.Workflow.PatternsEblockunblock TCache-0.12.0Data.Persistent.IDynamic safeFromIDyn Data.TCache syncWrite Synchronous cacheSizecheck frecuency Asyncronous SyncManualSyncModeData.TCache.DefsdefPathkey IndexableWFRefStatselfwfNamestaterecovertimeout lastActivecontext referencesversionsRunningWFststat0 statPrefix1 statPrefixheader getHeaderlenLenkeyWF pathWFlowsstFNamefrsafe hReadFile readHeader keyRunning showHistoryshowp1wFRefStr$fSerializeWFRef $fSerializea$fSerializeThreadId$fIResourceStat$fIndexableWFRef$fSerializeStatWFErrors WFExceptionTimeoutAlreadyRunningNotFoundHasForkfork MonadCatchIOcatch PMonadTransplift WorkflowListWorkflow unsafeIOtoWFthrowwfExecexec1dexec1execexec1ncstep getWFStatstepExec isInRecoverstartgetStaterunWF1startWFrestartWorkflowsgetAll getWFKeys getWFHistory delWFHistory delWFHistory1 waitWFActive killThreadWF killThreadWF1killWFdelWFclearRunningFlagnewWFRef stepWFRef readWFRef writeWFRef moveStatelogWFwaitFor waitForSTMgetTimeoutFlag waitUntilSTM withTimeoutwithKillTimeouteveroncerunConfigurationSelect FinishSelect FinishDiscardContinueDiscardsplitmergeselectvotesumUpfwfdbaseControl.Exception.BaseGHC.IOthrowIO stepDebug waitForData GHC.Conc.SyncorElse waitUntilGHC.Baseid onNothingexceptions-0.8.0.2Control.Monad.Catchfinally$fPMonadTranstma$fPMonadTransWFmaWFInfonamefinishedhaserror tvRunningWfsmv getTempName stepExec1runWF killThreadWFmkillWF1delWF1justifyMwaitForDataSTMgetTimeSecondswaittransientTimeout$fExceptionWFErrors $fHasForkWF $fHasForkIO $fMonadIOWF$fApplicativeWF $fFunctorWF $fMonadWFActionWF readWFRef1justifymainfmain2main3$fExceptionSelect