diff options
author | Eduardo Julian | 2018-04-05 07:48:25 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-04-05 07:48:25 -0400 |
commit | 435771d3c4d4ffa791805e7006ee3bde488a4090 (patch) | |
tree | 693b9e2a6d8c6ddf4e439336e5bfcd665c9955cd /stdlib/source/lux/control/monad.lux | |
parent | 3de94c8a341ef3f19fd75eeeb98e5333d2fe89d0 (diff) |
- Improved the syntax for the "lux.function" macro.
Diffstat (limited to 'stdlib/source/lux/control/monad.lux')
-rw-r--r-- | stdlib/source/lux/control/monad.lux | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux index fd940ea83..2e4045f3a 100644 --- a/stdlib/source/lux/control/monad.lux +++ b/stdlib/source/lux/control/monad.lux @@ -28,7 +28,7 @@ (def: (reverse xs) (All [a] (-> (List a) (List a))) - (list/fold (function [head tail] (#.Cons head tail)) + (list/fold (function (_ head tail) (#.Cons head tail)) #.Nil xs)) @@ -61,18 +61,19 @@ (case tokens (#.Cons monad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) (if (|> bindings list/size (n/% +2) (n/= +0)) - (let [g!map (: Code [_cursor (#.Symbol ["" " map "])]) + (let [g!_ (: Code [_cursor (#.Symbol ["" " _ "])]) + g!map (: Code [_cursor (#.Symbol ["" " map "])]) g!join (: Code [_cursor (#.Symbol ["" " join "])]) g!apply (: Code [_cursor (#.Symbol ["" " apply "])]) body' (list/fold (: (-> [Code Code] Code Code) - (function [binding body'] + (function (_ binding body') (let [[var value] binding] (case var [_ (#.Tag ["" "let"])] (` (let (~ value) (~ body'))) _ - (` (|> (~ value) ((~ g!map) (function [(~ var)] (~ body'))) (~ g!join))) + (` (|> (~ value) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))) (~ g!join))) )))) body (reverse (as-pairs bindings)))] @@ -139,7 +140,7 @@ {#.doc "Lift a normal function into the space of monads."} (All [M a b] (-> (Monad M) (-> a b) (-> (M a) (M b)))) - (function [ma] + (function (_ ma) (do Monad<M> [a ma] (wrap (f a))))) @@ -179,7 +180,7 @@ [(#Effect ff) _] (#Effect (:: dsl map - (function [f] (apply f ea)) + (function (_ f) (apply f ea)) ff)) ))) |