about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorArun Isaac2024-03-22 01:29:40 +0000
committerArun Isaac2024-03-22 01:48:25 +0000
commite430937727b881be2b2428ad0f09a32ea0aaf198 (patch)
treef824400ca255da28d25a23b8e4486de7c14b4f0b /doc
parentd005c17106add8bd9ab07eddc30e9cf9b17de544 (diff)
downloadccwl-e430937727b881be2b2428ad0f09a32ea0aaf198.tar.gz
ccwl-e430937727b881be2b2428ad0f09a32ea0aaf198.tar.lz
ccwl-e430937727b881be2b2428ad0f09a32ea0aaf198.zip
ccwl: Implement js-expression.
js-expression corresponds to ExpressionTool in the CWL specification.

* ccwl/ccwl.scm (<js-expression>): New type.
(js-expression): New macro.
(function-inputs, function-outputs, function-object): Support
<js-expression> objects.
(function-input-keys): Mention <js-expression> objects in docstring.
* ccwl/cwl.scm (function->cwl, workflow->cwl-scm): Support
<js-expression> objects.
(command->cwl-scm): Move staging requirements handling to ...
(staging-requirements): ... this new function.
(js-expression->cwl, js-expression->cwl-scm): New functions.
* ccwl/graphviz.scm (function->dot): Support <js-expression> objects.
(command->graph): Abstract to ...
(single-node-workflow->graph): ... this new function.
(js-expression->dot, js-expression->graph): New functions.
* scripts/ccwl (main): Support <js-expression> objects.
* doc/ccwl.skb (Cookbook){Javascript expressions via ExpressionTool}:
New section.
* doc/js-expression-iota.scm: New file.
Diffstat (limited to 'doc')
-rw-r--r--doc/ccwl.skb12
-rw-r--r--doc/js-expression-iota.scm7
2 files changed, 17 insertions, 2 deletions
diff --git a/doc/ccwl.skb b/doc/ccwl.skb
index cb78fd5..23bd798 100644
--- a/doc/ccwl.skb
+++ b/doc/ccwl.skb
@@ -1,5 +1,5 @@
 ;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021, 2023 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021, 2023–2024 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -389,7 +389,15 @@ the external CWL workflow.]
 keys forward to the output. This is what the ,(code [identity])
 construct is for. An example follows.]
          (scheme-source "doc/identity-construct.scm")
-         (image :file "doc/identity-construct.png"))))
+         (image :file "doc/identity-construct.png")))
+    (section :title [Javascript expressions via ExpressionTool]
+             :ident "javascript-expressions-via-expressiontool"
+      (p [ccwl supports CWL's ,(samp "ExpressionTool") using its
+,(code "js-expression") construct. The ,(code "js-expression")
+construct may be invoked from within workflows just like ,(code
+"command") constructs can be. Here's a workflow that uses ,(code
+"js-expression") to construct an array of numbers from 0 to n-1.]
+         (scheme-source "doc/js-expression-iota.scm"))))
 
   (chapter :title [Contributing]
            :ident "chapter-contributing"
diff --git a/doc/js-expression-iota.scm b/doc/js-expression-iota.scm
new file mode 100644
index 0000000..066e4ae
--- /dev/null
+++ b/doc/js-expression-iota.scm
@@ -0,0 +1,7 @@
+(define iota
+  (js-expression #:inputs (n #:type int)
+                 #:expression "$({\"sequence\": Array.from(Array(inputs.n).keys())})"
+                 #:outputs (sequence #:type (array int))))
+
+(workflow ((n #:type int))
+  (iota #:n n))