aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/control/pipe.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/control/pipe.lux')
-rw-r--r--stdlib/source/library/lux/control/pipe.lux69
1 files changed, 35 insertions, 34 deletions
diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux
index cac70fe6b..1945eec59 100644
--- a/stdlib/source/library/lux/control/pipe.lux
+++ b/stdlib/source/library/lux/control/pipe.lux
@@ -1,4 +1,5 @@
-(.module: {#.doc "Composable extensions to the piping macros (|> and <|) that enhance them with various abilities."}
+(.module:
+ {#.doc "Composable extensions to the piping macros (|> and <|) that enhance them with various abilities."}
[library
[lux #*
[abstract
@@ -32,15 +33,15 @@
(n.* 3)
(n.+ 4)
(new> 0 [inc]))))}
- (wrap (list (` (|> (~ start) (~+ body))))))
+ (in (list (` (|> (~ start) (~+ body))))))
(syntax: #export (let> binding body prev)
{#.doc (doc "Gives a name to the piped-argument, within the given expression."
(n.= 10
(|> 5
(let> x (n.+ x x)))))}
- (wrap (list (` (let [(~ binding) (~ prev)]
- (~ body))))))
+ (in (list (` (let [(~ binding) (~ prev)]
+ (~ body))))))
(def: _reverse_
(Parser Any)
@@ -59,22 +60,22 @@
[i.odd?] [(i.* +3)]
[(new> -1 [])])))}
(with_gensyms [g!temp]
- (wrap (list (` (let [(~ g!temp) (~ prev)]
- (cond (~+ (do list.monad
- [[test then] branches]
- (list (` (|> (~ g!temp) (~+ test)))
- (` (|> (~ g!temp) (~+ then))))))
- (|> (~ g!temp) (~+ else)))))))))
+ (in (list (` (let [(~ g!temp) (~ prev)]
+ (cond (~+ (do list.monad
+ [[test then] branches]
+ (list (` (|> (~ g!temp) (~+ test)))
+ (` (|> (~ g!temp) (~+ then))))))
+ (|> (~ g!temp) (~+ else)))))))))
(syntax: #export (if> {test body^} {then body^} {else body^} prev)
- (wrap (list (` (cond> [(~+ test)] [(~+ then)]
- [(~+ else)]
- (~ prev))))))
+ (in (list (` (cond> [(~+ test)] [(~+ then)]
+ [(~+ else)]
+ (~ prev))))))
(syntax: #export (when> {test body^} {then body^} prev)
- (wrap (list (` (cond> [(~+ test)] [(~+ then)]
- []
- (~ prev))))))
+ (in (list (` (cond> [(~+ test)] [(~+ then)]
+ []
+ (~ prev))))))
(syntax: #export (loop> {test body^}
{then body^}
@@ -85,10 +86,10 @@
(loop> [(i.< +10)]
[inc])))}
(with_gensyms [g!temp]
- (wrap (list (` (loop [(~ g!temp) (~ prev)]
- (if (|> (~ g!temp) (~+ test))
- ((~' recur) (|> (~ g!temp) (~+ then)))
- (~ g!temp))))))))
+ (in (list (` (loop [(~ g!temp) (~ prev)]
+ (if (|> (~ g!temp) (~+ test))
+ ((~' recur) (|> (~ g!temp) (~+ then)))
+ (~ g!temp))))))))
(syntax: #export (do> monad
{steps (p.some body^)}
@@ -106,13 +107,13 @@
(let [step_bindings (do list.monad
[step (list.reverse prev_steps)]
(list g!temp (` (|> (~ g!temp) (~+ step)))))]
- (wrap (list (` ((~! do) (~ monad)
- [(~' #let) [(~ g!temp) (~ prev)]
- (~+ step_bindings)]
- (|> (~ g!temp) (~+ last_step)))))))
+ (in (list (` ((~! do) (~ monad)
+ [(~' #let) [(~ g!temp) (~ prev)]
+ (~+ step_bindings)]
+ (|> (~ g!temp) (~+ last_step)))))))
_
- (wrap (list prev)))))
+ (in (list prev)))))
(syntax: #export (exec> {body body^}
prev)
@@ -122,9 +123,9 @@
(exec> [.nat %n log!])
(i.* +10)))}
(with_gensyms [g!temp]
- (wrap (list (` (let [(~ g!temp) (~ prev)]
- (exec (|> (~ g!temp) (~+ body))
- (~ g!temp))))))))
+ (in (list (` (let [(~ g!temp) (~ prev)]
+ (exec (|> (~ g!temp) (~+ body))
+ (~ g!temp))))))))
(syntax: #export (tuple> {paths (p.many body^)}
prev)
@@ -136,9 +137,9 @@
[Int/encode]))
"Will become: [+50 +2 '+5']")}
(with_gensyms [g!temp]
- (wrap (list (` (let [(~ g!temp) (~ prev)]
- [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body))))
- paths))]))))))
+ (in (list (` (let [(~ g!temp) (~ prev)]
+ [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body))))
+ paths))]))))))
(syntax: #export (case> {branches (p.many (p.and s.any s.any))}
prev)
@@ -156,6 +157,6 @@
+8 "eight"
+9 "nine"
_ "???")))}
- (wrap (list (` (case (~ prev)
- (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body))
- branches))))))))
+ (in (list (` (case (~ prev)
+ (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body))
+ branches))))))))