diff options
Diffstat (limited to '')
17 files changed, 438 insertions, 365 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index 91480ba4c..8fcfe64d9 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -1,46 +1,43 @@ (.using - [library - [lux - [program {"+" program:}] - ["$" documentation {"+" documentation:}] - ["[0]" debug] - [control - ["[0]" io] - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]] - [collection - ["[0]" list] - ["[0]" set]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]] - ["[0]" / "_" - ["[1][0]" abstract] - ["[1][0]" control] - ["[1][0]" data] - ["[1][0]" debug] - ["[1][0]" documentation] - ["[1][0]" extension] - ["[1][0]" ffi] - ["[1][0]" locale] - ["[1][0]" macro] - ["[1][0]" math] - ["[1][0]" meta] - ["[1][0]" program] - ["[1][0]" static] - ["[1][0]" target] - ["[1][0]" test] - ["[1][0]" time] - ["[1][0]" tool] ... TODO: Documentation for this - ["[1][0]" type] - ["[1][0]" world] - ... ["[1][0]" target "_" - ... <target>] - ]) + [library + [lux + [program {"+" program:}] + ["$" documentation {"+" documentation:}] + ["[0]" debug] + [control + ["[0]" io] + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]] + [collection + ["[0]" list] + ["[0]" set]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]] + ["[0]" / "_" + ["[1][0]" abstract] + ["[1][0]" control] + ["[1][0]" data] + ["[1][0]" debug] + ["[1][0]" documentation] + ["[1][0]" extension] + ["[1][0]" ffi] + ["[1][0]" locale] + ["[1][0]" macro] + ["[1][0]" math] + ["[1][0]" meta] + ["[1][0]" program] + ["[1][0]" static] + ["[1][0]" target] + ["[1][0]" test] + ["[1][0]" time] + ["[1][0]" tool] ... TODO: Documentation for this + ["[1][0]" type] + ["[1][0]" world]]) (documentation: /.prelude_module (format "The name of the prelude module" @@ -597,16 +594,16 @@ (documentation: /.using "Module-definition macro." [(.using - [lux "*" - [control - ["M" monad "*"]] - [data - maybe - ["[0]" name ("[1]#[0]" codec)]] - [macro - code]] - [// - [type ("[0]" equivalence)]])]) + [lux "*" + [control + ["M" monad "*"]] + [data + maybe + ["[0]" name ("[1]#[0]" codec)]] + [macro + code]] + [// + [type ("[0]" equivalence)]])]) (documentation: /.# "Allows accessing the value of a implementation's member." diff --git a/stdlib/source/documentation/lux/ffi.lua.lux b/stdlib/source/documentation/lux/ffi.lua.lux new file mode 100644 index 000000000..79d6f03ac --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.lua.lux @@ -0,0 +1,38 @@ +(.using + [library + [lux {"-" int char type :as} + ["$" documentation {"+" documentation:}] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) + +(documentation: /.import: + "Easily import types, methods, functions and constants." + [(import: (os/getenv [..String] "io" "?" ..String))]) + +(documentation: /.closure + (format "Allows defining closures/anonymous-functions in the form that Lua expects." + \n "This is useful for adapting Lux functions for usage by Lua code.") + [(: ..Function + (closure [left right] + (do_something (:as Foo left) (:as Bar right))))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..import: + ..closure + ($.default (/.Object brand)) + ($.default /.Nil) + ($.default /.Function) + ($.default /.Table) + ($.default /.Boolean) + ($.default /.Integer) + ($.default /.Float) + ($.default /.String)] + [])) diff --git a/stdlib/source/documentation/lux/ffi.py.lux b/stdlib/source/documentation/lux/ffi.py.lux new file mode 100644 index 000000000..6b24c1926 --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.py.lux @@ -0,0 +1,59 @@ +(.using + [library + [lux {"-" int char type :as} + ["$" documentation {"+" documentation:}] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) + +(documentation: /.import: + "Easily import types, methods, functions and constants." + [(import: os + ["[1]::[0]" + ("static" F_OK Integer) + ("static" R_OK Integer) + ("static" W_OK Integer) + ("static" X_OK Integer) + + ("static" mkdir [String] "io" "try" "?" Any) + ("static" access [String Integer] "io" "try" Boolean) + ("static" remove [String] "io" "try" "?" Any) + ("static" rmdir [String] "io" "try" "?" Any) + ("static" rename [String String] "io" "try" "?" Any) + ("static" listdir [String] "io" "try" (Array String))]) + + (import: os/path + ["[1]::[0]" + ("static" isfile [String] "io" "try" Boolean) + ("static" isdir [String] "io" "try" Boolean) + ("static" sep String) + ("static" getsize [String] "io" "try" Integer) + ("static" getmtime [String] "io" "try" Float)])]) + +(documentation: /.lambda + (format "Allows defining closures/anonymous-functions in the form that Python expects." + \n "This is useful for adapting Lux functions for usage by Python code.") + [(: ..Function + (lambda [left right] + (do_something (:as Foo left) + (:as Bar right))))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..import: + ..lambda + ($.default (/.Object brand)) + ($.default /.None) + ($.default /.Dict) + ($.default /.Function) + ($.default /.Boolean) + ($.default /.Integer) + ($.default /.Float) + ($.default /.String)] + [])) diff --git a/stdlib/source/documentation/lux/ffi.rb.lux b/stdlib/source/documentation/lux/ffi.rb.lux index 8f9a93724..33b4ef148 100644 --- a/stdlib/source/documentation/lux/ffi.rb.lux +++ b/stdlib/source/documentation/lux/ffi.rb.lux @@ -39,7 +39,6 @@ ($.default (/.Object brand)) ($.default /.Nil) ($.default /.Function) - ($.default /.Function) ($.default /.Integer) ($.default /.Float) ($.default /.String)] diff --git a/stdlib/source/documentation/lux/world/console.lux b/stdlib/source/documentation/lux/world/console.lux index 97ee7bacf..c091e6d36 100644 --- a/stdlib/source/documentation/lux/world/console.lux +++ b/stdlib/source/documentation/lux/world/console.lux @@ -1,17 +1,18 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux "*" + ["$" documentation {"+" documentation:}] + ["@" target] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: (/.Console !) "An interface to console/terminal I/O.") @@ -30,14 +31,15 @@ (.def: .public documentation (.List $.Module) - ($.module /._ - "" - [..Console - ..write_line - ..Mock - ..mock - ($.default /.async) - ($.default /.cannot_open) - ($.default /.cannot_close) - ($.default /.default)] - [])) + (`` (`` ($.module /._ + "" + [..Console + ..write_line + ..Mock + ..mock + ($.default /.async) + (~~ (for [@.jvm (~~ (as_is ($.default /.cannot_open) + ($.default /.cannot_close) + ($.default /.default)))] + (~~ (as_is))))] + [])))) diff --git a/stdlib/source/documentation/lux/world/file.lux b/stdlib/source/documentation/lux/world/file.lux index 866ecf959..e2f203abe 100644 --- a/stdlib/source/documentation/lux/world/file.lux +++ b/stdlib/source/documentation/lux/world/file.lux @@ -1,19 +1,20 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]] - ["[0]" / "_" - ["[1][0]" watch]]) + [library + [lux "*" + ["$" documentation {"+" documentation:}] + ["@" target] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]] + ["[0]" / "_" + ["[1][0]" watch]]) (documentation: /.Path "A path to a file or a directory in a file-system.") @@ -53,24 +54,28 @@ (.def: .public documentation (.List $.Module) - ($.module /._ - "" - [..Path - ..System - ..parent - ..name - ..rooted - ..exists? - ..mock - ..make_directories - ..make_file - ($.default /.async) - ($.default /.cannot_make_file) - ($.default /.cannot_find_file) - ($.default /.cannot_delete) - ($.default /.cannot_make_directory) - ($.default /.cannot_find_directory) - ($.default /.cannot_read_all_data) - ($.default /.cannot_modify_file) - ($.default /.default)] - [/watch.documentation])) + (`` (`` ($.module /._ + "" + [..Path + ..System + ..parent + ..name + ..rooted + ..exists? + ..mock + ..make_directories + ..make_file + ($.default /.async) + ($.default /.cannot_make_file) + ($.default /.cannot_find_file) + ($.default /.cannot_delete) + ($.default /.cannot_make_directory) + ($.default /.cannot_find_directory) + ($.default /.cannot_read_all_data) + (~~ (for [@.jvm (~~ (as_is ($.default /.cannot_modify_file) + ($.default /.default))) + @.js (~~ (as_is ($.default /.default))) + @.python (~~ (as_is ($.default /.default))) + @.ruby (~~ (as_is ($.default /.default)))] + (~~ (as_is))))] + [/watch.documentation])))) diff --git a/stdlib/source/documentation/lux/world/file/watch.lux b/stdlib/source/documentation/lux/world/file/watch.lux index 3328fba20..14b9faa0a 100644 --- a/stdlib/source/documentation/lux/world/file/watch.lux +++ b/stdlib/source/documentation/lux/world/file/watch.lux @@ -1,17 +1,18 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux "*" + ["$" documentation {"+" documentation:}] + ["@" target] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: /.Concern "A particular concern to watch-out for.") @@ -33,26 +34,28 @@ \n "Must be given a path separator for the file-system.") [(mock separator)]) -(documentation: /.default - "The default watcher for the default file-system.") +(for [@.jvm (as_is (documentation: /.default + "The default watcher for the default file-system."))] + (as_is)) (.def: .public documentation (.List $.Module) - ($.module /._ - "" - [..Concern - ..also - ..Watcher - ..polling - ..mock - ..default - ($.default /.creation) - ($.default /.creation?) - ($.default /.modification) - ($.default /.modification?) - ($.default /.deletion) - ($.default /.deletion?) - ($.default /.all) - ($.default /.not_being_watched) - ($.default /.cannot_poll_a_non_existent_directory)] - [])) + (`` (`` ($.module /._ + "" + [..Concern + ..also + ..Watcher + ..polling + ..mock + ($.default /.creation) + ($.default /.creation?) + ($.default /.modification) + ($.default /.modification?) + ($.default /.deletion) + ($.default /.deletion?) + ($.default /.all) + ($.default /.not_being_watched) + ($.default /.cannot_poll_a_non_existent_directory) + (~~ (for [@.jvm (~~ (as_is ..default))] + (~~ (as_is))))] + [])))) diff --git a/stdlib/source/documentation/lux/world/net/http/client.lux b/stdlib/source/documentation/lux/world/net/http/client.lux index d3124090c..a11e8a0bb 100644 --- a/stdlib/source/documentation/lux/world/net/http/client.lux +++ b/stdlib/source/documentation/lux/world/net/http/client.lux @@ -1,17 +1,18 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux "*" + ["$" documentation {"+" documentation:}] + ["@" target] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: (/.Client !) "A HTTP client capable of issuing requests to a HTTP server.") @@ -29,26 +30,24 @@ [/.connect] [/.options] [/.trace] - [/.default] - [/.async] - [/.headers] ) (.def: .public documentation (.List $.Module) - ($.module /._ - "" - [..Client - ..post - ..get - ..put - ..patch - ..delete - ..head - ..connect - ..options - ..trace - ..default - ..async - ..headers] - [])) + (`` (`` ($.module /._ + "" + [..Client + ..post + ..get + ..put + ..patch + ..delete + ..head + ..connect + ..options + ..trace + ($.default /.async) + ($.default /.headers) + (~~ (for [@.jvm (~~ (as_is ($.default /.default)))] + (~~ (as_is))))] + [])))) diff --git a/stdlib/source/documentation/lux/world/shell.lux b/stdlib/source/documentation/lux/world/shell.lux index 9b283f847..0a39e0c6a 100644 --- a/stdlib/source/documentation/lux/world/shell.lux +++ b/stdlib/source/documentation/lux/world/shell.lux @@ -1,17 +1,18 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux "*" + ["$" documentation {"+" documentation:}] + ["@" target] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: /.Exit "A program exit code.") @@ -37,18 +38,19 @@ (.def: .public documentation (.List $.Module) - ($.module /._ - "" - [..Exit - ..Process - ..Command - ..Argument - ..Shell - ..Mock - ..mock - ($.default /.normal) - ($.default /.error) - ($.default /.async) - ($.default /.no_more_output) - ($.default /.default)] - [])) + (`` (`` ($.module /._ + "" + [..Exit + ..Process + ..Command + ..Argument + ..Shell + ..Mock + ..mock + ($.default /.normal) + ($.default /.error) + ($.default /.async) + (~~ (for [@.jvm (~~ (as_is ($.default /.no_more_output) + ($.default /.default)))] + (~~ (as_is))))] + [])))) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 132fff652..923919c16 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -1,45 +1,45 @@ (.using - [library - [lux {"-" type private} - ["@" target] - ["[0]" type] - ["[0]" ffi {"+" import:}] - ["[0]" meta] - [abstract - ["[0]" monad {"+" do}]] - [control - [pipe {"+" new>}] - ["[0]" function] - ["[0]" try {"+" Try}] - ["[0]" exception {"+" exception:}] - ["<>" parser - ["<[0]>" type {"+" Parser}] - ["<[0]>" code]]] - [data - ["[0]" text - ["%" format {"+" Format}]] - [format - [xml {"+" XML}] - ["[0]" json]] - [collection - ["[0]" array] - ["[0]" list ("[1]#[0]" functor)] - ["[0]" dictionary]]] - [macro - ["[0]" template] - ["[0]" syntax {"+" syntax:}] - ["[0]" code]] - [math - [number - [ratio {"+" Ratio}] - ["n" nat] - ["i" int]]] - [time {"+" Time} - [instant {"+" Instant}] - [duration {"+" Duration}] - [date {"+" Date}] - [month {"+" Month}] - [day {"+" Day}]]]]) + [library + [lux {"-" type private} + ["@" target] + ["[0]" type] + ["[0]" ffi {"+" import:}] + ["[0]" meta] + [abstract + ["[0]" monad {"+" do}]] + [control + [pipe {"+" new>}] + ["[0]" function] + ["[0]" try {"+" Try}] + ["[0]" exception {"+" exception:}] + ["<>" parser + ["<[0]>" type {"+" Parser}] + ["<[0]>" code]]] + [data + ["[0]" text + ["%" format {"+" Format}]] + [format + [xml {"+" XML}] + ["[0]" json]] + [collection + ["[0]" array] + ["[0]" list ("[1]#[0]" functor)] + ["[0]" dictionary]]] + [macro + ["[0]" template] + ["[0]" syntax {"+" syntax:}] + ["[0]" code]] + [math + [number + [ratio {"+" Ratio}] + ["n" nat] + ["i" int]]] + [time {"+" Time} + [instant {"+" Instant}] + [duration {"+" Duration}] + [date {"+" Date}] + [month {"+" Month}] + [day {"+" Day}]]]]) (with_expansions [<jvm> (as_is (import: java/lang/String) diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index cfc38cc24..ece090ecd 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -1,6 +1,6 @@ (.using [library - [lux "*" + [lux {"-" Symbol} ["[0]" meta] [abstract [monad {"+" do}]] @@ -244,7 +244,7 @@ (function (_ member_name) (|> format (text.replaced "[1]" class_name) - (text.replaced "." member_name) + (text.replaced "[0]" member_name) code.local_symbol))) class_parameters (list#each code.local_symbol class_parameters) declaration (` ((~ (code.local_symbol class_name)) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 346519334..1a99178cd 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -1,27 +1,27 @@ (.using - [library - [lux "*" - ["@" target] - ["[0]" meta] - [abstract - [monad {"+" do}]] - [control - ["[0]" io] - ["[0]" maybe] - ["<>" parser ("[1]#[0]" monad) - ["<[0]>" code {"+" Parser}]]] - [data - ["[0]" product] - ["[0]" text - ["%" format]] - [collection - ["[0]" list ("[1]#[0]" functor mix)]]] - [type - abstract] - [macro {"+" with_symbols} - [syntax {"+" syntax:}] - ["[0]" code] - ["[0]" template]]]]) + [library + [lux "*" + ["@" target] + ["[0]" meta] + [abstract + [monad {"+" do}]] + [control + ["[0]" io] + ["[0]" maybe] + ["<>" parser ("[1]#[0]" monad) + ["<[0]>" code {"+" Parser}]]] + [data + ["[0]" product] + ["[0]" text + ["%" format]] + [collection + ["[0]" list ("[1]#[0]" functor mix)]]] + [type + abstract] + [macro {"+" with_symbols} + [syntax {"+" syntax:}] + ["[0]" code] + ["[0]" template]]]]) (abstract: .public (Object brand) Any) @@ -217,8 +217,6 @@ (~+ (list#each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) - ... {.#doc (example "Easily import types, methods, functions and constants." - ... (import: (os/getenv [..String] "io" "?" ..String)))} (with_symbols [g!temp] (case import {#Class [class format members]} @@ -309,11 +307,6 @@ ))) (template: .public (closure <inputs> <output>) - ... {.#doc (example "Allows defining closures/anonymous-functions in the form that Lua expects." - ... "This is useful for adapting Lux functions for usage by Lua code." - ... (: ..Function - ... (closure [left right] - ... (do_something (:as Foo left) (:as Bar right)))))} [(.:as ..Function (`` ("lua function" (~~ (template.amount <inputs>)) diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index e35da749c..4cb39155c 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -217,28 +217,6 @@ (~+ (list#each (with_none g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) - ... {.#doc (example "Easily import types, methods, functions and constants." - ... (import: os - ... ["[1]::[0]" - ... ("static" F_OK ..Integer) - ... ("static" R_OK ..Integer) - ... ("static" W_OK ..Integer) - ... ("static" X_OK ..Integer) - - ... ("static" mkdir [..String] "io" "try" "?" Any) - ... ("static" access [..String ..Integer] "io" "try" ..Boolean) - ... ("static" remove [..String] "io" "try" "?" Any) - ... ("static" rmdir [..String] "io" "try" "?" Any) - ... ("static" rename [..String ..String] "io" "try" "?" Any) - ... ("static" listdir [..String] "io" "try" (Array ..String))]) - - ... (import: os/path - ... ["[1]::[0]" - ... ("static" isfile [..String] "io" "try" ..Boolean) - ... ("static" isdir [..String] "io" "try" ..Boolean) - ... ("static" sep ..String) - ... ("static" getsize [..String] "io" "try" ..Integer) - ... ("static" getmtime [..String] "io" "try" ..Float)]))} (with_symbols [g!temp] (case import {#Class [class format members]} @@ -334,11 +312,6 @@ ))) (template: .public (lambda <inputs> <output>) - ... {.#doc (example "Allows defining closures/anonymous-functions in the form that Python expects." - ... "This is useful for adapting Lux functions for usage by Python code." - ... (: ..Function - ... (lambda [left right] - ... (do_something (:as Foo left) (:as Bar right)))))} [(.:as ..Function (`` ("python function" (~~ (template.amount <inputs>)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index c44b73500..c21dc12ec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -80,7 +80,7 @@ (in (list#mix (function (_ side source) (.let [method (.case side (^template [<side> <accessor>] - [(<side> lefts) + [{<side> lefts} (<accessor> (_.i32 (.int lefts)))]) ([.#Left //runtime.tuple//left] [.#Right //runtime.tuple//right]))] @@ -131,11 +131,12 @@ (_.statement (|> @cursor (_.do "splice" (list (|> @cursor ..length (_.- popsJS)) popsJS)))))) -(template [<name> <flag> <prep>] +(template [<name> <flag>] [(def: (<name> simple? idx) (-> Bit Nat Statement) ($_ _.then - (_.set @temp (|> idx <prep> .int _.i32 (//runtime.sum//get ..peek_cursor <flag>))) + (_.set @temp (//runtime.sum//get ..peek_cursor <flag> + (|> idx .int _.i32))) (.if simple? (_.when (_.= _.null @temp) ..fail_pm!) @@ -143,8 +144,8 @@ ..fail_pm! (push_cursor! @temp)))))] - [left_choice _.null (<|)] - [right_choice (_.string "") ++] + [left_choice _.null] + [right_choice //runtime.unit] ) (def: (alternation pre! post!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux index 25dab5ed7..0874ed4f3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux @@ -9,5 +9,5 @@ (implementation: .public system (System Expression) - (def: constant _.var) - (def: variable _.var)) + (def: constant' _.var) + (def: variable' _.var)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 766d7e940..1fdba6ac2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -190,38 +190,35 @@ (-> Expression Expression Expression Computation) (_.new ..variant//new (list tag last? value))) -(runtime: (sum//get sum wants_last wanted_tag) - (let [no_match! (_.return _.null) - sum_tag (|> sum (_.the ..variant_tag_field)) - sum_flag (|> sum (_.the ..variant_flag_field)) - sum_value (|> sum (_.the ..variant_value_field)) - is_last? (_.= ..unit sum_flag) - extact_match! (_.return sum_value) - test_recursion! (_.if is_last? - ... Must recurse. - ($_ _.then - (_.set wanted_tag (_.- sum_tag wanted_tag)) - (_.set sum sum_value)) - no_match!) - extrac_sub_variant! (_.return (..variant (_.- wanted_tag sum_tag) sum_flag sum_value))] +(runtime: (sum//get sum expected##right? expected##lefts) + (let [mismatch! (_.return _.null) + actual##lefts (|> sum (_.the ..variant_tag_field)) + actual##right? (|> sum (_.the ..variant_flag_field)) + actual##value (|> sum (_.the ..variant_value_field)) + is_last? (_.= ..unit actual##right?) + recur! ($_ _.then + (_.set expected##lefts (|> expected##lefts + (_.- actual##lefts) + (_.- (_.i32 +1)))) + (_.set sum actual##value))] (<| (_.while (_.boolean true)) - (_.cond (list [(_.= wanted_tag sum_tag) - (_.if (_.= wants_last sum_flag) - extact_match! - test_recursion!)] - [(_.< wanted_tag sum_tag) - test_recursion!] - [(_.= ..unit wants_last) - extrac_sub_variant!]) - no_match!)))) - -(def: none - Computation - (..variant (_.i32 +0) (flag #0) unit)) - -(def: some - (-> Expression Computation) - (..variant (_.i32 +1) (flag #1))) + (_.cond (list [(_.= expected##lefts actual##lefts) + (_.if (_.= expected##right? actual##right?) + (_.return actual##value) + mismatch!)] + + [(_.< expected##lefts actual##lefts) + (_.if (_.= ..unit actual##right?) + recur! + mismatch!)] + + [(_.= ..unit expected##right?) + (_.return (..variant (|> actual##lefts + (_.- expected##lefts) + (_.- (_.i32 +1))) + actual##right? + actual##value))]) + mismatch!)))) (def: left (-> Expression Computation) @@ -229,7 +226,15 @@ (def: right (-> Expression Computation) - (..variant (_.i32 +1) (flag #1))) + (..variant (_.i32 +0) (flag #1))) + +(def: none + Computation + (..left ..unit)) + +(def: some + (-> Expression Computation) + ..right) (def: runtime//structure Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 6629816d0..9aefc6a48 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -1,18 +1,18 @@ (.using - [library - [lux {"-" Variant Tuple} - [abstract - ["[0]" monad {"+" do}]] - [target - ["_" js {"+" Expression}]]]] - ["[0]" // "_" - ["[1][0]" runtime {"+" Operation Phase Generator}] - ["[1][0]" primitive] - ["///[1]" //// "_" - [analysis {"+" Variant Tuple}] - ["[1][0]" synthesis {"+" Synthesis}] - ["//[1]" /// - ["[1][0]" phase ("[1]#[0]" monad)]]]]) + [library + [lux {"-" Variant Tuple} + [abstract + ["[0]" monad {"+" do}]] + [target + ["_" js {"+" Expression}]]]] + ["[0]" // "_" + ["[1][0]" runtime {"+" Operation Phase Generator}] + ["[1][0]" primitive] + ["///[1]" //// "_" + [analysis {"+" Variant Tuple}] + ["[1][0]" synthesis {"+" Synthesis}] + ["//[1]" /// + ["[1][0]" phase ("[1]#[0]" monad)]]]]) (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) @@ -30,9 +30,6 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) - (let [tag (if right? - (++ lefts) - lefts)] - (///////phase#each (//runtime.variant (_.i32 (.int tag)) - (//runtime.flag right?)) - (generate archive valueS)))) + (///////phase#each (//runtime.variant (_.i32 (.int lefts)) + (//runtime.flag right?)) + (generate archive valueS))) |