Skip to main content

Sequencing Operations

Sequencing operations form the backbone of workflow composition, allowing you to define the order in which steps are executed. These operations enable you to build complex workflows by combining simpler ones, ensuring that each step completes before the next begins.

Declarative

Declarative sequencing provides a straightforward way to chain operations when selecting the next step doesn't depend on the result of the previous one. Step inputs and outputs are fully typechecked.

val step1 = WIO.pure(MyState(1)).autoNamed
val step2 = WIO.pure(MyState(2)).autoNamed
val step3 = WIO.pure(MyState(3)).autoNamed

val sequence1 = step1 >>> step2 >>> step3
val sequence2 = step1.andThen(step2).andThen(step3)
Rendering Outputs

Dynamic

Dynamic sequencing is more powerful, allowing the next workflow step to be determined based on the result of the previous step. This enables conditional branching and data-dependent workflow paths.

warning

Dynamic steps cannot be rendered statically. Consider using Forks instead.

val step1 = WIO.pure(MyState(1)).autoNamed
val step2 = WIO.pure(MyState(2)).autoNamed
val step3 = WIO.pure(MyState(3)).autoNamed

val sequence1 = for {
a <- step1
b <- step2
c <- step3
} yield c
val sequence2 = step1.flatMap(_ => step2).flatMap(_ => step3)
Rendering Outputs