diff options
Diffstat (limited to 'stdlib')
60 files changed, 562 insertions, 359 deletions
diff --git a/stdlib/source/documentation/lux/control/parser.lux b/stdlib/source/documentation/lux/control/parser.lux index ba7a726b2..a0ccd9f40 100644 --- a/stdlib/source/documentation/lux/control/parser.lux +++ b/stdlib/source/documentation/lux/control/parser.lux @@ -82,9 +82,9 @@ "Always fail with this 'message'." ($.example (failure message))) - ($.definition /.lifted + ($.definition /.of_try "Lift a potentially failed computation into a parser." - ($.example (lifted operation))) + ($.example (of_try operation))) ($.definition /.else "If the given parser fails, returns the default value." diff --git a/stdlib/source/documentation/lux/meta.lux b/stdlib/source/documentation/lux/meta.lux index a14f67132..f2a72fb32 100644 --- a/stdlib/source/documentation/lux/meta.lux +++ b/stdlib/source/documentation/lux/meta.lux @@ -144,7 +144,7 @@ ($.definition /.type_context "The current type-checking context.")) - computation (list ($.definition /.lifted) + computation (list ($.definition /.of_try) ($.definition /.try) ($.definition /.result' diff --git a/stdlib/source/documentation/lux/meta/compiler/language/lux/declaration.lux b/stdlib/source/documentation/lux/meta/compiler/language/lux/declaration.lux index 8a073556e..42c985ad2 100644 --- a/stdlib/source/documentation/lux/meta/compiler/language/lux/declaration.lux +++ b/stdlib/source/documentation/lux/meta/compiler/language/lux/declaration.lux @@ -29,8 +29,8 @@ ($.definition /.analysis) ($.definition /.synthesis) ($.definition /.translation) - ($.definition /.lifted_analysis) - ($.definition /.lifted_synthesis) - ($.definition /.lifted_translation) + ($.definition /.of_analysis) + ($.definition /.of_synthesis) + ($.definition /.of_translation) ($.definition /.set_current_module) )) diff --git a/stdlib/source/documentation/lux/meta/compiler/phase.lux b/stdlib/source/documentation/lux/meta/compiler/phase.lux index fe549b6c9..55c5cca7c 100644 --- a/stdlib/source/documentation/lux/meta/compiler/phase.lux +++ b/stdlib/source/documentation/lux/meta/compiler/phase.lux @@ -26,7 +26,7 @@ ($.definition /.sub) ($.definition /.failure) ($.definition /.except) - ($.definition /.lifted) + ($.definition /.of_try) ($.definition /.assertion) ($.definition /.identity) ($.definition /.composite) diff --git a/stdlib/source/experiment/tool/interpreter.lux b/stdlib/source/experiment/tool/interpreter.lux index a52ae4129..3a001396a 100644 --- a/stdlib/source/experiment/tool/interpreter.lux +++ b/stdlib/source/experiment/tool/interpreter.lux @@ -60,7 +60,7 @@ (def enter_module (All (_ anchor expression declaration) (Operation anchor expression declaration Any)) - (declaration.lifted_analysis + (declaration.of_analysis (do phase.monad [_ (module.create 0 ..module)] (analysis.set_current_module ..module)))) @@ -103,7 +103,7 @@ .let [analyse (the [declaration.#analysis declaration.#phase] state) synthesize (the [declaration.#synthesis declaration.#phase] state) translate (the [declaration.#translation declaration.#phase] state)] - [_ codeT codeA] (declaration.lifted_analysis + [_ codeT codeA] (declaration.of_analysis (analysis.with_scope (type.with_fresh_env (do ! @@ -112,9 +112,9 @@ codeT (type.with_env (check.clean codeT))] (in [codeT codeA]))))) - codeS (declaration.lifted_synthesis + codeS (declaration.of_synthesis (synthesize codeA))] - (declaration.lifted_translation + (declaration.of_translation (translation.with_buffer (do ! [codeH (translate codeS) diff --git a/stdlib/source/library/lux/control/aspect.lux b/stdlib/source/library/lux/control/aspect.lux index df37fce28..f117ded5e 100644 --- a/stdlib/source/library/lux/control/aspect.lux +++ b/stdlib/source/library/lux/control/aspect.lux @@ -166,17 +166,17 @@ (-> Symbol (-> [Code .Global] (declaration.Operation anchor expression declaration of)) (declaration.Operation anchor expression declaration of))) (do phase.monad - [g!cache (declaration.lifted_analysis + [g!cache (declaration.of_analysis (macro.symbol "g!cache")) - [exported? global] (declaration.lifted_analysis + [exported? global] (declaration.of_analysis (global_reference name)) .let [cache_name (%.code g!cache)] - _ (declaration.lifted_analysis + _ (declaration.of_analysis (module.define cache_name [exported? global])) it (then [g!cache global]) - current_module_name (declaration.lifted_analysis + current_module_name (declaration.of_analysis meta.current_module_name) - _ (declaration.lifted_analysis + _ (declaration.of_analysis (without_global [current_module_name cache_name]))] (in it))) @@ -196,12 +196,12 @@ (-> [Symbol .Global] (declaration.Operation anchor expression declaration of) (declaration.Operation anchor expression declaration of))) (do phase.monad - [[exported? old] (declaration.lifted_analysis + [[exported? old] (declaration.of_analysis (global_reference name)) - _ (declaration.lifted_analysis + _ (declaration.of_analysis (module.override_definition name [exported? new])) it then - _ (declaration.lifted_analysis + _ (declaration.of_analysis (module.override_definition name [exported? old]))] (in it))) @@ -284,7 +284,7 @@ (declaration (_ phase archive [aspect ?code.any body ?code.any]) (do [! phase.monad] - [aspect (declaration.lifted_analysis + [aspect (declaration.of_analysis (meta.eval Aspect aspect)) .let [aspect (as Aspect aspect)]] (list#mix (function (_ [original value] then) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 0d7fd1217..453c293b4 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -210,8 +210,10 @@ (function (_ input) {try.#Failure message})) -(def .public (lifted operation) - (All (_ s a) (-> (Try a) (Parser s a))) +(def .public (of_try operation) + (All (_ state of) + (-> (Try of) + (Parser state of))) (function (_ input) (when operation {try.#Success output} diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index e2bd180f3..d61e01b02 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -40,13 +40,6 @@ (type .public HSL [Frac Frac Frac]) -(type .public CMYK - (Record - [#cyan Frac - #magenta Frac - #yellow Frac - #key Frac])) - (type .public HSB [Frac Frac Frac]) @@ -226,40 +219,6 @@ try.trusted of_rgb))) -(def .public (cmyk color) - (-> Color CMYK) - (let [[red green blue] (rgb color) - red (..down (rgb.number red)) - green (..down (rgb.number green)) - blue (..down (rgb.number blue)) - key (|> +1.0 (f.- (all f.max red green blue))) - f (if (f.< +1.0 key) - (|> +1.0 (f./ (|> +1.0 (f.- key)))) - +0.0) - cyan (|> +1.0 (f.- red) (f.- key) (f.* f)) - magenta (|> +1.0 (f.- green) (f.- key) (f.* f)) - yellow (|> +1.0 (f.- blue) (f.- key) (f.* f))] - [#cyan cyan - #magenta magenta - #yellow yellow - #key key])) - -(def .public (of_cmyk [cyan magenta yellow key]) - (-> CMYK Color) - (if (f.= +1.0 key) - ..black - (let [red (|> (|> +1.0 (f.- cyan)) - (f.* (|> +1.0 (f.- key)))) - green (|> (|> +1.0 (f.- magenta)) - (f.* (|> +1.0 (f.- key)))) - blue (|> (|> +1.0 (f.- yellow)) - (f.* (|> +1.0 (f.- key))))] - (|> (rgb.rgb (..up red) - (..up green) - (..up blue)) - try.trusted - of_rgb)))) - (def (normal ratio) (-> Frac Frac) (cond (f.> +1.0 ratio) diff --git a/stdlib/source/library/lux/data/color/cmyk.lux b/stdlib/source/library/lux/data/color/cmyk.lux new file mode 100644 index 000000000..3e22ab333 --- /dev/null +++ b/stdlib/source/library/lux/data/color/cmyk.lux @@ -0,0 +1,133 @@ +(.require + [library + [lux (.except) + [abstract + [equivalence (.only Equivalence)]] + [control + ["[0]" try (.only Try)] + ["[0]" exception (.only Exception)]] + [data + [text + ["%" \\format]]] + [math + [number + ["f" frac] + ["[0]" int]]] + [meta + [type + ["[0]" primitive]]]]] + [// + ["[0]" rgb (.only RGB)]]) + +(with_expansions [<min> +0.0 + <max> +1.0] + (primitive.def .public Value + Frac + + (with_template [<number> <name>] + [(def .public <name> + Value + (primitive.abstraction <number>))] + + [<min> least] + [<max> most] + ) + + (exception.def .public (invalid it) + (Exception Frac) + (exception.report + (list ["Minimum" (%.frac (primitive.representation ..least))] + ["Maximum" (%.frac (primitive.representation ..most))] + ["Value" (%.frac it)]))) + + (def .public (value it) + (-> Frac + (Try Value)) + (if (or (f.> (primitive.representation ..most) + it) + (f.< (primitive.representation ..least) + it)) + (exception.except ..invalid [it]) + {try.#Success (primitive.abstraction it)})) + + (def .public number + (-> Value + Frac) + (|>> primitive.representation)) + + (type .public CMYK + (Record + [#cyan Value + #magenta Value + #yellow Value + #key Value])) + + (def .public equivalence + (Equivalence CMYK) + (implementation + (def (= [cR mR yR kR] [cS mS yS kS]) + (and (f.= (primitive.representation cR) (primitive.representation cS)) + (f.= (primitive.representation mR) (primitive.representation mS)) + (f.= (primitive.representation yR) (primitive.representation yS)) + (f.= (primitive.representation kR) (primitive.representation kS)))))) + + (def top + (-- rgb.limit)) + + (def rgb_factor + (|> top .int int.frac)) + + (def down + (-> Nat + Frac) + (|>> .int int.frac (f./ rgb_factor))) + + (def up + (-> Frac + Nat) + (|>> (f.* rgb_factor) f.int .nat)) + + (def (opposite it) + (-> Frac + Frac) + (f.- it <max>)) + + (def .public (cmyk it) + (-> RGB + CMYK) + (let [red (..down (rgb.number (the rgb.#red it))) + green (..down (rgb.number (the rgb.#green it))) + blue (..down (rgb.number (the rgb.#blue it))) + key (opposite (all f.max red green blue)) + f (if (f.< <max> key) + (f./ (opposite key) + <max>) + <min>) + cyan (|> <max> (f.- red) (f.- key) (f.* f)) + magenta (|> <max> (f.- green) (f.- key) (f.* f)) + yellow (|> <max> (f.- blue) (f.- key) (f.* f))] + [#cyan (primitive.abstraction cyan) + #magenta (primitive.abstraction magenta) + #yellow (primitive.abstraction yellow) + #key (primitive.abstraction key)])) + + (def .public (rgb it) + (-> CMYK + RGB) + (when (primitive.representation (the #key it)) + <max> + rgb.black + + key + (let [~key (opposite key) + red (f.* ~key + (opposite (primitive.representation (the #cyan it)))) + green (f.* ~key + (opposite (primitive.representation (the #magenta it)))) + blue (f.* ~key + (opposite (primitive.representation (the #yellow it))))] + (|> (rgb.rgb (..up red) + (..up green) + (..up blue)) + try.trusted)))) + )) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index aaa41f747..8daa5be57 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -3,7 +3,8 @@ [lux (.except Mode #mode and) [ffi (.only)] [abstract - [monad (.only do)]] + [monad (.only do)] + [codec (.only Codec)]] [control ["<>" parser] ["[0]" pipe] @@ -13,8 +14,8 @@ ["[0]" product] ["[0]" binary (.only Binary) ["[1]!" \\unsafe] - ["[0]" \\format (.only Format) (.use "[1]#[0]" monoid)] - ["<[1]>" \\parser (.only Parser)]] + ["![1]" \\format (.only Format) (.use "[1]#[0]" monoid)] + ["?[1]" \\parser (.only Parser)]] ["[0]" text (.only) [char (.only Char)] ["%" \\format] @@ -100,7 +101,7 @@ (..octal_padding <size>) (text.suffix suffix) (at utf8.codec encoded) - (\\format.segment padded_size)))) + (!binary.segment padded_size)))) (def <coercion> (-> Nat <type>) @@ -127,12 +128,12 @@ (def small_suffix (Parser Any) (do <>.monad - [pre_end <binary>.bits_8 + [pre_end ?binary.bits_8 _ (let [expected (`` (char (,, (static ..blank))))] (<>.assertion (exception.error ..wrong_character [expected pre_end]) (n.= expected pre_end))) - end <binary>.bits_8 + end ?binary.bits_8 _ (let [expected (`` (char (,, (static ..null))))] (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end)))] @@ -141,10 +142,10 @@ (def small_parser (Parser Small) (do <>.monad - [digits (<binary>.segment ..small_size) - digits (<>.lifted (at utf8.codec decoded digits)) + [digits (?binary.segment ..small_size) + digits (<>.of_try (at utf8.codec decoded digits)) _ ..small_suffix] - (<>.lifted + (<>.of_try (do [! try.monad] [value (at n.octal decoded digits)] (..small value))))) @@ -152,13 +153,13 @@ (def big_parser (Parser Big) (do <>.monad - [digits (<binary>.segment ..big_size) - digits (<>.lifted (at utf8.codec decoded digits)) - end <binary>.bits_8 + [digits (?binary.segment ..big_size) + digits (<>.of_try (at utf8.codec decoded digits)) + end ?binary.bits_8 _ (let [expected (`` (char (,, (static ..blank))))] (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end)))] - (<>.lifted + (<>.of_try (do [! try.monad] [value (at n.octal decoded digits)] (..big value))))) @@ -203,15 +204,15 @@ ..small_size)] (|>> representation (at utf8.codec encoded) - (\\format.segment padded_size)))) + (!binary.segment padded_size)))) (def checksum_parser (Parser [Nat Checksum]) (do <>.monad - [ascii (<binary>.segment ..small_size) - digits (<>.lifted (at utf8.codec decoded ascii)) + [ascii (?binary.segment ..small_size) + digits (<>.of_try (at utf8.codec decoded ascii)) _ ..small_suffix - value (<>.lifted + value (<>.of_try (at n.octal decoded digits))] (in [value (abstraction (%.format digits ..checksum_suffix))]))) @@ -288,17 +289,17 @@ (|>> representation (text.suffix suffix) (at utf8.codec encoded) - (\\format.segment padded_size)))) + (!binary.segment padded_size)))) (def <parser> (Parser <type>) (do <>.monad - [string (<binary>.segment <size>) - end <binary>.bits_8 + [string (?binary.segment <size>) + end ?binary.bits_8 .let [expected (`` (char (,, (static ..null))))] _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] - (<>.lifted + (<>.of_try (do [! try.monad] [text (at utf8.codec decoded (..un_padded string))] (<in> text))))) @@ -330,17 +331,17 @@ ..magic_size)] (|>> representation (at utf8.codec encoded) - (\\format.segment padded_size)))) + (!binary.segment padded_size)))) (def magic_parser (Parser Magic) (do <>.monad - [string (<binary>.segment ..magic_size) - end <binary>.bits_8 + [string (?binary.segment ..magic_size) + end ?binary.bits_8 .let [expected (`` (char (,, (static ..null))))] _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] - (<>.lifted + (<>.of_try (at try.monad each (|>> abstraction) (at utf8.codec decoded string))))) ) @@ -411,7 +412,7 @@ (def link_flag_format (Format Link_Flag) (|>> representation - \\format.bits_8)) + !binary.bits_8)) (with_expansions [<options> (these [0 old_normal] [(char "0") normal] @@ -438,7 +439,7 @@ (def link_flag_parser (Parser Link_Flag) (do <>.monad - [it <binary>.bits_8] + [it ?binary.bits_8] (when (.nat it) (^.with_template [<value> <link_flag>] [<value> @@ -446,7 +447,7 @@ (<options>) _ - (<>.lifted + (<>.of_try (exception.except ..invalid_link_flag [(.nat it)])))))) ) @@ -528,7 +529,7 @@ [value (at ! each ..from_small ..small_parser)] (if (n.> (representation ..maximum_mode) value) - (<>.lifted + (<>.of_try (exception.except ..invalid_mode [value])) (in (abstraction value)))))) ) @@ -542,11 +543,11 @@ (primitive.def .public Content [Big Binary] - (def .public (content content) + (def .public (content it) (-> Binary (Try Content)) (do try.monad - [size (..big (binary!.size content))] - (in (abstraction [size content])))) + [size (..big (binary!.size it))] + (in (abstraction [size it])))) (def from_content (-> Content [Big Binary]) @@ -569,11 +570,21 @@ [#name Name #id ID])) +(def .public no_owner + Owner + [#name (try.trusted (..name "")) + #id ..no_id]) + (type .public Ownership (Record [#user Owner #group Owner])) +(def .public no_ownership + Ownership + [#user ..no_owner + #group ..no_owner]) + (type .public File [Path Instant Mode Ownership Content]) @@ -631,7 +642,7 @@ (def header_format' (Format Header) - (all \\format.and + (all !binary.and ..path_format ..mode_format ..small_format @@ -652,12 +663,12 @@ (Format Header) (let [checksum (|> header (has #checksum ..dummy_checksum) - (\\format.result ..header_format') + (!binary.result ..header_format') ..checksum_code)] (|> header (has #checksum checksum) - (\\format.result ..header_format') - (\\format.segment ..block_size)))) + (!binary.result ..header_format') + (!binary.segment ..block_size)))) (def modification_time (-> Instant Big) @@ -670,9 +681,9 @@ (-> Link_Flag (Format File)) (function (_ [path modification_time mode ownership content]) (let [[size content] (..from_content content) - format (all \\format.and + format (all !binary.and ..header_format - (\\format.segment (..rounded_content_size size)))] + (!binary.segment (..rounded_content_size size)))] (format [[#path path #mode mode #user_id (the [#user #id] ownership) @@ -749,11 +760,11 @@ (Format Tar) (let [end_of_archive (binary!.empty ..end_of_archive_size)] (function (_ tar) - (\\format#composite (sequence#mix (function (_ next total) - (\\format#composite total (..entry_format next))) - \\format#identity - tar) - (\\format.segment ..end_of_archive_size end_of_archive))))) + (!binary#composite (sequence#mix (function (_ next total) + (!binary#composite total (..entry_format next))) + !binary#identity + tar) + (!binary.segment ..end_of_archive_size end_of_archive))))) (exception.def .public (wrong_checksum [expected actual]) (Exception [Nat Nat]) @@ -783,7 +794,7 @@ (def header_parser (Parser Header) (do <>.monad - [binary_header (<>.speculative (<binary>.segment block_size)) + [binary_header (<>.speculative (?binary.segment block_size)) path ..path_parser mode ..mode_parser user_id ..small_parser @@ -792,7 +803,7 @@ modification_time ..big_parser [actual checksum_code] ..checksum_parser _ (let [expected (expected_checksum checksum_code binary_header)] - (<>.lifted + (<>.of_try (exception.assertion ..wrong_checksum [expected actual] (n.= expected actual)))) link_flag ..link_flag_parser @@ -802,7 +813,7 @@ group_name ..name_parser major_device ..small_parser minor_device ..small_parser - _ (<binary>.segment ..header_padding_size)] + _ (?binary.segment ..header_padding_size)] (in [#path path #mode mode #user_id user_id @@ -823,9 +834,9 @@ (do <>.monad [.let [size (the #size header) rounded_size (..rounded_content_size size)] - content (<binary>.segment (..from_big size)) - content (<>.lifted (..content content)) - _ (<binary>.segment (n.- (..from_big size) rounded_size))] + content (?binary.segment (..from_big size)) + content (<>.of_try (..content content)) + _ (?binary.segment (n.- (..from_big size) rounded_size))] (in [(the #path header) (|> header (the #modification_time) @@ -863,9 +874,9 @@ (def end_of_archive_block_parser (Parser Any) (do <>.monad - [block (<binary>.segment ..block_size)] + [block (?binary.segment ..block_size)] (let [actual (..checksum block)] - (<>.lifted + (<>.of_try (exception.assertion ..wrong_checksum [0 actual] (n.= 0 actual)))))) @@ -875,8 +886,8 @@ (Parser Any) (do <>.monad [_ (<>.at_most 2 end_of_archive_block_parser) - done? <binary>.end?] - (<>.lifted + done? ?binary.end?] + (<>.of_try (exception.assertion ..invalid_end_of_archive [] done?)))) @@ -885,3 +896,9 @@ (|> (<>.some ..entry_parser) (at <>.monad each sequence.of_list) (<>.before ..end_of_archive_parser))) + +(def .public codec + (Codec Binary Tar) + (implementation + (def encoded (!binary.result ..format)) + (def decoded (?binary.result ..parser)))) diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index 1a54cb8ee..0ca0d157f 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -45,7 +45,7 @@ (all <>.and <code>.local <code>.any))) - meta.lifted)) + meta.of_try)) (with_expansions [<extension> (static.random (|>> %.nat (%.format "js export ") code.text) random.nat)] @@ -53,23 +53,23 @@ term <code>.any]) (do [! phase.monad] [next declaration.analysis - [_ term] (<| declaration.lifted_analysis + [_ term] (<| declaration.of_analysis type.inferring (next archive term)) next declaration.synthesis - term (declaration.lifted_synthesis + term (declaration.of_synthesis (next archive term)) - dependencies (declaration.lifted_translation + dependencies (declaration.of_translation (dependency.dependencies archive term)) next declaration.translation - [interim_artifacts term] (declaration.lifted_translation + [interim_artifacts term] (declaration.of_translation (translation.with_interim_artifacts archive (next archive term))) - _ (declaration.lifted_translation + _ (declaration.of_translation (do ! [@self (translation.learn_custom name (list#mix set.has dependencies interim_artifacts)) .let [$module (/.var "module") diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index 3153f1d47..64a94c874 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -45,7 +45,7 @@ (all <>.and <code>.local <code>.any))) - meta.lifted)) + meta.of_try)) ... [15.2 – Privacy](https://www.lua.org/pil/15.2.html) ... [15.3 – Packages and Files](https://www.lua.org/pil/15.3.html) @@ -57,23 +57,23 @@ term <code>.any]) (do [! phase.monad] [next declaration.analysis - [_ term] (<| declaration.lifted_analysis + [_ term] (<| declaration.of_analysis type.inferring (next archive term)) next declaration.synthesis - term (declaration.lifted_synthesis + term (declaration.of_synthesis (next archive term)) - dependencies (declaration.lifted_translation + dependencies (declaration.of_translation (dependency.dependencies archive term)) next declaration.translation - [interim_artifacts term] (declaration.lifted_translation + [interim_artifacts term] (declaration.of_translation (translation.with_interim_artifacts archive (next archive term))) - _ (declaration.lifted_translation + _ (declaration.of_translation (do ! [@self (translation.learn_custom name (list#mix set.has dependencies interim_artifacts)) .let [$exports (/.var "_REQUIREDNAME") diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index d46e632aa..21266bc51 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -42,31 +42,31 @@ (all <>.and <code>.local <code>.any))) - meta.lifted)) + meta.of_try)) (def .public export_one (declaration (_ phase archive [name <code>.text term <code>.any]) (do [! phase.monad] [next declaration.analysis - [_ term] (<| declaration.lifted_analysis + [_ term] (<| declaration.of_analysis type.inferring (next archive term)) - lux (declaration.lifted_analysis meta.compiler_state) + lux (declaration.of_analysis meta.compiler_state) next declaration.synthesis - term (declaration.lifted_synthesis + term (declaration.of_synthesis (next lux archive term)) - dependencies (declaration.lifted_translation + dependencies (declaration.of_translation (dependency.dependencies archive term)) next declaration.translation - [interim_artifacts term] (declaration.lifted_translation + [interim_artifacts term] (declaration.of_translation (translation.with_interim_artifacts archive (next lux archive term))) - _ (declaration.lifted_translation + _ (declaration.of_translation (do ! [@self (translation.learn_custom name (list#mix set.has dependencies interim_artifacts)) .let [code (/.set (list (/.item (/.string name) /.globals/0)) term)] diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 5d3fff361..023338afe 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -83,7 +83,7 @@ (all <>.and (<text>.then ..name <code>.local) <code>.any))) - meta.lifted)) + meta.of_try)) (with_expansions [<extension> (static.random (|>> %.nat (%.format "ruby export ") code.text) random.nat)] @@ -92,23 +92,23 @@ term <code>.any]) (do [! phase.monad] [next declaration.analysis - [type term] (<| declaration.lifted_analysis + [type term] (<| declaration.of_analysis analysis.inferring (next archive term)) next declaration.synthesis - term (declaration.lifted_synthesis + term (declaration.of_synthesis (next archive term)) - dependencies (declaration.lifted_translation + dependencies (declaration.of_translation (dependency.dependencies archive term)) next declaration.translation - [interim_artifacts term] (declaration.lifted_translation + [interim_artifacts term] (declaration.of_translation (translation.with_interim_artifacts archive (next archive term))) - _ (declaration.lifted_translation + _ (declaration.of_translation (do ! [@self (translation.learn_custom name (list#mix set.has dependencies interim_artifacts)) .let [[:input:/* :output:] (type.flat_function type) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index ca56d9d74..ed7e5eb59 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -47,7 +47,7 @@ (def .public literal (syntax (_ [divisor <code>.int]) - (meta.lifted + (meta.of_try (do try.monad [_ (..modulus divisor)] (in (list (` (try.trusted (..modulus (, (code.int divisor))))))))))) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 57476530a..fc31b8659 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -718,8 +718,10 @@ {.#Default _} def_name)))) -(def .public (lifted result) - (All (_ a) (-> (Try a) (Meta a))) +(def .public (of_try result) + (All (_ of) + (-> (Try of) + (Meta of))) (when result {try.#Success output} (at ..monad in output) diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index 2999dad49..d4c342829 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -107,7 +107,7 @@ dictionary.entries (monad.each ! (function (_ [name handler]) - (///declaration.lifted_analysis + (///declaration.of_analysis (moduleA.override_definition [.prelude name] [true {.#Default [.Analysis handler]}])))))] (in []))) @@ -119,7 +119,7 @@ dictionary.entries (monad.each ! (function (_ [name handler]) - (///declaration.lifted_analysis + (///declaration.of_analysis (moduleA.override_definition [.prelude name] [true {.#Default [.Synthesis handler]}])))))] (in []))) @@ -132,7 +132,7 @@ dictionary.entries (monad.each ! (function (_ [name handler]) - (///declaration.lifted_analysis + (///declaration.of_analysis (moduleA.override_definition [.prelude name] [true {.#Default [.Translation handler]}])))))] (in []))) @@ -146,7 +146,7 @@ (monad.each ! (function (_ [name handler]) (do ! - [_ (///declaration.lifted_analysis + [_ (///declaration.of_analysis (moduleA.override_definition [.prelude name] [true {.#Default [.Declaration handler]}]))] (in [])))))] (in []))) @@ -183,10 +183,10 @@ (do ///phase.monad [.let [module (the ///.#module input)] _ (///declaration.set_current_module module) - _ (///declaration.lifted_analysis + _ (///declaration.of_analysis (moduleA.create hash module)) _ (with_defaults module all_extensions)] - (///declaration.lifted_analysis + (///declaration.of_analysis (do [! ///phase.monad] [_ (monad.each ! moduleA.import dependencies) .let [source (///analysis.source (the ///.#module input) (the ///.#code input))] @@ -199,14 +199,14 @@ (All (_ anchor expression declaration) (///declaration.Operation anchor expression declaration [.Module (Payload declaration)]))) (do ///phase.monad - [_ (///declaration.lifted_analysis + [_ (///declaration.of_analysis (moduleA.set_compiled module)) analysis_module (<| (is (Operation .Module)) - ///declaration.lifted_analysis + ///declaration.of_analysis meta.current_module) - final_buffer (///declaration.lifted_translation + final_buffer (///declaration.of_translation ///translation.buffer) - final_registry (///declaration.lifted_translation + final_registry (///declaration.of_translation ///translation.get_registry)] (in [analysis_module [final_buffer final_registry]]))) @@ -218,9 +218,9 @@ (///declaration.Operation anchor expression declaration (Payload declaration)))) (do ///phase.monad - [buffer (///declaration.lifted_translation + [buffer (///declaration.of_translation ///translation.buffer) - registry (///declaration.lifted_translation + registry (///declaration.of_translation ///translation.get_registry)] (in [buffer registry]))) @@ -232,9 +232,9 @@ [Requirements (Payload declaration)]))) (do ///phase.monad [.let [[pre_buffer pre_registry] pre_payoad] - _ (///declaration.lifted_translation + _ (///declaration.of_translation (///translation.set_buffer pre_buffer)) - _ (///declaration.lifted_translation + _ (///declaration.of_translation (///translation.set_registry pre_registry)) requirements (let [execute! (declarationP.phase wrapper extender expander)] (execute! archive code)) @@ -247,7 +247,7 @@ (///declaration.Operation anchor expression declaration [Source Requirements (Payload declaration)]))) (do ///phase.monad - [[source code] (///declaration.lifted_analysis + [[source code] (///declaration.of_analysis (..read source reader)) [requirements post_payload] (process_declaration wrapper archive extender expander pre_payload code)] (in [source requirements post_payload]))) @@ -258,7 +258,7 @@ (///declaration.Operation anchor expression declaration (Maybe [Source Requirements (Payload declaration)])))) (do ///phase.monad - [reader (///declaration.lifted_analysis + [reader (///declaration.of_analysis (..reader module aliases source))] (function (_ state) (when (///phase.result' state (..iteration' wrapper archive extender expander reader source pre_payload)) @@ -293,7 +293,7 @@ @self (///translation.learn [///program.name {.#None}] true (set.has @program (set.empty unit.hash))) |program| (global archive [program_module program_definition]) - @module (///phase.lifted (archive.id program_module archive))] + @module (///phase.of_try (archive.id program_module archive))] (///translation.save! @self {.#None} (program [@module @self] |program|)))) (def .public (compiler program global wrapper extender expander prelude write_declaration program_module program_definition @@ -327,7 +327,7 @@ [_ (if (text#= program_module module) (when program_definition {.#Some program_definition} - (///declaration.lifted_translation + (///declaration.of_translation (define_program! archive program global program_module program_definition)) {.#None} @@ -358,11 +358,11 @@ (again (<| (///phase.result' state) (do [! ///phase.monad] [analysis_module (<| (is (Operation .Module)) - ///declaration.lifted_analysis + ///declaration.of_analysis meta.current_module) - _ (///declaration.lifted_translation + _ (///declaration.of_translation (///translation.set_buffer temporary_buffer)) - _ (///declaration.lifted_translation + _ (///declaration.of_translation (///translation.set_registry temporary_registry)) _ (|> requirements (the ///declaration.#referrals) diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index 0e56f0d61..0f95c121a 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -178,10 +178,10 @@ (///declaration.Operation <type_vars> [Archive (archive.Entry .Module)]))) (do phase.monad - [[registry payload] (///declaration.lifted_translation + [[registry payload] (///declaration.of_translation (..compile_runtime! platform)) .let [entry [..runtime_module payload registry]] - archive (phase.lifted (if (archive.reserved? archive descriptor.runtime) + archive (phase.of_try (if (archive.reserved? archive descriptor.runtime) (archive.has descriptor.runtime entry archive) (do try.monad [[_ archive] (archive.reserve descriptor.runtime archive)] @@ -193,7 +193,7 @@ (-> .Lux (//init.Extensions <type_vars>) (///declaration.Operation <type_vars> Any))) (do [! phase.monad] - [_ (///declaration.lifted_analysis + [_ (///declaration.of_analysis (///analysis.set_state analysis_state))] (//init.with_defaults .prelude all_extensions))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux index 0a6cd7660..8ef79556a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux @@ -57,7 +57,7 @@ (analysis archive exprC)) module meta.current_module_name lux meta.compiler_state] - (<| phase.lifted + (<| phase.of_try (do try.monad [exprS (|> exprA (synthesis lux archive) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux index 43c7d23a4..b0e7db3c2 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux @@ -90,14 +90,14 @@ (phase.sub [(the [<component> ..#state]) (has [<component> ..#state])]))] - [lifted_analysis ..#analysis analysis.Operation] - [lifted_synthesis ..#synthesis synthesis.Operation] - [lifted_translation ..#translation (translation.Operation anchor expression declaration)] + [of_analysis ..#analysis analysis.Operation] + [of_synthesis ..#synthesis synthesis.Operation] + [of_translation ..#translation (translation.Operation anchor expression declaration)] ) (def .public (set_current_module module) (All (_ anchor expression declaration) (-> Module (Operation anchor expression declaration Any))) (do phase.monad - [_ (..lifted_analysis (analysis.set_current_module module))] - (..lifted_translation (translation.enter_module module)))) + [_ (..of_analysis (analysis.set_current_module module))] + (..of_translation (translation.enter_module module)))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux index 0c6da0e7b..7646655c1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux @@ -70,7 +70,7 @@ function_term (do phase.monad - [[type analysis] (/.lifted_analysis + [[type analysis] (/.of_analysis (analysis/type.inferring (analysis archive function_term)))] (when analysis @@ -109,10 +109,10 @@ (|>> {#Done}) (function (_ _) {.#Some (do ! - [macro (/.lifted_analysis (meta.macro macro|extension))] + [macro (/.of_analysis (meta.macro macro|extension))] (when macro {.#Some macro} - (/.lifted_analysis + (/.of_analysis (do ! [expansion (analysis/macro.expansion expander macro|extension macro inputs)] (in {#More expansion}))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux index f6da727d8..86f8c8a90 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -181,7 +181,7 @@ (def (ensure_fresh_class! class_loader name) (-> java/lang/ClassLoader External (Operation Any)) (do phase.monad - [class (phase.lifted (reflection!.load class_loader name))] + [class (phase.of_try (reflection!.load class_loader name))] (phase.assertion ..deprecated_class [name] (|> class java/lang/Class::getDeclaredAnnotations @@ -446,7 +446,7 @@ (|> objectJ ..signature (<text>.result parser.array) - phase.lifted))) + phase.of_try))) (def (primitive_array_length_handler primitive_type) (-> (Type Primitive) (-> Text Handler)) @@ -863,7 +863,7 @@ [exceptionT exceptionA] (typeA.inferring (analyse archive exceptionC)) [exception_class _] (check_object exceptionT) - ? (phase.lifted (reflection!.sub? class_loader "java.lang.Throwable" exception_class)) + ? (phase.of_try (reflection!.sub? class_loader "java.lang.Throwable" exception_class)) _ (is (Operation Any) (if ? (in []) @@ -880,7 +880,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) _ (typeA.inference {.#Primitive "java.lang.Class" (list {.#Primitive class (list)})}) - _ (phase.lifted (reflection!.load class_loader class)) + _ (phase.of_try (reflection!.load class_loader class)) @ meta.location] (in [@ {/////analysis.#Extension [.prelude (%.format extension_name "|translation")] (list (/////analysis.text @ class))}])))])) @@ -896,7 +896,7 @@ [objectT objectA] (typeA.inferring (analyse archive objectC)) [object_class _] (check_object objectT) - ? (phase.lifted (reflection!.sub? class_loader object_class sub_class)) + ? (phase.of_try (reflection!.sub? class_loader object_class sub_class)) @ meta.location] (if ? (in [@ {/////analysis.#Extension [.prelude (%.format extension_name "|translation")] @@ -906,14 +906,14 @@ (def (class_candidate_parents class_loader from_name fromT to_name to_class) (-> java/lang/ClassLoader External .Type External (java/lang/Class java/lang/Object) (Operation (List [[Text .Type] Bit]))) (do [! phase.monad] - [from_class (phase.lifted (reflection!.load class_loader from_name)) - mapping (phase.lifted (reflection!.correspond from_class fromT))] + [from_class (phase.of_try (reflection!.load class_loader from_name)) + mapping (phase.of_try (reflection!.correspond from_class fromT))] (monad.each ! (function (_ superJT) (do ! - [superJT (phase.lifted (reflection!.type superJT)) + [superJT (phase.of_try (reflection!.type superJT)) .let [super_name (..reflection superJT)] - super_class (phase.lifted (reflection!.load class_loader super_name)) + super_class (phase.of_try (reflection!.load class_loader super_name)) superT (reflection_type mapping superJT)] (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class to_class)]))) (when (java/lang/Class::getGenericSuperclass from_class) @@ -964,8 +964,8 @@ (not (dictionary.key? ..boxes from_name))) _ (phase.assertion ..primitives_are_not_objects [to_name] (not (dictionary.key? ..boxes to_name))) - to_class (phase.lifted (reflection!.load class_loader to_name)) - from_class (phase.lifted (reflection!.load class_loader from_name))] + to_class (phase.of_try (reflection!.load class_loader to_name)) + from_class (phase.of_try (reflection!.load class_loader from_name))] (if (java/lang/Class::isAssignableFrom from_class to_class) (loop (again [[current_name currentT] [from_name fromT]]) (if (text#= to_name current_name) @@ -1014,7 +1014,7 @@ (function (_ extension_name analyse archive [class field]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - [final? deprecated? fieldJT] (phase.lifted + [final? deprecated? fieldJT] (phase.of_try (do try.monad [class (reflection!.load class_loader class)] (reflection!.static_field field class))) @@ -1036,7 +1036,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) _ (typeA.inference Any) - [final? deprecated? fieldJT] (phase.lifted + [final? deprecated? fieldJT] (phase.of_try (do try.monad [class (reflection!.load class_loader class)] (reflection!.static_field field class))) @@ -1063,7 +1063,7 @@ [_ (..ensure_fresh_class! class_loader class) [objectT objectA] (typeA.inferring (analyse archive objectC)) - [deprecated? mapping fieldJT] (phase.lifted + [deprecated? mapping fieldJT] (phase.of_try (do try.monad [class (reflection!.load class_loader class) [final? deprecated? fieldJT] (reflection!.virtual_field field class) @@ -1090,7 +1090,7 @@ [objectT objectA] (typeA.inferring (analyse archive objectC)) _ (typeA.inference objectT) - [final? deprecated? mapping fieldJT] (phase.lifted + [final? deprecated? mapping fieldJT] (phase.of_try (do try.monad [class (reflection!.load class_loader class) [final? deprecated? fieldJT] (reflection!.virtual_field field class) @@ -1153,7 +1153,7 @@ [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) (array.list {.#None}) (monad.each try.monad reflection!.type) - phase.lifted) + phase.of_try) .let [modifiers (java/lang/reflect/Method::getModifiers method) correct_class? (java/lang/Class::isAssignableFrom class (java/lang/reflect/Method::getDeclaringClass method)) correct_method? (text#= method_name (java/lang/reflect/Method::getName method)) @@ -1187,7 +1187,7 @@ [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) (array.list {.#None}) (monad.each try.monad reflection!.type) - phase.lifted)] + phase.of_try)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) (n.= (list.size inputsJT) (list.size parameters)) (list.every? (function (_ [expectedJC actualJC]) @@ -1255,19 +1255,19 @@ (do [! phase.monad] [inputsT (|> (java/lang/reflect/Method::getGenericParameterTypes method) (array.list {.#None}) - (monad.each ! (|>> reflection!.type phase.lifted)) + (monad.each ! (|>> reflection!.type phase.of_try)) (phase#each (monad.each ! (..reflection_type mapping))) phase#conjoint) outputT (|> method ..return_type - phase.lifted + phase.of_try (phase#each (..reflection_return mapping)) phase#conjoint) .let [concrete_exceptions (..concrete_method_exceptions method)] concrete_exceptions (monad.each ! (..reflection_type mapping) concrete_exceptions) generic_exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) (array.list {.#None}) - (monad.each ! (|>> reflection!.type phase.lifted)) + (monad.each ! (|>> reflection!.type phase.of_try)) (phase#each (monad.each ! (..reflection_type mapping))) phase#conjoint) .let [methodT (<| (type.univ_q (dictionary.size mapping)) @@ -1298,14 +1298,14 @@ (do [! phase.monad] [inputsT (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) (array.list {.#None}) - (monad.each ! (|>> reflection!.type phase.lifted)) + (monad.each ! (|>> reflection!.type phase.of_try)) (phase#each (monad.each ! (reflection_type mapping))) phase#conjoint) .let [concrete_exceptions (..concrete_constructor_exceptions constructor)] concrete_exceptions (monad.each ! (..reflection_type mapping) concrete_exceptions) generic_exceptions (|> (java/lang/reflect/Constructor::getGenericExceptionTypes constructor) (array.list {.#None}) - (monad.each ! (|>> reflection!.type phase.lifted)) + (monad.each ! (|>> reflection!.type phase.of_try)) (phase#each (monad.each ! (reflection_type mapping))) phase#conjoint) .let [objectT {.#Primitive (java/lang/Class::getName owner) owner_tvarsT} @@ -1391,7 +1391,7 @@ (def (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) (-> Bit java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] - [class (phase.lifted (reflection!.load class_loader class_name)) + [class (phase.of_try (reflection!.load class_loader class_name)) .let [expected_class_tvars (class_type_variables class)] candidates (|> (if allow_inheritance? (all_declared_methods class) @@ -1426,7 +1426,7 @@ (def (constructor_candidate class_loader actual_class_tvars class_name actual_method_tvars inputsJT) (-> java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] - [class (phase.lifted (reflection!.load class_loader class_name)) + [class (phase.of_try (reflection!.load class_loader class_name)) .let [expected_class_tvars (class_type_variables class)] candidates (|> class java/lang/Class::getConstructors @@ -1559,7 +1559,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class_name) .let [argsT (list#each product.left argsTC)] - class (phase.lifted (reflection!.load class_loader class_name)) + class (phase.of_try (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) [methodT deprecated? exceptionsT] (..method_candidate true class_loader class_tvars class_name method_tvars method {#Interface} argsT) @@ -2272,14 +2272,14 @@ [parent_parameters (|> parent_parameters (monad.each maybe.monad parser.var?) try.of_maybe - phase.lifted)] + phase.of_try)] (|> super_parameters (monad.each ! (..reflection_type mapping)) (at ! each (|>> (list.zipped_2 parent_parameters))))) - (phase.lifted (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) + (phase.of_try (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) {.#None} - (phase.lifted (exception.except ..unknown_super [parent_name supers]))))) + (phase.of_try (exception.except ..unknown_super [parent_name supers]))))) (def .public (with_override_mapping supers parent_type mapping) (-> (List (Type Class)) (Type Class) Mapping (Operation Mapping)) @@ -2371,7 +2371,7 @@ (-> java/lang/ClassLoader (Type Class) (Operation Aliasing)) (do phase.monad [.let [[name actual_parameters] (parser.read_class class)] - jvm_class (phase.lifted (reflection!.load class_loader name)) + jvm_class (phase.of_try (reflection!.load class_loader name)) .let [expected_parameters (|> (java/lang/Class::getTypeParameters jvm_class) (array.list {.#None}) (list#each (|>> java/lang/reflect/TypeVariable::getName)))] @@ -2397,8 +2397,8 @@ (def .public (require_complete_method_concretion class_loader supers methods) (-> java/lang/ClassLoader (List (Type Class)) (List (Overriden_Method Code)) (Operation Any)) (do [! phase.monad] - [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) - available_methods (phase.lifted (all_methods class_loader supers)) + [required_abstract_methods (phase.of_try (all_abstract_methods class_loader supers)) + available_methods (phase.of_try (all_methods class_loader supers)) overriden_methods (monad.each ! (function (_ [parent_type method_name strict_fp? annotations type_vars self_name arguments return exceptions @@ -2673,7 +2673,7 @@ id meta.seed] (in (..anonymous_class_name where id))) .let [selfT {.#Primitive self_name (list)}] - mock (<| phase.lifted + mock (<| phase.of_try (..mock [self_name parameters] super_class super_interfaces @@ -2681,7 +2681,7 @@ (list) (list#each (|>> {#Overriden_Method}) methods))) ... Necessary for reflection to work properly during analysis. - _ (phase.lifted (at host execute mock)) + _ (phase.of_try (at host execute mock)) mapping (typeA.check (..class_mapping parameters)) super_classT (typeA.check (luxT.check (luxT.class mapping) (..signature super_class))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux index 63c16cafa..bd02f425d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux @@ -462,7 +462,7 @@ bodyS (when (list.size arguments) 0 (host.without_fake_parameter bodyS) _ bodyS)]) - declaration.lifted_translation + declaration.of_translation (do [! phase.monad] [constructor_argumentsG (monad.each ! (|>> product.right (translate archive)) constructor_argumentsS) @@ -536,7 +536,7 @@ bodyS (when (list.size arguments) 0 (host.without_fake_parameter bodyS) _ bodyS)]) - declaration.lifted_translation + declaration.of_translation (do [! phase.monad] [bodyG (translate archive bodyS) .let [argumentsT (list#each product.right arguments)]] @@ -561,7 +561,7 @@ bodyS (when (list.size arguments) 0 (host.without_fake_parameter bodyS) _ bodyS)]) - declaration.lifted_translation + declaration.of_translation (do [! phase.monad] [bodyG (translate archive bodyS) .let [argumentsT (list#each product.right arguments)]] @@ -586,7 +586,7 @@ (<| (let [[method_name privacy strict_floating_point? annotations method_tvars arguments returnJ exceptionsJ bodyS] method]) - declaration.lifted_translation + declaration.of_translation (do [! phase.monad] [bodyG (translate archive bodyS) .let [argumentsT (list#each product.right arguments)]] @@ -646,7 +646,7 @@ (function (_ methodC) (do phase.monad [methodA (is (Operation Analysis) - (declaration.lifted_analysis + (declaration.of_analysis (when methodC {#Constructor method} (jvm.analyse_constructor_method analyse archive selfT mapping method) @@ -663,14 +663,14 @@ {#Abstract_Method method} (jvm.analyse_abstract_method analyse archive method)))) methodS (is (Operation Synthesis) - (declaration.lifted_synthesis + (declaration.of_synthesis (synthesize archive methodA))) - dependencies (declaration.lifted_translation + dependencies (declaration.of_translation (cache.dependencies archive methodS)) methodS' (|> methodS list (<synthesis>.result ..method_synthesis) - phase.lifted) + phase.of_try) methodG (method_translation translate archive super methodS')] (in [dependencies methodG])))) @@ -836,14 +836,14 @@ (Parser <type>) (do [! <>.monad] [raw <code>.text] - (<>.lifted (<text>.result <parser> raw))))] + (<>.of_try (<text>.result <parser> raw))))] [class_declaration [External (List (Type Var))] parser.declaration'] ) (def (save_class! name bytecode dependencies) (-> Text Binary (Set unit.ID) (Operation Any)) - (declaration.lifted_translation + (declaration.of_translation (do [! phase.monad] [.let [artifact [name bytecode]] artifact_id (translation.learn_custom name dependencies) @@ -877,7 +877,7 @@ type_declaration (signature.inheritance (list#each type.signature parameters) (type.signature super) (list#each type.signature interfaces))] - mock (<| phase.lifted + mock (<| phase.of_try (..mock class_declaration super interfaces @@ -885,9 +885,9 @@ fields methods)) ... Necessary for reflection to work properly during analysis. - _ (declaration.lifted_translation + _ (declaration.of_translation (translation.execute! mock)) - parameters (declaration.lifted_analysis + parameters (declaration.of_analysis (typeA.check (jvm.parameter_types parameters))) .let [mapping (list#mix (function (_ [parameterJ parameterT] mapping) (dictionary.has (parser.name parameterJ) parameterT mapping)) @@ -903,7 +903,7 @@ methods) .let [all_dependencies (cache.all (list#each product.left methods))] bytecode (<| (at ! each (\\format.result class.format)) - phase.lifted + phase.of_try (class.class version.v6_0 (all modifier#composite class.public @@ -939,10 +939,10 @@ (<code>.tuple (<>.some ..annotation)) (<>.some jvm.method_declaration)) (function (_ phase archive [[name parameters] supers annotations method_declarations]) - (declaration.lifted_translation + (declaration.of_translation (do [! phase.monad] [bytecode (<| (at ! each (\\format.result class.format)) - phase.lifted + phase.of_try (class.class version.v6_0 (all modifier#composite class.public diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux index f9df8a9c7..c024f832a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux @@ -88,7 +88,7 @@ Type Synthesis (Operation anchor expression declaration [Type expression Any]))) - (/////declaration.lifted_translation + (/////declaration.of_translation (do phase.monad [module /////translation.module id /////translation.next @@ -106,12 +106,12 @@ analysis (the [/////declaration.#analysis /////declaration.#phase] state) synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state) translation ((the [/////declaration.#translation /////declaration.#phase] state) analysis_state)] - [_ codeA] (<| /////declaration.lifted_analysis + [_ codeA] (<| /////declaration.of_analysis scope.with typeA.fresh (typeA.expecting type) (analysis archive codeC)) - codeS (/////declaration.lifted_synthesis + codeS (/////declaration.of_synthesis (synthesis archive codeA))] (evaluate!' archive translation type codeS))) @@ -124,7 +124,7 @@ Type Synthesis (Operation anchor expression declaration [Type expression Any]))) - (/////declaration.lifted_translation + (/////declaration.of_translation (do phase.monad [dependencies (cache/artifact.dependencies archive codeS) [interim_artifacts codeG] (/////translation.with_interim_artifacts archive @@ -137,7 +137,7 @@ _ {.#None})] - @module (phase.lifted (archive.id module archive)) + @module (phase.of_try (archive.id module archive)) @self (/////translation.learn [name @abstraction] false (list#mix set.has dependencies interim_artifacts)) [target_name value declaration] (/////translation.define! [@module @self] {.#None} [(maybe#each product.right @abstraction) codeG]) _ (/////translation.save! @self {.#None} declaration)] @@ -153,7 +153,7 @@ analysis (the [/////declaration.#analysis /////declaration.#phase] state) synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state) translation ((the [/////declaration.#translation /////declaration.#phase] state) analysis_state)] - [_ code//type codeA] (/////declaration.lifted_analysis + [_ code//type codeA] (/////declaration.of_analysis (scope.with (typeA.fresh (when expected @@ -169,7 +169,7 @@ [codeA (<| (typeA.expecting expected) (analysis archive codeC))] (in [expected codeA])))))) - codeS (/////declaration.lifted_synthesis + codeS (/////declaration.of_synthesis (synthesis archive codeA))] (definition' archive translation name code//type codeS))) @@ -184,13 +184,13 @@ Synthesis (Operation anchor expression declaration [expression Any]))) (do phase.monad - [current_module (/////declaration.lifted_analysis meta.current_module_name)] - (/////declaration.lifted_translation + [current_module (/////declaration.of_analysis meta.current_module_name)] + (/////declaration.of_translation (do phase.monad [dependencies (cache/artifact.dependencies archive codeS) [interim_artifacts codeG] (/////translation.with_interim_artifacts archive (translation archive codeS)) - @module (phase.lifted (archive.id current_module archive)) + @module (phase.of_try (archive.id current_module archive)) @self (<learn> extension (list#mix set.has dependencies interim_artifacts)) [target_name value declaration] (/////translation.define! [@module @self] {.#None} [{.#None} codeG]) _ (/////translation.save! @self {.#None} declaration)] @@ -206,12 +206,12 @@ analysis (the [/////declaration.#analysis /////declaration.#phase] state) synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state) translation ((the [/////declaration.#translation /////declaration.#phase] state) analysis_state)] - [_ codeA] (<| /////declaration.lifted_analysis + [_ codeA] (<| /////declaration.of_analysis scope.with typeA.fresh (typeA.expecting codeT) (analysis archive codeC)) - codeS (/////declaration.lifted_synthesis + codeS (/////declaration.of_synthesis (synthesis archive codeA))] (<partial> archive translation extension codeT codeS)))] @@ -232,7 +232,7 @@ (the [/////declaration.#synthesis /////declaration.#phase] state)] [(the [/////declaration.#translation /////declaration.#state] state) (the [/////declaration.#translation /////declaration.#phase] state)])] - _ (/////declaration.lifted_analysis + _ (/////declaration.of_analysis (do ! [_ (moduleA.override_definition [.prelude "is#"] [true {.#Default [.Analysis (analysisE.is#_extension eval "is#")]}]) _ (moduleA.override_definition [.prelude "as#"] [true {.#Default [.Analysis (analysisE.as#_extension eval "as#")]}])] @@ -242,7 +242,7 @@ (def (announce_definition! short type) (All (_ anchor expression declaration) (-> Text Type (Operation anchor expression declaration Any))) - (/////declaration.lifted_translation + (/////declaration.of_translation (/////translation.log! (format short " : " (%.type type))))) (def lux::def @@ -256,7 +256,7 @@ [_ ..refresh state phase.state .let [analysis (the [/////declaration.#analysis /////declaration.#phase] state)] - [code//type codeA] (<| /////declaration.lifted_analysis + [code//type codeA] (<| /////declaration.of_analysis typeA.fresh typeA.inferring (analysis archive valueC)) @@ -267,18 +267,18 @@ _ (undefined))] - _ (/////declaration.lifted_analysis + _ (/////declaration.of_analysis (moduleA.define short_name [(as Bit exported?) {.#Alias original}]))] (in /////declaration.no_requirements)) _ (do phase.monad [_ ..refresh - current_module (/////declaration.lifted_analysis meta.current_module_name) + current_module (/////declaration.of_analysis meta.current_module_name) .let [full_name [current_module short_name]] [type valueT value] (..definition archive full_name {.#None} valueC) [_ _ exported?] (evaluate! archive Bit exported?C) - _ (/////declaration.lifted_analysis + _ (/////declaration.of_analysis (moduleA.define short_name [(as Bit exported?) {.#Definition [type value]}])) _ (..announce_definition! short_name type)] (in /////declaration.no_requirements))))])) @@ -295,7 +295,7 @@ [..imports (function (_ phase archive imports) (do [! phase.monad] - [_ (/////declaration.lifted_analysis + [_ (/////declaration.of_analysis (monad.each ! (function (_ [module alias]) (do ! [_ (moduleA.import module)] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux index c2eafe2a2..57d0c3bbc 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -1333,7 +1333,7 @@ (list#each (normalized_method global_mapping)) (monad.each ! (method_definition translate archive artifact_id))) bytecode (<| (at ! each (\\format.result class.format)) - //////.lifted + //////.of_try (class.class version.v6_0 (all modifier#composite class.public class.final) (name.internal anonymous_class_name) {.#None} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux index a840feeb8..825a2e8d6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux @@ -106,4 +106,4 @@ (-> Extender Lux Phase) (do phase.monad [synthesis (..optimization extender lux archive analysis)] - (phase.lifted (/variable.optimization synthesis)))) + (phase.of_try (/variable.optimization synthesis)))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux index 98248e985..2a9141d88 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux @@ -297,7 +297,7 @@ path (///#in (when input (/.branch/get @ [sub_path sub_input]) - (/.branch/get @ [(list#composite path sub_path) sub_input]) + (/.branch/get @ [(list#composite sub_path path) sub_input]) _ (/.branch/get @ [path input]))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/js/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/js/when.lux index 2e959853a..44ea85f03 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/js/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/js/when.lux @@ -105,7 +105,7 @@ (//runtime.tuple//left (_.i32 (.int (the member.#lefts side)))))] (method source))) valueO - (list.reversed pathP))))) + pathP)))) (def @savepoint (_.var "lux_pm_cursor_savepoint")) (def @cursor (_.var "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux index f009e3fe3..33135b11a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux @@ -121,7 +121,7 @@ .let [function_class (//runtime.class_name function_context)] [fields methods instance] (..with translate archive @begin function_class environment arity bodyG) module translation.module - class (phase.lifted (class.class version.v6_0 + class (phase.of_try (class.class version.v6_0 ..modifier (name.internal function_class) {.#None} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux index 7629e3031..04f4efff7 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux @@ -310,7 +310,7 @@ so_far! next!))) record! - (list.reversed path))))) + path)))) (def .public (when phase archive [valueS path]) (Translator [Synthesis Path]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/lua/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/lua/when.lux index 318fde486..d9ada6190 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/lua/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/lua/when.lux @@ -91,7 +91,7 @@ (//runtime.tuple//left (_.int (.int (the member.#lefts side)))))] (method source))) valueO - (list.reversed pathP))))) + pathP)))) (def .public (if expression archive [testS thenS elseS]) (Translator [Synthesis Synthesis Synthesis]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/php/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/php/when.lux index 3bab8fc81..098cd0d48 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/php/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/php/when.lux @@ -95,7 +95,7 @@ [.#Right //runtime.tuple//right]))] (method source))) valueG - (list.reversed pathP))))) + pathP)))) (def @savepoint (_.var "lux_pm_savepoint")) (def @cursor (_.var "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux index 9dadc3fab..b1fbb6fec 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux @@ -119,7 +119,7 @@ (method (_.int (.int (the member.#lefts side))) source))) valueO - (list.reversed pathP))))) + pathP)))) (def @savepoint (_.var "lux_pm_savepoint")) (def @cursor (_.var "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/r/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/r/when.lux index 09638b0f5..1f0b1b16a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/r/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/r/when.lux @@ -77,7 +77,7 @@ [.#Right //runtime.tuple::right]))] (method source))) valueO - (list.reversed pathP))))) + pathP)))) (def $savepoint (_.var "lux_pm_cursor_savepoint")) (def $cursor (_.var "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux index 9e6575e64..ab9c20baa 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux @@ -117,7 +117,7 @@ (//runtime.tuple//left (_.int (.int (the member.#lefts side)))))] (method source))) valueO - (list.reversed pathP))))) + pathP)))) (def @savepoint (_.local "lux_pm_savepoint")) (def @cursor (_.local "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/scheme/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/scheme/when.lux index 9e6baef9a..ad7e4ca51 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/scheme/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/scheme/when.lux @@ -75,7 +75,7 @@ [.#Right //runtime.tuple//right]))] (method source))) valueO - (list.reversed pathP))))) + pathP)))) (def @savepoint (_.var "lux_pm_cursor_savepoint")) (def @cursor (_.var "lux_pm_cursor")) diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive/module/document.lux b/stdlib/source/library/lux/meta/compiler/meta/archive/module/document.lux index 3068bb35a..8778ecd01 100644 --- a/stdlib/source/library/lux/meta/compiler/meta/archive/module/document.lux +++ b/stdlib/source/library/lux/meta/compiler/meta/archive/module/document.lux @@ -74,7 +74,7 @@ .let [expected (key.signature key)] _ (if (signature#= expected actual) (in []) - (<>.lifted (exception.except ..invalid_signature [expected actual]))) + (<>.of_try (exception.except ..invalid_signature [expected actual]))) it it] (in (abstraction [actual it])))) ) diff --git a/stdlib/source/library/lux/meta/compiler/phase.lux b/stdlib/source/library/lux/meta/compiler/phase.lux index d67fb5633..ee0f650f0 100644 --- a/stdlib/source/library/lux/meta/compiler/phase.lux +++ b/stdlib/source/library/lux/meta/compiler/phase.lux @@ -102,8 +102,10 @@ (All (_ e) (-> (Exception e) e Operation)) (..failure (exception.error exception parameters))) -(def .public (lifted error) - (All (_ s a) (-> (Try a) (Operation s a))) +(def .public (of_try error) + (All (_ state of) + (-> (Try of) + (Operation state of))) (function (_ state) (try#each (|>> [state]) error))) diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux index 9d43881f1..1f1569c5b 100644 --- a/stdlib/source/library/lux/meta/extension.lux +++ b/stdlib/source/library/lux/meta/extension.lux @@ -1,58 +1,57 @@ -(.`` (.`` (.require - [library - [lux (.except) - [abstract - ["[0]" monad]] - [control - ["<>" parser (.use "[1]#[0]" monad)]] - [data - ["[0]" product] - [collection - ["[0]" list (.use "[1]#[0]" functor)]]] - [meta - ["@" target (.only) - (.,, (.for "JVM" - [jvm - ["_" bytecode (.only Bytecode)]] +(.`` (.require + [library + [lux (.except) + [abstract + ["[0]" monad]] + [control + ["<>" parser (.use "[1]#[0]" monad)]] + [data + ["[0]" product] + [collection + ["[0]" list (.use "[1]#[0]" functor)]]] + [meta + ["@" target (.only) + (.,, (.for "JVM" + [jvm + ["_" bytecode (.only Bytecode)]] - ... else - [/]))] - ["[0]" code (.only) - ["<c>" \\parser (.only Parser)]] - [macro (.only with_symbols) - [syntax (.only syntax)] - ["[0]" template]] - [compiler - ["[0]" phase] - [language - [lux - ["[0]" analysis (.only) - ["<a>" \\parser]] - ["[0]" synthesis (.only) - ["<s>" \\parser]] - ["[0]" translation] - ["[0]" declaration] - [phase - [translation - (.,, (.for "JVM" - ["[0]" jvm - ["[1]" runtime]] + ... else + [/]))] + ["[0]" code (.only) + ["<c>" \\parser (.only Parser)]] + [macro (.only with_symbols) + [syntax (.only syntax)] + ["[0]" template]] + [compiler + ["[0]" phase] + [language + [lux + ["[0]" analysis (.only) + ["<a>" \\parser]] + ["[0]" synthesis (.only) + ["<s>" \\parser]] + ["[0]" translation] + ["[0]" declaration] + [phase + [translation + (.,, (.for "{old}" + ["[0]" jvm + ["[1]" runtime]] - "JavaScript" - ["[0]" js - ["[1]" runtime]] + "JVM" + ["[0]" jvm + ["[1]" runtime]] - "Lua" - ["[0]" lua - ["[1]" runtime]] - - "Python" - ["[0]" python - ["[1]" runtime]] - - "Ruby" - ["[0]" ruby - ["[1]" runtime]]))]]]]]]]]))) + ... else + [/])) + ["[0]" js + ["[1]" runtime]] + ["[0]" lua + ["[1]" runtime]] + ["[0]" python + ["[1]" runtime]] + ["[0]" ruby + ["[1]" runtime]]]]]]]]]])) (with_template [<any> <end> <and> <result> <name> <extension_type> <handler_type>] [(def .public <name> diff --git a/stdlib/source/library/lux/meta/macro/syntax/definition.lux b/stdlib/source/library/lux/meta/macro/syntax/definition.lux index 6c58ff992..5fdd016f9 100644 --- a/stdlib/source/library/lux/meta/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/meta/macro/syntax/definition.lux @@ -70,7 +70,7 @@ me_raw (|> raw expansion.total (meta.result compiler) - <>.lifted)] + <>.of_try)] (<| (<code>.locally me_raw) <code>.form (<>.after (<code>.this_symbol ..extension)) @@ -95,5 +95,5 @@ (in []) {.#Right _} - (<>.lifted (exception.except ..lacks_type [definition])))] + (<>.of_try (exception.except ..lacks_type [definition])))] (in definition))) diff --git a/stdlib/source/library/lux/meta/type.lux b/stdlib/source/library/lux/meta/type.lux index a024a45bc..da2463a52 100644 --- a/stdlib/source/library/lux/meta/type.lux +++ b/stdlib/source/library/lux/meta/type.lux @@ -474,7 +474,7 @@ (-> Lux (Parser Typed)) (do <>.monad [it <code>.any - type_check (<>.lifted (meta.result lux (expansion.complete it)))] + type_check (<>.of_try (meta.result lux (expansion.complete it)))] (<| (<code>.locally type_check) <code>.form (<>.after (<code>.this (` .is#))) diff --git a/stdlib/source/library/lux/meta/type/row.lux b/stdlib/source/library/lux/meta/type/row.lux index 3d3ac324d..b33924a27 100644 --- a/stdlib/source/library/lux/meta/type/row.lux +++ b/stdlib/source/library/lux/meta/type/row.lux @@ -151,7 +151,7 @@ (` (, record_slot))))))))) (list.zipped_2 slots slots')) ))))) - (meta.lifted (exception.except ..cannot_repeat_slot_names [slot_names])))))) + (meta.of_try (exception.except ..cannot_repeat_slot_names [slot_names])))))) (def .public the (syntax (_ [slot ?code.symbol @@ -210,7 +210,7 @@ ..#extra (, extra)])) {.#None} - (meta.lifted (exception.except ..missing_level [level])))) + (meta.of_try (exception.except ..missing_level [level])))) (` []) (|> (dictionary.size levels) list.indices diff --git a/stdlib/source/library/lux/world/net/uri/query.lux b/stdlib/source/library/lux/world/net/uri/query.lux index 24b03512b..78ca893fe 100644 --- a/stdlib/source/library/lux/world/net/uri/query.lux +++ b/stdlib/source/library/lux/world/net/uri/query.lux @@ -74,11 +74,11 @@ (do [! ?.monad] [key (?text.some (?text.none_of ..invalid)) key (?text.local key ..component) - key (?.lifted (uri.decoded key))] + key (?.of_try (uri.decoded key))] (?.either (do ! [_ (?text.this ..assignment) value ..component - value (?.lifted (uri.decoded value))] + value (?.of_try (uri.decoded value))] (form (dictionary.has key value query))) (do ! [_ (all ?.or diff --git a/stdlib/source/library/lux/world/time.lux b/stdlib/source/library/lux/world/time.lux index b4147a5cb..a1e2cea24 100644 --- a/stdlib/source/library/lux/world/time.lux +++ b/stdlib/source/library/lux/world/time.lux @@ -72,7 +72,7 @@ [value <sub_parser>] (if (n.< <maximum> value) (in value) - (<>.lifted (exception.except <exception> [value])))))] + (<>.of_try (exception.except <exception> [value])))))] [..hours hour_parser invalid_hour ..section_parser] [..minutes minute_parser invalid_minute ..section_parser] diff --git a/stdlib/source/library/lux/world/time/date.lux b/stdlib/source/library/lux/world/time/date.lux index 123cfb667..cf6906bee 100644 --- a/stdlib/source/library/lux/world/time/date.lux +++ b/stdlib/source/library/lux/world/time/date.lux @@ -166,7 +166,7 @@ [value ..section_parser] (if (or (n.< <minimum> value) (n.> <maximum> value)) - (<>.lifted (exception.except <exception> [value])) + (<>.of_try (exception.except <exception> [value])) (in value))))] [1 12 month_parser invalid_month] @@ -181,7 +181,7 @@ _ (<text>.this ..separator) .let [month (maybe.trusted (dictionary.value utc_month ..month_by_number))] utc_day ..section_parser] - (<>.lifted (..date utc_year month utc_day)))) + (<>.of_try (..date utc_year month utc_day)))) (def (format value) (-> Date Text) diff --git a/stdlib/source/library/lux/world/time/year.lux b/stdlib/source/library/lux/world/time/year.lux index 3098270f8..3dd0c9960 100644 --- a/stdlib/source/library/lux/world/time/year.lux +++ b/stdlib/source/library/lux/world/time/year.lux @@ -118,7 +118,7 @@ [sign (<>.or (<text>.this "-") (in [])) digits (<text>.many <text>.decimal) raw_year (<>.codec i.decimal (in (text#composite "+" digits)))] - (<>.lifted (..year (when sign + (<>.of_try (..year (when sign {.#Left _} (i.* -1 raw_year) {.#Right _} raw_year))))) diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux index 3130b607a..7ed8a1fdd 100644 --- a/stdlib/source/parser/lux/data/binary.lux +++ b/stdlib/source/parser/lux/data/binary.lux @@ -142,7 +142,7 @@ [<number> (`` (at ! each (|>> {(,, (template.spliced <tag>))}) <parser>))]) (<case>+') - _ (//.lifted (exception.except ..invalid_tag [(template.amount [<case>+]) flag])))))])) + _ (//.of_try (exception.except ..invalid_tag [(template.amount [<case>+]) flag])))))])) (def .public (or left right) (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) @@ -173,7 +173,7 @@ (when value 0 (in #0) 1 (in #1) - _ (//.lifted (exception.except ..not_a_bit [value]))))) + _ (//.of_try (exception.except ..not_a_bit [value]))))) (def .public (segment size) (-> Nat (Parser Binary)) @@ -206,7 +206,7 @@ (Parser Text) (do //.monad [utf8 <binary>] - (//.lifted (at utf8.codec decoded utf8)))))] + (//.of_try (at utf8.codec decoded utf8)))))] [08 utf8_8 ..binary_8] [16 utf8_16 ..binary_16] diff --git a/stdlib/source/parser/lux/data/text.lux b/stdlib/source/parser/lux/data/text.lux index 3c2b9baf8..0fe1fb3ec 100644 --- a/stdlib/source/parser/lux/data/text.lux +++ b/stdlib/source/parser/lux/data/text.lux @@ -407,4 +407,4 @@ (//.Parser s a))) (do //.monad [raw text] - (//.lifted (..result structured raw)))) + (//.of_try (..result structured raw)))) diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux index f78a6c54d..43b5efe6e 100644 --- a/stdlib/source/program/aedifex/artifact/time/date.lux +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -77,9 +77,9 @@ (Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) - year (<>.lifted (year.year (.int year))) + year (<>.of_try (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lifted (month.by_number month)) + month (<>.of_try (month.by_number month)) day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - date (<>.lifted (date.date year month day_of_month))] + date (<>.of_try (date.date year month day_of_month))] (in (abstraction date))))) diff --git a/stdlib/source/program/aedifex/artifact/time/time.lux b/stdlib/source/program/aedifex/artifact/time/time.lux index f093c7577..0bac9a892 100644 --- a/stdlib/source/program/aedifex/artifact/time/time.lux +++ b/stdlib/source/program/aedifex/artifact/time/time.lux @@ -33,7 +33,7 @@ [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) minute (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) second (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lifted (time.time + (<>.of_try (time.time [time.#hour hour time.#minute minute time.#second second diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index 61fa4f9bb..3fa300bf8 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -116,11 +116,11 @@ (<text>.Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) - year (<>.lifted (year.year (.int year))) + year (<>.of_try (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lifted (month.by_number month)) + month (<>.of_try (month.by_number month)) day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lifted (date.date year month day_of_month)))) + (<>.of_try (date.date year month day_of_month)))) (def time_parser (<text>.Parser Time) @@ -128,7 +128,7 @@ [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) minute (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) second (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lifted (time.time + (<>.of_try (time.time [time.#hour hour time.#minute minute time.#second second diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index cafb480a2..93c6b9f47 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -184,7 +184,7 @@ [properties (at ! each (dictionary.of_list symbol.hash) (<| (<xml>.node ["" ..dependency_tag]) (<>.some ..property_parser)))] - (<| <>.lifted + (<| <>.of_try try.of_maybe (do maybe.monad [group (dictionary.value ["" ..group_tag] properties) diff --git a/stdlib/source/specification/lux/abstract/mix.lux b/stdlib/source/specification/lux/abstract/mix.lux index f1389f9e3..51c2d5d71 100644 --- a/stdlib/source/specification/lux/abstract/mix.lux +++ b/stdlib/source/specification/lux/abstract/mix.lux @@ -14,11 +14,12 @@ [\\library ["[0]" /]]) -(def .public (spec injection comparison (open "@//[0]")) +(def .public (spec injection comparison (open "/#[0]")) (All (_ f) (-> (Injection f) (Comparison f) (/.Mix f) Test)) (do random.monad [subject random.nat parameter random.nat] - (_.coverage [/.Mix] - (n.= (@//mix n.+ parameter (injection subject)) - (n.+ parameter subject))))) + (<| (_.for [/.Mix]) + (_.coverage [/.mix] + (n.= (/#mix n.+ parameter (injection subject)) + (n.+ parameter subject)))))) diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 10e897f03..7a8a37245 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -357,12 +357,12 @@ (|> (list) (/.result (/.failure failure)) (should_fail failure))) - (_.coverage [/.lifted] + (_.coverage [/.of_try] (and (|> (list) - (/.result (/.lifted {try.#Success expected})) + (/.result (/.of_try {try.#Success expected})) (match actual (n.= expected actual))) (|> (list) - (/.result (/.lifted {try.#Failure failure})) + (/.result (/.of_try {try.#Failure failure})) (should_fail failure)))) (_.coverage [/.assertion] (and (|> (list (code.bit #1) (code.int +123)) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index e53d5d0b7..7434e8c15 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -24,6 +24,7 @@ ["[0]" rgb]]] ["[0]" / ["[1][0]" rgb] + ["[1][0]" cmyk] ["[1][0]" named] ["[1][0]" terminal]]) @@ -86,18 +87,14 @@ (|> expected /.hsb /.of_hsb (distance/3 expected) (f.<= ..rgb_error_margin))) - (_.coverage [/.CMYK /.cmyk /.of_cmyk] - (|> expected /.cmyk /.of_cmyk - (distance/3 expected) - (f.<= ..rgb_error_margin))) )) (def transformation Test (do random.monad [colorful (|> ..random - (random.only (function (_ color) (|> (distance/3 color /.black) (f.>= +100.0)))) - (random.only (function (_ color) (|> (distance/3 color /.white) (f.>= +100.0))))) + (random.only (function (_ color) (and (|> (distance/3 color /.black) (f.>= +100.0)) + (|> (distance/3 color /.white) (f.>= +100.0)))))) mediocre (|> ..random (random.only (|>> saturation ((function (_ saturation) @@ -217,6 +214,7 @@ )) /rgb.test + /cmyk.test /named.test /terminal.test )))) diff --git a/stdlib/source/test/lux/data/color/cmyk.lux b/stdlib/source/test/lux/data/color/cmyk.lux new file mode 100644 index 000000000..4a9736762 --- /dev/null +++ b/stdlib/source/test/lux/data/color/cmyk.lux @@ -0,0 +1,90 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)] + [\\specification + ["[0]S" equivalence]]] + [control + ["[0]" try (.use "[1]#[0]" functor)] + ["[0]" exception]] + [math + ["[0]" random (.only Random)] + [number + ["f" frac]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" / (.only) + [// + ["[0]" rgb]]]] + [// + ["[0]T" rgb]]) + +(def .public value + (Random /.Value) + (random.one (|>> /.value try.maybe) + random.safe_frac)) + +(def .public random + (Random /.CMYK) + (do random.monad + [cyan ..value + magenta ..value + yellow ..value + key ..value] + (in [/.#cyan cyan + /.#magenta magenta + /.#yellow yellow + /.#key key]))) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [expected_value ..value + expected_rgb rgbT.random + expected_cmyk ..random]) + (all _.and + (_.for [/.Value] + (all _.and + (_.coverage [/.number /.value] + (|> expected_value + /.number + /.value + (try#each (|>> /.number + (f.= (/.number expected_value)))) + (try.else false))) + (_.coverage [/.least] + (when (/.value (f.+ +0.001 (/.number /.least))) + {try.#Failure _} false + {try.#Success _} true)) + (_.coverage [/.most] + (when (/.value (f.- +0.001 (/.number /.most))) + {try.#Failure _} false + {try.#Success _} true)) + (_.coverage [/.invalid] + (and (when (/.value (f.- +0.001 (/.number /.least))) + {try.#Failure it} (exception.match? /.invalid it) + {try.#Success _} false) + (when (/.value (f.+ +0.001 (/.number /.most))) + {try.#Failure it} (exception.match? /.invalid it) + {try.#Success _} false))) + )) + (_.for [/.CMYK + /.#cyan /.#magenta /.#yellow /.#key] + (all _.and + (_.for [/.equivalence] + (equivalenceS.spec /.equivalence ..random)) + + (_.coverage [/.cmyk /.rgb] + (and (|> expected_rgb + /.cmyk + /.rgb + (at rgb.equivalence = expected_rgb)) + (|> expected_cmyk + /.rgb + /.cmyk + (at /.equivalence = expected_cmyk)))) + )) + ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux index f4fd18a31..0e833953f 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux @@ -143,7 +143,7 @@ (do //phase.monad [var/0' (/.variable name/0) [scope/1 var/0''] (/.with (/.variable name/0))] - (<| //phase.lifted + (<| //phase.of_try try.of_maybe (do maybe.monad [var/0' var/0' diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux index 138dd3f82..f108a9334 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux @@ -216,7 +216,7 @@ /.#state state]) (try.else false)) (|> (is (/.Operation Int Nat Nat Nat) - (/.lifted (phase.lifted {try.#Failure expected_error}))) + (/.lifted (phase.of_try {try.#Failure expected_error}))) (phase.result [/.#bundle /.empty /.#state state]) (pipe.when diff --git a/stdlib/source/test/lux/meta/compiler/phase.lux b/stdlib/source/test/lux/meta/compiler/phase.lux index 963dd07fd..d3b55aaf3 100644 --- a/stdlib/source/test/lux/meta/compiler/phase.lux +++ b/stdlib/source/test/lux/meta/compiler/phase.lux @@ -60,15 +60,15 @@ _ false))) - (_.coverage [/.lifted] - (and (|> (/.lifted {try.#Failure expected_error}) + (_.coverage [/.of_try] + (and (|> (/.of_try {try.#Failure expected_error}) (/.result state) (pipe.when {try.#Failure actual_error} (same? expected_error actual_error) _ false)) - (|> (/.lifted {try.#Success expected}) + (|> (/.of_try {try.#Success expected}) (at /.functor each (same? expected)) (/.result state) (try.else false)))) diff --git a/stdlib/source/test/lux/meta/extension.lux b/stdlib/source/test/lux/meta/extension.lux index 4391469e0..64905a9f2 100644 --- a/stdlib/source/test/lux/meta/extension.lux +++ b/stdlib/source/test/lux/meta/extension.lux @@ -149,21 +149,21 @@ (do [! phase.monad] [.let [[_ self] (symbol ..my_declaration)] analysis_phase declaration.analysis - expressionA (<| declaration.lifted_analysis + expressionA (<| declaration.of_analysis (type.expecting .Any) (analysis_phase archive expression)) - lux (declaration.lifted_analysis meta.compiler_state) + lux (declaration.of_analysis meta.compiler_state) synthesis_phase declaration.synthesis - expressionS (declaration.lifted_synthesis + expressionS (declaration.of_synthesis (synthesis_phase lux archive expressionA)) translation_phase declaration.translation - expressionG (declaration.lifted_translation + expressionG (declaration.of_translation (translation_phase lux archive expressionS)) - _ (declaration.lifted_translation + _ (declaration.of_translation (translation.with_new_context archive unit.none (do ! [[module_id artifact_id] (translation.context archive) |