_r      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqNone#TReturn the unique name of a workflow with a parameter (executed with exec or start) +Qshow the state changes along the workflow, that is, all the intermediate results rdefault instances (  !"#$%&'()*+,-srtuvw$  !"#$%&xy'()*+,-" !"# $%&'()*+,-    !"#$%&'()*+,-srtuvwNone+..Return conditions from the invocation of start/restart primitives 5Adapted from the MonadCatchIO-mtlm package. However, in this case it is needed to express serializable constraints about the returned values, Jso the usual class definitions for lifting IO functions are not suitable. 6Generalized version of z 7Generalized version of { 8Generalized version of | 9 PMonadTrans\ 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: D $ unsafeIOtoWF... iTo perform IO actions in a workflow that encapsulates an IO monad, use step over the IO action directly:   D $ action instead of  D $ 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*A version of exec with no seed parameter. B5Start or continue a workflow with exception handling ; the workflow flags are updated even in case of exception  WFerrors are raised as exceptions C>executes 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. W 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. DsLifts a monadic computation to the WF monad, and provides transparent state loging and resuming the computation a Note: Side effect can be repeated at recovery time if the log was not complete before shut down * see the integer sequence example, above. GTTrue if the workflow in recovery mode, reading the log to recover the process state ~For debugging purposes. F At recovery time, instead of returning the stored value from the log & , stepDebug executes the computation f as normally. ; . It permits the exact re-execution of a workflow process H Start or continue a workflow .  . and exceptions are returned as Left err. (even if they were triggered as exceptions). " Other exceptions are returned as Left (Exception e)  use U or V$ in case of error to clear the log. KQStart or continue a workflow from a list of workflows with exception handling.  see H0 for details about exception and error handling LlRe-start the non finished workflows in the list, for all the initial values that they may have been invoked MAReturn all the steps of the workflow log. The values are dynamic /to get all the steps with result of type Int:  all <- M  let lfacts = mapMaybe  all :: [Int] NGReturn the keys of the workflows that are running with a given prefix O=Return the current state of the computation, in the IO monad P"Delete the history of a workflow. $ Be sure that this WF has finished. R%wait until the workflow is restarted S<Kill the executing thread if not killed, but not its state.  B H or L will continue the workflow T A version of  KillThreadWF+ for workflows started wit no parameter by A U;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. =When the workflow has been called with no parameter, use: () V[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: () X>Log a value in the workflow log and return a reference to it.  newWFRef x= Y (return x) >>= return . fstYPExecute an step and return a reference to the result besides the result itself Z\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.  Why would you use this?. Don'=t do that!. modifiying the content of the workflow log would e change the excution flow when the workflow restarts. This metod is used internally in the package. Q The best way to communicate with a workflow is trough a persistent queue, using Data.Persistent.Collection: worflow= exec1 wf do  r <- Y expr  push "queue" r  back <- pop " queueback"  ... \VMoves 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 one ]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 longer work 4 inside the wokflow, it can be used by lifting it :  do  x < - step $ ..  y <- step $ waitForData ...  .. ^3Observe the workflow log until a condition is met. `9Start the timeout and return the flag to be monitored by a l This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag j 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. aVWait 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 <- D4 . atomically $ readSomewhere >>= return . Just  a 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 a bOReturn either the result of the STM conputation or Nothing in case of timeout.  The computation can retry l This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag j 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. c<Executes a computation understanding that it is inside the  workflow identified by . If f finish after time  it genetates a 0> exception which may result in the end of the workflow if the  programmer does not catch it. $ If the workflow is restarted after time2 has elapsed, the workflow V will restart from the beginning. If not, it will restart after the last logged step. Usually  time2> time time2=0 means time2 is infinite PwithKillTimeout :: 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 b 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) a writeDBRef ref s{lastActive= tnow,timeout= Just (time2 - fromIntegral (tnow - tstart))}  clearRunningFlag id  let proc= do  twatchdog <- liftIO $ case time of ' 0 -> return tid Y _ -> forkIO $ threadDelay (time * 1000000) >> throwTo tid Timeout  r <- f $ liftIO $ killThread twatchdog  return r proc  final 8An instance of MonadTrans is an instance of PMonadTrans  plift= stepU./0123456789:;<=>?@ABCDEFG~H#name that identifies the workflow. workflow to execute Ginitial value (ever use the initial value for restarting the workflow) result of the computation IJK&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 LMNOPQRSTUVWXYZ[\]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 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 ^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 'The INITIAL value used in the workflow (The first event that meet the condition `abcF #+./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcF<;9:567834> #HB@AC?KL.210/DEF= XYZ[\RMNO^_a`bc]WSUVTPQ+GJIH.210/3456789:;<=>?@ABCDEFG~HIJKLMNOPQRSTUVWXYZ[\]^_`abcNonedCto execute a computation every time it is invoked. A synonimous of = eDto execute one computation once . It executes at the first run only fexecutes a computation with e and d statements  a synonym of C defdefedfdefNone h=Select this output, kill all and return the selected outputs i>Discard this output, kill all and return the selected outputs jContinue the source process kDiscard the source output lselect the source output m%spawn a list of independent workflow actions with a seed value a  The results are reduced by n or o nYwait for the results and apply the cond to produce a single output in the Workflow monad o0select the outputs of the workflows produced by m 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 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. fThis is necessary for the modelization of real-life institutional cycles such are political elections " A timeout of 0 means no timeout. pEspawn 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 qMsum the outputs of a list of workflows according with its monoid definition @ sumUp timeout actions = vote timeout actions (return . mconcat)ghijklmnopq ghijklmnopq mnopqglkjihglkjihmnopq      !!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqmrstuvwxyz{|}~<=>Workflow-0.8.0.8Control.WorkflowControl.Workflow.StatControl.Workflow.ConfigurationControl.Workflow.PatternsTCache-0.10.2.4Data.Persistent.IDynamic safeFromIDyn Data.TCache syncWrite Synchronous cacheSizecheck frecuency Asyncronous SyncManualSyncModeData.TCache.DefsdefPathkey IndexableWFRefStatselfwfNamestaterecovertimeout lastActivecontext referencesversionsRunningWFststat0 statPrefix1 statPrefixheader getHeaderlenLenkeyWF pathWFlowsstFNamefrsafe hReadFile readHeader keyRunning showHistoryshowp1wFRefStrWFErrors WFExceptionTimeoutAlreadyRunningNotFoundHasForkfork MonadCatchIOcatchblockunblock PMonadTransplift WorkflowListWorkflow unsafeIOtoWFthrowwfExecexec1dexec1execexec1ncstep getWFStatstepExec isInRecoverstartgetStaterunWF1startWFrestartWorkflowsgetAll getWFKeys getWFHistory delWFHistory delWFHistory1 waitWFActive killThreadWF killThreadWF1killWFdelWFclearRunningFlagnewWFRef stepWFRef readWFRef writeWFRef moveStatelogWFwaitFor waitForSTMgetTimeoutFlag waitUntilSTM withTimeoutwithKillTimeouteveroncerunConfigurationSelect FinishSelect FinishDiscardContinueDiscardsplitmergeselectvotesumUp $fSerializea$fSerializeWFRef$fSerializeThreadId$fIResourceStat$fIndexableWFRef$fSerializeStatfwfdbaseControl.Exception.BaseGHC.IOthrowIO stepDebug waitForData GHC.Conc.SyncorElse waitUntilGHC.Baseid onNothing!MonadCatchIO-transformers-0.3.0.0Control.Monad.CatchIOfinally$fPMonadTranstma$fPMonadTransWFmaWFInfonamefinishedhaserror tvRunningWfsmv getTempName stepExec1runWF killThreadWFmkillWF1delWF1justifyMwaitForDataSTMgetTimeSecondswaittransientTimeout$fExceptionWFErrors $fHasForkWF $fHasForkIO$fMonadCatchIOWFa $fMonadIOWF$fApplicativeWF $fFunctorWF $fMonadWFActionWF readWFRef1justifymainfmain2main3$fExceptionSelect