Skip to content

Commit

Permalink
Renamed the threading macros after their inspiration
Browse files Browse the repository at this point in the history
Thus demonstrating how you can build the threading macros using the do>
and L/R arrow mini-DSL.
  • Loading branch information
jarcane committed Nov 27, 2015
1 parent 630fc7c commit f58415a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions examples/pipeland.hsy
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#lang heresy

(def fn -> (iv . fns)
(def fn do> (iv . fns)
(for (f in fns with iv)
(carry (f cry))))

(def macro <L (f args ...)
(fn (x)
(f x args ...)))
(f x args ...)))

(def macro R> (f args ...)
(fn (x)
(f args ... x)))
(f args ... x)))

(def macro L-> (iv (f args ...) ...)
(-> iv
(<L f args ...)
...))
(def macro -> (iv (f args ...) ...)
(do> iv
(<L f args ...)
...))

(def macro R-> (iv (f args ...) ...)
(-> iv
(R> f args ...)
...))
(def macro ->> (iv (f args ...) ...)
(do> iv
(R> f args ...)
...))

(-> '(1 2 3 4)
(R> map (fn (x) (* x x)))
(<L left 2)
(R> append '(a b))
(<L append '(a b)))
(do> '(1 2 3 4)
(R> map (fn (x) (* x x)))
(<L left 2)
(R> append '(a b))
(<L append '(a b)))

(L-> '(1 2 3 4)
(left 2)
(append '(a b)))
(-> '(1 2 3 4)
(left 2)
(append '(a b)))

(R-> '(1 2 3 4)
(->> '(1 2 3 4)
(map (fn (x) (* x x)))
(append '(a b)))

0 comments on commit f58415a

Please sign in to comment.