usage.org 1.2 KB

The hygienic syntax rules macro for threading / pipeline / chain allows for leaving out the threaded argument in function calls. pipe-left is used as follows:

(define-syntax -> (syntax-rules () [(-> exp) exp] [(-> exp ... (op args ...)) (op (-> exp ...) args ...)]))

(simple-format (current-output-port) "~s\n" (-> 123 (* 2) (- 6) (/ 4) (number->string)))

:results: "60" While executing meta-command: Wrong type to apply: # scheme@(guile-user)> :end:

As one can see each function call in the macro call is missing the threaded argument. It will be put in the left-most position automatically by the macro, which rewrites the function calles into valid calls.