#lang scheme/base
(provide dfl-compose)
(require "dfl.ss"
(for-syntax scheme/base
scheme/match
"../tools/stx.ss" "dfl.ss"))
(define-syntax (dfl-compose stx)
(syntax-case stx ()
((_ formals body ...)
(let-staged ((nodes (dfl-graph formals body ...))) #`(dfl-sequence
formals
#,@(dfl-sort-graph
nodes
(syntax->list #'(body ...))))))))
(define (test)
(define (debug x) (printf "DEBUG: ~x\n" x))
(define (foo x) (add1 x))
(define (bar x y) (* x y))
(dfl-compose ((in1 in2) (out1) (tmp))
(debug (in1) ())
(foo (tmp) (out1))
(bar (in1 in2) (tmp))))