diff options
author | LuxLang | 2017-03-24 17:02:05 -0400 |
---|---|---|
committer | GitHub | 2017-03-24 17:02:05 -0400 |
commit | 67835905186803efa763b2c107ecadc835ebe0a6 (patch) | |
tree | 626b3240bf1c5131d630358efa57951f157daa2d /stdlib/source/lux/control/comonad.lux | |
parent | 7886f9da86c2b6d3da6ab801d07005d21686c275 (diff) | |
parent | 3ad92cceba0ebd2fa4b6ced5302d4a9290229e43 (diff) |
Merge pull request #29 from LuxLang/js_port
Js port
Diffstat (limited to 'stdlib/source/lux/control/comonad.lux')
-rw-r--r-- | stdlib/source/lux/control/comonad.lux | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index f78ffea17..5ed443040 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -18,6 +18,8 @@ split)) ## [Syntax] +(def: _cursor Cursor ["" +0 +0]) + (macro: #export (be tokens state) {#;doc (doc "A co-monadic parallel to the \"do\" macro." (let [square (lambda [n] (i.* n n))] @@ -26,9 +28,8 @@ (square (head inputs)))))} (case tokens (#;Cons comonad (#;Cons [_ (#;TupleS bindings)] (#;Cons body #;Nil))) - (let [g!@ (: AST [["" -1 -1] (#;SymbolS ["" "@"])]) - g!map (: AST [["" -1 -1] (#;SymbolS ["" " map "])]) - g!split (: AST [["" -1 -1] (#;SymbolS ["" " split "])]) + (let [g!map (: AST [_cursor (#;SymbolS ["" " map "])]) + g!split (: AST [_cursor (#;SymbolS ["" " split "])]) body' (fold (: (-> [AST AST] AST AST) (lambda [binding body'] (let [[var value] binding] @@ -42,8 +43,8 @@ body (reverse (as-pairs bindings)))] (#;Right [state (#;Cons (` (;_lux_case (~ comonad) - (~ g!@) - (;_lux_case (~ g!@) + (~' @) + (;_lux_case (~' @) {#functor {#F;map (~ g!map)} #unwrap (~' unwrap) #split (~ g!split)} (~ body')))) #;Nil)])) |