aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-12-01 22:34:03 +0000
committerArun Isaac2023-12-01 22:35:23 +0000
commit770b738fe62112fc16c5213bd5769a8a54074fc7 (patch)
treea704111e059737002c3c6a558ffc3449382e7fa0
parented207cdbdace951595a18548b77bc38fb3f1c6ef (diff)
downloadccwl-770b738fe62112fc16c5213bd5769a8a54074fc7.tar.gz
ccwl-770b738fe62112fc16c5213bd5769a8a54074fc7.tar.lz
ccwl-770b738fe62112fc16c5213bd5769a8a54074fc7.zip
ccwl: Implement identity construct.
* ccwl/ccwl.scm (collect-steps): Implement identity construct. * doc/ccwl.skb (Cookbook)[The identity construct]: New section. * doc/identity-construct.scm: New file.
-rw-r--r--ccwl/ccwl.scm4
-rw-r--r--doc/ccwl.skb9
-rw-r--r--doc/identity-construct.scm14
3 files changed, 25 insertions, 2 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index d00609d..bbc5de1 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -625,7 +625,7 @@ supplied input keys."
output keys and a list of steps. INPUT-KEYS is a list of supplied
input keys. Keys are represented by <key> objects, and steps are
represented by <step> objects."
- (syntax-case x (pipe tee rename scatter scatter-cross scatter-nested-cross)
+ (syntax-case x (pipe tee identity rename scatter scatter-cross scatter-nested-cross)
;; pipe
((pipe expressions ...)
(foldn (lambda (expression input-keys steps)
@@ -638,6 +638,8 @@ represented by <step> objects."
((tee expressions ...)
(append-mapn (cut collect-steps <> input-keys)
#'(expressions ...)))
+ ((identity)
+ (values input-keys (list)))
;; rename keys (base case)
((rename new-key old-key)
(begin
diff --git a/doc/ccwl.skb b/doc/ccwl.skb
index 726b405..cb78fd5 100644
--- a/doc/ccwl.skb
+++ b/doc/ccwl.skb
@@ -382,7 +382,14 @@ the external CWL workflow.]
(scheme-source "doc/external-cwl-workflow.scm")
[,(file "echo.cwl") is defined as]
;; TODO: Syntax highlight doc/external-cwl-workflow.cwl.
- (prog :line #f (source :file "doc/echo.cwl")))))
+ (prog :line #f (source :file "doc/echo.cwl"))))
+ (section :title [The ,(code [identity]) construct]
+ :ident "identity-construct"
+ (p [Sometimes, it is helpful for a step to simply copy all input
+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"))))
(chapter :title [Contributing]
:ident "chapter-contributing"
diff --git a/doc/identity-construct.scm b/doc/identity-construct.scm
new file mode 100644
index 0000000..626568f
--- /dev/null
+++ b/doc/identity-construct.scm
@@ -0,0 +1,14 @@
+(define print-message
+ (command #:inputs (message #:type string)
+ #:run "echo" message
+ #:outputs (printed-message #:type stdout)))
+
+(define print-file
+ (command #:inputs (file #:type File)
+ #:run "cat" file
+ #:outputs (printed-file #:type stdout)))
+
+(workflow ((message #:type string))
+ (pipe (print-message #:message message)
+ (tee (print-file #:file printed-message)
+ (identity))))