h-inoue / ContextWorkflowForked

A DSL for Interruptible and Compensable Execution

Home Page:https://scastie.scala-lang.org/h-inoue/NF9nSWfLR9S9BwAH0bEI1Q/1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ContextWorkflow

This is an embedded domain specific language for program interruption and compensation.

A simple example is:

import contextworkflow._
import cwutil._

var sum = 0
def add(i:Int):CW[Unit] = {sum += i} /+ {_ => sum -= i}
val add10:CW[Unit] = foreachCW(1 to 10)(add(_))
val ctx:Stream[Context] = Stream(Continue,Continue,Continue,Continue,Abort)
add10.exec(ctx) // sum = 0
add10.exec() // sum = 55

Requirements

  • sbt 0.13

Demos

sbt examples/run

and choose one.

Using ContextWorkflow

CW becomes a monad of scalaz so we can use many constructs introduced in scalaz.

About

A DSL for Interruptible and Compensable Execution

https://scastie.scala-lang.org/h-inoue/NF9nSWfLR9S9BwAH0bEI1Q/1

License:MIT License


Languages

Language:Scala 100.0%