aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-01-16 01:58:58 +0530
committerArun Isaac2022-01-16 12:25:16 +0530
commitfa44bd5c81bf6cbc357abe613e9fdf5c3a0f81dd (patch)
treed6094b28fdebe5fa788fb7edf1a1068b03b3eb84
parent0df4c3586cd9f2000070278a80c0d7aad3b4fac8 (diff)
downloadccwl-fa44bd5c81bf6cbc357abe613e9fdf5c3a0f81dd.tar.gz
ccwl-fa44bd5c81bf6cbc357abe613e9fdf5c3a0f81dd.tar.lz
ccwl-fa44bd5c81bf6cbc357abe613e9fdf5c3a0f81dd.zip
ccwl: Do not expand to syntax values.
Macros should not normally expand to syntax values as constant literals. We now do more work at the macro-expansion phase so that this is not necessary. * ccwl/ccwl.scm (collect-steps): In the returned <step> objects, put syntax to reference function object instead of the function object itself. (key->output): Return syntax to construct an <output> object instead of the <output> object itself. (workflow): Do not expand to syntax values as constant literals.
-rw-r--r--ccwl/ccwl.scm54
1 files changed, 32 insertions, 22 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index b6a2920..903f161 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -405,7 +405,7 @@ represented by <step> objects."
(key (output-id output) step-id))
(function-outputs function-object)))
(list (make-step step-id
- function-object
+ #'function
(map (match-lambda
((arg . value)
(cons (keyword->symbol arg)
@@ -422,34 +422,44 @@ represented by <step> objects."
(x (error "Unrecognized syntax:" (syntax->datum #'x)))))
(define (key->output key steps)
- "Return the <output> object corresponding to KEY, a <key> object, in
-STEPS, a list of <step> objects. If no such <output> object is found,
-return #f."
+ "Return syntax to construct an <output> object corresponding to KEY,
+a <key> object, in STEPS, a list of <step> objects. If no such
+<output> object is found, return #f."
(and-let* ((step-with-output (find (lambda (step)
(eq? (step-id step)
(key-step key)))
- steps))
- (output (find (lambda (output)
- (eq? (output-id output)
- (key-cwl-id key)))
- (step-out step-with-output))))
- (set-output-source output (cwl-key-address key))))
+ steps)))
+ (with-syntax ((key-cwl-id (datum->syntax #f (key-cwl-id key))))
+ #`(set-output-source (find (lambda (output)
+ (eq? (output-id output)
+ 'key-cwl-id))
+ (function-outputs
+ #,(step-run step-with-output)))
+ #,(cwl-key-address key)))))
(define-syntax workflow
(lambda (x)
(syntax-case x ()
((_ (inputs ...) tree)
- #`(let ((input-objects (list #,@(map input #'(inputs ...))))
- (output-keys steps (collect-steps #'tree (map (compose key input-spec-id)
- #'(inputs ...)))))
- ;; TODO: Error out on duplicated step IDs.
- ;; TODO: Implement escape hatch #:other in workflow syntax.
- (make-workflow steps
- input-objects
- ;; Find the output object for each output
- ;; key. Filter out global workflow inputs.
- (filter-map (cut key->output <> steps)
- output-keys)
- '())))
+ (let ((output-keys steps (collect-steps
+ #'tree (map (compose key input-spec-id)
+ #'(inputs ...)))))
+ ;; TODO: Error out on duplicated step IDs.
+ ;; TODO: Implement escape hatch #:other in workflow syntax.
+ #`(make-workflow
+ (list #,@(map (lambda (step)
+ #`(make-step
+ #,(with-syntax ((id (datum->syntax #f (step-id step))))
+ #''id)
+ #,(step-run step)
+ #,(with-syntax ((in (datum->syntax #f (step-in step))))
+ #''in)))
+ steps))
+ (list #,@(map input #'(inputs ...)))
+ ;; Find the output object for each output
+ ;; key. Filter out global workflow inputs.
+ (list #,@(filter-map (cut key->output <> steps)
+ output-keys))
+ '())))
(x (error "Unrecognized workflow syntax [expected (workflow (input ...) tree)]:"
(syntax->datum #'x))))))