Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
A workflow can be seen as a persistent thread. The workflow monad writes a log that permits to restore the thread at the interrupted point. step is the (partial) monad transformer for the Workflow monad. A workflow is defined by its name and, optionally by the key of the single parameter passed. There primitives for starting workflows also restart the interrupted workflow when it has been in execution previously.

A small example that prints the sequence of integers in the console if you interrupt the program. When restarted again, it will start from the last printed number:

module Main where
import Control.Workflow
import Control.Concurrent(threadDelay)
import System.IO (hFlush,stdout)

mcount n= do step $  do
                       putStr (show n ++ " ")
                       hFlush stdout
                       threadDelay 1000000
             mcount (n+1)
             return () -- to disambiguate the return type

main= exec1  "count"  $ mcount (0 :: Int)
>>> runghc demos\sequence.hs
>0 1 2 3
>CTRL-C Pressed
>>> runghc demos\sequence.hs
>3 4 5 6 7
>CTRL-C Pressed
>>> runghc demos\sequence.hs
>7 8 9 10 11
...

The program restarts at the last saved step.

As you can see, some side effect can be re-executed after recovery if the log is not complete. This may happen after an unexpected shutdown (in this case) or due to an asynchronous log writing policy (see syncWrite).

When the step results are big and complex, use the Data.RefSerialize package to define the (de)serialization instances. Then the log size will be reduced. printWFHistory method will print the structure changes in each step.

If instead of RefSerialize, you use read and show instances, there will be no reduction. But it will still work, and the log will be readable for debugging purposes. The RefSerialize instance is automatically derived from Read, Show instances.

Data.Binary instances are also fine for serialization. To use Binary, just define a binary instance of your data by using showpBinary and readpBinary.

Within the RefSerialize instance of a structure, you can freely mix Show, Read, RefSerialize and Data Binary instances.

Control.Workflow.Patterns contains higher level workflow patters of multiuser workflows.

Control.Workflow.Configuration permits the use of workflows for configuration purposes.

About

re-startable monad that recover the execution state from a log, and workflow patterns

Resources

License

Releases

No releases published

Packages

No packages published