From 085c9a6ef151531cb01b842ed2f4366a49b78367 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 8 Sep 2021 23:14:59 -0400 Subject: De-bracing | part 2 --- lux-cl/source/program.lux | 4 +- lux-js/source/program.lux | 42 ++++---- lux-lua/source/program.lux | 32 +++--- lux-php/source/program.lux | 4 +- lux-python/source/program.lux | 16 +-- lux-r/source/program.lux | 4 +- lux-ruby/source/program.lux | 8 +- lux-scheme/source/program.lux | 4 +- stdlib/source/documentation/lux.lux | 4 +- .../documentation/lux/control/concatenative.lux | 8 +- stdlib/source/documentation/lux/extension.lux | 4 +- stdlib/source/documentation/lux/type/poly.lux | 45 +-------- stdlib/source/library/lux.lux | 27 +++++- stdlib/source/library/lux/abstract/apply.lux | 4 +- .../source/library/lux/control/concatenative.lux | 84 ++++++++-------- .../library/lux/control/concurrency/atom.lux | 32 +++--- .../library/lux/control/concurrency/thread.lux | 20 ++-- stdlib/source/library/lux/control/thread.lux | 4 +- stdlib/source/library/lux/control/writer.lux | 4 +- stdlib/source/library/lux/data/binary.lux | 44 ++++----- .../source/library/lux/data/collection/array.lux | 24 ++--- stdlib/source/library/lux/data/collection/list.lux | 8 +- stdlib/source/library/lux/data/collection/row.lux | 8 +- .../library/lux/data/collection/tree/zipper.lux | 12 +-- stdlib/source/library/lux/data/text.lux | 16 +-- stdlib/source/library/lux/data/text/buffer.lux | 24 ++--- .../source/library/lux/data/text/encoding/utf8.lux | 12 +-- stdlib/source/library/lux/debug.lux | 14 +-- stdlib/source/library/lux/math.lux | 4 +- stdlib/source/library/lux/program.lux | 4 +- stdlib/source/library/lux/target/jvm/constant.lux | 4 +- stdlib/source/library/lux/target/jvm/loader.lux | 4 +- stdlib/source/library/lux/target/python.lux | 8 +- stdlib/source/library/lux/time/instant.lux | 4 +- .../library/lux/tool/compiler/default/platform.lux | 4 +- .../language/lux/phase/extension/analysis/js.lux | 2 +- .../language/lux/phase/extension/analysis/lua.lux | 6 +- .../language/lux/phase/extension/analysis/php.lux | 6 +- .../lux/phase/extension/analysis/python.lux | 13 ++- .../language/lux/phase/extension/analysis/ruby.lux | 6 +- .../lux/phase/extension/analysis/scheme.lux | 6 +- .../lux/phase/extension/generation/lua/common.lux | 2 +- .../language/lux/phase/generation/lua/runtime.lux | 8 +- .../lux/phase/generation/python/runtime.lux | 2 +- .../language/lux/phase/generation/reference.lux | 8 +- .../lux/tool/compiler/language/lux/syntax.lux | 2 +- stdlib/source/library/lux/type.lux | 3 +- stdlib/source/library/lux/type/check.lux | 3 +- stdlib/source/library/lux/world/console.lux | 4 +- stdlib/source/library/lux/world/file.lux | 4 +- stdlib/source/library/lux/world/file/watch.lux | 4 +- .../source/library/lux/world/net/http/client.lux | 4 +- stdlib/source/library/lux/world/program.lux | 24 ++--- stdlib/source/library/lux/world/shell.lux | 4 +- .../program/aedifex/dependency/resolution.lux | 4 +- stdlib/source/program/compositor.lux | 4 +- stdlib/source/test/lux.lux | 26 ++--- .../source/test/lux/control/concurrency/async.lux | 4 +- .../test/lux/control/concurrency/semaphore.lux | 4 +- stdlib/source/test/lux/debug.lux | 2 +- stdlib/source/test/lux/extension.lux | 20 ++-- stdlib/source/test/lux/math/number/frac.lux | 8 +- stdlib/source/test/lux/static.lux | 2 +- stdlib/source/test/lux/target/jvm.lux | 108 ++++++++++----------- stdlib/source/test/lux/type/poly/equivalence.lux | 4 +- stdlib/source/test/lux/type/poly/functor.lux | 2 +- stdlib/source/test/lux/type/poly/json.lux | 4 +- 67 files changed, 415 insertions(+), 432 deletions(-) diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index 744474bc9..cf4ff1036 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -364,7 +364,7 @@ (_.list/* (list))))] (_.call/2 [(runtime.lux//program_args raw_inputs) _.nil] program))) -(for {@.old +(for [@.old (def: extender Extender ... TODO: Stop relying on coercions ASAP. @@ -386,7 +386,7 @@ @.common_lisp (def: (extender handler) Extender - (:expected handler))}) + (:expected handler))]) (def: (declare_success! _) (-> Any (Promise Any)) diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 06d718f14..1e36e2906 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -75,7 +75,7 @@ #.None "???")) -(for {@.old +(for [@.old (as_is (import: java/lang/String) (import: (java/lang/Class a)) @@ -160,7 +160,7 @@ (-> Int org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/IntValue] [] - ... Methods +... Methods (program/IntValue [] (getValue self []) java/lang/Object (:as java/lang/Object value)) @@ -221,11 +221,11 @@ (#.Some sub_value) (|> sub_value (:as Int) js_int) #.None) - ... else +... else (:as org/openjdk/nashorn/api/scripting/JSObject sub_value))))] (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/StructureValue] [] - ... Methods +... Methods (program/StructureValue [] (getValue self []) java/lang/Object (:as (Array java/lang/Object) value)) @@ -401,12 +401,12 @@ #.None (if (org/openjdk/nashorn/api/scripting/JSObject::isFunction js_object) (#try.Success js_object) - ... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)]) +... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)]) (#try.Success js_object) )))) #.None) - ... else - ... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)]) +... else +... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)]) (#try.Success js_object) ))) @@ -422,9 +422,9 @@ ) @.js - (as_is)}) + (as_is)]) -(for {@.old +(for [@.old (as_is (def: (call_macro inputs lux macro) (-> (List Code) Lux org/openjdk/nashorn/api/scripting/JSObject (Try (Try [Lux (List Code)]))) (let [to_js (: (-> Any java/lang/Object) @@ -463,9 +463,9 @@ (def: (expander macro inputs lux) Expander (#try.Success ((:as Macro' macro) inputs lux))) - }) + ]) -(for {@.old +(for [@.old (as_is (def: (evaluate! interpreter alias input) (-> javax/script/ScriptEngine Context _.Expression (Try Any)) (do try.monad @@ -519,9 +519,9 @@ @.js (as_is (def: (eval code) (-> Text (Try (Maybe Any))) - ... Note: I have to call "eval" this way - ... in order to avoid a quirk of calling eval in Node - ... when the code is running under "use strict";. +... Note: I have to call "eval" this way +... in order to avoid a quirk of calling eval in Node +... when the code is running under "use strict";. (try (let [return ("js apply" (function.identity ("js constant" "eval")) code)] (if ("js object null?" return) #.None @@ -573,28 +573,28 @@ (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) - )}) + )]) (def: (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] (in (:as phase.Wrapper - (for {... The implementation for @.old is technically incorrect. + (for [ ... The implementation for @.old is technically incorrect. ... However, the JS compiler runs fast enough on Node to be fully hosted there. ... And running the JS compiler on the JVM (on top of Nashorn) is impractically slow. ... This means that in practice, only the @.js implementation matters. ... And since no cross-language boundary needs to be handled, it's a correct implementation. @.old (|>>) - @.js (|>>)}))))) + @.js (|>>)]))))) (def: platform (IO (Platform [Register Text] _.Expression _.Statement)) (do io.monad [host ..host] - (in [#platform.&file_system (for {@.old (file.async file.default) + (in [#platform.&file_system (for [@.old (file.async file.default) @.jvm (file.async file.default) - @.js file.default}) + @.js file.default]) #platform.host host #platform.phase js.generate #platform.runtime runtime.generate @@ -618,7 +618,7 @@ no_inputs))) (_.string ""))))) -(for {@.old +(for [@.old (def: (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. @@ -651,7 +651,7 @@ @.js (def: (extender phase_wrapper handler) (-> phase.Wrapper Extender) - (:expected handler))}) + (:expected handler))]) (def: (declare_success! _) (-> Any (Async Any)) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 2bba13d08..1ff6e2e57 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -339,13 +339,13 @@ #.None (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.lua (def: (expander macro inputs lux) Expander - (#try.Success ((:as Macro' macro) inputs lux)))})) + (#try.Success ((:as Macro' macro) inputs lux)))])) (with_expansions [ (as_is (with_expansions [$var_args (_.var "...") $str_rel_to_abs (_.var "_utf8_str_rel_to_abs") @@ -586,7 +586,7 @@ (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context))))))))]))))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.lua (as_is (ffi.import: (load [ffi.String] "try" ffi.Function)) (def: host @@ -625,7 +625,7 @@ (def: (re_load context custom content) (do try.monad [_ (run! content)] - (run! (_.return (_.var (reference.artifact context))))))))))))})) + (run! (_.return (_.var (reference.artifact context))))))))))))])) (with_expansions [ (as_is (exception: .public (invaid_phase_application [partial_application (List Any) arity Nat]) @@ -755,22 +755,22 @@ maybe.trusted (:as java/lang/Object) ..read)))))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.lua (def: (extender phase_wrapper handler) (-> phase.Wrapper Extender) - (:expected handler))})) + (:expected handler))])) (def: (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] (in (:as phase.Wrapper - (for {@.old (..host_phase (list)) + (for [@.old (..host_phase (list)) @.jvm (..host_phase (list)) - @.lua (|>>)}))))) + @.lua (|>>)]))))) (with_expansions [ (def: platform (IO [Baggage (Platform [Register _.Label] _.Expression _.Statement)]) @@ -783,7 +783,7 @@ #platform.runtime runtime.generate #platform.phase_wrapper ..phase_wrapper #platform.write (|>> _.code (\ utf8.codec encoded))]])))] - (for {@.old + (for [@.old @.jvm @.lua (def: platform (IO (Platform [Register _.Label] _.Expression _.Statement)) @@ -794,7 +794,7 @@ #platform.phase lua.generate #platform.runtime runtime.generate #platform.phase_wrapper ..phase_wrapper - #platform.write (|>> _.code (\ utf8.codec encoded))])))})) + #platform.write (|>> _.code (\ utf8.codec encoded))])))])) (def: (program context program) (Program _.Expression _.Statement) @@ -810,18 +810,18 @@ (`` (program: [service /cli.service] (let [extension ".lua"] (do io.monad - [(~~ (for {@.old [baggage platform] + [(~~ (for [@.old [baggage platform] @.jvm [baggage platform] - @.lua platform})) + @.lua platform])) ..platform] (exec (do async.monad [_ (/.compiler [#/static.host @.lua #/static.host_module_extension extension #/static.target (/cli.target service) #/static.artifact_extension extension] - (for {@.old (..expander baggage) + (for [@.old (..expander baggage) @.jvm (..expander baggage) - @.lua ..expander}) + @.lua ..expander]) analysis.bundle (io.io platform) generation.bundle @@ -830,9 +830,9 @@ [(type [Register _.Label]) _.Expression _.Statement] - (for {@.old (..extender baggage) + (for [@.old (..extender baggage) @.jvm (..extender baggage) - @.lua ..extender}) + @.lua ..extender]) service [(packager.package (_.manual "") _.code diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 1696206c6..c2c61b1ef 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -513,7 +513,7 @@ [(runtime.lux//program_args _.command_line_arguments) _.null]))) -(for {@.old +(for [@.old (def: extender Extender ... TODO: Stop relying on coercions ASAP. @@ -547,7 +547,7 @@ @.php (def: (extender handler) Extender - (:expected handler))}) + (:expected handler))]) (def: (declare_success! _) (-> Any (Promise Any)) diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index fb8c39e8e..afb244311 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -232,9 +232,9 @@ (|>> (:as java/lang/Object) (ffi.check org/python/core/PyFunction))) )] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) - @.python (as_is)})) + @.python (as_is)])) (with_expansions [ (as_is (def: (call_macro inputs lux macro) (-> (List Code) Lux org/python/core/PyFunction (Try (Try [Lux (List Code)]))) @@ -262,13 +262,13 @@ #.None (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.python (def: (expander macro inputs lux) Expander - (#try.Success ((:as Macro' macro) inputs lux)))})) + (#try.Success ((:as Macro' macro) inputs lux)))])) (with_expansions [ (def: host (IO (Host (_.Expression Any) (_.Statement Any))) @@ -315,7 +315,7 @@ (do try.monad [_ (execute! content)] (evaluate! context (_.var (reference.artifact context))))))))))] - (for {@.old + (for [@.old @.jvm @.python @@ -355,7 +355,7 @@ (def: (re_load context content) (do try.monad [_ (execute! content)] - (evaluate! context (_.var (reference.artifact context)))))))))))})) + (evaluate! context (_.var (reference.artifact context)))))))))))])) (with_expansions [ (as_is (exception: .public (invaid_phase_application [partial_application (List Any) arity Nat]) @@ -458,13 +458,13 @@ (ffi.write! 4 (..to_host state))) handler)] (..read output)))))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.python (def: (extender phase_wrapper handler) (-> phase.Wrapper Extender) - (:expected handler))})) + (:expected handler))])) (def: (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 15323662a..ec77f8c0d 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -552,7 +552,7 @@ (Program _.Expression _.Expression) (_.apply/2 program [(runtime.lux::program_args (_.commandArgs/0 [])) _.null])) -(for {@.old +(for [@.old (def: extender Extender ... TODO: Stop relying on coercions ASAP. @@ -574,7 +574,7 @@ @.r (def: (extender handler) Extender - (:expected handler))}) + (:expected handler))]) (def: (declare_success! _) (-> Any (Promise Any)) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index d5a0c9b82..25e3cc2ab 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -637,7 +637,7 @@ [_ (run! content)] (run! (_.global (reference.artifact context)))))))))) -(for {@.old +(for [@.old (as_is (exception: .public (invaid_phase_application [partial_application (List Any) arity Nat]) (exception.report @@ -778,15 +778,15 @@ @.ruby (def: (extender phase_wrapper handler) (-> phase.Wrapper Extender) - (:expected handler))}) + (:expected handler))]) (def: (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] (in (:as phase.Wrapper - (for {@.old (..host_phase (list)) - @.ruby (|>>)}))))) + (for [@.old (..host_phase (list)) + @.ruby (|>>)]))))) (def: platform (IO (Platform Register _.Expression _.Statement)) diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index 51ed54a32..ee5b95952 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -410,7 +410,7 @@ (runtime.lux//program_args _.nil) _.nil)) -(for {@.old +(for [@.old (def: extender Extender ... TODO: Stop relying on coercions ASAP. @@ -438,7 +438,7 @@ @.scheme (def: (extender handler) Extender - (:expected handler))}) + (:expected handler))]) (def: (declare_success! _) (-> Any (Promise Any)) diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index e9c09dfee..e81beecb2 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -861,8 +861,8 @@ [(def: js "JavaScript") - (for {"JVM" (do jvm stuff) - js (do js stuff)} + (for ["JVM" (do jvm stuff) + js (do js stuff)] (do default stuff))]) (documentation: /.`` diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux index ef19810e2..745cca04f 100644 --- a/stdlib/source/documentation/lux/control/concatenative.lux +++ b/stdlib/source/documentation/lux/control/concatenative.lux @@ -27,10 +27,10 @@ (=> [t] []))] [(All (_ a b c) (=> [a b c] [b c a]))] - [(All (_ ___a ___z) - (=> {then (=> ___a ___z) - else (=> ___a ___z)} - ___a [Bit then else] ___z))]) + [(All (_ ,,,0 ,,,1) + (=> [then (=> ,,,0 ,,,1) + else (=> ,,,0 ,,,1)] + ,,,0 [Bit then else] ,,,1))]) (documentation: /.||> "A self-contained sequence of concatenative instructions." diff --git a/stdlib/source/documentation/lux/extension.lux b/stdlib/source/documentation/lux/extension.lux index c9216cb0c..5d0e64f51 100644 --- a/stdlib/source/documentation/lux/extension.lux +++ b/stdlib/source/documentation/lux/extension.lux @@ -38,10 +38,10 @@ (documentation: /.generation: "" [(generation: ("my generation" self phase archive [pass_through .any]) - (for {@.jvm + (for [@.jvm (\ phase.monad each (|>> #jvm.Embedded row.row) - (phase archive pass_through))} + (phase archive pass_through))] (phase archive pass_through)))]) (documentation: /.directive: diff --git a/stdlib/source/documentation/lux/type/poly.lux b/stdlib/source/documentation/lux/type/poly.lux index 8708d3f90..f3d1ef3af 100644 --- a/stdlib/source/documentation/lux/type/poly.lux +++ b/stdlib/source/documentation/lux/type/poly.lux @@ -17,48 +17,6 @@ [\\library ["[0]" /]]) -(documentation: /.derived: - "" - [(type: Variant - (.Variant - (#Bit Bit) - (#Text Text) - (#Frac Frac))) - - (type: Recursive - (Rec Recursive - (.Variant - (#Number Frac) - (#Addition Frac Recursive)))) - - (type: Record - (.Record - [#bit Bit - #frac Frac - #text Text - #maybe (Maybe Frac) - #list (List Frac) - #dictionary (Dictionary Text Frac) - #variant Variant - #tuple [Bit Text Frac] - #recursive Recursive - #date Date - #grams (Qty Gram)])) - - (derived: equivalence - ($equivalence.equivalence - Record)) - - (: (Equivalence Record) - equivalence) - - (derived: codec - ($codec.codec - Record)) - - (: (Codec Json Record) - codec)]) - (documentation: /.code "" [(code env type)]) @@ -67,7 +25,6 @@ (.List $.Module) ($.module /._ "" - [..derived: - ..code + [..code ($.default /.poly:)] [])) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index d10f8d2f5..0872e57c1 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -4868,15 +4868,34 @@ (in_meta (list pick)) (target_pick target options' default))))) +(def: (pairs' tokens) + (-> (List Code) (Maybe (List [Code Code]))) + (if (|> tokens + list\size + (n/% 2) + ("lux i64 =" 0)) + (#Some (pairs tokens)) + #None)) + (macro: .public (for tokens) (do meta_monad [target ..target] (case tokens - (^ (list [_ (#Record options)])) - (target_pick target options #None) + (^ (list [_ (#Tuple options)])) + (case (pairs' options) + (#Some options) + (target_pick target options #None) + + #None + (failure (..wrong_syntax_error (name_of ..for)))) - (^ (list [_ (#Record options)] default)) - (target_pick target options (#Some default)) + (^ (list [_ (#Tuple options)] default)) + (case (pairs' options) + (#Some options) + (target_pick target options (#Some default)) + + #None + (failure (..wrong_syntax_error (name_of ..for)))) _ (failure (..wrong_syntax_error (name_of ..for)))))) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index 48598dfa5..f1b2b9344 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -26,10 +26,10 @@ (def: (on fgx fgf) ... TODO: Switch from this version to the one below (in comments) ASAP. - (for {@.old (let [fgf' (\ f_apply on + (for [@.old (let [fgf' (\ f_apply on fgf (\ f_monad in (function (_ gf gx) (\ g_apply on gx gf))))] - (:expected (\ f_apply on (:expected fgx) (:expected fgf'))))} + (:expected (\ f_apply on (:expected fgx) (:expected fgf'))))] (let [fgf' (\ f_apply on fgf (\ f_monad in (function (_ gf gx) (\ g_apply on gx gf))))] diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 24883f901..28a48035f 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -38,8 +38,7 @@ (Parser (List Alias)) (|> (<>.and .local_identifier .any) <>.some - .record - (<>.else (list)))) + .tuple)) (def: top^ (Parser (List Code)) @@ -75,9 +74,12 @@ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line (|> expansion (list\each %.code) (text.interposed " "))))))) -(syntax: .public (=> [aliases aliases^ - inputs stack^ - outputs stack^]) +(def: signature^ + (Parser [(List Alias) Stack Stack]) + (<>.either ($_ <>.and aliases^ stack^ stack^) + ($_ <>.and (<>\in (list)) stack^ stack^))) + +(syntax: .public (=> [[aliases inputs outputs] signature^]) (let [de_alias (function (_ aliased) (list\mix (function (_ [from to] pre) (code.replaced (code.local_identifier from) to pre)) @@ -248,26 +250,26 @@ ) (def: .public if - (All (_ ___a ___z) - (=> {then (=> ___a ___z) - else (=> ___a ___z)} - ___a [Bit then else] ___z)) + (All (_ ,,,0 ,,,1) + (=> [then (=> ,,,0 ,,,1) + else (=> ,,,0 ,,,1)] + ,,,0 [Bit then else] ,,,1)) (function (_ [[[stack test] then] else]) (.if test (then stack) (else stack)))) (def: .public call - (All (_ ___a ___z) - (=> {quote (=> ___a ___z)} - ___a [quote] ___z)) + (All (_ ,,,0 ,,,1) + (=> [quote (=> ,,,0 ,,,1)] + ,,,0 [quote] ,,,1)) (function (_ [stack quote]) (quote stack))) (def: .public loop - (All (_ ___) - (=> {test (=> ___ ___ [Bit])} - ___ [test] ___)) + (All (_ ,,,) + (=> [test (=> ,,, ,,, [Bit])] + ,,, [test] ,,,)) (function (loop [stack pred]) (let [[stack' verdict] (pred stack)] (.if verdict @@ -275,34 +277,34 @@ stack')))) (def: .public dip - (All (_ ___ a) - (=> ___ [a (=> ___ ___)] - ___ [a])) + (All (_ ,,, a) + (=> ,,, [a (=> ,,, ,,,)] + ,,, [a])) (function (_ [[stack a] quote]) [(quote stack) a])) (def: .public dip/2 - (All (_ ___ a b) - (=> ___ [a b (=> ___ ___)] - ___ [a b])) + (All (_ ,,, a b) + (=> ,,, [a b (=> ,,, ,,,)] + ,,, [a b])) (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) (def: .public do - (All (_ ___a ___z) - (=> {body (=> ___a ___z) - pred (=> ___z ___a [Bit])} - ___a [pred body] - ___z [pred body])) + (All (_ ,,,0 ,,,1) + (=> [body (=> ,,,0 ,,,1) + pred (=> ,,,1 ,,,0 [Bit])] + ,,,0 [pred body] + ,,,1 [pred body])) (function (_ [[stack pred] body]) [[(body stack) pred] body])) (def: .public while - (All (_ ___a ___z) - (=> {body (=> ___z ___a) - pred (=> ___a ___z [Bit])} - ___a [pred body] - ___z)) + (All (_ ,,,0 ,,,1) + (=> [body (=> ,,,1 ,,,0) + pred (=> ,,,0 ,,,1 [Bit])] + ,,,0 [pred body] + ,,,1)) (function (while [[stack pred] body]) (let [[stack' verdict] (pred stack)] (.if verdict @@ -310,24 +312,24 @@ stack')))) (def: .public compose - (All (_ ___a ___ ___z) - (=> [(=> ___a ___) (=> ___ ___z)] - [(=> ___a ___z)])) + (All (_ ,,,0 ,,, ,,,1) + (=> [(=> ,,,0 ,,,) (=> ,,, ,,,1)] + [(=> ,,,0 ,,,1)])) (function (_ [[stack f] g]) [stack (|>> f g)])) (def: .public partial - (All (_ ___a ___z a) - (=> ___a [a (=> ___a [a] ___z)] - ___a [(=> ___a ___z)])) + (All (_ ,,,0 ,,,1 a) + (=> ,,,0 [a (=> ,,,0 [a] ,,,1)] + ,,,0 [(=> ,,,0 ,,,1)])) (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) (word: .public when - (All (_ ___) - (=> {body (=> ___ ___)} - ___ [Bit body] - ___)) + (All (_ ,,,) + (=> [body (=> ,,, ,,,)] + ,,, [Bit body] + ,,,)) swap (push ..call) (push ..drop) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 6309f4f35..091273281 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -20,57 +20,57 @@ (new [a]) (get [] a) (compareAndSet [a a] boolean)]))] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] (as_is))) -(with_expansions [ (for {@.js "js array new" +(with_expansions [ (for [@.js "js array new" @.python "python array new" @.lua "lua array new" @.ruby "ruby array new" @.php "php array new" - @.scheme "scheme array new"} + @.scheme "scheme array new"] (as_is)) - (for {@.js "js array write" + (for [@.js "js array write" @.python "python array write" @.lua "lua array write" @.ruby "ruby array write" @.php "php array write" - @.scheme "scheme array write"} + @.scheme "scheme array write"] (as_is)) - (for {@.js "js array read" + (for [@.js "js array read" @.python "python array read" @.lua "lua array read" @.ruby "ruby array read" @.php "php array read" - @.scheme "scheme array read"} + @.scheme "scheme array read"] (as_is))] (abstract: .public (Atom a) (with_expansions [ (java/util/concurrent/atomic/AtomicReference a)] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] (array.Array a))) [(def: .public (atom value) (All (_ a) (-> a (Atom a))) (:abstraction (with_expansions [ (java/util/concurrent/atomic/AtomicReference::new value)] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] ( 0 value ( 1)))))) (def: .public (read! atom) (All (_ a) (-> (Atom a) (IO a))) (io.io (with_expansions [ (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] ( 0 (:representation atom)))))) (def: .public (compare_and_swap! current new atom) (All (_ a) (-> a a (Atom a) (IO Bit))) (io.io (with_expansions [ (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (:representation atom))] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] (let [old ( 0 (:representation atom))] (if (same? old current) (exec ( 0 new (:representation atom)) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 4e82d76a6..c9430c1ed 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -45,7 +45,7 @@ ["[1]::[0]" (new [int]) (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] "io" (java/util/concurrent/ScheduledFuture java/lang/Object))]))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.js @@ -55,7 +55,7 @@ (ffi.import: threading/Timer ["[1]::[0]" (new [ffi.Float ffi.Function]) - (start [] "io" "?" Any)])} + (start [] "io" "?" Any)])] ... Default (type: Thread @@ -70,18 +70,18 @@ (with_expansions [ (|> (java/lang/Runtime::getRuntime) (java/lang/Runtime::availableProcessors) .nat)] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] ... Default 1))) (with_expansions [ (as_is (def: runner java/util/concurrent/ScheduledThreadPoolExecutor (java/util/concurrent/ScheduledThreadPoolExecutor::new (.int ..parallelism))))] - (for {@.old + (for [@.old @.jvm @.js (as_is) - @.python (as_is)} + @.python (as_is)] ... Default (def: runner @@ -111,7 +111,7 @@ 0 (java/util/concurrent/Executor::execute runnable runner) _ (java/util/concurrent/ScheduledThreadPoolExecutor::schedule runnable (.int milli_seconds) java/util/concurrent/TimeUnit::MILLISECONDS runner))))] - (for {@.old + (for [@.old @.jvm @.js @@ -124,7 +124,7 @@ [(|> milli_seconds n.frac (f./ +1,000.0))] threading/Timer::new (threading/Timer::start []))] - (in []))} + (in []))] ... Default (do [! io.monad] @@ -135,10 +135,10 @@ ..runner)] (in []))))) -(for {@.old (as_is) +(for [@.old (as_is) @.jvm (as_is) @.js (as_is) - @.python (as_is)} + @.python (as_is)] ... Default (as_is (exception: .public cannot_continue_running_threads) diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index b2945a7a0..ec49d9a1a 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -30,7 +30,7 @@ (def: .public (read! box) (All (_ ! a) (-> (Box ! a) (Thread ! a))) (function (_ !) - (for {@.old + (for [@.old ("jvm aaload" (:representation box) 0) @.jvm @@ -46,7 +46,7 @@ @.lua ("lua array read" 0 (:representation box)) @.ruby ("ruby array read" 0 (:representation box)) @.php ("php array read" 0 (:representation box)) - @.scheme ("scheme array read" 0 (:representation box))}))) + @.scheme ("scheme array read" 0 (:representation box))]))) (def: .public (write! value box) (All (_ a) (-> a (All (_ !) (-> (Box ! a) (Thread ! Any))))) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index cabc9268c..0805da036 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -62,9 +62,9 @@ (def: (conjoint MlMla) (do monad - [[l1 Mla] (for {@.old + [[l1 Mla] (for [@.old (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) - MlMla)} + MlMla)] ... On new compiler MlMla) [l2 a] Mla] diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 8d1975b8f..33bac997b 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -60,12 +60,12 @@ (def: byte (-> (I64 Any) (primitive "java.lang.Byte")) - (for {@.old + (for [@.old (|>> .int ffi.long_to_byte) @.jvm - (|>> .int (:as (primitive "java.lang.Long")) ffi.long_to_byte)})))] - (for {@.old (as_is ) + (|>> .int (:as (primitive "java.lang.Long")) ffi.long_to_byte)])))] + (for [@.old (as_is ) @.jvm (as_is ) @.js @@ -92,14 +92,14 @@ (ffi.import: (make-bytevector [Nat] Binary)) (ffi.import: (bytevector-u8-ref [Binary Nat] I64)) (ffi.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) - (ffi.import: (bytevector-length [Binary] Nat)))} + (ffi.import: (bytevector-length [Binary] Nat)))] ... Default (type: .public Binary (array.Array (I64 Any))))) (template: (!size binary) - [(for {@.old (ffi.length binary) + [(for [@.old (ffi.length binary) @.jvm (ffi.length binary) @.js @@ -113,13 +113,13 @@ "python array length") @.scheme - (..bytevector-length [binary])} + (..bytevector-length [binary])] ... Default (array.size binary))]) (template: (!read index binary) - [(for {@.old (..i64 (ffi.read! index binary)) + [(for [@.old (..i64 (ffi.read! index binary)) @.jvm (..i64 (ffi.read! index binary)) @.js @@ -136,7 +136,7 @@ ("python array read" index)) @.scheme - (..bytevector-u8-ref [binary index])} + (..bytevector-u8-ref [binary index])] ... Default (|> binary @@ -152,13 +152,13 @@ (:as ..Binary))]) (template: (!write index value binary) - [(for {@.old (ffi.write! index (..byte value) binary) + [(for [@.old (ffi.write! index (..byte value) binary) @.jvm (ffi.write! index (..byte value) binary) @.js (!!write .Frac n.frac "js array write" index value binary) @.python (!!write (I64 Any) (:as (I64 Any)) "python array write" index value binary) @.scheme (exec (..bytevector-u8-set! [binary index value]) - binary)} + binary)] ... Default (array.write! index (|> value .nat (n.% (hex "100"))) binary))]) @@ -169,7 +169,7 @@ (def: .public (empty size) (-> Nat Binary) - (for {@.old (ffi.array byte size) + (for [@.old (ffi.array byte size) @.jvm (ffi.array byte size) @.js @@ -181,7 +181,7 @@ (:as Binary)) @.scheme - (..make-bytevector size)} + (..make-bytevector size)] ... Default (array.empty size))) @@ -261,7 +261,7 @@ (def: .public (write/64! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 7 index)) - (for {@.scheme (let [write_high (|>> (!write index (i64.right_shifted 56 value)) + (for [@.scheme (let [write_high (|>> (!write index (i64.right_shifted 56 value)) (!write (n.+ 1 index) (i64.right_shifted 48 value)) (!write (n.+ 2 index) (i64.right_shifted 40 value)) (!write (n.+ 3 index) (i64.right_shifted 32 value))) @@ -269,7 +269,7 @@ (!write (n.+ 5 index) (i64.right_shifted 16 value)) (!write (n.+ 6 index) (i64.right_shifted 8 value)) (!write (n.+ 7 index) value))] - (|> binary write_high write_low #try.Success))} + (|> binary write_high write_low #try.Success))] (#try.Success (|> binary (!write index (i64.right_shifted 56 value)) (!write (n.+ 1 index) (i64.right_shifted 48 value)) @@ -286,8 +286,8 @@ (def: (= reference sample) (with_expansions [ (java/util/Arrays::equals reference sample)] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] (let [limit (!size reference)] (and (n.= limit (!size sample)) @@ -298,8 +298,8 @@ (recur (++ index))) true)))))))) -(for {@.old (as_is) - @.jvm (as_is)} +(for [@.old (as_is) + @.jvm (as_is)] ... Default (exception: .public (cannot_copy_bytes [bytes Nat @@ -315,8 +315,8 @@ (with_expansions [ (as_is (do try.monad [_ (java/lang/System::arraycopy source (.int source_offset) target (.int target_offset) (.int bytes))] (in target)))] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] ... Default (let [source_input (n.- source_offset (!size source)) @@ -338,8 +338,8 @@ (if (n.> size limit) (exception.except ..slice_out_of_bounds [size offset length]) (with_expansions [ (as_is (#try.Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))))] - (for {@.old - @.jvm } + (for [@.old + @.jvm ] ... Default (..copy length offset binary 0 (..empty length))))))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 3c04a7d7f..0bd99245d 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -27,17 +27,17 @@ (with_expansions [ (primitive "java.lang.Long") (primitive "java.lang.Object") (type (Array ))] - (for {@.jvm + (for [@.jvm (template: (!int value) [(|> value (:as ) "jvm object cast" - "jvm conversion long-to-int")])} + "jvm conversion long-to-int")])] (as_is)) (def: .public (empty size) (All (_ a) (-> Nat (Array a))) - (for {@.old + (for [@.old (:expected ("jvm anewarray" "(java.lang.Object )" size)) @.jvm @@ -52,11 +52,11 @@ @.lua ("lua array new" size) @.ruby ("ruby array new" size) @.php ("php array new" size) - @.scheme ("scheme array new" size)})) + @.scheme ("scheme array new" size)])) (def: .public (size array) (All (_ a) (-> (Array a) Nat)) - (for {@.old + (for [@.old ("jvm arraylength" array) @.jvm @@ -73,7 +73,7 @@ @.lua ("lua array length" array) @.ruby ("ruby array length" array) @.php ("php array length" array) - @.scheme ("scheme array length" array)})) + @.scheme ("scheme array length" array)])) (template: (!read! ) [(let [output ( index array)] @@ -85,7 +85,7 @@ (All (_ a) (-> Nat (Array a) (Maybe a))) (if (n.< (size array) index) - (for {@.old + (for [@.old (let [value ("jvm aaload" array index)] (if ("jvm object null?" value) #.None @@ -104,13 +104,13 @@ @.lua (!read! "lua array read" "lua object nil?") @.ruby (!read! "ruby array read" "ruby object nil?") @.php (!read! "php array read" "php object null?") - @.scheme (!read! "scheme array read" "scheme object nil?")}) + @.scheme (!read! "scheme array read" "scheme object nil?")]) #.None)) (def: .public (write! index value array) (All (_ a) (-> Nat a (Array a) (Array a))) - (for {@.old + (for [@.old ("jvm aastore" array index value) @.jvm @@ -124,13 +124,13 @@ @.lua ("lua array write" index value array) @.ruby ("ruby array write" index value array) @.php ("php array write" index value array) - @.scheme ("scheme array write" index value array)})) + @.scheme ("scheme array write" index value array)])) (def: .public (delete! index array) (All (_ a) (-> Nat (Array a) (Array a))) (if (n.< (size array) index) - (for {@.old + (for [@.old (write! index (:expected ("jvm object null")) array) @.jvm @@ -141,7 +141,7 @@ @.lua ("lua array delete" index array) @.ruby ("ruby array delete" index array) @.php ("php array delete" index array) - @.scheme ("scheme array delete" index array)}) + @.scheme ("scheme array delete" index array)]) array)) ) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index ead69db05..286290c96 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -203,7 +203,7 @@ (def: .public (all check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (List b))) - (for {... TODO: Stop relying on this ASAP. + (for [... TODO: Stop relying on this ASAP. @.js (mix (function (_ head tail) (case (check head) @@ -213,7 +213,7 @@ #.None tail)) #.End - (reversed xs))} + (reversed xs))] (case xs #.End #.End @@ -572,9 +572,9 @@ (do [! monad] [lMla MlMla ... TODO: Remove this version ASAP and use one below. - lla (for {@.old + lla (for [@.old (: ((:parameter 0) (List (List (:parameter 1)))) - (monad.all ! lMla))} + (monad.all ! lMla))] (monad.all ! lMla))] (in (..together lla))))) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 5080c4c1c..728a67ce4 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -224,9 +224,9 @@ ... If so, a brand-new root must be established, that is ... 1-level taller. (|> row - (with@ #root (|> (for {@.old + (with@ #root (|> (for [@.old (: (Hierarchy (:parameter 0)) - (empty_hierarchy []))} + (empty_hierarchy []))] (empty_hierarchy [])) (array.write! 0 (#Hierarchy (value@ #root row))) (array.write! 1 (..path (value@ #level row) (value@ #tail row))))) @@ -293,9 +293,9 @@ (#try.Success (if (n.< (tail_off row_size) idx) (revised@ #root (hierarchy\has (value@ #level row) idx val) row) - (revised@ #tail (for {@.old + (revised@ #tail (for [@.old (: (-> (Base (:parameter 0)) (Base (:parameter 0))) - (|>> array.clone (array.write! (branch_idx idx) val)))} + (|>> array.clone (array.write! (branch_idx idx) val)))] (|>> array.clone (array.write! (branch_idx idx) val))) row))) (exception.except ..index_out_of_bounds [row idx])))) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 36b162843..ee7daa341 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -103,13 +103,13 @@ (do maybe.monad [family (value@ #family zipper)] (in (let [(^slots [#parent #lefts #rights]) family] - (for {@.old + (for [@.old (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) (with@ #//.children (list\composite (list.reversed lefts) (#.Item (value@ #node zipper) rights)))) - parent)} + parent)] (with@ [#node #//.children] (list\composite (list.reversed lefts) (#.Item (value@ #node zipper) @@ -123,11 +123,11 @@ (#.Some family) (case (value@ family) (#.Item next side') - (#.Some (for {@.old + (#.Some (for [@.old [#family (#.Some (|> family (with@ side') (revised@ (|>> (#.Item (value@ #node zipper)))))) - #node next]} + #node next]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (with@ side') @@ -153,11 +153,11 @@ #.None (#.Item last prevs) - (#.Some (for {@.old [#family (#.Some (|> family + (#.Some (for [@.old [#family (#.Some (|> family (with@ #.End) (revised@ (|>> (#.Item (value@ #node zipper)) (list\composite prevs))))) - #node last]} + #node last]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) (|>> (with@ #.End) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index aadcb9dbe..b3961edc4 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -184,7 +184,7 @@ (def: .public (replaced pattern replacement template) (-> Text Text Text Text) - (for {@.old + (for [@.old (:as Text ("jvm invokevirtual:java.lang.String:replace:java.lang.CharSequence,java.lang.CharSequence" (:as (primitive "java.lang.String") template) @@ -214,7 +214,7 @@ ... TODO @.scheme ... TODO @.common_lisp ... TODO @.r - } + ] ... Inefficient default (loop [left "" right template] @@ -253,7 +253,7 @@ (def: &equivalence ..equivalence) (def: (hash input) - (for {@.old + (for [@.old (|> input (: (primitive "java.lang.String")) "jvm invokevirtual:java.lang.String:hashCode:" @@ -267,7 +267,7 @@ "jvm conversion int-to-long" "jvm object cast" (: (primitive "java.lang.Long")) - (:as Nat))} + (:as Nat))] ... Platform-independent default. (let [length ("lux text size" input)] (loop [index 0 @@ -323,7 +323,7 @@ (def: .public (lower_cased value) (-> Text Text) - (for {@.old + (for [@.old (:as Text ("jvm invokevirtual:java.lang.String:toLowerCase:" (:as (primitive "java.lang.String") value))) @@ -342,11 +342,11 @@ ("lua apply" ("lua constant" "string.lower") value)) @.ruby (:as Text - ("ruby object do" "downcase" value))})) + ("ruby object do" "downcase" value))])) (def: .public (upper_cased value) (-> Text Text) - (for {@.old + (for [@.old (:as Text ("jvm invokevirtual:java.lang.String:toUpperCase:" (:as (primitive "java.lang.String") value))) @@ -365,4 +365,4 @@ ("lua apply" ("lua constant" "string.upper") value)) @.ruby (:as Text - ("ruby object do" "upcase" value))})) + ("ruby object do" "upcase" value))])) diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index af3341930..b8955f732 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -34,7 +34,7 @@ ["[1]::[0]" (new [int]) (toString [] java/lang/String)]))] - (`` (for {@.old (as_is ) + (`` (for [@.old (as_is ) @.jvm (as_is ) @.js (as_is (import: (JS_Array a) ["[1]::[0]" @@ -44,24 +44,24 @@ ...https://www.lua.org/manual/5.3/manual.html#pdf-table.concat (import: (table/insert [(array.Array Text) Text] "?" Nothing)) ... https://www.lua.org/manual/5.3/manual.html#pdf-table.insert - )} + )] (as_is)))) (`` (abstract: .public Buffer - (for {@.old [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] + (for [@.old [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] @.jvm [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] @.js [Nat (-> (JS_Array Text) (JS_Array Text))] - @.lua [Nat (-> (array.Array Text) (array.Array Text))]} + @.lua [Nat (-> (array.Array Text) (array.Array Text))]] ... default (Row Text)) [(def: .public empty Buffer (:abstraction (with_expansions [ [0 function.identity]] - (for {@.old + (for [@.old @.jvm @.js [0 function.identity] - @.lua [0 function.identity]} + @.lua [0 function.identity]] ... default row.empty)))) @@ -76,7 +76,7 @@ builder)))] (:abstraction [(n.+ (//.size chunk) capacity) (|>> transform (then! chunk))]))] - (for {@.old + (for [@.old @.jvm @.js (let [[capacity transform] (:representation buffer) then! (: (-> (JS_Array Text) (JS_Array Text)) @@ -93,17 +93,17 @@ (table/insert [array chunk]) array)))] (:abstraction [(n.+ (//.size chunk) capacity) - (|>> transform then!)]))} + (|>> transform then!)]))] ... default (|> buffer :representation (row.suffix chunk) :abstraction)))) (def: .public size (-> Buffer Nat) (with_expansions [ (|>> :representation product.left)] - (for {@.old + (for [@.old @.jvm @.js - @.lua } + @.lua ] ... default (|>> :representation (row\mix (function (_ chunk total) @@ -116,7 +116,7 @@ (|> (java/lang/StringBuilder::new (.int capacity)) transform java/lang/StringBuilder::toString))] - (for {@.old + (for [@.old @.jvm @.js (let [[capacity transform] (:representation buffer)] (|> (array.empty 0) @@ -124,7 +124,7 @@ transform (JS_Array::join [""]))) @.lua (let [[capacity transform] (:representation buffer)] - (table/concat [(transform (array.empty 0)) ""]))} + (table/concat [(transform (array.empty 0)) ""]))] ... default (row\mix (function (_ chunk total) (format total chunk)) diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index 19867bae4..817288316 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -15,7 +15,7 @@ ["[1]::[0]" (new [[byte] java/lang/String]) (getBytes [java/lang/String] [byte])]))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.js @@ -59,12 +59,12 @@ @.scheme ... https://srfi.schemers.org/srfi-140/srfi-140.html (as_is (ffi.import: (string->utf8 [Text] Binary)) - (ffi.import: (utf8->string [Binary] Text)))} + (ffi.import: (utf8->string [Binary] Text)))] (as_is))) (def: (encoded value) (-> Text Binary) - (for {@.old + (for [@.old (java/lang/String::getBytes (//.name //.utf_8) ... TODO: Remove coercion below. ... The coercion below may seem @@ -109,12 +109,12 @@ (:as Binary)) @.scheme - (..string->utf8 value)})) + (..string->utf8 value)])) (def: (decoded value) (-> Binary (Try Text)) (with_expansions [ (#try.Success (java/lang/String::new value (//.name //.utf_8)))] - (for {@.old + (for [@.old @.jvm @.js @@ -155,7 +155,7 @@ @.scheme (|> value ..utf8->string - #try.Success)}))) + #try.Success)]))) (implementation: .public codec (Codec Binary Text) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 8ce5e58e7..8f3245ea2 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -66,7 +66,7 @@ (intValue [] int) (longValue [] long) (doubleValue [] double)]))] - (for {@.old (as_is ) + (for [@.old (as_is ) @.jvm (as_is ) @.js @@ -114,24 +114,24 @@ (import: (car [.Any] .Any)) (import: (cdr [.Any] .Any)) (import: (format [Text .Any] Text))) - })) + ])) (def: Inspector (.type (Format Any))) -(for {@.lua (def: (tuple_array tuple) +(for [@.lua (def: (tuple_array tuple) (-> (array.Array Any) (array.Array Any)) (array.of_list (loop [idx 0] (let [member ("lua array read" idx tuple)] (if ("lua object nil?" member) #.End - (#.Item member (recur (++ idx))))))))} + (#.Item member (recur (++ idx))))))))] (as_is)) (def: (tuple_inspection inspection) (-> Inspector Inspector) - (with_expansions [ (for {@.lua (~~ (as_is ..tuple_array))} + (with_expansions [ (for [@.lua (~~ (as_is ..tuple_array))] (~~ (as_is)))] (`` (|>> (:as (array.Array Any)) @@ -175,7 +175,7 @@ (tuple_inspection inspection value))) #.None) (java/lang/Object::toString object))))] - (for {@.old + (for [@.old @.jvm @.js @@ -374,7 +374,7 @@ ... else (..format ["~s" value]) )) - }))) + ]))) (exception: .public (cannot_represent_value [type Type]) (exception.report diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index b81ca5c50..d6c85234d 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -18,7 +18,7 @@ [tau +6.28318530717958647692] ) -(for {@.old +(for [@.old (as_is (template [ ] [(def: .public ( it) (-> Frac Frac) @@ -282,7 +282,7 @@ (def: .public root/3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) - }) + ]) (def: .public (round it) (-> Frac Frac) diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 00e75d32c..7b81afa69 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -35,10 +35,10 @@ (let [initialization+event_loop (` ((~! do) (~! io.monad) [(~ g!output) (~ body) - (~+ (for {@.old (list) + (~+ (for [@.old (list) @.jvm (list) @.js (list) - @.python (list)} + @.python (list)] (list g!_ (` (~! thread.run!)))))] ((~' in) (~ g!output))))] (in (list (` ("lux def program" diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index ef1076787..d1e9b2122 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -71,13 +71,13 @@ (Equivalence java/lang/Float) (def: (= parameter subject) - (for {@.old + (for [@.old ("jvm feq" parameter subject) @.jvm ("jvm float =" ("jvm object cast" parameter) - ("jvm object cast" subject))}))) + ("jvm object cast" subject))]))) (import: java/lang/Double ["[1]::[0]" diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index fe2bba2e6..1d5eda342 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -102,11 +102,11 @@ (def: .public (memory library) (-> Library java/lang/ClassLoader) - (with_expansions [ (for {@.old + (with_expansions [ (for [@.old (<|) @.jvm - "jvm object cast"})] + "jvm object cast"])] (<| (object [] java/lang/ClassLoader [] [] diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 4988e4d78..af0514a76 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -31,19 +31,19 @@ (-> Text Text) (text.enclosed ["(" ")"])) -(for {@.old (as_is (ffi.import: java/lang/CharSequence) +(for [@.old (as_is (ffi.import: java/lang/CharSequence) (ffi.import: java/lang/String ["[1]::[0]" - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} + (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))] (as_is)) (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (format text.new_line) + (for [@.old (|>> (format text.new_line) (:as java/lang/String) (java/lang/String::replace (:as java/lang/CharSequence text.new_line) - (:as java/lang/CharSequence nested_new_line)))} + (:as java/lang/CharSequence nested_new_line)))] (|>> (format text.new_line) (text.replaced text.new_line nested_new_line))))) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 696b204b0..57063a5a0 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -152,7 +152,7 @@ (def: .public now (IO Instant) - (io (..of_millis (for {@.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") + (io (..of_millis (for [@.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" []) ("jvm object cast") (: (primitive "java.lang.Long")) @@ -189,7 +189,7 @@ "common_lisp apply" (:as Int) (i.* +1,000)) - })))) + ])))) (template [ ] [(def: .public ( instant) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index be5d7df27..d24ad8f33 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -101,11 +101,11 @@ (ioW.write system static module_id artifact_id content)))] (do [! ..monad] [_ (ioW.prepare system static module_id) - _ (for {@.python (|> output + _ (for [@.python (|> output row.list (list.sub 128) (monad.each ! (monad.each ! write_artifact!)) - (: (Action (List (List Any)))))} + (: (Action (List (List Any)))))] (|> output row.list (monad.each ..monad write_artifact!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index f5f47f98d..66b58bf74 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -199,7 +199,7 @@ [.let [inputT (type.tuple (list.repeated arity Any))] abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) - _ (analysis/type.infer (for {@.js ffi.Function} + _ (analysis/type.infer (for [@.js ffi.Function] Any))] (in (#analysis.Extension extension (list (analysis.nat arity) abstractionA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index dd7d43516..f7ed4ed54 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -29,15 +29,15 @@ ["[0]" phase]]]]]]) (def: Nil - (for {@.lua ffi.Nil} + (for [@.lua ffi.Nil] Any)) (def: Object - (for {@.lua (type (ffi.Object Any))} + (for [@.lua (type (ffi.Object Any))] Any)) (def: Function - (for {@.lua ffi.Function} + (for [@.lua ffi.Function] Any)) (def: array::new diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 227bc4539..a52f8bb53 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -108,15 +108,15 @@ ))) (def: Null - (for {@.php ffi.Null} + (for [@.php ffi.Null] Any)) (def: Object - (for {@.php (type (ffi.Object Any))} + (for [@.php (type (ffi.Object Any))] Any)) (def: Function - (for {@.php ffi.Function} + (for [@.php ffi.Function] Any)) (def: object::new diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index 2f07f677b..700f80163 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -108,20 +108,23 @@ ))) (def: None - (for {@.python - ffi.None} + (for [@.python + ffi.None] Any)) (def: Object - (for {@.python (type (ffi.Object Any))} + (for [@.python + (type (ffi.Object Any))] Any)) (def: Function - (for {@.python ffi.Function} + (for [@.python + ffi.Function] Any)) (def: Dict - (for {@.python ffi.Dict} + (for [@.python + ffi.Dict] Any)) (def: object::get diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index d267ca612..6bf24f1fa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -108,15 +108,15 @@ ))) (def: Nil - (for {@.ruby ffi.Nil} + (for [@.ruby ffi.Nil] Any)) (def: Object - (for {@.ruby (type (ffi.Object Any))} + (for [@.ruby (type (ffi.Object Any))] Any)) (def: Function - (for {@.ruby ffi.Function} + (for [@.ruby ffi.Function] Any)) (def: object::get diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index 688803a33..2075522d7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -108,12 +108,12 @@ ))) (def: Nil - (for {@.scheme - ffi.Nil} + (for [@.scheme + ffi.Nil] Any)) (def: Function - (for {@.scheme ffi.Function} + (for [@.scheme ffi.Function] Any)) (def: bundle::object diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index e71de0758..1be1bcfa5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -211,7 +211,7 @@ (/.install "index" (trinary ..text//index)) (/.install "size" (unary //runtime.text//size)) ... TODO: Use version below once the Lua compiler becomes self-hosted. - ... (/.install "size" (unary (for {@.lua (!unary "utf8.len")} + ... (/.install "size" (unary (for [@.lua (!unary "utf8.len")] ... (!unary "string.len")))) (/.install "char" (binary ..text//char)) (/.install "clip" (trinary ..text//clip)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index d2b823b85..9ed2c2624 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -342,7 +342,7 @@ (..char_index subject) ..lux_index)))))] (with_vars [byte_index] - (for {@.lua } + (for [@.lua ] (_.if ..on_rembulan? ))))) @@ -356,7 +356,7 @@ ... (_.+ (_.int +1)) (..byte_index text) (_.- (_.int +1)))))] - (for {@.lua } + (for [@.lua ] (_.if ..on_rembulan? )))) @@ -364,7 +364,7 @@ (runtime: (text//size subject) (with_expansions [ (_.return (_.apply/1 (_.var "string.len") subject)) (_.return (_.apply/1 (_.var "utf8.len") subject))] - (for {@.lua } + (for [@.lua ] (_.if ..on_rembulan? )))) @@ -383,7 +383,7 @@ (_.if (_.= _.nil offset) (_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text."))) (_.return (_.apply/2 (_.var "utf8.codepoint") text offset)))))] - (for {@.lua } + (for [@.lua ] (_.if ..on_rembulan? )))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index bfdf279fa..16283e2e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -291,7 +291,7 @@ [(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit] [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] )) - (_.return (for {@.python input} + (_.return (for [@.python input] ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index b256823f5..4913559a1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -18,23 +18,23 @@ ... This universe constant is for languages where one can't just turn all compiled definitions ... into the local variables of some scoping function. (def: .public universe - (for {... In the case of Lua, there is a limit of 200 locals in a function's scope. + (for [ ... In the case of Lua, there is a limit of 200 locals in a function's scope. @.lua (not ("lua script universe")) ... Cannot make all definitions be local variables because of limitations with JRuby. @.ruby (not ("ruby script universe")) ... Cannot make all definitions be local variables because of limitations with PHP itself. @.php (not ("php script universe")) ... Cannot make all definitions be local variables because of limitations with Kawa. - @.scheme (not ("scheme script universe"))} + @.scheme (not ("scheme script universe"))] #0)) (def: universe_label Text (with_expansions [