From 435771d3c4d4ffa791805e7006ee3bde488a4090 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Apr 2018 07:48:25 -0400 Subject: - Improved the syntax for the "lux.function" macro. --- stdlib/source/lux.lux | 204 +++++++++++----------- stdlib/source/lux/cli.lux | 12 +- stdlib/source/lux/concurrency/actor.lux | 20 ++- stdlib/source/lux/concurrency/frp.lux | 6 +- stdlib/source/lux/concurrency/promise.lux | 16 +- stdlib/source/lux/concurrency/stm.lux | 24 +-- stdlib/source/lux/concurrency/task.lux | 2 +- stdlib/source/lux/control/comonad.lux | 9 +- stdlib/source/lux/control/concatenative.lux | 54 +++--- stdlib/source/lux/control/cont.lux | 30 ++-- stdlib/source/lux/control/exception.lux | 2 +- stdlib/source/lux/control/monad.lux | 13 +- stdlib/source/lux/control/monad/indexed.lux | 6 +- stdlib/source/lux/control/parser.lux | 32 ++-- stdlib/source/lux/control/pipe.lux | 6 +- stdlib/source/lux/control/predicate.lux | 4 +- stdlib/source/lux/control/reader.lux | 12 +- stdlib/source/lux/control/region.lux | 24 +-- stdlib/source/lux/control/state.lux | 30 ++-- stdlib/source/lux/control/thread.lux | 18 +- stdlib/source/lux/control/writer.lux | 6 +- stdlib/source/lux/data/coll/array.lux | 14 +- stdlib/source/lux/data/coll/bits.lux | 2 +- stdlib/source/lux/data/coll/dict.lux | 24 +-- stdlib/source/lux/data/coll/list.lux | 22 +-- stdlib/source/lux/data/coll/ordered/dict.lux | 2 +- stdlib/source/lux/data/coll/sequence.lux | 15 +- stdlib/source/lux/data/coll/set.lux | 2 +- stdlib/source/lux/data/coll/stream.lux | 2 +- stdlib/source/lux/data/coll/tree/parser.lux | 4 +- stdlib/source/lux/data/coll/tree/rose.lux | 2 +- stdlib/source/lux/data/coll/tree/zipper.lux | 41 +++-- stdlib/source/lux/data/color.lux | 6 +- stdlib/source/lux/data/format/context.lux | 2 +- stdlib/source/lux/data/format/css.lux | 6 +- stdlib/source/lux/data/format/html.lux | 2 +- stdlib/source/lux/data/format/json.lux | 20 +-- stdlib/source/lux/data/format/xml.lux | 14 +- stdlib/source/lux/data/lazy.lux | 4 +- stdlib/source/lux/data/number/complex.lux | 2 +- stdlib/source/lux/data/product.lux | 8 +- stdlib/source/lux/data/store.lux | 4 +- stdlib/source/lux/data/sum.lux | 4 +- stdlib/source/lux/data/text/format.lux | 2 +- stdlib/source/lux/data/text/lexer.lux | 24 +-- stdlib/source/lux/data/text/regex.lux | 8 +- stdlib/source/lux/data/trace.lux | 4 +- stdlib/source/lux/function.lux | 4 +- stdlib/source/lux/host.js.lux | 2 +- stdlib/source/lux/host.jvm.lux | 29 +-- stdlib/source/lux/lang/syntax.lux | 4 +- stdlib/source/lux/lang/type.lux | 4 +- stdlib/source/lux/lang/type/check.lux | 54 +++--- stdlib/source/lux/macro.lux | 58 +++--- stdlib/source/lux/macro/code.lux | 8 +- stdlib/source/lux/macro/poly.lux | 16 +- stdlib/source/lux/macro/poly/eq.lux | 29 +-- stdlib/source/lux/macro/poly/functor.lux | 21 +-- stdlib/source/lux/macro/poly/json.lux | 52 +++--- stdlib/source/lux/macro/syntax.lux | 24 +-- stdlib/source/lux/math.lux | 6 +- stdlib/source/lux/math/constructive.lux | 7 +- stdlib/source/lux/math/logic/fuzzy.lux | 22 +-- stdlib/source/lux/math/modular.lux | 2 +- stdlib/source/lux/math/random.lux | 26 +-- stdlib/source/lux/test.lux | 12 +- stdlib/source/lux/time/duration.lux | 2 +- stdlib/source/lux/time/instant.lux | 4 +- stdlib/source/lux/type/abstract.lux | 8 +- stdlib/source/lux/type/implicit.lux | 16 +- stdlib/source/lux/type/object/interface.lux | 10 +- stdlib/source/lux/type/object/protocol.lux | 4 +- stdlib/source/lux/type/refinement.lux | 4 +- stdlib/source/lux/type/resource.lux | 22 +-- stdlib/source/lux/type/unit.lux | 4 +- stdlib/source/lux/world/net/tcp.jvm.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 2 +- stdlib/test/test/lux/concurrency/semaphore.lux | 4 +- stdlib/test/test/lux/concurrency/stm.lux | 6 +- stdlib/test/test/lux/control/cont.lux | 6 +- stdlib/test/test/lux/control/exception.lux | 6 +- stdlib/test/test/lux/control/region.lux | 6 +- stdlib/test/test/lux/data/coll/array.lux | 4 +- stdlib/test/test/lux/data/coll/dict.lux | 16 +- stdlib/test/test/lux/data/coll/list.lux | 25 +-- stdlib/test/test/lux/data/coll/ordered/dict.lux | 6 +- stdlib/test/test/lux/data/coll/priority-queue.lux | 2 +- stdlib/test/test/lux/data/coll/stream.lux | 2 +- stdlib/test/test/lux/data/coll/tree/rose.lux | 4 +- stdlib/test/test/lux/data/coll/tree/zipper.lux | 2 +- stdlib/test/test/lux/data/color.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 9 +- stdlib/test/test/lux/data/format/xml.lux | 2 +- stdlib/test/test/lux/data/number.lux | 30 ++-- stdlib/test/test/lux/data/sum.lux | 8 +- stdlib/test/test/lux/data/text/lexer.lux | 4 +- stdlib/test/test/lux/lang/syntax.lux | 10 +- stdlib/test/test/lux/lang/type.lux | 8 +- stdlib/test/test/lux/lang/type/check.lux | 6 +- stdlib/test/test/lux/macro/poly/eq.lux | 2 +- stdlib/test/test/lux/math/modular.lux | 4 +- stdlib/test/test/lux/type/object/protocol.lux | 2 +- stdlib/test/test/lux/world/net/tcp.lux | 2 +- 103 files changed, 725 insertions(+), 685 deletions(-) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index ec9ac013e..10e188769 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2003,7 +2003,7 @@ (text$ "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms. ## All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used. (` (def: (~ name) - (function [(~+ args)] + (function ((~' _) (~+ args)) (~ body))))")]) ("lux case" tokens {(#Cons template #Nil) @@ -2021,7 +2021,7 @@ (list [(tag$ ["lux" "doc"]) (text$ "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms. (`' (def: (~ name) - (function [(~+ args)] + (function (_ (~+ args)) (~ body))))")]) ("lux case" tokens {(#Cons template #Nil) @@ -3034,23 +3034,20 @@ (text$ "## Syntax for creating functions. ## Allows for giving the function itself a name, for the sake of recursion. (: (All [a b] (-> a b a)) - (function [x y] x)) + (function (_ x y) x)) (: (All [a b] (-> a b a)) - (function const [x y] x))")]) - (case (: (Maybe [Ident Code (List Code) Code]) + (function (const x y) x))")]) + (case (: (Maybe [Text Code (List Code) Code]) (case tokens - (^ (list [_ (#Tuple (#Cons head tail))] body)) - (#Some ["" ""] head tail body) - - (^ (list [_ (#Symbol ["" name])] [_ (#Tuple (#Cons head tail))] body)) - (#Some ["" name] head tail body) + (^ (list [_ (#Form (list& [_ (#Symbol ["" name])] head tail))] body)) + (#Some name head tail body) _ #None)) (#Some g!name head tail body) (let [g!blank (symbol$ ["" ""]) - g!name (symbol$ g!name) + g!name (symbol$ ["" g!name]) body+ (list/fold (: (-> Code Code Code) (function' [arg body'] (if (symbol? arg) @@ -3102,7 +3099,7 @@ [_ (#Record kvs)] (|> kvs (list/map (: (-> [Code Code] Code) - (function [[k v]] + (function (_ [k v]) (` [(~ (process-def-meta-value k)) (~ (process-def-meta-value v))])))) untemplate-list @@ -3112,7 +3109,7 @@ (def:' (process-def-meta kvs) (-> (List [Code Code]) Code) (untemplate-list (list/map (: (-> [Code Code] Code) - (function [[k v]] + (function (_ [k v]) (` [(~ (process-def-meta-value k)) (~ (process-def-meta-value v))]))) kvs))) @@ -3125,14 +3122,14 @@ _ (` (#.Cons [[(~ cursor-code) (#.Tag ["lux" "func-args"])] - [(~ cursor-code) (#.Tuple (.list (~+ (list/map (function [arg] + [(~ cursor-code) (#.Tuple (.list (~+ (list/map (function (_ arg) (` [(~ cursor-code) (#.Text (~ (text$ (code-to-text arg))))])) args))))]] (~ meta))))) (def:' (with-type-args args) (-> (List Code) Code) - (` {#.type-args [(~+ (list/map (function [arg] (text$ (code-to-text arg))) + (` {#.type-args [(~+ (list/map (function (_ arg) (text$ (code-to-text arg))) args))]})) (def:' (export^ tokens) @@ -3197,7 +3194,7 @@ body _ - (` (function (~ name) [(~+ args)] (~ body)))) + (` (function ((~ name) (~+ args)) (~ body)))) body (case ?type (#Some type) (` (: (~ type) (~ body))) @@ -3320,7 +3317,7 @@ members (: (Meta (List [Text Code])) (monad/map Monad (: (-> Code (Meta [Text Code])) - (function [token] + (function (_ token) (case token (^ [_ (#Form (list [_ (#Text "lux check")] type [_ (#Symbol ["" name])]))]) (wrap [name type]) @@ -3331,7 +3328,7 @@ #let [[_module _name] name+ def-name (symbol$ name) sig-type (record$ (list/map (: (-> [Text Code] [Code Code]) - (function [[m-name m-type]] + (function (_ [m-name m-type]) [(tag$ ["" m-name]) m-type])) members)) sig-meta (meta-code-merge (` {#.sig? true}) @@ -3368,7 +3365,7 @@ (case (list/reverse tokens) (^ (list& last init)) (return (list (list/fold (: (-> Code Code Code) - (function [pre post] (`