Next: , Previous: , Up: Top   [Contents][Index]


3 A Simple Workflow

To get a little taste of what the workflow language looks like, let’s start by writing a simple workflow.

Here is a simple workflow example:

process greet
  packages "hello"
  # { hello }

process sleep
  packages "coreutils"
  # {
    echo "Sleeping..."
    sleep 10
  }

process eat (with something)
  name
    string-append "eat-" something
  # {
    echo "Eating {{something}}"
  }

process bye
  # { echo "Farewell, world!" }

workflow simple-wisp
  processes
    let
      :
        eat-fruit : eat "fruit"
        eat-veges : eat "vegetables"
      graph
        eat-fruit -> greet
        eat-veges -> greet
        sleep     -> eat-fruit eat-veges
        bye       -> sleep

This white-space sensitive syntax is called Wisp and if your familiar with Python or YAML you should feel right at home. To use this syntax simply save your workflow to a file ending on .w, .wisp, or .gwl.

The workflow language really is a domain specific language (DSL) embedded in Guile Scheme, so if you’re a Lisper you may prefer to write your workflows directly in Scheme while basking in its parenthetical glow:

(import (gnu packages base))

(define-public greet
  (make-process
   (name "greet")
   (packages (list hello))
   (procedure '(system "hello"))))

(define-public sleep
  (make-process
   (name "sleep")
   (packages (list coreutils))
    (procedure
     '(begin
        (display "Sleeping...\n")
        (system "sleep 10")))))

(define-public (eat something)
  (make-process
   (name (string-append "eat-" something))
   (procedure
    `(format #t "Eating ~a\n" ,something))))

(define-public bye
  (make-process
   (name "bye")
   (procedure
    '(display "Farewell, world!\n"))))

(make-workflow
 (name "simple")
 (processes
  (let ((eat-fruit (eat "fruit"))
        (eat-veges (eat "vegetables")))
    (graph (eat-fruit -> greet)
           (eat-veges -> greet)
           (sleep     -> eat-fruit eat-veges)
           (bye       -> sleep)))))

Everything you can express in Scheme can also be expressed with the Wisp syntax, so the choice is down to personal preference.


Next: , Previous: , Up: Top   [Contents][Index]