Threading macros for guile scheme
a438588baf9d — Linus Björnstam default tip 7 months ago
Rename readme.md to README.md so that sourcehut shows it
2cee96da857e — Linus Björnstam 1 year, 4 months ago
the readme was wrong.
a26c33c2875e — Linus Björnstam 1 year, 7 months ago
first commit

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~bjoli/guile-threading-macros
read/write
ssh://hg@hg.sr.ht/~bjoli/guile-threading-macros

#(syntax threading)

This implements a version of the famous clojure threading macros.

#examples

(use-modules (syntax threading))
;; ~> inserts arguments in the leftmost position
(~> 5 (+ 4) (/ 3)) ;; => 3
;; You can also use the placeholders <> and <...>
(~> (list 1 2 3) (cons -1 <>) (+ <...>)) ;; => 5
;; it also supports threading lambdas
((lambda~> (+ 4) (/ 3)) 5) ;; => 3
;; and~> stops the execution if any expression returns #f
(and~> 5 (- <> 1) (= 5) (display <>)) ;; => #f

#Exported procedures

~> left threading

~>> right threading

and~> left threading that stops when any intermediate value is #f

and~>> right threading version of and~>

lambda~> (lambda~> (-) abs) is the same as (lambda (id) (abs (- id)))

(define~> id ... is the same as (define id (lambda~> ...))

#Portability

These are syntax-rules macros, and are as such portable across r(5 6 7)rs-conforming implementations. R6RS implementations might have some issuse using both srfi-26 and (syntax threading) at the same time due to module issues unless you import the <> and <...> bindings from srfi-26 and re-export them.

#License

BSD-style with less restrictions. See the source files for the license text.