diff options
author | Eduardo Julian | 2022-06-26 02:57:13 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-26 02:57:13 -0400 |
commit | 716ca5377386ca87eded7dd514ccc17f8ed281c3 (patch) | |
tree | 30ecd03de0f32057d453ab2c342fd17f88732ae3 /stdlib | |
parent | cfdc546e6834ceeb78cb692d17fd5c60695be982 (diff) |
De-sigil-ification: suffix : [Part 16]
Diffstat (limited to 'stdlib')
137 files changed, 2850 insertions, 2684 deletions
diff --git a/stdlib/source/documentation/lux/control/exception.lux b/stdlib/source/documentation/lux/control/exception.lux index a2ab6278c..f0936e27e 100644 --- a/stdlib/source/documentation/lux/control/exception.lux +++ b/stdlib/source/documentation/lux/control/exception.lux @@ -34,14 +34,14 @@ "Decorate an error message with an Exception and lift it into the error-handling context." [(except exception message)]) -(documentation: /.exception: +(documentation: /.exception (format "Define a new exception type." \n "It mostly just serves as a way to tag error messages for later catching.") ["Simple case:" - (exception: .public some_exception)] + (exception .public some_exception)] ["Complex case:" - (exception: .public [arbitrary type variables] (some_exception [optional Text - arguments Int]) + (exception .public [arbitrary type variables] (some_exception [optional Text + arguments Int]) optional_body)]) (documentation: /.report @@ -71,7 +71,7 @@ ..otherwise ..error ..except - ..exception: + ..exception ..report ..listing ..with diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index f777f5aa5..ce8daea6a 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -6,7 +6,7 @@ [control ["[0]" pipe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io)]] [data ["[0]" bit] @@ -20,8 +20,8 @@ ["[0]" async (.only Async Resolver)] ["[0]" frp (.only Channel Channel')]]) -(exception: .public poisoned) -(exception: .public dead) +(exception .public poisoned) +(exception .public dead) (local.let [<Mail> (template (_ Actor s) [(-> s (Actor s) (Async (Try s)))]) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index ec845f70d..3cf496cf1 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -9,7 +9,7 @@ [control ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io)]] [type (.only sharing) ["[0]" variance (.only Mutable)]]]] @@ -26,7 +26,7 @@ (type .public (Channel a) (Channel'' (Mutable a a))) -(exception: .public channel_is_already_closed) +(exception .public channel_is_already_closed) (type .public (Sink w) (Interface diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 135dd3abb..db74c0728 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -7,7 +7,7 @@ ["[0]" pipe] ["[0]" io (.only IO)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -65,7 +65,7 @@ <get_in_line>))))) signal))) - (exception: .public (semaphore_is_maxed_out [max_positions Nat]) + (exception .public (semaphore_is_maxed_out [max_positions Nat]) (exception.report "Max Positions" (%.nat max_positions))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 57ab5f6e5..a9563b79d 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -7,7 +7,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io)]] [data ["[0]" text] @@ -159,7 +159,7 @@ @.python (these) ... Default - (these (exception: .public cannot_continue_running_threads) + (these (exception .public cannot_continue_running_threads) ... https://en.wikipedia.org/wiki/Event_loop ... Starts the event-loop. diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index bbd25489e..98e0c6f72 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -76,7 +76,7 @@ {//.#Success []} (..except exception message))) -(def exception +(def exceptionP (Parser [Code (List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (let [private (is (Parser [(List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (all <>.and @@ -90,8 +90,8 @@ (<>.and (<>#in (` .private)) private) ))) -(def .public exception: - (syntax (_ [[export_policy t_vars [name inputs] body] ..exception]) +(def .public exception + (syntax (_ [[export_policy t_vars [name inputs] body] ..exceptionP]) (macro.with_symbols [g!_ g!descriptor] (do meta.monad [current_module meta.current_module_name diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 7304423cc..80e90f6ca 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -2,7 +2,7 @@ [library [lux (.except) [control - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [parser ["<[0]>" code]]] [data @@ -16,7 +16,7 @@ ["i" int]]]]]) (with_template [<name>] - [(exception: .public (<name> [condition Code]) + [(exception .public (<name> [condition Code]) (exception.report "Condition" (%.code condition)))] diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index bcf8753c6..617efe7de 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -6,7 +6,6 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] ["<>" parser (.use "[1]#[0]" monad) ["<[0]>" code (.only Parser)]]] [data diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index e685ae64d..df9bf0fbc 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -3,7 +3,7 @@ [lux (.except) [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" text (.only) @@ -18,7 +18,7 @@ (type .public Environment (Dictionary Property Text)) -(exception: .public (unknown_property [property Property]) +(exception .public (unknown_property [property Property]) (exception.report "Property" (%.text property))) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 8b232b07f..e94e8a96c 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -5,7 +5,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [collection [tree (.only Tree) @@ -30,7 +30,7 @@ (function (_ zipper) {try.#Success [zipper (zipper.value zipper)]})) -(exception: .public cannot_move_further) +(exception .public cannot_move_further) (with_template [<name> <direction>] [(def .public <name> diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 9546c128f..b4609b897 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -5,7 +5,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" function]] [data ["[0]" text (.use "[1]#[0]" monoid) @@ -28,7 +28,7 @@ [{.#Primitive "" {.#End}}])) (with_template [<name>] - [(exception: .public (<name> [type Type]) + [(exception .public (<name> [type Type]) (exception.report "Type" (%.type type)))] @@ -45,8 +45,8 @@ ) (with_template [<name>] - [(exception: .public (<name> [expected Type - actual Type]) + [(exception .public (<name> [expected Type + actual Type]) (exception.report "Expected" (%.type expected) "Actual" (%.type actual)))] @@ -55,9 +55,9 @@ [wrong_parameter] ) -(exception: .public empty_input) +(exception .public empty_input) -(exception: .public (unconsumed_input [remaining (List Type)]) +(exception .public (unconsumed_input [remaining (List Type)]) (exception.report "Types" (|> remaining (list#each (|>> %.type (format text.new_line "* "))) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 15f4a25af..1edddc5a0 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -13,7 +13,7 @@ [collection ["[0]" list (.use "[1]#[0]" mix)]]]]] [// - ["[0]" exception (.only Exception exception:)]]) + ["[0]" exception (.only Exception exception)]]) (type (Cleaner r !) (-> r (! (Try Any)))) @@ -31,8 +31,8 @@ "-----------------------------------------" text.new_line text.new_line)) -(exception: .public [a] (clean_up_error [error Text - output (Try a)]) +(exception .public [a] (clean_up_error [error Text + output (Try a)]) (format error (case output {try.#Success _} diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index c33f6d38b..264d13adb 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -6,7 +6,7 @@ [control ["[0]" io] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.use "[1]#[0]" functor) ["<c>" code (.only Parser)]]] [data @@ -21,10 +21,10 @@ ["[0]" template] [syntax (.only syntax)]]]]) -(exception: .public (must_remember [deadline Date - today Date - message Text - focus (Maybe Code)]) +(exception .public (must_remember [deadline Date + today Date + message Text + focus (Maybe Code)]) (exception.report "Deadline" (%.date deadline) "Today" (%.date today) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index caf7e01b8..57b7353ad 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -7,7 +7,7 @@ [monoid (.only Monoid)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format]] @@ -40,8 +40,8 @@ (again (++ index) ($ (/.bits_8 index it) output)) output)))) -(exception: .public (index_out_of_bounds [size Nat - index Nat]) +(exception .public (index_out_of_bounds [size Nat + index Nat]) (exception.report "Size" (%.nat size) "Index" (%.nat index))) @@ -78,9 +78,9 @@ (def (= reference sample) (/.= reference sample)))) -(exception: .public (cannot_copy [bytes Nat - source_input Nat - target_output Nat]) +(exception .public (cannot_copy [bytes Nat + source_input Nat + target_output Nat]) (exception.report "Bytes" (%.nat bytes) "Source input space" (%.nat source_input) @@ -95,9 +95,9 @@ (exception.except ..cannot_copy [bytes source_input target_output]) {try.#Success (/.copy! bytes source_offset source target_offset target)}))) -(exception: .public (slice_out_of_bounds [size Nat - offset Nat - length Nat]) +(exception .public (slice_out_of_bounds [size Nat + offset Nat + length Nat]) (exception.report "Size" (%.nat size) "Offset" (%.nat offset) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 1a960a6e9..afb711861 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -9,7 +9,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [collection @@ -595,7 +595,7 @@ {.#None} #0 {.#Some _} #1)) -(exception: .public key_already_exists) +(exception .public key_already_exists) (def .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 477d034a7..493b5d411 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -16,7 +16,7 @@ [control ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -239,15 +239,15 @@ (.has #tail (..tail val))) ))) -(exception: incorrect_sequence_structure) +(exception incorrect_sequence_structure) -(exception: .public [a] (index_out_of_bounds [sequence (Sequence a) - index Nat]) +(exception .public [a] (index_out_of_bounds [sequence (Sequence a) + index Nat]) (exception.report "Size" (at n.decimal encoded (the #size sequence)) "Index" (at n.decimal encoded index))) -(exception: base_was_not_found) +(exception base_was_not_found) (def .public (within_bounds? sequence idx) (All (_ a) (-> (Sequence a) Nat Bit)) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 628e1fde8..f40e0c4ab 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -8,7 +8,7 @@ ["<>" parser] ["[0]" pipe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" binary (.only Binary) @@ -70,7 +70,7 @@ (list#mix n.* 1) ++)) - (exception: .public (<exception> [value Nat]) + (exception .public (<exception> [value Nat]) (exception.report "Value" (%.nat value) "Maximum" (%.nat (-- <limit>)))) @@ -115,8 +115,8 @@ as_big] ) -(exception: .public (wrong_character [expected Char - actual Char]) +(exception .public (wrong_character [expected Char + actual Char]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual))) @@ -226,7 +226,7 @@ (n.<= ..last_ascii char))) true))) -(exception: .public (not_ascii [text Text]) +(exception .public (not_ascii [text Text]) (exception.report "Text" (%.text text))) @@ -252,7 +252,7 @@ [(primitive .public <type> <representation> - (exception: .public (<exception> [value Text]) + (exception .public (<exception> [value Text]) (exception.report "Value" (%.text value) "Size" (%.nat (text.size value)) @@ -422,7 +422,7 @@ <options> ) - (exception: .public (invalid_link_flag [value Nat]) + (exception .public (invalid_link_flag [value Nat]) (exception.report "Value" (%.nat value))) @@ -461,7 +461,7 @@ try.trusted ..small_writer)) - (exception: .public (invalid_mode [value Nat]) + (exception .public (invalid_mode [value Nat]) (exception.report "Value" (%.nat value))) @@ -745,8 +745,8 @@ tar) (\\format.segment ..end_of_archive_size end_of_archive))))) -(exception: .public (wrong_checksum [expected Nat - actual Nat]) +(exception .public (wrong_checksum [expected Nat + actual Nat]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual))) @@ -859,7 +859,7 @@ (exception.assertion ..wrong_checksum [0 actual] (n.= 0 actual)))))) -(exception: .public invalid_end_of_archive) +(exception .public invalid_end_of_archive) (def end_of_archive_parser (Parser Any) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 616dba61d..f8980caf1 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser ["<[0]>" code]]] [math @@ -141,21 +141,21 @@ (again (++ offset) previous current limit))) (format previous current)))) -(exception: .public (dangling_escape [text Text]) +(exception .public (dangling_escape [text Text]) (exception.report "In" (%.text text) "At" (%.nat (-- (//.size text))))) -(exception: .public (invalid_escape [text Text - offset Nat - sigil Char]) +(exception .public (invalid_escape [text Text + offset Nat + sigil Char]) (exception.report "In" (%.text text) "At" (%.nat offset) "Name" (%.text (//.of_char sigil)))) -(exception: .public (invalid_unicode_escape [text Text - offset Nat]) +(exception .public (invalid_unicode_escape [text Text + offset Nat]) (exception.report "In" (%.text text) "At" (%.nat offset))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 7f3846e1e..957c12bd7 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.use "[1]#[0]" monad) ["<[0]>" code]]] [data @@ -231,8 +231,8 @@ (in (` ((~! together^) ((~! <>.many) (~ base))))) ))) -(exception: .public (incorrect_quantification [from Nat - to Nat]) +(exception .public (incorrect_quantification [from Nat + to Nat]) (exception.report "Input" (format (%.nat from) "," (%.nat to)) "Should be" (format (%.nat to) "," (%.nat from)))) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 0351ca9d0..3db55592d 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -11,7 +11,7 @@ ["[0]" pipe] ["[0]" function] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" type (.only Parser)] ["<[0]>" code]]] @@ -380,7 +380,7 @@ )) ))) -(exception: .public (cannot_represent_value [type Type]) +(exception .public (cannot_represent_value [type Type]) (exception.report "Type" (%.type type))) @@ -533,8 +533,8 @@ (-> Text Any) ("lux io log" message)) -(exception: .public (type_hole [location Location - type Type]) +(exception .public (type_hole [location Location + type Type]) (exception.report "Location" (%.location location) "Type" (%.type type))) @@ -556,7 +556,7 @@ (<code>.tuple (<>.and <code>.local (at <>.monad each (|>> {.#Some}) <code>.any))))) -(exception: .public (unknown_local_binding [name Text]) +(exception .public (unknown_local_binding [name Text]) (exception.report "Name" (%.text name))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index bc67d8eb8..26e87d50d 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -8,7 +8,7 @@ ["[0]" enum]] [control ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.use "[1]#[0]" monad) ["<[0]>" code (.only Parser)]]] [data @@ -451,7 +451,7 @@ (<>.or (<code>.this_text "") <code>.any)) -(exception: .public (unqualified_symbol [name Symbol]) +(exception .public (unqualified_symbol [name Symbol]) (exception.report "Name" (%.symbol name))) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index b3ece286c..fddb85cb7 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -8,7 +8,7 @@ ["[0]" io] ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only Exception exception:)] + ["[0]" exception (.only Exception exception)] ["<>" parser (.use "[1]#[0]" monad) ["<[0]>" code (.only Parser)]]] [data @@ -556,12 +556,12 @@ (<code>.this (' "abstract")) (in [])))) -(exception: .public (class_names_cannot_contain_periods [name Text]) +(exception .public (class_names_cannot_contain_periods [name Text]) (exception.report "Name" (%.text name))) -(exception: .public (class_name_cannot_be_a_type_variable [name Text - type_vars (List (Type Var))]) +(exception .public (class_name_cannot_be_a_type_variable [name Text + type_vars (List (Type Var))]) (exception.report "Name" (%.text name) "Type Variables" (exception.listing parser.name type_vars))) @@ -594,8 +594,8 @@ (<code>.form (<>.and class_name^ (<>.some (parameter^ type_vars))))))] (in (jvm.class (name.safe name) parameters)))) -(exception: .public (unknown_type_variable [name Text - type_vars (List (Type Var))]) +(exception .public (unknown_type_variable [name Text + type_vars (List (Type Var))]) (exception.report "Unexpected Type Variable" (%.text name) "Expected Type Variables" (exception.listing parser.name type_vars))) @@ -1153,8 +1153,8 @@ [body (super_expression declaration,method,self body)] (in (list body))))) -(exception: .public (insufficient_parameters [expected Nat - actual Nat]) +(exception .public (insufficient_parameters [expected Nat + actual Nat]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual))) @@ -1580,8 +1580,8 @@ (list name (` (~! <code>.any))))) list#conjoint)) -(exception: .public (cannot_write_to_field [class Text - field Text]) +(exception .public (cannot_write_to_field [class Text + field Text]) (exception.report "Class" (%.text class) "Field" (%.text field))) @@ -1815,7 +1815,7 @@ (.is (~ (value_type {#ManualPrM} (jvm.array type))) ("jvm array new object" (~ g!size)))))))))))) -(exception: .public (cannot_convert_to_jvm_type [type .Type]) +(exception .public (cannot_convert_to_jvm_type [type .Type]) (exception.report "Lux Type" (%.type type))) @@ -2042,7 +2042,7 @@ (syntax (_ [type (..type^ (list))]) (in (list (..value_type {#ManualPrM} type))))) -(exception: .public (cannot_cast_to_non_object [type (Type Value)]) +(exception .public (cannot_cast_to_non_object [type (Type Value)]) (exception.report "Signature" (..signature type) "Reflection" (..reflection type))) diff --git a/stdlib/source/library/lux/macro/context.lux b/stdlib/source/library/lux/macro/context.lux index ae958a606..fef8ae1d8 100644 --- a/stdlib/source/library/lux/macro/context.lux +++ b/stdlib/source/library/lux/macro/context.lux @@ -5,7 +5,7 @@ [monad (.only do)] ["[0]" predicate (.only Predicate)]] [control - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" maybe] ["?" parser (.only) ["?[0]" code]]] @@ -25,7 +25,7 @@ (type .public Stack List) -(exception: .public (no_definition [it Symbol]) +(exception .public (no_definition [it Symbol]) (exception.report "Definition" (symbol#encoded it))) @@ -45,7 +45,7 @@ {.#None} (meta.failure (exception.error ..no_definition [it]))))) -(exception: .public no_active_context) +(exception .public no_active_context) (.def (peek' _ context) (All (_ a) (-> (Stack a) Symbol (Meta a))) @@ -64,7 +64,7 @@ (syntax (_ [g!it (at ?.monad each code.symbol ?code.global)]) (in (list (` ((~! ..peek') (~ g!it) (.symbol (~ g!it)))))))) -(exception: .public no_example) +(exception .public no_example) (.def (search' _ ? context) (All (_ a) (-> (Stack a) (Predicate a) Symbol (Meta a))) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 234820376..4e762b81d 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -6,7 +6,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -20,13 +20,13 @@ [syntax (.only syntax)] ["[1][0]" code]]) -(exception: .public (unknown_module [module Text]) +(exception .public (unknown_module [module Text]) (exception.report "Module" (text.format module))) (with_template [<name>] - [(exception: .public (<name> [module Text - definition Text]) + [(exception .public (<name> [module Text + definition Text]) (exception.report "Module" (text.format module) "Definition" (text.format definition)))] diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index c1ae94377..6649a6864 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -6,7 +6,6 @@ [equivalence (.only Equivalence)] [monad (.only do)]] [control - ["[0]" exception (.only exception:)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index b0aa68194..eee400dfe 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -5,7 +5,7 @@ [equivalence (.only Equivalence)] [monad (.only do)]] [control - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -80,7 +80,7 @@ <code>.bit )))) -(exception: .public (lacks_type [definition Definition]) +(exception .public (lacks_type [definition Definition]) (exception.report "Definition" (%.code (..format definition)))) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index f1298bd46..834599518 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -6,7 +6,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.use "[1]#[0]" functor) ["<[0]>" code (.only Parser)]]] [data @@ -128,8 +128,8 @@ #parameters (List Text) #template (List Code)])) -(exception: .public (irregular_arguments [expected Nat - actual Nat]) +(exception .public (irregular_arguments [expected Nat + actual Nat]) (exception.report "Expected" (at nat.decimal encoded expected) "Actual" (at nat.decimal encoded actual))) diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 6feb0ce11..6404b3343 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -8,7 +8,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -40,7 +40,7 @@ ["[0]" ratio (.only Ratio)] ["[0]" complex (.only Complex)]]]) -(exception: (no_arithmetic_for [type Type]) +(exception (no_arithmetic_for [type Type]) (exception.report "Type" (%.type type))) diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index b8b2a3adf..4fcb27d65 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -9,7 +9,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -45,8 +45,8 @@ [value Int product.right] ) - (exception: .public [%] (incorrect_modulus [modulus (Modulus %) - parsed Int]) + (exception .public [%] (incorrect_modulus [modulus (Modulus %) + parsed Int]) (exception.report "Expected" (i#encoded (//.divisor modulus)) "Actual" (i#encoded parsed))) @@ -139,8 +139,8 @@ _ {.#None}))) ) -(exception: .public [r% s%] (moduli_are_not_equal [reference (Modulus r%) - subject (Modulus s%)]) +(exception .public [r% s%] (moduli_are_not_equal [reference (Modulus r%) + subject (Modulus s%)]) (exception.report "Reference" (i#encoded (//.divisor reference)) "Subject" (i#encoded (//.divisor subject)))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index d6fb7577e..f22bb1d39 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -6,7 +6,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [parser ["<[0]>" code]]] [macro @@ -18,7 +18,7 @@ [type [primitive (.except)]]]]) -(exception: .public zero_cannot_be_a_modulus) +(exception .public zero_cannot_be_a_modulus) (primitive .public (Modulus %) Int diff --git a/stdlib/source/library/lux/meta/configuration.lux b/stdlib/source/library/lux/meta/configuration.lux index 727a48fb7..d52b60914 100644 --- a/stdlib/source/library/lux/meta/configuration.lux +++ b/stdlib/source/library/lux/meta/configuration.lux @@ -8,7 +8,7 @@ [monad (.only do)]] [control ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -67,7 +67,7 @@ (<text>.slice (<text>.some! (<text>.none_of! ..end)))))] (<>.some (<>.and parser' parser')))) -(exception: .public invalid) +(exception .public invalid) (def configuration (<code>.Parser Configuration) diff --git a/stdlib/source/library/lux/meta/version.lux b/stdlib/source/library/lux/meta/version.lux index 12789a755..da5d349bb 100644 --- a/stdlib/source/library/lux/meta/version.lux +++ b/stdlib/source/library/lux/meta/version.lux @@ -5,7 +5,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -29,7 +29,7 @@ [it meta.version] (in (list (code.text it)))))) -(exception: .public invalid) +(exception .public invalid) (def .public for (syntax (_ [specializations (<>.some (<>.and <code>.text <code>.any)) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 61e9401f5..3ecaa7321 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -5,8 +5,7 @@ [monad (.only do)] ["[0]" equivalence (.only Equivalence)]] [control - ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" try]] [data ["[0]" sum] ["[0]" product] diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 9f71fd570..f6a439799 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -11,7 +11,7 @@ ["[0]" state (.only +State)] ["[0]" maybe] ["[0]" try (.only Try) (.use "[1]#[0]" monad)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [text @@ -128,15 +128,15 @@ [..relative#identity (the #next tracker)]]})) -(exception: .public (label_has_already_been_set [label Label]) +(exception .public (label_has_already_been_set [label Label]) (exception.report "Label" (%.nat label))) -(exception: .public (mismatched_environments [instruction Symbol - label Label - address Address - expected Stack - actual Stack]) +(exception .public (mismatched_environments [instruction Symbol + label Label + address Address + expected Stack + actual Stack]) (exception.report "Instruction" (%.symbol instruction) "Label" (%.nat label) @@ -678,7 +678,7 @@ _ (..arbitrary_double value)))) -(exception: .public (invalid_register [id Nat]) +(exception .public (invalid_register [id Nat]) (exception.report "ID" (%.nat id))) @@ -780,13 +780,13 @@ [$0 $1 sipush _.sipush S2] ) -(exception: .public (unknown_label [label Label]) +(exception .public (unknown_label [label Label]) (exception.report "Label" (%.nat label))) -(exception: .public (cannot_do_a_big_jump [label Label - @from Address - jump Big_Jump]) +(exception .public (cannot_do_a_big_jump [label Label + @from Address + jump Big_Jump]) (exception.report "Label" (%.nat label) "Start" (|> @from /address.value //unsigned.value %.nat) @@ -808,7 +808,7 @@ (try#each (|>> {.#Left}) (//signed.s4 jump)) (try#each (|>> {.#Right}) (//signed.s2 jump))))) -(exception: .public (unset_label [label Label]) +(exception .public (unset_label [label Label]) (exception.report "Label" (%.nat label))) @@ -937,7 +937,7 @@ {.#Right small} (/jump.lifted small))) -(exception: .public invalid_tableswitch) +(exception .public invalid_tableswitch) (def .public (tableswitch minimum default [at_minimum afterwards]) (-> S4 Label [Label (List Label)] (Bytecode Any)) @@ -975,7 +975,7 @@ (exception.except ..invalid_tableswitch [])))) []]])))))) -(exception: .public invalid_lookupswitch) +(exception .public invalid_lookupswitch) (def .public (lookupswitch default cases) (-> Label (List [S4 Label]) (Bytecode Any)) @@ -1041,7 +1041,7 @@ [register (..register register)] (..bytecode $0 $0 (/registry.for register) _.iinc [register increase]))) -(exception: .public (multiarray_cannot_be_zero_dimensional [class (Type Object)]) +(exception .public (multiarray_cannot_be_zero_dimensional [class (Type Object)]) (exception.report "Class" (..reflection class))) @@ -1127,8 +1127,8 @@ [putfield $2 _.putfield/1 $3 _.putfield/2] ) -(exception: .public (invalid_range_for_try [start Address - end Address]) +(exception .public (invalid_range_for_try [start Address + end Address]) (exception.report "Start" (|> start /address.value //unsigned.value %.nat) "End" (|> end /address.value //unsigned.value %.nat))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index a0c93c974..82f6f0937 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -6,7 +6,7 @@ [monoid (.only Monoid)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]]]] + ["[0]" exception (.only exception)]]]] [/ ["/[0]" limit (.only Limit) ["/[0]" stack (.only Stack)] @@ -49,7 +49,7 @@ [environment (left environment)] (right environment)))))) -(exception: .public discontinuity) +(exception .public discontinuity) (def .public (stack environment) (-> Environment (Try Stack)) @@ -64,8 +64,8 @@ (-> Environment Environment) (.has ..#stack {.#None})) -(exception: .public (mismatched_stacks [expected Stack - actual Stack]) +(exception .public (mismatched_stacks [expected Stack + actual Stack]) (exception.report "Expected" (/stack.format expected) "Actual" (/stack.format actual))) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 83d6bc4d8..c786ae13d 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -6,7 +6,7 @@ [order (.only Order)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -42,8 +42,8 @@ (def (< reference sample) (i.< (representation reference) (representation sample))))) - (exception: .public (value_exceeds_the_scope [value Int - scope Nat]) + (exception .public (value_exceeds_the_scope [value Int + scope Nat]) (exception.report "Value" (%.int value) "Scope (in bytes)" (%.nat scope))) diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index b31a67dcb..a3c89b40b 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -6,7 +6,7 @@ [order (.only Order)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -43,18 +43,18 @@ (n.< (representation reference) (representation sample))))) - (exception: .public (value_exceeds_the_maximum [type Symbol - value Nat - maximum (Unsigned Any)]) + (exception .public (value_exceeds_the_maximum [type Symbol + value Nat + maximum (Unsigned Any)]) (exception.report "Type" (%.symbol type) "Value" (%.nat value) "Maximum" (%.nat (representation maximum)))) - (exception: .public [brand] (subtraction_cannot_yield_negative_value - [type Symbol - parameter (Unsigned brand) - subject (Unsigned brand)]) + (exception .public [brand] (subtraction_cannot_yield_negative_value + [type Symbol + parameter (Unsigned brand) + subject (Unsigned brand)]) (exception.report "Type" (%.symbol type) "Parameter" (%.nat (representation parameter)) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 04ea3f433..cdbfd1c56 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -7,7 +7,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO)] [concurrency ["[0]" atom (.only Atom)]]] @@ -22,16 +22,16 @@ (type .public Library (Atom (Dictionary Text Binary))) -(exception: .public (already_stored [class Text]) +(exception .public (already_stored [class Text]) (exception.report "Class" class)) -(exception: .public (unknown [class Text]) +(exception .public (unknown [class Text]) (exception.report "Class" class)) -(exception: .public (cannot_define [class Text - error Text]) +(exception .public (cannot_define [class Text + error Text]) (exception.report "Class" class "Error" error)) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 1076bfff2..4922fd23e 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -7,7 +7,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)] @@ -95,12 +95,12 @@ (isArray [] boolean) (getComponentType [] (java/lang/Class java/lang/Object))) -(exception: .public (unknown_class [class External]) +(exception .public (unknown_class [class External]) (exception.report "Class" (%.text class))) (with_template [<name>] - [(exception: .public (<name> [jvm_type java/lang/reflect/Type]) + [(exception .public (<name> [jvm_type java/lang/reflect/Type]) (exception.report "Type" (java/lang/reflect/Type::getTypeName jvm_type) "Class" (|> jvm_type java/lang/Object::getClass java/lang/Object::toString)))] @@ -266,23 +266,23 @@ {.#None} <else>))) -(exception: .public (cannot_correspond [class (java/lang/Class java/lang/Object) - type Type]) +(exception .public (cannot_correspond [class (java/lang/Class java/lang/Object) + type Type]) (exception.report "Class" (java/lang/Object::toString class) "Type" (%.type type))) -(exception: .public (type_parameter_mismatch [expected Nat - actual Nat - class (java/lang/Class java/lang/Object) - type Type]) +(exception .public (type_parameter_mismatch [expected Nat + actual Nat + class (java/lang/Class java/lang/Object) + type Type]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual) "Class" (java/lang/Object::toString class) "Type" (%.type type))) -(exception: .public (non_jvm_type [type Type]) +(exception .public (non_jvm_type [type Type]) (exception.report "Type" (%.type type))) @@ -326,17 +326,17 @@ _ (exception.except ..non_jvm_type [type]))) -(exception: .public (mistaken_field_owner [field java/lang/reflect/Field - owner (java/lang/Class java/lang/Object) - target (java/lang/Class java/lang/Object)]) +(exception .public (mistaken_field_owner [field java/lang/reflect/Field + owner (java/lang/Class java/lang/Object) + target (java/lang/Class java/lang/Object)]) (exception.report "Field" (java/lang/Object::toString field) "Owner" (java/lang/Object::toString owner) "Target" (java/lang/Object::toString target))) (with_template [<name>] - [(exception: .public (<name> [field Text - class (java/lang/Class java/lang/Object)]) + [(exception .public (<name> [field Text + class (java/lang/Class java/lang/Object)]) (exception.report "Field" (%.text field) "Class" (java/lang/Object::toString class)))] diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 5db726862..a7cb3625b 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -6,7 +6,6 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] ["<>" parser (.only)]] [data ["[0]" text (.only) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 3e3b02271..b68215990 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -5,7 +5,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.use "[1]#[0]" monad)]] [data ["[0]" product] @@ -42,7 +42,7 @@ Mapping (dictionary.empty text.hash)) -(exception: .public (unknown_var [var Text]) +(exception .public (unknown_var [var Text]) (exception.report "Var" (%.text var))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 5f3e5d8bf..b7cdc5ca7 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -9,7 +9,7 @@ ["[0]" pipe] ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io] [concurrency ["[0]" atom (.only Atom)] @@ -164,7 +164,7 @@ (format documentation ..separator ..separator "Failed with this seed: " (%.nat seed))) -(exception: .public must_try_test_at_least_once) +(exception .public must_try_test_at_least_once) (def .public (times amount test) (-> Nat Test Test) @@ -388,7 +388,7 @@ (~ (code.text coverage)) (~ test)))))))) -(exception: .public (error_during_execution [error Text]) +(exception .public (error_during_execution [error Text]) (exception.report "Error" (%.text error))) diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index 13fa9b63f..3f57e5889 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -11,7 +11,7 @@ ["<>" parser (.only)] ["[0]" pipe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" monoid) ["<[1]>" \\parser (.only Parser)]]] @@ -38,7 +38,7 @@ Nat (.nat (duration.millis duration.day))) -(exception: .public (time_exceeds_a_day [time Nat]) +(exception .public (time_exceeds_a_day [time Nat]) (exception.report "Time (in milli-seconds)" (n#encoded time) "Maximum (in milli-seconds)" (n#encoded (-- limit)))) @@ -57,7 +57,7 @@ (at <>.monad in 0))) (with_template [<maximum> <parser> <exception> <sub_parser>] - [(exception: .public (<exception> [value Nat]) + [(exception .public (<exception> [value Nat]) (exception.report "Value" (n#encoded value) "Minimum" (n#encoded 0) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index fcc1bdc79..78bd79237 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -11,7 +11,7 @@ ["<>" parser (.only)] ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" monoid) ["<[1]>" \\parser (.only Parser)]] @@ -49,9 +49,9 @@ (or (n.< ..minimum_day day) (n.> (..month_days year month) day))) -(exception: .public (invalid_day [year Year - month Month - day Nat]) +(exception .public (invalid_day [year Year + month Month + day Nat]) (exception.report "Value" (n#encoded day) "Minimum" (n#encoded ..minimum_day) @@ -153,7 +153,7 @@ (at <>.monad in 0))) (with_template [<minimum> <maximum> <parser> <exception>] - [(exception: .public (<exception> [value Nat]) + [(exception .public (<exception> [value Nat]) (exception.report "Value" (n#encoded value) "Minimum" (n#encoded <minimum>) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index 689c5af7f..2a85f5107 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -9,7 +9,7 @@ [codec (.only Codec)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" monoid)]] [macro @@ -92,7 +92,7 @@ {#Saturday} {#Friday} {#Sunday} {#Saturday})))) -(exception: .public (not_a_day_of_the_week [value Text]) +(exception .public (not_a_day_of_the_week [value Text]) (exception.report "Value" (text.format value))) @@ -150,7 +150,7 @@ <number>]) (<pairs>))) - (exception: .public (invalid_day [number Nat]) + (exception .public (invalid_day [number Nat]) (exception.report "Number" (at n.decimal encoded number) "Valid range" (all "lux text concat" diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index cf0c7f1db..a453d5f58 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -12,8 +12,7 @@ [io (.only IO io)] ["<>" parser (.only)] ["[0]" maybe] - ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" try]] [data ["[0]" text (.use "[1]#[0]" monoid) ["<[1]>" \\parser (.only Parser)]]] diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 3cac9c162..a8e01bc39 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -9,7 +9,7 @@ [codec (.only Codec)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" monoid)]] [macro @@ -78,7 +78,7 @@ <number>]) (<pairs>))) - (exception: .public (invalid_month [number Nat]) + (exception .public (invalid_month [number Nat]) (exception.report "Number" (at n.decimal encoded number) "Valid range" (all "lux text concat" @@ -207,7 +207,7 @@ {#November} {#December})) -(exception: .public (not_a_month_of_the_year [value Text]) +(exception .public (not_a_month_of_the_year [value Text]) (exception.report "Value" (text.format value))) diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 8552a8394..494f3355b 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -9,7 +9,7 @@ [control ["<>" parser (.only)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" monoid) ["<[1]>" \\parser (.only Parser)]]] @@ -32,7 +32,7 @@ year (-- year))) -(exception: .public there_is_no_year_0) +(exception .public there_is_no_year_0) ... https://en.wikipedia.org/wiki/Gregorian_calendar (primitive .public Year diff --git a/stdlib/source/library/lux/tool/compiler.lux b/stdlib/source/library/lux/tool/compiler.lux index 536804e4b..8d34b580c 100644 --- a/stdlib/source/library/lux/tool/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler.lux @@ -4,7 +4,7 @@ [control ["<>" parser (.only)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text] ["[0]" binary (.only Binary) @@ -54,6 +54,6 @@ (type .public (Instancer s d o) (-> (Key d) (List Parameter) (Compiler s d o))) -(exception: .public (cannot_compile [module Module]) +(exception .public (cannot_compile [module Module]) (exception.report "Module" module)) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index d4213ccfc..f9c201df1 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -7,7 +7,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception]] [data [binary (.only Binary)] ["[0]" product] diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 6d19f4b14..d20ddcc8a 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -10,7 +10,7 @@ ["[0]" function] ["[0]" maybe] ["[0]" try (.only Try) (.use "[1]#[0]" monad)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" async (.only Async Resolver) (.use "[1]#[0]" monad)] ["[0]" stm (.only Var STM)]]] @@ -189,12 +189,12 @@ (in [archive entry]))) (def (initialize_state extender - [analysers - synthesizers - generators - directives] - analysis_state - state) + [analysers + synthesizers + generators + directives] + analysis_state + state) (All (_ <type_vars>) (-> Extender [(Dictionary Text ///analysis.Handler) @@ -248,7 +248,7 @@ (dictionary.composite directives (host_directive_bundle phase_wrapper))]) (def .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender - import compilation_sources compilation_configuration) + import compilation_sources compilation_configuration) (All (_ <type_vars>) (-> context.Context descriptor.Module @@ -387,18 +387,18 @@ (or (dependence? import (the #depends_on) module) (dependence? module (the #depended_by) import)))) - (exception: .public (module_cannot_import_itself [module descriptor.Module]) + (exception .public (module_cannot_import_itself [module descriptor.Module]) (exception.report "Module" (%.text module))) - (exception: .public (cannot_import_circular_dependency [importer descriptor.Module - importee descriptor.Module]) + (exception .public (cannot_import_circular_dependency [importer descriptor.Module + importee descriptor.Module]) (exception.report "Importer" (%.text importer) "importee" (%.text importee))) - (exception: .public (cannot_import_twice [importer descriptor.Module - duplicates (Set descriptor.Module)]) + (exception .public (cannot_import_twice [importer descriptor.Module + duplicates (Set descriptor.Module)]) (exception.report "Importer" (%.text importer) "Duplicates" (%.list %.text (set.list duplicates)))) @@ -414,7 +414,7 @@ ... else {try.#Success []})) - (exception: .public (cannot_overwrite_extension [extension extension.Name]) + (exception .public (cannot_overwrite_extension [extension extension.Name]) (exception.report "Extension" (%.text extension))) @@ -701,7 +701,7 @@ (instancer $.key (list)))) (def (custom_compiler import context platform compilation_sources compiler - custom_key custom_format custom_compilation) + custom_key custom_format custom_compilation) (All (_ <type_vars> state document object) (-> Import context.Context <Platform> (List _io.Context) (///.Compiler <State+> .Module Any) @@ -840,8 +840,8 @@ Type (type_literal (-> (List Text) (Try ///.Custom)))) - (exception: .public (invalid_custom_compiler [definition Symbol - type Type]) + (exception .public (invalid_custom_compiler [definition Symbol + type Type]) (exception.report "Definition" (%.symbol definition) "Expected Type" (%.type ..Custom) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux index fdd6d9b75..04023ab5c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe (.use "[1]#[0]" monoid monad)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.only) @@ -157,7 +157,7 @@ {#Exhaustive} "*")) -(exception: .public (invalid_tuple [size Nat]) +(exception .public (invalid_tuple [size Nat]) (exception.report "Expected size" ">= 2" "Actual size" (%.nat size))) @@ -233,14 +233,14 @@ ... always be a pattern prior to them that would match the input. ... Because of that, the presence of redundant patterns is assumed to ... be a bug, likely due to programmer carelessness. -(exception: .public (redundancy [so_far Coverage - addition Coverage]) +(exception .public (redundancy [so_far Coverage + addition Coverage]) (exception.report "Coverage so-far" (format so_far) "Additional coverage" (format addition))) -(exception: .public (variant_mismatch [expected Nat - mismatched Nat]) +(exception .public (variant_mismatch [expected Nat + mismatched Nat]) (exception.report "Expected cases" (%.nat expected) "Mismatched cases" (%.nat mismatched))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux index f177b638e..da4761411 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux @@ -8,7 +8,7 @@ ["[0]" pipe] ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.only) ["%" \\format (.only format)]] @@ -32,20 +32,20 @@ [meta [archive (.only Archive)]]]]]) -(exception: .public (cannot_infer [type Type - arguments (List Code)]) +(exception .public (cannot_infer [type Type + arguments (List Code)]) (exception.report "Type" (%.type type) "Arguments" (exception.listing %.code arguments))) -(exception: .public (cannot_infer_argument [type Type - argument Code]) +(exception .public (cannot_infer_argument [type Type + argument Code]) (exception.report "Type" (%.type type) "Argument" (%.code argument))) (with_template [<name>] - [(exception: .public (<name> [type Type]) + [(exception .public (<name> [type Type]) (exception.report "Type" (%.type type)))] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux index 68e1540b4..73ce2ea01 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux @@ -5,7 +5,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text ["%" \\format (.only format)]]] @@ -13,17 +13,17 @@ [///// ["[0]" phase]]) -(exception: .public (expansion_failed [macro Symbol - inputs (List Code) - error Text]) +(exception .public (expansion_failed [macro Symbol + inputs (List Code) + error Text]) (exception.report "Macro" (%.symbol macro) "Inputs" (exception.listing %.code inputs) "Error" error)) -(exception: .public (must_have_single_expansion [macro Symbol - inputs (List Code) - outputs (List Code)]) +(exception .public (must_have_single_expansion [macro Symbol + inputs (List Code) + outputs (List Code)]) (exception.report "Macro" (%.symbol macro) "Inputs" (exception.listing %.code inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux index 2c7f2f42b..c86bdc9b5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux @@ -6,7 +6,7 @@ [control ["[0]" pipe] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]] @@ -25,13 +25,13 @@ (type .public Label Text) -(exception: .public (unknown_module [module Text]) +(exception .public (unknown_module [module Text]) (exception.report "Module" module)) (with_template [<name>] - [(exception: .public (<name> [labels (List Label) - owner Type]) + [(exception .public (<name> [labels (List Label) + owner Type]) (exception.report "Labels" (text.interposed " " labels) "Type" (%.type owner)))] @@ -40,8 +40,8 @@ [cannot_declare_labels_for_foreign_type] ) -(exception: .public (cannot_define_more_than_once [name Symbol - already_existing Global]) +(exception .public (cannot_define_more_than_once [name Symbol + already_existing Global]) (exception.report "Definition" (%.symbol name) "Original" (case already_existing @@ -60,8 +60,8 @@ {.#Slot _} (format "slot " (%.symbol name))))) -(exception: .public (can_only_change_state_of_active_module [module Text - state Module_State]) +(exception .public (can_only_change_state_of_active_module [module Text + state Module_State]) (exception.report "Module" module "Desired state" (case state diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux index 9e4749526..8832c4b7e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux @@ -6,7 +6,7 @@ [control ["[0]" maybe (.use "[1]#[0]" monad)] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence)] ["[0]" product] @@ -106,8 +106,8 @@ {.#Some [ref_type ref]}]}) ))))) -(exception: .public no_scope) -(exception: .public drained) +(exception .public no_scope) +(exception .public drained) (def .public (with_local [name type] action) (All (_ a) (-> [Text Type] (Operation a) (Operation a))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index a0dc6d5d3..67bc8b4c1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -5,7 +5,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" function]] [data [binary (.only Binary)] @@ -42,12 +42,12 @@ (type .public (Buffer directive) (Sequence [artifact.ID (Maybe Text) directive])) -(exception: .public (cannot_interpret [error Text]) +(exception .public (cannot_interpret [error Text]) (exception.report "Error" error)) (with_template [<name>] - [(exception: .public (<name> [it artifact.ID]) + [(exception .public (<name> [it artifact.ID]) (exception.report "Artifact ID" (%.nat it)))] @@ -117,9 +117,9 @@ sequence.empty) (with_template [<tag> - <with_declaration> <with_type> <with_value> - <set> <get> <get_type> <exception>] - [(exception: .public <exception>) + <with_declaration> <with_type> <with_value> + <set> <get> <get_type> <exception>] + [(exception .public <exception>) (def .public <with_declaration> (All (_ anchor expression directive output) <with_type>) @@ -267,8 +267,8 @@ [Text #0 [] [] learn_directive registry.directive] ) -(exception: .public (unknown_definition [name Symbol - known_definitions (List category.Definition)]) +(exception .public (unknown_definition [name Symbol + known_definitions (List category.Definition)]) (exception.report "Definition" (symbol.short name) "Module" (symbol.module name) @@ -312,7 +312,7 @@ {.#Some [@artifact def]} {try.#Success [stateE [[@module @artifact] def]]}))))) -(exception: .public no_context) +(exception .public no_context) (def .public (module_id module archive) (All (_ anchor expression directive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index 025c953c3..804b99019 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -36,7 +36,7 @@ [meta [archive (.only Archive)]]]]]]) -(exception: .public (invalid [syntax Code]) +(exception .public (invalid [syntax Code]) (exception.report "Syntax" (%.code syntax))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index 8e3fff991..ba5d13ca3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [text @@ -38,29 +38,29 @@ [/// ["[1]" phase]]]]]]) -(exception: .public (mismatch [type Type - pattern Code]) +(exception .public (mismatch [type Type + pattern Code]) (exception.report "Type" (%.type type) "Pattern" (%.code pattern))) -(exception: .public (sum_has_no_case [case Nat - type Type]) +(exception .public (sum_has_no_case [case Nat + type Type]) (exception.report "Case" (%.nat case) "Type" (%.type type))) -(exception: .public (invalid [it Code]) +(exception .public (invalid [it Code]) (exception.report "Pattern" (%.code it))) -(exception: .public (non_tuple [type Type]) +(exception .public (non_tuple [type Type]) (exception.report "Type" (%.type type))) -(exception: .public (non_exhaustive [input Code - branches (List [Code Code]) - coverage Coverage]) +(exception .public (non_exhaustive [input Code + branches (List [Code Code]) + coverage Coverage]) (exception.report "Input" (%.code input) "Branches" (%.code (code.tuple (|> branches @@ -69,7 +69,7 @@ list#conjoint))) "Coverage" (/coverage.format coverage))) -(exception: .public empty_branches) +(exception .public empty_branches) (def (quantified envs baseT) (-> (List (List Type)) Type Type) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux index b0c35fb9f..3293fb170 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" state]] [data ["[0]" product] @@ -39,13 +39,13 @@ [meta [archive (.only Archive)]]]]]]) -(exception: .public (not_a_quantified_type [type Type]) +(exception .public (not_a_quantified_type [type Type]) (exception.report "Type" (%.type type))) (with_template [<name>] - [(exception: .public (<name> [type Type - members (List Code)]) + [(exception .public (<name> [type Type + members (List Code)]) (exception.report "Type" (%.type type) "Expression" (%.code (` [(~+ members)]))))] @@ -55,10 +55,10 @@ ) (with_template [<name>] - [(exception: .public (<name> [type Type - lefts Nat - right? Bit - code Code]) + [(exception .public (<name> [type Type + lefts Nat + right? Bit + code Code]) (exception.report "Type" (%.type type) "Lefts" (%.nat lefts) @@ -70,8 +70,8 @@ [cannot_infer_sum] ) -(exception: .public (cannot_repeat_slot [key Symbol - record (List [Symbol Code])]) +(exception .public (cannot_repeat_slot [key Symbol + record (List [Symbol Code])]) (exception.report "Slot" (%.code (code.symbol key)) "Record" (%.code (code.tuple (|> record @@ -79,16 +79,16 @@ (list (code.symbol keyI) valC))) list#conjoint))))) -(exception: .public (slot_does_not_belong_to_record [key Symbol - type Type]) +(exception .public (slot_does_not_belong_to_record [key Symbol + type Type]) (exception.report "Slot" (%.code (code.symbol key)) "Type" (%.type type))) -(exception: .public (record_size_mismatch [expected Nat - actual Nat - type Type - record (List [Symbol Code])]) +(exception .public (record_size_mismatch [expected Nat + actual Nat + type Type + record (List [Symbol Code])]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 0592768b2..4354f10a1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" text (.only) @@ -31,19 +31,19 @@ [reference (.only) [variable (.only)]]]]]) -(exception: .public (cannot_analyse [expected Type - function Text - argument Text - body Code]) +(exception .public (cannot_analyse [expected Type + function Text + argument Text + body Code]) (exception.report "Type" (%.type expected) "Function" function "Argument" argument "Body" (%.code body))) -(exception: .public (cannot_apply [:function: Type - functionC Code - arguments (List Code)]) +(exception .public (cannot_apply [:function: Type + functionC Code + arguments (List Code)]) (exception.report "Function type" (%.type :function:) "Function" (%.code functionC) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux index a46905cf1..2e43232b3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -5,7 +5,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]]] @@ -22,19 +22,19 @@ ["[1][0]" reference] ["[1]" phase]]]]]) -(exception: .public (foreign_module_has_not_been_imported [current Text - foreign Text - definition Symbol]) +(exception .public (foreign_module_has_not_been_imported [current Text + foreign Text + definition Symbol]) (exception.report "Current" current "Foreign" foreign "Definition" (%.symbol definition))) -(exception: .public (definition_has_not_been_exported [definition Symbol]) +(exception .public (definition_has_not_been_exported [definition Symbol]) (exception.report "Definition" (%.symbol definition))) -(exception: .public (labels_are_not_definitions [definition Symbol]) +(exception .public (labels_are_not_definitions [definition Symbol]) (exception.report "Label" (%.symbol definition))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index b601ba77a..cffe0d681 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -6,7 +6,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -28,15 +28,15 @@ [meta [archive (.only Archive)]]]]]) -(exception: .public (not_a_directive [code Code]) +(exception .public (not_a_directive [code Code]) (exception.report "Directive" (%.code code))) -(exception: .public (invalid_macro_call [code Code]) +(exception .public (invalid_macro_call [code Code]) (exception.report "Code" (%.code code))) -(exception: .public (macro_was_not_found [name Symbol]) +(exception .public (macro_was_not_found [name Symbol]) (exception.report "Name" (%.symbol name))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index 069ee2483..c8ffe0bb7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -8,7 +8,7 @@ [control ["[0]" function] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" text (.use "[1]#[0]" order) @@ -63,27 +63,27 @@ (type .public (Phase s i o) (//.Phase (State s i o) i o)) -(exception: .public (cannot_overwrite [name Name]) +(exception .public (cannot_overwrite [name Name]) (exception.report "Extension" (%.text name))) -(exception: .public (incorrect_arity [name Name - arity Nat - args Nat]) +(exception .public (incorrect_arity [name Name + arity Nat + args Nat]) (exception.report "Extension" (%.text name) "Expected" (%.nat arity) "Actual" (%.nat args))) -(exception: .public [a] (invalid_syntax [name Name - %format (Format a) - inputs (List a)]) +(exception .public [a] (invalid_syntax [name Name + %format (Format a) + inputs (List a)]) (exception.report "Extension" (%.text name) "Inputs" (exception.listing %format inputs))) -(exception: .public [s i o] (unknown [name Name - bundle (Bundle s i o)]) +(exception .public [s i o] (unknown [name Name + bundle (Bundle s i o)]) (exception.report "Extension" (%.text name) "Available" (|> bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 193a1e8b5..32ca3161d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -10,7 +10,7 @@ ["[0]" pipe] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try) (.use "[1]#[0]" monad)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -154,8 +154,8 @@ (getInterfaces [] [(java/lang/Class java/lang/Object)])) (with_template [<name>] - [(exception: .public (<name> [class External - field Text]) + [(exception .public (<name> [class External + field Text]) (exception.report "Class" (%.text class) "Field" (%.text field)))] @@ -164,15 +164,15 @@ [deprecated_field] ) -(exception: .public (deprecated_method [class External - method Text - type .Type]) +(exception .public (deprecated_method [class External + method Text + type .Type]) (exception.report "Class" (%.text class) "Method" (%.text method) "Type" (%.type type))) -(exception: .public (deprecated_class [class External]) +(exception .public (deprecated_class [class External]) (exception.report "Class" (%.text class))) @@ -241,7 +241,7 @@ #throws (List .Type)])) (with_template [<name>] - [(exception: .public (<name> [type .Type]) + [(exception .public (<name> [type .Type]) (exception.report "Type" (%.type type)))] @@ -252,7 +252,7 @@ ) (with_template [<name>] - [(exception: .public (<name> [class External]) + [(exception .public (<name> [class External]) (exception.report "Class/type" (%.text class)))] @@ -262,12 +262,12 @@ ) (with_template [<name>] - [(exception: .public (<name> [class_variables (List (Type Var)) - class External - method Text - method_variables (List (Type Var)) - inputsJT (List (Type Value)) - hints (List Method_Signature)]) + [(exception .public (<name> [class_variables (List (Type Var)) + class External + method Text + method_variables (List (Type Var)) + inputsJT (List (Type Value)) + hints (List Method_Signature)]) (exception.report "Class Variables" (exception.listing ..signature class_variables) "Class" class @@ -280,16 +280,16 @@ [too_many_candidates] ) -(exception: .public (cannot_cast [from .Type - to .Type - value Code]) +(exception .public (cannot_cast [from .Type + to .Type + value Code]) (exception.report "From" (%.type from) "To" (%.type to) "Value" (%.code value))) (with_template [<name>] - [(exception: .public (<name> [message Text]) + [(exception .public (<name> [message Text]) message)] [primitives_cannot_have_type_parameters] @@ -1753,8 +1753,8 @@ ) (with_template [<name>] - [(exception: .public (<name> [expected (List [(Type Class) Text (Type Method)]) - actual (List [(Type Class) Text (Type Method)])]) + [(exception .public (<name> [expected (List [(Type Class) Text (Type Method)]) + actual (List [(Type Class) Text (Type Method)])]) (let [%method (is (%.Format [(Type Class) Text (Type Method)]) (function (_ [super name type]) (format (..signature super) " :: " (%.text name) " " (..signature type))))] @@ -2155,15 +2155,15 @@ <code>.any ))) -(exception: .public (unknown_super [name Text - supers (List (Type Class))]) +(exception .public (unknown_super [name Text + supers (List (Type Class))]) (exception.report "Name" (%.text name) "Available" (exception.listing (|>> parser.read_class product.left) supers))) -(exception: .public (mismatched_super_parameters [name Text - expected Nat - actual Nat]) +(exception .public (mismatched_super_parameters [name Text + expected Nat + actual Nat]) (exception.report "Name" (%.text name) "Expected" (%.nat expected) @@ -2370,10 +2370,10 @@ (not (list.any? (matched? sub) super_set))) sub_set)) -(exception: .public (class_parameter_mismatch [name Text - declaration (Type Class) - expected (List Text) - actual (List (Type Parameter))]) +(exception .public (class_parameter_mismatch [name Text + declaration (Type Class) + expected (List Text) + actual (List (Type Parameter))]) (exception.report "Class" (%.text name) "Declaration" (signature.signature (jvm.signature declaration)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index e7711d4a0..448735394 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -6,7 +6,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -82,7 +82,7 @@ ... TODO: Get rid of this ASAP (these - (exception: .public (char_text_must_be_size_1 [text Text]) + (exception .public (char_text_must_be_size_1 [text Text]) (exception.report "Text" (%.text text))) @@ -202,7 +202,7 @@ (<| (typeA.expecting input) (phase archive valueC))))])) -(exception: .public (not_a_type [symbol Symbol]) +(exception .public (not_a_type [symbol Symbol]) (exception.report "Symbol" (%.symbol symbol))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index ac8d969ab..20f7aa448 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -9,7 +9,7 @@ [io (.only IO)] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -332,16 +332,16 @@ (in [/////directive.#imports imports /////directive.#referrals (list)])))])) -(exception: .public (cannot_alias_an_alias [local Alias - foreign Alias - target Symbol]) +(exception .public (cannot_alias_an_alias [local Alias + foreign Alias + target Symbol]) (exception.report "Local alias" (%.symbol local) "Foreign alias" (%.symbol foreign) "Target definition" (%.symbol target))) -(exception: .public (cannot_alias_a_label [local Alias - foreign Alias]) +(exception .public (cannot_alias_a_label [local Alias + foreign Alias]) (exception.report "Alias" (%.symbol local) "Label" (%.symbol foreign))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index 8daa095ba..53c38e858 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -5,8 +5,7 @@ ["[0]" monad (.only do)]] [control ["<>" parser] - ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" try]] [data ["[0]" product] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index 354be5da3..2cebcc690 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -6,7 +6,7 @@ [control ["<>" parser] ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [binary @@ -363,7 +363,7 @@ (-> (Type category) Text)) (|>> type.signature signature.signature)) -(exception: .public (not_an_object_array [arrayJT (Type Array)]) +(exception .public (not_an_object_array [arrayJT (Type Array)]) (exception.report "JVM Type" (..signature arrayJT))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 333171c4a..a839ca4ba 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -3,8 +3,6 @@ [lux (.except case let if) [abstract ["[0]" monad (.only do)]] - [control - ["[0]" exception (.only exception:)]] [data ["[0]" text (.only) ["%" \\format (.only format)]] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index 5032d0f0a..25e2a8d21 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -100,7 +100,7 @@ list.together))] (~ body)))))))) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -139,25 +139,27 @@ (_.defun (~ runtime_name) (_.args (list (~+ inputsC))) (~ code)))))))))))))) -(runtime: (lux//try op) - (with_vars [error] - (_.handler_case - (list [(_.bool true) error - (..left (_.format/3 [_.nil (_.string "~A") error]))]) - (..right (_.funcall/+ [op (list ..unit)]))))) +(runtime + (lux//try op) + (with_vars [error] + (_.handler_case + (list [(_.bool true) error + (..left (_.format/3 [_.nil (_.string "~A") error]))]) + (..right (_.funcall/+ [op (list ..unit)]))))) ... TODO: Use Common Lisp's swiss-army loop macro instead. -(runtime: (lux//program_args inputs) - (with_vars [loop input tail] - (_.labels (list [loop [(_.args (list input tail)) - (_.if (_.null/1 input) - tail - (_.funcall/+ [(_.function/1 loop) - (list (_.cdr/1 input) - (..some (_.vector/* (list (_.car/1 input) tail))))]))]]) - (_.funcall/+ [(_.function/1 loop) - (list (_.reverse/1 inputs) - ..none)])))) +(runtime + (lux//program_args inputs) + (with_vars [loop input tail] + (_.labels (list [loop [(_.args (list input tail)) + (_.if (_.null/1 input) + tail + (_.funcall/+ [(_.function/1 loop) + (list (_.cdr/1 input) + (..some (_.vector/* (list (_.car/1 input) tail))))]))]]) + (_.funcall/+ [(_.function/1 loop) + (list (_.reverse/1 inputs) + ..none)])))) (def runtime//lux (List (Expression Any)) @@ -175,53 +177,56 @@ (<side> (_.-/2 [last_index_right lefts]) (_.elt/2 [tuple last_index_right])))) - (runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (_.let (list [last_index_right (..last_index tuple)]) - (list (_.if (_.>/2 [lefts last_index_right]) - ... No need for recursion - (_.elt/2 [tuple lefts]) - ... Needs recursion - (!recur tuple//left)))))) - - (runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index] - (_.let (list [last_index_right (..last_index tuple)] - [right_index (_.+/2 [(_.int +1) lefts])]) - (list (_.cond (list [(_.=/2 [last_index_right right_index]) - (_.elt/2 [tuple right_index])] - [(_.>/2 [last_index_right right_index]) - ... Needs recursion. - (!recur tuple//right)]) - (_.subseq/3 [tuple right_index (_.length/1 tuple)]))))))) + (runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (_.let (list [last_index_right (..last_index tuple)]) + (list (_.if (_.>/2 [lefts last_index_right]) + ... No need for recursion + (_.elt/2 [tuple lefts]) + ... Needs recursion + (!recur tuple//left)))))) + + (runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index] + (_.let (list [last_index_right (..last_index tuple)] + [right_index (_.+/2 [(_.int +1) lefts])]) + (list (_.cond (list [(_.=/2 [last_index_right right_index]) + (_.elt/2 [tuple right_index])] + [(_.>/2 [last_index_right right_index]) + ... Needs recursion. + (!recur tuple//right)]) + (_.subseq/3 [tuple right_index (_.length/1 tuple)]))))))) ... TODO: Find a way to extract parts of the sum without "nth", which ... does a linear search, and is thus expensive. -(runtime: (sum//get sum wantsLast wantedTag) - (with_vars [sum_tag sum_flag] - (let [no_match! (_.return sum) - sum_value (_.nth/2 [(_.int +2) sum]) - test_recursion! (_.if sum_flag - ... Must iterate. - (_.progn (list (_.setq wantedTag (_.-/2 [sum_tag wantedTag])) - (_.setq sum sum_value))) - no_match!)] - (_.while (_.bool true) - (_.let (list [sum_tag (_.nth/2 [(_.int +0) sum])] - [sum_flag (_.nth/2 [(_.int +1) sum])]) - (list (_.cond (list [(_.=/2 [sum_tag wantedTag]) - (_.if (_.equal/2 [wantsLast sum_flag]) - (_.return sum_value) - test_recursion!)] - - [(_.>/2 [sum_tag wantedTag]) - test_recursion!] - - [(_.and (_.</2 [sum_tag wantedTag]) - wantsLast) - (_.return (variant' (_.-/2 [wantedTag sum_tag]) sum_flag sum_value))]) - - no_match!))))))) +(runtime + (sum//get sum wantsLast wantedTag) + (with_vars [sum_tag sum_flag] + (let [no_match! (_.return sum) + sum_value (_.nth/2 [(_.int +2) sum]) + test_recursion! (_.if sum_flag + ... Must iterate. + (_.progn (list (_.setq wantedTag (_.-/2 [sum_tag wantedTag])) + (_.setq sum sum_value))) + no_match!)] + (_.while (_.bool true) + (_.let (list [sum_tag (_.nth/2 [(_.int +0) sum])] + [sum_flag (_.nth/2 [(_.int +1) sum])]) + (list (_.cond (list [(_.=/2 [sum_tag wantedTag]) + (_.if (_.equal/2 [wantsLast sum_flag]) + (_.return sum_value) + test_recursion!)] + + [(_.>/2 [sum_tag wantedTag]) + test_recursion!] + + [(_.and (_.</2 [sum_tag wantedTag]) + wantsLast) + (_.return (variant' (_.-/2 [wantedTag sum_tag]) sum_flag sum_value))]) + + no_match!))))))) (def runtime//adt (List (Expression Any)) @@ -229,46 +234,50 @@ @tuple//right @sum//get)) -(runtime: (i64//right_shifted shift input) - (_.if (_.=/2 [(_.int +0) shift]) - input - (let [anti_shift (_.-/2 [shift (_.int +64)]) - mask (|> (_.int +1) - [anti_shift] _.ash/2 - [(_.int +1)] _.-/2)] - (|> input - [(_.*/2 [(_.int -1) shift])] _.ash/2 - [mask] _.logand/2)))) +(runtime + (i64//right_shifted shift input) + (_.if (_.=/2 [(_.int +0) shift]) + input + (let [anti_shift (_.-/2 [shift (_.int +64)]) + mask (|> (_.int +1) + [anti_shift] _.ash/2 + [(_.int +1)] _.-/2)] + (|> input + [(_.*/2 [(_.int -1) shift])] _.ash/2 + [mask] _.logand/2)))) (def runtime//i64 (List (Expression Any)) (list @i64//right_shifted)) -(runtime: (text//clip offset length text) - (_.subseq/3 [text offset (_.+/2 [offset length])])) +(runtime + (text//clip offset length text) + (_.subseq/3 [text offset (_.+/2 [offset length])])) -(runtime: (text//index offset sub text) - (with_vars [index] - (_.let (list [index (_.search/3 [sub text offset])]) - (list (_.if index - (..some index) - ..none))))) +(runtime + (text//index offset sub text) + (with_vars [index] + (_.let (list [index (_.search/3 [sub text offset])]) + (list (_.if index + (..some index) + ..none))))) (def runtime//text (List (Expression Any)) (list @text//index @text//clip)) -(runtime: (io//exit code) - (_.progn (list (_.conditional+ (list "sbcl") - (_.call/* (_.var "sb-ext:quit") (list code))) - (_.conditional+ (list "clisp") - (_.call/* (_.var "ext:exit") (list code))) - (_.conditional+ (list "ccl") - (_.call/* (_.var "ccl:quit") (list code))) - (_.conditional+ (list "allegro") - (_.call/* (_.var "excl:exit") (list code))) - (_.call/* (_.var "cl-user::quit") (list code))))) +(runtime + (io//exit code) + (_.progn (list (_.conditional+ (list "sbcl") + (_.call/* (_.var "sb-ext:quit") (list code))) + (_.conditional+ (list "clisp") + (_.call/* (_.var "ext:exit") (list code))) + (_.conditional+ (list "ccl") + (_.call/* (_.var "ccl:quit") (list code))) + (_.conditional+ (list "allegro") + (_.call/* (_.var "excl:exit") (list code))) + (_.call/* (_.var "cl-user::quit") (list code))))) (def runtime//io (List (Expression Any)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index 657e876ea..4c6b002c2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [macro ["^" pattern]] [target @@ -32,7 +32,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(exception: .public cannot_recur_as_an_expression) +(exception .public cannot_recur_as_an_expression) (def (expression archive synthesis) Phase 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 28c22f430..45ec51f44 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 @@ -94,7 +94,7 @@ list.together))] (~ body)))))))) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -145,76 +145,80 @@ (with_expansions [<recur> (these (all _.then (_.set lefts (_.- last_index_right lefts)) (_.set tuple (_.at last_index_right tuple))))] - (runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (<| (_.while (_.boolean true)) - (all _.then - (_.define last_index_right (..last_index tuple)) - (_.if (_.> lefts last_index_right) - ... No need for recursion - (_.return (_.at lefts tuple)) - ... Needs recursion - <recur>))))) - - (runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index] - (<| (_.while (_.boolean true)) - (all _.then - (_.define last_index_right (..last_index tuple)) - (_.define right_index (_.+ (_.i32 +1) lefts)) - (<| (_.if (_.= last_index_right right_index) - (_.return (_.at right_index tuple))) - (_.if (_.> last_index_right right_index) - ... Needs recursion. - <recur>) - (_.return (_.do "slice" (list right_index) tuple))) - ))))) + (runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (<| (_.while (_.boolean true)) + (all _.then + (_.define last_index_right (..last_index tuple)) + (_.if (_.> lefts last_index_right) + ... No need for recursion + (_.return (_.at lefts tuple)) + ... Needs recursion + <recur>))))) + + (runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index] + (<| (_.while (_.boolean true)) + (all _.then + (_.define last_index_right (..last_index tuple)) + (_.define right_index (_.+ (_.i32 +1) lefts)) + (<| (_.if (_.= last_index_right right_index) + (_.return (_.at right_index tuple))) + (_.if (_.> last_index_right right_index) + ... Needs recursion. + <recur>) + (_.return (_.do "slice" (list right_index) tuple))) + ))))) (def .public variant_tag_field "_lux_tag") (def .public variant_flag_field "_lux_flag") (def .public variant_value_field "_lux_value") -(runtime: variant//new - (let [@this (_.var "this")] - (with_vars [tag is_last value] - (_.closure (list tag is_last value) - (all _.then - (_.set (_.the ..variant_tag_field @this) tag) - (_.set (_.the ..variant_flag_field @this) is_last) - (_.set (_.the ..variant_value_field @this) value) - ))))) +(runtime + variant//new + (let [@this (_.var "this")] + (with_vars [tag is_last value] + (_.closure (list tag is_last value) + (all _.then + (_.set (_.the ..variant_tag_field @this) tag) + (_.set (_.the ..variant_flag_field @this) is_last) + (_.set (_.the ..variant_value_field @this) value) + ))))) (def .public (variant tag last? value) (-> Expression Expression Expression Computation) (_.new ..variant//new (list tag last? 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! (all _.then - (_.set expected::lefts (|> expected::lefts - (_.- actual::lefts) - (_.- (_.i32 +1)))) - (_.set sum actual::value))] - (<| (_.while (_.boolean true)) - (_.if (_.= expected::lefts actual::lefts) - (_.if (_.= expected::right? actual::right?) - (_.return actual::value) - mismatch!)) - (_.if (_.< expected::lefts actual::lefts) - (_.if (_.= ..unit actual::right?) - recur! - mismatch!)) - (_.if (_.= ..unit expected::right?) - (_.return (..variant (|> actual::lefts - (_.- expected::lefts) - (_.- (_.i32 +1))) - actual::right? - actual::value))) - mismatch!))) +(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! (all _.then + (_.set expected::lefts (|> expected::lefts + (_.- actual::lefts) + (_.- (_.i32 +1)))) + (_.set sum actual::value))] + (<| (_.while (_.boolean true)) + (_.if (_.= expected::lefts actual::lefts) + (_.if (_.= expected::right? actual::right?) + (_.return actual::value) + mismatch!)) + (_.if (_.< expected::lefts actual::lefts) + (_.if (_.= ..unit actual::right?) + recur! + mismatch!)) + (_.if (_.= ..unit expected::right?) + (_.return (..variant (|> actual::lefts + (_.- expected::lefts) + (_.- (_.i32 +1))) + actual::right? + actual::value))) + mismatch!))) (def left (-> Expression Computation) @@ -241,22 +245,24 @@ @sum//get )) -(runtime: (lux//try op) - (with_vars [ex] - (_.try (_.return (..right (_.apply_1 op ..unit))) - [ex (_.return (..left (|> ex (_.do "toString" (list)))))]))) - -(runtime: (lux//program_args inputs) - (with_vars [output idx] - (all _.then - (_.define output ..none) - (_.for idx - (..last_index inputs) - (_.>= (_.i32 +0) idx) - (_.-- idx) - (_.set output (..some (_.array (list (_.at idx inputs) - output))))) - (_.return output)))) +(runtime + (lux//try op) + (with_vars [ex] + (_.try (_.return (..right (_.apply_1 op ..unit))) + [ex (_.return (..left (|> ex (_.do "toString" (list)))))]))) + +(runtime + (lux//program_args inputs) + (with_vars [output idx] + (all _.then + (_.define output ..none) + (_.for idx + (..last_index inputs) + (_.>= (_.i32 +0) idx) + (_.-- idx) + (_.set output (..some (_.array (list (_.at idx inputs) + output))))) + (_.return output)))) (def runtime//lux Statement @@ -268,34 +274,37 @@ (def .public i64_low_field Text "_lux_low") (def .public i64_high_field Text "_lux_high") -(runtime: i64::new - (let [@this (_.var "this")] - (with_vars [high low] - (_.closure (list high low) - (all _.then - (_.set (_.the ..i64_high_field @this) high) - (_.set (_.the ..i64_low_field @this) low) - ))))) +(runtime + i64::new + (let [@this (_.var "this")] + (with_vars [high low] + (_.closure (list high low) + (all _.then + (_.set (_.the ..i64_high_field @this) high) + (_.set (_.the ..i64_low_field @this) low) + ))))) (def .public (i64 high low) (-> Expression Expression Computation) (_.new ..i64::new (list high low))) (with_template [<name> <op>] - [(runtime: (<name> subject parameter) - (_.return (..i64 (<op> (_.the ..i64_high_field subject) - (_.the ..i64_high_field parameter)) - (<op> (_.the ..i64_low_field subject) - (_.the ..i64_low_field parameter)))))] + [(runtime + (<name> subject parameter) + (_.return (..i64 (<op> (_.the ..i64_high_field subject) + (_.the ..i64_high_field parameter)) + (<op> (_.the ..i64_low_field subject) + (_.the ..i64_low_field parameter)))))] [i64::xor _.bit_xor] [i64::or _.bit_or] [i64::and _.bit_and] ) -(runtime: (i64::not value) - (_.return (..i64 (_.bit_not (_.the ..i64_high_field value)) - (_.bit_not (_.the ..i64_low_field value))))) +(runtime + (i64::not value) + (_.return (..i64 (_.bit_not (_.the ..i64_high_field value)) + (_.bit_not (_.the ..i64_low_field value))))) (def (cap_shift! shift) (-> Var Statement) @@ -310,47 +319,50 @@ (-> Var Expression) (|>> (_.< (_.i32 +32)))) -(runtime: (i64::left_shifted input shift) - (all _.then - (..cap_shift! shift) - (_.return (<| (..no_shift! shift input) - (_.? (..small_shift? shift) - (let [high (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift shift)) - (|> input (_.the ..i64_low_field) (_.logic_right_shift (_.- shift (_.i32 +32))))) - low (|> input (_.the ..i64_low_field) (_.left_shift shift))] - (..i64 high low))) - (let [high (|> input (_.the ..i64_low_field) (_.left_shift (_.- (_.i32 +32) shift)))] - (..i64 high (_.i32 +0))))) - )) - -(runtime: (i64::arithmetic_right_shifted input shift) - (all _.then - (..cap_shift! shift) - (_.return (<| (..no_shift! shift input) - (_.? (..small_shift? shift) - (let [high (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift shift)) - low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift) - (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))] - (..i64 high low))) - (let [high (_.? (|> input (_.the ..i64_high_field) (_.>= (_.i32 +0))) - (_.i32 +0) - (_.i32 -1)) - low (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift (_.- (_.i32 +32) shift)))] - (..i64 high low)))))) - -(runtime: (i64::right_shifted input shift) - (all _.then - (..cap_shift! shift) - (_.return (<| (..no_shift! shift input) - (_.? (..small_shift? shift) - (let [high (|> input (_.the ..i64_high_field) (_.logic_right_shift shift)) - low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift) - (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))] - (..i64 high low))) - (_.? (|> shift (_.= (_.i32 +32))) - (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field)))) - (..i64 (_.i32 +0) - (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift)))))))) +(runtime + (i64::left_shifted input shift) + (all _.then + (..cap_shift! shift) + (_.return (<| (..no_shift! shift input) + (_.? (..small_shift? shift) + (let [high (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift shift)) + (|> input (_.the ..i64_low_field) (_.logic_right_shift (_.- shift (_.i32 +32))))) + low (|> input (_.the ..i64_low_field) (_.left_shift shift))] + (..i64 high low))) + (let [high (|> input (_.the ..i64_low_field) (_.left_shift (_.- (_.i32 +32) shift)))] + (..i64 high (_.i32 +0))))) + )) + +(runtime + (i64::arithmetic_right_shifted input shift) + (all _.then + (..cap_shift! shift) + (_.return (<| (..no_shift! shift input) + (_.? (..small_shift? shift) + (let [high (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift shift)) + low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift) + (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))] + (..i64 high low))) + (let [high (_.? (|> input (_.the ..i64_high_field) (_.>= (_.i32 +0))) + (_.i32 +0) + (_.i32 -1)) + low (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift (_.- (_.i32 +32) shift)))] + (..i64 high low)))))) + +(runtime + (i64::right_shifted input shift) + (all _.then + (..cap_shift! shift) + (_.return (<| (..no_shift! shift input) + (_.? (..small_shift? shift) + (let [high (|> input (_.the ..i64_high_field) (_.logic_right_shift shift)) + low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift) + (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))] + (..i64 high low))) + (_.? (|> shift (_.= (_.i32 +32))) + (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field)))) + (..i64 (_.i32 +0) + (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift)))))))) (def runtime//bit Statement @@ -364,177 +376,195 @@ @i64::right_shifted )) -(runtime: i64::2^16 - (_.left_shift (_.i32 +16) (_.i32 +1))) - -(runtime: i64::2^32 - (_.* i64::2^16 i64::2^16)) - -(runtime: i64::2^64 - (_.* i64::2^32 i64::2^32)) - -(runtime: i64::2^63 - (|> i64::2^64 (_./ (_.i32 +2)))) - -(runtime: (i64::unsigned_low i64) - (_.return (_.? (|> i64 (_.the ..i64_low_field) (_.>= (_.i32 +0))) - (|> i64 (_.the ..i64_low_field)) - (|> i64 (_.the ..i64_low_field) (_.+ i64::2^32))))) - -(runtime: (i64::number i64) - (_.return (|> i64 - (_.the ..i64_high_field) - (_.* i64::2^32) - (_.+ (i64::unsigned_low i64))))) - -(runtime: i64::zero - (..i64 (_.i32 +0) (_.i32 +0))) - -(runtime: i64::min - (..i64 (_.i32 (.int (hex "80,00,00,00"))) - (_.i32 +0))) - -(runtime: i64::max - (..i64 (_.i32 (.int (hex "7F,FF,FF,FF"))) - (_.i32 (.int (hex "FF,FF,FF,FF"))))) - -(runtime: i64::one - (..i64 (_.i32 +0) (_.i32 +1))) - -(runtime: (i64::= reference sample) - (_.return (_.and (_.= (_.the ..i64_high_field reference) - (_.the ..i64_high_field sample)) - (_.= (_.the ..i64_low_field reference) - (_.the ..i64_low_field sample))))) - -(runtime: (i64::+ parameter subject) - (let [up_16 (_.left_shift (_.i32 +16)) - high_16 (_.logic_right_shift (_.i32 +16)) - low_16 (_.bit_and (_.i32 (.int (hex "FFFF")))) - hh (|>> (_.the ..i64_high_field) high_16) - hl (|>> (_.the ..i64_high_field) low_16) - lh (|>> (_.the ..i64_low_field) high_16) - ll (|>> (_.the ..i64_low_field) low_16)] - (with_vars [l48 l32 l16 l00 - r48 r32 r16 r00 - x48 x32 x16 x00] - (all _.then - (_.define l48 (hh subject)) - (_.define l32 (hl subject)) - (_.define l16 (lh subject)) - (_.define l00 (ll subject)) - - (_.define r48 (hh parameter)) - (_.define r32 (hl parameter)) - (_.define r16 (lh parameter)) - (_.define r00 (ll parameter)) - - (_.define x00 (_.+ l00 r00)) - - (_.define x16 (|> (high_16 x00) - (_.+ l16) - (_.+ r16))) - (_.set x00 (low_16 x00)) - - (_.define x32 (|> (high_16 x16) - (_.+ l32) - (_.+ r32))) - (_.set x16 (low_16 x16)) - - (_.define x48 (|> (high_16 x32) - (_.+ l48) - (_.+ r48) - low_16)) - (_.set x32 (low_16 x32)) - - (_.return (..i64 (_.bit_or (up_16 x48) x32) - (_.bit_or (up_16 x16) x00))) - )))) - -(runtime: (i64::opposite value) - (_.return (_.? (i64::= i64::min value) - i64::min - (i64::+ i64::one (i64::not value))))) - -(runtime: i64::-one - (i64::opposite i64::one)) - -(runtime: (i64::of_number value) - (_.return (<| (_.? (_.not_a_number? value) - i64::zero) - (_.? (_.<= (_.opposite i64::2^63) value) - i64::min) - (_.? (|> value (_.+ (_.i32 +1)) (_.>= i64::2^63)) - i64::max) - (_.? (|> value (_.< (_.i32 +0))) - (|> value _.opposite i64::of_number i64::opposite)) - (..i64 (|> value (_./ i64::2^32) _.to_i32) - (|> value (_.% i64::2^32) _.to_i32))))) - -(runtime: (i64::- parameter subject) - (_.return (i64::+ (i64::opposite parameter) subject))) - -(runtime: (i64::* parameter subject) - (let [up_16 (_.left_shift (_.i32 +16)) - high_16 (_.logic_right_shift (_.i32 +16)) - low_16 (_.bit_and (_.i32 (.int (hex "FFFF")))) - hh (|>> (_.the ..i64_high_field) high_16) - hl (|>> (_.the ..i64_high_field) low_16) - lh (|>> (_.the ..i64_low_field) high_16) - ll (|>> (_.the ..i64_low_field) low_16)] - (with_vars [l48 l32 l16 l00 - r48 r32 r16 r00 - x48 x32 x16 x00] - (all _.then - (_.define l48 (hh subject)) - (_.define l32 (hl subject)) - (_.define l16 (lh subject)) - (_.define l00 (ll subject)) - - (_.define r48 (hh parameter)) - (_.define r32 (hl parameter)) - (_.define r16 (lh parameter)) - (_.define r00 (ll parameter)) - - (_.define x00 (_.* l00 r00)) - (_.define x16 (high_16 x00)) - (_.set x00 (low_16 x00)) - - (_.set x16 (|> x16 (_.+ (_.* l16 r00)))) - (_.define x32 (high_16 x16)) (_.set x16 (low_16 x16)) - (_.set x16 (|> x16 (_.+ (_.* l00 r16)))) - (_.set x32 (|> x32 (_.+ (high_16 x16)))) (_.set x16 (low_16 x16)) - - (_.set x32 (|> x32 (_.+ (_.* l32 r00)))) - (_.define x48 (high_16 x32)) (_.set x32 (low_16 x32)) - (_.set x32 (|> x32 (_.+ (_.* l16 r16)))) - (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32)) - (_.set x32 (|> x32 (_.+ (_.* l00 r32)))) - (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32)) - - (_.set x48 (|> x48 - (_.+ (_.* l48 r00)) - (_.+ (_.* l32 r16)) - (_.+ (_.* l16 r32)) - (_.+ (_.* l00 r48)) - low_16)) - - (_.return (..i64 (_.bit_or (up_16 x48) x32) - (_.bit_or (up_16 x16) x00))) - )))) - -(runtime: (i64::< parameter subject) - (let [negative? (|>> (_.the ..i64_high_field) (_.< (_.i32 +0)))] - (with_vars [-subject? -parameter?] - (all _.then - (_.define -subject? (negative? subject)) - (_.define -parameter? (negative? parameter)) - (_.return (<| (_.? (_.and -subject? (_.not -parameter?)) - (_.boolean true)) - (_.? (_.and (_.not -subject?) -parameter?) - (_.boolean false)) - (negative? (i64::- parameter subject)))) - )))) +(runtime + i64::2^16 + (_.left_shift (_.i32 +16) (_.i32 +1))) + +(runtime + i64::2^32 + (_.* i64::2^16 i64::2^16)) + +(runtime + i64::2^64 + (_.* i64::2^32 i64::2^32)) + +(runtime + i64::2^63 + (|> i64::2^64 (_./ (_.i32 +2)))) + +(runtime + (i64::unsigned_low i64) + (_.return (_.? (|> i64 (_.the ..i64_low_field) (_.>= (_.i32 +0))) + (|> i64 (_.the ..i64_low_field)) + (|> i64 (_.the ..i64_low_field) (_.+ i64::2^32))))) + +(runtime + (i64::number i64) + (_.return (|> i64 + (_.the ..i64_high_field) + (_.* i64::2^32) + (_.+ (i64::unsigned_low i64))))) + +(runtime + i64::zero + (..i64 (_.i32 +0) (_.i32 +0))) + +(runtime + i64::min + (..i64 (_.i32 (.int (hex "80,00,00,00"))) + (_.i32 +0))) + +(runtime + i64::max + (..i64 (_.i32 (.int (hex "7F,FF,FF,FF"))) + (_.i32 (.int (hex "FF,FF,FF,FF"))))) + +(runtime + i64::one + (..i64 (_.i32 +0) (_.i32 +1))) + +(runtime + (i64::= reference sample) + (_.return (_.and (_.= (_.the ..i64_high_field reference) + (_.the ..i64_high_field sample)) + (_.= (_.the ..i64_low_field reference) + (_.the ..i64_low_field sample))))) + +(runtime + (i64::+ parameter subject) + (let [up_16 (_.left_shift (_.i32 +16)) + high_16 (_.logic_right_shift (_.i32 +16)) + low_16 (_.bit_and (_.i32 (.int (hex "FFFF")))) + hh (|>> (_.the ..i64_high_field) high_16) + hl (|>> (_.the ..i64_high_field) low_16) + lh (|>> (_.the ..i64_low_field) high_16) + ll (|>> (_.the ..i64_low_field) low_16)] + (with_vars [l48 l32 l16 l00 + r48 r32 r16 r00 + x48 x32 x16 x00] + (all _.then + (_.define l48 (hh subject)) + (_.define l32 (hl subject)) + (_.define l16 (lh subject)) + (_.define l00 (ll subject)) + + (_.define r48 (hh parameter)) + (_.define r32 (hl parameter)) + (_.define r16 (lh parameter)) + (_.define r00 (ll parameter)) + + (_.define x00 (_.+ l00 r00)) + + (_.define x16 (|> (high_16 x00) + (_.+ l16) + (_.+ r16))) + (_.set x00 (low_16 x00)) + + (_.define x32 (|> (high_16 x16) + (_.+ l32) + (_.+ r32))) + (_.set x16 (low_16 x16)) + + (_.define x48 (|> (high_16 x32) + (_.+ l48) + (_.+ r48) + low_16)) + (_.set x32 (low_16 x32)) + + (_.return (..i64 (_.bit_or (up_16 x48) x32) + (_.bit_or (up_16 x16) x00))) + )))) + +(runtime + (i64::opposite value) + (_.return (_.? (i64::= i64::min value) + i64::min + (i64::+ i64::one (i64::not value))))) + +(runtime + i64::-one + (i64::opposite i64::one)) + +(runtime + (i64::of_number value) + (_.return (<| (_.? (_.not_a_number? value) + i64::zero) + (_.? (_.<= (_.opposite i64::2^63) value) + i64::min) + (_.? (|> value (_.+ (_.i32 +1)) (_.>= i64::2^63)) + i64::max) + (_.? (|> value (_.< (_.i32 +0))) + (|> value _.opposite i64::of_number i64::opposite)) + (..i64 (|> value (_./ i64::2^32) _.to_i32) + (|> value (_.% i64::2^32) _.to_i32))))) + +(runtime + (i64::- parameter subject) + (_.return (i64::+ (i64::opposite parameter) subject))) + +(runtime + (i64::* parameter subject) + (let [up_16 (_.left_shift (_.i32 +16)) + high_16 (_.logic_right_shift (_.i32 +16)) + low_16 (_.bit_and (_.i32 (.int (hex "FFFF")))) + hh (|>> (_.the ..i64_high_field) high_16) + hl (|>> (_.the ..i64_high_field) low_16) + lh (|>> (_.the ..i64_low_field) high_16) + ll (|>> (_.the ..i64_low_field) low_16)] + (with_vars [l48 l32 l16 l00 + r48 r32 r16 r00 + x48 x32 x16 x00] + (all _.then + (_.define l48 (hh subject)) + (_.define l32 (hl subject)) + (_.define l16 (lh subject)) + (_.define l00 (ll subject)) + + (_.define r48 (hh parameter)) + (_.define r32 (hl parameter)) + (_.define r16 (lh parameter)) + (_.define r00 (ll parameter)) + + (_.define x00 (_.* l00 r00)) + (_.define x16 (high_16 x00)) + (_.set x00 (low_16 x00)) + + (_.set x16 (|> x16 (_.+ (_.* l16 r00)))) + (_.define x32 (high_16 x16)) (_.set x16 (low_16 x16)) + (_.set x16 (|> x16 (_.+ (_.* l00 r16)))) + (_.set x32 (|> x32 (_.+ (high_16 x16)))) (_.set x16 (low_16 x16)) + + (_.set x32 (|> x32 (_.+ (_.* l32 r00)))) + (_.define x48 (high_16 x32)) (_.set x32 (low_16 x32)) + (_.set x32 (|> x32 (_.+ (_.* l16 r16)))) + (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32)) + (_.set x32 (|> x32 (_.+ (_.* l00 r32)))) + (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32)) + + (_.set x48 (|> x48 + (_.+ (_.* l48 r00)) + (_.+ (_.* l32 r16)) + (_.+ (_.* l16 r32)) + (_.+ (_.* l00 r48)) + low_16)) + + (_.return (..i64 (_.bit_or (up_16 x48) x32) + (_.bit_or (up_16 x16) x00))) + )))) + +(runtime + (i64::< parameter subject) + (let [negative? (|>> (_.the ..i64_high_field) (_.< (_.i32 +0)))] + (with_vars [-subject? -parameter?] + (all _.then + (_.define -subject? (negative? subject)) + (_.define -parameter? (negative? parameter)) + (_.return (<| (_.? (_.and -subject? (_.not -parameter?)) + (_.boolean true)) + (_.? (_.and (_.not -subject?) -parameter?) + (_.boolean false)) + (negative? (i64::- parameter subject)))) + )))) (def (i64::<= param subject) (-> Expression Expression Expression) @@ -544,87 +574,89 @@ (def negative? (i64::< i64::zero)) -(runtime: (i64::/ parameter subject) - (<| (_.if (i64::= i64::zero parameter) - (_.throw (_.string "Cannot divide by zero!"))) - (_.if (i64::= i64::zero subject) - (_.return i64::zero)) - (_.if (i64::= i64::min subject) - (<| (_.if (_.or (i64::= i64::one parameter) - (i64::= i64::-one parameter)) - (_.return i64::min)) - (_.if (i64::= i64::min parameter) - (_.return i64::one)) - (with_vars [approximation] - (let [subject/2 (..i64::arithmetic_right_shifted subject (_.i32 +1))] - (all _.then - (_.define approximation (i64::left_shifted (i64::/ parameter - subject/2) - (_.i32 +1))) - (_.if (i64::= i64::zero approximation) - (_.return (_.? (..negative? parameter) - i64::one - i64::-one)) - (let [remainder (i64::- (i64::* approximation - parameter) - subject)] - (_.return (i64::+ (i64::/ parameter - remainder) - approximation))))))))) - (_.if (i64::= i64::min parameter) - (_.return i64::zero)) - (_.if (..negative? subject) - (_.return (_.? (..negative? parameter) - (i64::/ (i64::opposite parameter) - (i64::opposite subject)) - (i64::opposite (i64::/ parameter - (i64::opposite subject)))))) - (_.if (..negative? parameter) - (_.return (i64::opposite (i64::/ (i64::opposite parameter) subject)))) - (with_vars [result remainder] - (all _.then - (_.define result i64::zero) - (_.define remainder subject) - (_.while (i64::<= remainder parameter) - (with_vars [approximate approximate_result approximate_remainder log2 delta] - (let [approximate_result' (i64::of_number approximate) - approx_remainder (i64::* parameter approximate_result)] - (all _.then - (_.define approximate (|> (i64::number remainder) - (_./ (i64::number parameter)) - (_.apply_1 (_.var "Math.floor")) - (_.apply_2 (_.var "Math.max") (_.i32 +1)))) - (_.define log2 (|> approximate - (_.apply_1 (_.var "Math.log")) - (_./ (_.var "Math.LN2")) - (_.apply_1 (_.var "Math.ceil")))) - (_.define delta (_.? (_.> (_.i32 +48) log2) - (_.apply_2 (_.var "Math.pow") - (_.i32 +2) - (_.- (_.i32 +48) - log2)) - (_.i32 +1))) - (_.define approximate_result approximate_result') - (_.define approximate_remainder approx_remainder) - (_.while (_.or (..negative? approximate_remainder) - (i64::< approximate_remainder - remainder)) - (all _.then - (_.set approximate (_.- delta approximate)) - (_.set approximate_result approximate_result') - (_.set approximate_remainder approx_remainder))) - (_.set result (i64::+ (_.? (i64::= i64::zero approximate_result) - i64::one - approximate_result) - result)) - (_.set remainder (i64::- approximate_remainder remainder)))))) - (_.return result))))) - -(runtime: (i64::% parameter subject) - (let [flat (|> subject - (i64::/ parameter) - (i64::* parameter))] - (_.return (i64::- flat subject)))) +(runtime + (i64::/ parameter subject) + (<| (_.if (i64::= i64::zero parameter) + (_.throw (_.string "Cannot divide by zero!"))) + (_.if (i64::= i64::zero subject) + (_.return i64::zero)) + (_.if (i64::= i64::min subject) + (<| (_.if (_.or (i64::= i64::one parameter) + (i64::= i64::-one parameter)) + (_.return i64::min)) + (_.if (i64::= i64::min parameter) + (_.return i64::one)) + (with_vars [approximation] + (let [subject/2 (..i64::arithmetic_right_shifted subject (_.i32 +1))] + (all _.then + (_.define approximation (i64::left_shifted (i64::/ parameter + subject/2) + (_.i32 +1))) + (_.if (i64::= i64::zero approximation) + (_.return (_.? (..negative? parameter) + i64::one + i64::-one)) + (let [remainder (i64::- (i64::* approximation + parameter) + subject)] + (_.return (i64::+ (i64::/ parameter + remainder) + approximation))))))))) + (_.if (i64::= i64::min parameter) + (_.return i64::zero)) + (_.if (..negative? subject) + (_.return (_.? (..negative? parameter) + (i64::/ (i64::opposite parameter) + (i64::opposite subject)) + (i64::opposite (i64::/ parameter + (i64::opposite subject)))))) + (_.if (..negative? parameter) + (_.return (i64::opposite (i64::/ (i64::opposite parameter) subject)))) + (with_vars [result remainder] + (all _.then + (_.define result i64::zero) + (_.define remainder subject) + (_.while (i64::<= remainder parameter) + (with_vars [approximate approximate_result approximate_remainder log2 delta] + (let [approximate_result' (i64::of_number approximate) + approx_remainder (i64::* parameter approximate_result)] + (all _.then + (_.define approximate (|> (i64::number remainder) + (_./ (i64::number parameter)) + (_.apply_1 (_.var "Math.floor")) + (_.apply_2 (_.var "Math.max") (_.i32 +1)))) + (_.define log2 (|> approximate + (_.apply_1 (_.var "Math.log")) + (_./ (_.var "Math.LN2")) + (_.apply_1 (_.var "Math.ceil")))) + (_.define delta (_.? (_.> (_.i32 +48) log2) + (_.apply_2 (_.var "Math.pow") + (_.i32 +2) + (_.- (_.i32 +48) + log2)) + (_.i32 +1))) + (_.define approximate_result approximate_result') + (_.define approximate_remainder approx_remainder) + (_.while (_.or (..negative? approximate_remainder) + (i64::< approximate_remainder + remainder)) + (all _.then + (_.set approximate (_.- delta approximate)) + (_.set approximate_result approximate_result') + (_.set approximate_remainder approx_remainder))) + (_.set result (i64::+ (_.? (i64::= i64::zero approximate_result) + i64::one + approximate_result) + result)) + (_.set remainder (i64::- approximate_remainder remainder)))))) + (_.return result))))) + +(runtime + (i64::% parameter subject) + (let [flat (|> subject + (i64::/ parameter) + (i64::* parameter))] + (_.return (i64::- flat subject)))) (def runtime//i64 Statement @@ -654,26 +686,29 @@ @i64::% )) -(runtime: (text//index start part text) - (with_vars [idx] - (all _.then - (_.define idx (|> text (_.do "indexOf" (list part (i64::number start))))) - (_.return (_.? (_.= (_.i32 -1) idx) - ..none - (..some (i64::of_number idx))))))) - -(runtime: (text//clip offset length text) - (_.return (|> text (_.do "substring" (list (_.the ..i64_low_field offset) - (_.+ (_.the ..i64_low_field offset) - (_.the ..i64_low_field length))))))) - -(runtime: (text//char idx text) - (with_vars [result] - (all _.then - (_.define result (|> text (_.do "charCodeAt" (list (_.the ..i64_low_field idx))))) - (_.if (_.not_a_number? result) - (_.throw (_.string "[Lux Error] Cannot get char from text.")) - (_.return (i64::of_number result)))))) +(runtime + (text//index start part text) + (with_vars [idx] + (all _.then + (_.define idx (|> text (_.do "indexOf" (list part (i64::number start))))) + (_.return (_.? (_.= (_.i32 -1) idx) + ..none + (..some (i64::of_number idx))))))) + +(runtime + (text//clip offset length text) + (_.return (|> text (_.do "substring" (list (_.the ..i64_low_field offset) + (_.+ (_.the ..i64_low_field offset) + (_.the ..i64_low_field length))))))) + +(runtime + (text//char idx text) + (with_vars [result] + (all _.then + (_.define result (|> text (_.do "charCodeAt" (list (_.the ..i64_low_field idx))))) + (_.if (_.not_a_number? result) + (_.throw (_.string "[Lux Error] Cannot get char from text.")) + (_.return (i64::of_number result)))))) (def runtime//text Statement @@ -683,26 +718,28 @@ @text//char )) -(runtime: (io//log message) - (let [console (_.var "console") - print (_.var "print") - end! (_.return ..unit)] - (<| (_.if (|> console _.type_of (_.= (_.string "undefined")) _.not - (_.and (_.the "log" console))) - (all _.then - (_.statement (|> console (_.do "log" (list message)))) - end!)) - (_.if (|> print _.type_of (_.= (_.string "undefined")) _.not) - (all _.then - (_.statement (_.apply_1 print (_.? (_.= (_.string "string") - (_.type_of message)) - message - (_.apply_1 (_.var "JSON.stringify") message)))) - end!)) - end!))) - -(runtime: (io//error message) - (_.throw message)) +(runtime + (io//log message) + (let [console (_.var "console") + print (_.var "print") + end! (_.return ..unit)] + (<| (_.if (|> console _.type_of (_.= (_.string "undefined")) _.not + (_.and (_.the "log" console))) + (all _.then + (_.statement (|> console (_.do "log" (list message)))) + end!)) + (_.if (|> print _.type_of (_.= (_.string "undefined")) _.not) + (all _.then + (_.statement (_.apply_1 print (_.? (_.= (_.string "string") + (_.type_of message)) + message + (_.apply_1 (_.var "JSON.stringify") message)))) + end!)) + end!))) + +(runtime + (io//error message) + (_.throw message)) (def runtime//io Statement @@ -711,23 +748,26 @@ @io//error )) -(runtime: (js//get object field) - (with_vars [temp] - (all _.then - (_.define temp (_.at field object)) - (_.return (_.? (_.= _.undefined temp) - ..none - (..some temp)))))) - -(runtime: (js//set object field input) - (all _.then - (_.set (_.at field object) input) - (_.return object))) - -(runtime: (js//delete object field) - (all _.then - (_.statement (_.delete (_.at field object))) - (_.return object))) +(runtime + (js//get object field) + (with_vars [temp] + (all _.then + (_.define temp (_.at field object)) + (_.return (_.? (_.= _.undefined temp) + ..none + (..some temp)))))) + +(runtime + (js//set object field input) + (all _.then + (_.set (_.at field object) input) + (_.return object))) + +(runtime + (js//delete object field) + (all _.then + (_.statement (_.delete (_.at field object))) + (_.return object))) (def runtime//js Statement @@ -737,15 +777,17 @@ @js//delete )) -(runtime: (array//write idx value array) - (all _.then - (_.set (_.at (_.the ..i64_low_field idx) array) value) - (_.return array))) - -(runtime: (array//delete idx array) - (all _.then - (_.statement (_.delete (_.at (_.the ..i64_low_field idx) array))) - (_.return array))) +(runtime + (array//write idx value array) + (all _.then + (_.set (_.at (_.the ..i64_low_field idx) array) value) + (_.return array))) + +(runtime + (array//delete idx array) + (all _.then + (_.statement (_.delete (_.at (_.the ..i64_low_field idx) array))) + (_.return array))) (def runtime//array Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 4dd8d10c4..61bd54986 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io)] [concurrency ["[0]" atom (.only Atom atom)]]] @@ -66,21 +66,21 @@ (def init::type (type.method [(list) (list) type.void (list)])) (def init::modifier (all modifier#composite method.public method.static method.strict)) -(exception: .public (cannot_load [class Text - error Text]) +(exception .public (cannot_load [class Text + error Text]) (exception.report "Class" class "Error" error)) -(exception: .public (invalid_field [class Text - field Text - error Text]) +(exception .public (invalid_field [class Text + field Text + error Text]) (exception.report "Class" class "Field" field "Error" error)) -(exception: .public (invalid_value [class Text]) +(exception .public (invalid_value [class Text]) (exception.report "Class" class)) @@ -116,20 +116,20 @@ {.#None} //type.value) bytecode (class.class version.v6_0 - class.public - (encoding/name.internal bytecode_name) - {.#None} - (encoding/name.internal "java.lang.Object") (list) - (list (field.field ..value::modifier //value.field #0 :value: (sequence.sequence))) - (list (method.method ..init::modifier "<clinit>" - #0 ..init::type - (list) - {.#Some - (all _.composite - valueG - (_.putstatic (type.class bytecode_name (list)) //value.field :value:) - _.return)})) - (sequence.sequence))] + class.public + (encoding/name.internal bytecode_name) + {.#None} + (encoding/name.internal "java.lang.Object") (list) + (list (field.field ..value::modifier //value.field #0 :value: (sequence.sequence))) + (list (method.method ..init::modifier "<clinit>" + #0 ..init::type + (list) + {.#Some + (all _.composite + valueG + (_.putstatic (type.class bytecode_name (list)) //value.field :value:) + _.return)})) + (sequence.sequence))] (io.run! (do [! (try.with io.monad)] [bytecode (at ! each (\\format.result class.writer) (io.io bytecode)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 686747752..e3929c22c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [macro ["^" pattern]] [target @@ -32,7 +32,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(exception: .public cannot_recur_as_an_expression) +(exception .public cannot_recur_as_an_expression) (def (expression archive synthesis) Phase diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index 20a32d95a..1e9b333c4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -119,7 +119,7 @@ (def module_id 0) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -171,62 +171,65 @@ (with_expansions [<recur> (these (all _.then (_.set (list lefts) (_.- last_index_right lefts)) (_.set (list tuple) (..item last_index_right tuple))))] - (runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (<| (_.while (_.boolean true)) - (all _.then - (_.local/1 last_index_right (..last_index tuple)) - (_.if (_.> lefts last_index_right) - ... No need for recursion - (_.return (..item lefts tuple)) - ... Needs recursion - <recur>))))) - - (runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index] - (<| (_.while (_.boolean true)) - (all _.then - (_.local/1 last_index_right (..last_index tuple)) - (_.local/1 right_index (_.+ (_.int +1) lefts)) - (<| (_.if (_.= last_index_right right_index) - (_.return (..item right_index tuple))) - (_.if (_.> last_index_right right_index) - ... Needs recursion. - <recur>) - (_.return (_.apply (list tuple - (_.+ (_.int +1) right_index) - (_.length tuple) - (_.int +1) - (_.array (list))) - (_.var "table.move")))) - ))))) - -(runtime: (sum//get sum expected::right? expected::lefts) - (let [mismatch! (_.return _.nil) - actual::lefts (_.the ..variant_tag_field sum) - actual::right? (_.the ..variant_flag_field sum) - actual::value (_.the ..variant_value_field sum) - recur! (all _.then - (_.set (list expected::lefts) (|> expected::lefts - (_.- actual::lefts) - (_.- (_.int +1)))) - (_.set (list sum) actual::value))] - (<| (_.while (_.boolean true)) - (_.if (_.= expected::lefts actual::lefts) - (_.if (_.= expected::right? actual::right?) - (_.return actual::value) - mismatch!)) - (_.if (_.< expected::lefts actual::lefts) - (_.if (_.= ..unit actual::right?) - recur! - mismatch!)) - (_.if (_.= ..unit expected::right?) - (_.return (variant' (|> actual::lefts - (_.- expected::lefts) - (_.- (_.int +1))) - actual::right? - actual::value))) - mismatch!))) + (runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (<| (_.while (_.boolean true)) + (all _.then + (_.local/1 last_index_right (..last_index tuple)) + (_.if (_.> lefts last_index_right) + ... No need for recursion + (_.return (..item lefts tuple)) + ... Needs recursion + <recur>))))) + + (runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index] + (<| (_.while (_.boolean true)) + (all _.then + (_.local/1 last_index_right (..last_index tuple)) + (_.local/1 right_index (_.+ (_.int +1) lefts)) + (<| (_.if (_.= last_index_right right_index) + (_.return (..item right_index tuple))) + (_.if (_.> last_index_right right_index) + ... Needs recursion. + <recur>) + (_.return (_.apply (list tuple + (_.+ (_.int +1) right_index) + (_.length tuple) + (_.int +1) + (_.array (list))) + (_.var "table.move")))) + ))))) + +(runtime + (sum//get sum expected::right? expected::lefts) + (let [mismatch! (_.return _.nil) + actual::lefts (_.the ..variant_tag_field sum) + actual::right? (_.the ..variant_flag_field sum) + actual::value (_.the ..variant_value_field sum) + recur! (all _.then + (_.set (list expected::lefts) (|> expected::lefts + (_.- actual::lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual::value))] + (<| (_.while (_.boolean true)) + (_.if (_.= expected::lefts actual::lefts) + (_.if (_.= expected::right? actual::right?) + (_.return actual::value) + mismatch!)) + (_.if (_.< expected::lefts actual::lefts) + (_.if (_.= ..unit actual::right?) + recur! + mismatch!)) + (_.if (_.= ..unit expected::right?) + (_.return (variant' (|> actual::lefts + (_.- expected::lefts) + (_.- (_.int +1))) + actual::right? + actual::value))) + mismatch!))) (def runtime//adt Statement @@ -236,24 +239,26 @@ @sum//get )) -(runtime: (lux//try risky) - (with_vars [success value] - (all _.then - (_.let (list success value) (|> risky (_.apply (list ..unit)) - _.return (_.closure (list)) - list _.apply (|> (_.var "pcall")))) - (_.if success - (_.return (..right value)) - (_.return (..left value)))))) - -(runtime: (lux//program_args raw) - (with_vars [tail head idx] - (all _.then - (_.let (list tail) ..none) - (<| (_.for_step idx (_.length raw) (_.int +1) (_.int -1)) - (_.set (list tail) (..some (_.array (list (_.item idx raw) - tail))))) - (_.return tail)))) +(runtime + (lux//try risky) + (with_vars [success value] + (all _.then + (_.let (list success value) (|> risky (_.apply (list ..unit)) + _.return (_.closure (list)) + list _.apply (|> (_.var "pcall")))) + (_.if success + (_.return (..right value)) + (_.return (..left value)))))) + +(runtime + (lux//program_args raw) + (with_vars [tail head idx] + (all _.then + (_.let (list tail) ..none) + (<| (_.for_step idx (_.length raw) (_.int +1) (_.int -1)) + (_.set (list tail) (..some (_.array (list (_.item idx raw) + tail))))) + (_.return tail)))) (def runtime//lux Statement @@ -265,36 +270,40 @@ (def cap_shift (_.% (_.int +64))) -(runtime: (i64//left_shifted param subject) - (_.return (_.bit_shl (..cap_shift param) subject))) - -(runtime: (i64//right_shifted param subject) - (let [mask (|> (_.int +1) - (_.bit_shl (_.- param (_.int +64))) - (_.- (_.int +1)))] - (all _.then - (_.set (list param) (..cap_shift param)) - (_.return (|> subject - (_.bit_shr param) - (_.bit_and mask)))))) - -(runtime: (i64//division param subject) - (with_vars [floored] - (all _.then - (_.local/1 floored (_.// param subject)) - (let [potentially_floored? (_.< (_.int +0) floored) - inexact? (|> subject - (_.% param) - (_.= (_.int +0)) - _.not)] - (_.if (_.and potentially_floored? - inexact?) - (_.return (_.+ (_.int +1) floored)) - (_.return floored)))))) - -(runtime: (i64//remainder param subject) - (_.return (_.- (|> subject (..i64//division param) (_.* param)) - subject))) +(runtime + (i64//left_shifted param subject) + (_.return (_.bit_shl (..cap_shift param) subject))) + +(runtime + (i64//right_shifted param subject) + (let [mask (|> (_.int +1) + (_.bit_shl (_.- param (_.int +64))) + (_.- (_.int +1)))] + (all _.then + (_.set (list param) (..cap_shift param)) + (_.return (|> subject + (_.bit_shr param) + (_.bit_and mask)))))) + +(runtime + (i64//division param subject) + (with_vars [floored] + (all _.then + (_.local/1 floored (_.// param subject)) + (let [potentially_floored? (_.< (_.int +0) floored) + inexact? (|> subject + (_.% param) + (_.= (_.int +0)) + _.not)] + (_.if (_.and potentially_floored? + inexact?) + (_.return (_.+ (_.int +1) floored)) + (_.return floored)))))) + +(runtime + (i64//remainder param subject) + (_.return (_.- (|> subject (..i64//division param) (_.* param)) + subject))) (def runtime//i64 Statement @@ -328,70 +337,74 @@ (_.= (_.string "Lua 5.3") (_.var "_VERSION"))) -(runtime: (text//index subject param start) - (with_expansions [<rembulan> (all _.then - (_.local/1 byte_index (|> start - (_.+ (_.int +1)) - (..find_byte_index subject param))) - (_.if (_.= _.nil byte_index) - (_.return ..none) - (_.return (..some (..lux_index byte_index))))) - <normal> (all _.then - (_.local/1 byte_index (|> start - (..byte_index subject) - (..find_byte_index subject param))) - (_.if (_.= _.nil byte_index) - (_.return ..none) - (_.return (..some (|> byte_index - (..char_index subject) - ..lux_index)))))] - (with_vars [byte_index] - (for @.lua <normal> - (_.if ..on_rembulan? - <rembulan> - <normal>))))) - -(runtime: (text//clip text offset length) - (with_expansions [<rembulan> (_.return (_.apply (list text (_.+ (_.int +1) offset) (_.+ offset length)) - (_.var "string.sub"))) - <normal> (_.return (_.apply (list text - (..byte_index text offset) - (|> (_.+ offset length) - ... (_.+ (_.int +1)) - (..byte_index text) - (_.- (_.int +1)))) - (_.var "string.sub")))] - (for @.lua <normal> - (_.if ..on_rembulan? - <rembulan> - <normal>)))) - -(runtime: (text//size subject) - (with_expansions [<rembulan> (_.return (_.apply (list subject) (_.var "string.len"))) - <normal> (_.return (_.apply (list subject) (_.var "utf8.len")))] - (for @.lua <normal> - (_.if ..on_rembulan? - <rembulan> - <normal>)))) - -(runtime: (text//char idx text) - (with_expansions [<rembulan> (with_vars [char] - (all _.then - (_.local/1 char (_.apply (list text idx) - (_.var "string.byte"))) - (_.if (_.= _.nil char) - (_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text."))) - (_.return char)))) - <normal> (with_vars [offset char] - (all _.then - (_.local/1 offset (_.apply (list text idx) (_.var "utf8.offset"))) - (_.if (_.= _.nil offset) - (_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text."))) - (_.return (_.apply (list text offset) (_.var "utf8.codepoint"))))))] - (for @.lua <normal> - (_.if ..on_rembulan? - <rembulan> - <normal>)))) +(runtime + (text//index subject param start) + (with_expansions [<rembulan> (all _.then + (_.local/1 byte_index (|> start + (_.+ (_.int +1)) + (..find_byte_index subject param))) + (_.if (_.= _.nil byte_index) + (_.return ..none) + (_.return (..some (..lux_index byte_index))))) + <normal> (all _.then + (_.local/1 byte_index (|> start + (..byte_index subject) + (..find_byte_index subject param))) + (_.if (_.= _.nil byte_index) + (_.return ..none) + (_.return (..some (|> byte_index + (..char_index subject) + ..lux_index)))))] + (with_vars [byte_index] + (for @.lua <normal> + (_.if ..on_rembulan? + <rembulan> + <normal>))))) + +(runtime + (text//clip text offset length) + (with_expansions [<rembulan> (_.return (_.apply (list text (_.+ (_.int +1) offset) (_.+ offset length)) + (_.var "string.sub"))) + <normal> (_.return (_.apply (list text + (..byte_index text offset) + (|> (_.+ offset length) + ... (_.+ (_.int +1)) + (..byte_index text) + (_.- (_.int +1)))) + (_.var "string.sub")))] + (for @.lua <normal> + (_.if ..on_rembulan? + <rembulan> + <normal>)))) + +(runtime + (text//size subject) + (with_expansions [<rembulan> (_.return (_.apply (list subject) (_.var "string.len"))) + <normal> (_.return (_.apply (list subject) (_.var "utf8.len")))] + (for @.lua <normal> + (_.if ..on_rembulan? + <rembulan> + <normal>)))) + +(runtime + (text//char idx text) + (with_expansions [<rembulan> (with_vars [char] + (all _.then + (_.local/1 char (_.apply (list text idx) + (_.var "string.byte"))) + (_.if (_.= _.nil char) + (_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text."))) + (_.return char)))) + <normal> (with_vars [offset char] + (all _.then + (_.local/1 offset (_.apply (list text idx) (_.var "utf8.offset"))) + (_.if (_.= _.nil offset) + (_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text."))) + (_.return (_.apply (list text offset) (_.var "utf8.codepoint"))))))] + (for @.lua <normal> + (_.if ..on_rembulan? + <rembulan> + <normal>)))) (def runtime//text Statement @@ -402,10 +415,11 @@ @text//char )) -(runtime: (array//write idx value array) - (all _.then - (_.set (list (..item idx array)) value) - (_.return array))) +(runtime + (array//write idx value array) + (all _.then + (_.set (list (..item idx array)) value) + (_.return array))) (def runtime//array Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index f70ea250f..030565284 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [macro ["^" pattern]] [target @@ -65,7 +65,7 @@ (//////phase#each _.return (/function.function statement expression archive abstraction)) )) -(exception: .public cannot_recur_as_an_expression) +(exception .public cannot_recur_as_an_expression) (def .public (expression archive synthesis) Phase diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index d8549fb2c..c1867a620 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -86,7 +86,7 @@ (def module_id 0) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -129,16 +129,18 @@ (list (~+ (list#each (|>> (~) [false] (`)) inputsC))) (~ code))))))))))))))))) -(runtime: (io//log! message) - (all _.then - (_.echo message) - (_.echo (_.string text.new_line)) - (_.return ..unit))) +(runtime + (io//log! message) + (all _.then + (_.echo message) + (_.echo (_.string text.new_line)) + (_.return ..unit))) -(runtime: (io//throw! message) - (all _.then - (_.throw (_.new (_.constant "Exception") (list message))) - (_.return ..unit))) +(runtime + (io//throw! message) + (all _.then + (_.throw (_.new (_.constant "Exception") (list message))) + (_.return ..unit))) (def runtime//io Statement @@ -156,16 +158,18 @@ (def jphp? (_.=== (_.string "5.6.99") (_.phpversion/0 []))) -(runtime: (array//length array) - ... TODO: Get rid of this as soon as JPHP is no longer necessary. - (_.if ..jphp? - (_.return (..tuple_size array)) - (_.return (_.count/1 array)))) +(runtime + (array//length array) + ... TODO: Get rid of this as soon as JPHP is no longer necessary. + (_.if ..jphp? + (_.return (..tuple_size array)) + (_.return (_.count/1 array)))) -(runtime: (array//write idx value array) - (all _.then - (_.set! (_.item idx array) value) - (_.return array))) +(runtime + (array//write idx value array) + (all _.then + (_.set! (_.item idx array) value) + (_.return array))) (def runtime//array Statement @@ -183,74 +187,79 @@ (with_expansions [<recur> (these (all _.then (_.set! lefts (_.- last_index_right lefts)) (_.set! tuple (_.item last_index_right tuple))))] - (runtime: (tuple//make size values) - (_.if ..jphp? - (all _.then - (_.set! (..tuple_size values) size) - (_.return values)) - ... https://www.php.net/manual/en/language.operators.assignment.php - ... https://www.php.net/manual/en/language.references.php - ... https://www.php.net/manual/en/functions.arguments.php - ... https://www.php.net/manual/en/language.oop5.references.php - ... https://www.php.net/manual/en/class.arrayobject.php - (_.return (_.new (_.constant "ArrayObject") (list values))))) - - (runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (<| (_.while (_.bool true)) - (all _.then - (_.if ..jphp? - (_.set! last_index_right (..jphp_last_index tuple)) - (_.set! last_index_right (..normal_last_index tuple))) - (_.if (_.> lefts last_index_right) - ... No need for recursion - (_.return (_.item lefts tuple)) - ... Needs recursion - <recur>))))) + (runtime + (tuple//make size values) + (_.if ..jphp? + (all _.then + (_.set! (..tuple_size values) size) + (_.return values)) + ... https://www.php.net/manual/en/language.operators.assignment.php + ... https://www.php.net/manual/en/language.references.php + ... https://www.php.net/manual/en/functions.arguments.php + ... https://www.php.net/manual/en/language.oop5.references.php + ... https://www.php.net/manual/en/class.arrayobject.php + (_.return (_.new (_.constant "ArrayObject") (list values))))) + + (runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (<| (_.while (_.bool true)) + (all _.then + (_.if ..jphp? + (_.set! last_index_right (..jphp_last_index tuple)) + (_.set! last_index_right (..normal_last_index tuple))) + (_.if (_.> lefts last_index_right) + ... No need for recursion + (_.return (_.item lefts tuple)) + ... Needs recursion + <recur>))))) ... TODO: Get rid of this as soon as JPHP is no longer necessary. - (runtime: (tuple//slice offset input) - (with_vars [size index output] - (all _.then - (_.set! size (..array//length input)) - (_.set! index (_.int +0)) - (_.set! output (_.array/* (list))) - (<| (_.while (|> index (_.+ offset) (_.< size))) - (all _.then - (_.set! (_.item index output) (_.item (_.+ offset index) input)) - (_.set! index (_.+ (_.int +1) index)) - )) - (_.return (..tuple//make (_.- offset size) output)) - ))) - - (runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index] - (<| (_.while (_.bool true)) - (all _.then - (_.if ..jphp? - (_.set! last_index_right (..jphp_last_index tuple)) - (_.set! last_index_right (..normal_last_index tuple))) - (_.set! right_index (_.+ (_.int +1) lefts)) - (_.cond (list [(_.=== last_index_right right_index) - (_.return (_.item right_index tuple))] - [(_.> last_index_right right_index) - ... Needs recursion. - <recur>]) - (_.if ..jphp? - (_.return (..tuple//make (_.- right_index (..tuple_size tuple)) - (..tuple//slice right_index tuple))) - (_.return (..tuple//make (_.- right_index (_.count/1 tuple)) - (_.array_slice/2 [(_.do "getArrayCopy" (list) tuple) right_index]))))) - ))))) + (runtime + (tuple//slice offset input) + (with_vars [size index output] + (all _.then + (_.set! size (..array//length input)) + (_.set! index (_.int +0)) + (_.set! output (_.array/* (list))) + (<| (_.while (|> index (_.+ offset) (_.< size))) + (all _.then + (_.set! (_.item index output) (_.item (_.+ offset index) input)) + (_.set! index (_.+ (_.int +1) index)) + )) + (_.return (..tuple//make (_.- offset size) output)) + ))) + + (runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index] + (<| (_.while (_.bool true)) + (all _.then + (_.if ..jphp? + (_.set! last_index_right (..jphp_last_index tuple)) + (_.set! last_index_right (..normal_last_index tuple))) + (_.set! right_index (_.+ (_.int +1) lefts)) + (_.cond (list [(_.=== last_index_right right_index) + (_.return (_.item right_index tuple))] + [(_.> last_index_right right_index) + ... Needs recursion. + <recur>]) + (_.if ..jphp? + (_.return (..tuple//make (_.- right_index (..tuple_size tuple)) + (..tuple//slice right_index tuple))) + (_.return (..tuple//make (_.- right_index (_.count/1 tuple)) + (_.array_slice/2 [(_.do "getArrayCopy" (list) tuple) right_index]))))) + ))))) (def .public variant_tag_field "_lux_tag") (def .public variant_flag_field "_lux_flag") (def .public variant_value_field "_lux_value") -(runtime: (sum//make tag last? value) - (_.return (_.array/** (list [(_.string ..variant_tag_field) tag] - [(_.string ..variant_flag_field) last?] - [(_.string ..variant_value_field) value])))) +(runtime + (sum//make tag last? value) + (_.return (_.array/** (list [(_.string ..variant_tag_field) tag] + [(_.string ..variant_flag_field) last?] + [(_.string ..variant_value_field) value])))) (def .public (variant tag last? value) (-> Nat Bit Expression Computation) @@ -274,33 +283,34 @@ (-> Expression Computation) (..variant 1 #1)) -(runtime: (sum//get sum wantsLast wantedTag) - (let [no_match! (_.return _.null) - sum_tag (_.item (_.string ..variant_tag_field) sum) - ... sum_tag (_.item (_.int +0) sum) - sum_flag (_.item (_.string ..variant_flag_field) sum) - ... sum_flag (_.item (_.int +1) sum) - sum_value (_.item (_.string ..variant_value_field) sum) - ... sum_value (_.item (_.int +2) sum) - is_last? (_.=== ..unit sum_flag) - test_recursion! (_.if is_last? - ... Must recurse. - (all _.then - (_.set! wantedTag (_.- sum_tag wantedTag)) - (_.set! sum sum_value)) - no_match!)] - (<| (_.while (_.bool true)) - (_.cond (list [(_.=== sum_tag wantedTag) - (_.if (_.=== wantsLast sum_flag) - (_.return sum_value) - test_recursion!)] - - [(_.< wantedTag sum_tag) - test_recursion!] - - [(_.=== ..unit wantsLast) - (_.return (sum//make (_.- wantedTag sum_tag) sum_flag sum_value))]) - no_match!)))) +(runtime + (sum//get sum wantsLast wantedTag) + (let [no_match! (_.return _.null) + sum_tag (_.item (_.string ..variant_tag_field) sum) + ... sum_tag (_.item (_.int +0) sum) + sum_flag (_.item (_.string ..variant_flag_field) sum) + ... sum_flag (_.item (_.int +1) sum) + sum_value (_.item (_.string ..variant_value_field) sum) + ... sum_value (_.item (_.int +2) sum) + is_last? (_.=== ..unit sum_flag) + test_recursion! (_.if is_last? + ... Must recurse. + (all _.then + (_.set! wantedTag (_.- sum_tag wantedTag)) + (_.set! sum sum_value)) + no_match!)] + (<| (_.while (_.bool true)) + (_.cond (list [(_.=== sum_tag wantedTag) + (_.if (_.=== wantsLast sum_flag) + (_.return sum_value) + test_recursion!)] + + [(_.< wantedTag sum_tag) + test_recursion!] + + [(_.=== ..unit wantsLast) + (_.return (sum//make (_.- wantedTag sum_tag) sum_flag sum_value))]) + no_match!)))) (def runtime//adt Statement @@ -313,23 +323,25 @@ @sum//get )) -(runtime: (lux//try op) - (with_vars [value] - (_.try (all _.then - (_.set! value (_.apply/1 op [..unit])) - (_.return (..right value))) - (list (with_vars [error] - [_.#class (_.constant "Exception") - _.#exception error - _.#handler (_.return (..left (_.do "getMessage" (list) error)))]))))) - -(runtime: (lux//program_args inputs) - (with_vars [head tail] - (all _.then - (_.set! tail ..none) - (<| (_.for_each (_.array_reverse/1 inputs) head) - (_.set! tail (..some (_.array/* (list head tail))))) - (_.return tail)))) +(runtime + (lux//try op) + (with_vars [value] + (_.try (all _.then + (_.set! value (_.apply/1 op [..unit])) + (_.return (..right value))) + (list (with_vars [error] + [_.#class (_.constant "Exception") + _.#exception error + _.#handler (_.return (..left (_.do "getMessage" (list) error)))]))))) + +(runtime + (lux//program_args inputs) + (with_vars [head tail] + (all _.then + (_.set! tail ..none) + (<| (_.for_each (_.array_reverse/1 inputs) head) + (_.set! tail (..some (_.array/* (list head tail))))) + (_.return tail)))) (def runtime//lux Statement @@ -347,149 +359,155 @@ (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) -(runtime: (i64//right_shifted param subject) - (let [... The mask has to be calculated this way instead of in a more straightforward way - ... because in some languages, 1<<63 = max_negative_value - ... and max_negative_value-1 = max_positive_value. - ... And bitwise, max_positive_value works out to the mask that is desired when param = 0. - ... However, in PHP, max_negative_value-1 underflows and gets cast into a float. - ... And this messes up the computation. - ... This slightly more convoluted calculation avoids that problem. - mask (|> (_.int +1) - (_.bit_shl (_.- param (_.int +63))) - (_.- (_.int +1)) - (_.bit_shl (_.int +1)) - (_.+ (_.int +1)))] - (all _.then - (_.set! param (_.% (_.int +64) param)) - (_.if (_.=== (_.int +0) param) - (_.return subject) - (_.return (|> subject - (_.bit_shr param) - (_.bit_and mask))))))) - -(runtime: (i64//char code) - (_.if ..jphp? - (_.return (_.chr/1 [code])) - (_.return (|> code - [(_.string "V")] - _.pack/2 - [(_.string "UTF-32LE") (_.string "UTF-8")] - _.iconv/3)))) - -(runtime: (i64//+ parameter subject) - (let [high_16 (..i64//right_shifted (_.int +16)) - low_16 (_.bit_and (_.int (.int (hex "FFFF")))) - - cap_16 low_16 - hh (..i64//right_shifted (_.int +48)) - hl (|>> (..i64//right_shifted (_.int +32)) cap_16) - lh (|>> (..i64//right_shifted (_.int +16)) cap_16) - ll cap_16 - - up_16 (_.bit_shl (_.int +16))] - (with_vars [l48 l32 l16 l00 - r48 r32 r16 r00 - x48 x32 x16 x00] - (all _.then - (_.set! l48 (hh subject)) - (_.set! l32 (hl subject)) - (_.set! l16 (lh subject)) - (_.set! l00 (ll subject)) - - (_.set! r48 (hh parameter)) - (_.set! r32 (hl parameter)) - (_.set! r16 (lh parameter)) - (_.set! r00 (ll parameter)) - - (_.set! x00 (_.+ l00 r00)) - - (_.set! x16 (|> (high_16 x00) - (_.+ l16) - (_.+ r16))) - (_.set! x00 (low_16 x00)) - - (_.set! x32 (|> (high_16 x16) - (_.+ l32) - (_.+ r32))) - (_.set! x16 (low_16 x16)) - - (_.set! x48 (|> (high_16 x32) - (_.+ l48) - (_.+ r48) - low_16)) - (_.set! x32 (low_16 x32)) - - (let [high32 (_.bit_or (up_16 x48) x32) - low32 (_.bit_or (up_16 x16) x00)] - (_.return (|> high32 - (_.bit_shl (_.int +32)) - (_.bit_or low32)))) - )))) - -(runtime: (i64//negate value) - (let [i64//min (_.int (.int (hex "80,00,00,00,00,00,00,00")))] - (_.if (_.=== i64//min value) - (_.return i64//min) - (_.return (..i64//+ (_.int +1) (_.bit_not value)))))) - -(runtime: (i64//- parameter subject) - (_.return (..i64//+ (..i64//negate parameter) subject))) - -(runtime: (i64//* parameter subject) - (let [high_16 (..i64//right_shifted (_.int +16)) - low_16 (_.bit_and (_.int (.int (hex "FFFF")))) - - cap_16 low_16 - hh (..i64//right_shifted (_.int +48)) - hl (|>> (..i64//right_shifted (_.int +32)) cap_16) - lh (|>> (..i64//right_shifted (_.int +16)) cap_16) - ll cap_16 - - up_16 (_.bit_shl (_.int +16))] - (with_vars [l48 l32 l16 l00 - r48 r32 r16 r00 - x48 x32 x16 x00] - (all _.then - (_.set! l48 (hh subject)) - (_.set! l32 (hl subject)) - (_.set! l16 (lh subject)) - (_.set! l00 (ll subject)) - - (_.set! r48 (hh parameter)) - (_.set! r32 (hl parameter)) - (_.set! r16 (lh parameter)) - (_.set! r00 (ll parameter)) - - (_.set! x00 (_.* l00 r00)) - (_.set! x16 (high_16 x00)) - (_.set! x00 (low_16 x00)) - - (_.set! x16 (|> x16 (_.+ (_.* l16 r00)))) - (_.set! x32 (high_16 x16)) (_.set! x16 (low_16 x16)) - (_.set! x16 (|> x16 (_.+ (_.* l00 r16)))) - (_.set! x32 (|> x32 (_.+ (high_16 x16)))) (_.set! x16 (low_16 x16)) - - (_.set! x32 (|> x32 (_.+ (_.* l32 r00)))) - (_.set! x48 (high_16 x32)) (_.set! x32 (low_16 x32)) - (_.set! x32 (|> x32 (_.+ (_.* l16 r16)))) - (_.set! x48 (|> x48 (_.+ (high_16 x32)))) (_.set! x32 (low_16 x32)) - (_.set! x32 (|> x32 (_.+ (_.* l00 r32)))) - (_.set! x48 (|> x48 (_.+ (high_16 x32)))) (_.set! x32 (low_16 x32)) - - (_.set! x48 (|> x48 - (_.+ (_.* l48 r00)) - (_.+ (_.* l32 r16)) - (_.+ (_.* l16 r32)) - (_.+ (_.* l00 r48)) - low_16)) - - (let [high32 (_.bit_or (up_16 x48) x32) - low32 (_.bit_or (up_16 x16) x00)] - (_.return (|> high32 - (_.bit_shl (_.int +32)) - (_.bit_or low32)))) - )))) +(runtime + (i64//right_shifted param subject) + (let [... The mask has to be calculated this way instead of in a more straightforward way + ... because in some languages, 1<<63 = max_negative_value + ... and max_negative_value-1 = max_positive_value. + ... And bitwise, max_positive_value works out to the mask that is desired when param = 0. + ... However, in PHP, max_negative_value-1 underflows and gets cast into a float. + ... And this messes up the computation. + ... This slightly more convoluted calculation avoids that problem. + mask (|> (_.int +1) + (_.bit_shl (_.- param (_.int +63))) + (_.- (_.int +1)) + (_.bit_shl (_.int +1)) + (_.+ (_.int +1)))] + (all _.then + (_.set! param (_.% (_.int +64) param)) + (_.if (_.=== (_.int +0) param) + (_.return subject) + (_.return (|> subject + (_.bit_shr param) + (_.bit_and mask))))))) + +(runtime + (i64//char code) + (_.if ..jphp? + (_.return (_.chr/1 [code])) + (_.return (|> code + [(_.string "V")] + _.pack/2 + [(_.string "UTF-32LE") (_.string "UTF-8")] + _.iconv/3)))) + +(runtime + (i64//+ parameter subject) + (let [high_16 (..i64//right_shifted (_.int +16)) + low_16 (_.bit_and (_.int (.int (hex "FFFF")))) + + cap_16 low_16 + hh (..i64//right_shifted (_.int +48)) + hl (|>> (..i64//right_shifted (_.int +32)) cap_16) + lh (|>> (..i64//right_shifted (_.int +16)) cap_16) + ll cap_16 + + up_16 (_.bit_shl (_.int +16))] + (with_vars [l48 l32 l16 l00 + r48 r32 r16 r00 + x48 x32 x16 x00] + (all _.then + (_.set! l48 (hh subject)) + (_.set! l32 (hl subject)) + (_.set! l16 (lh subject)) + (_.set! l00 (ll subject)) + + (_.set! r48 (hh parameter)) + (_.set! r32 (hl parameter)) + (_.set! r16 (lh parameter)) + (_.set! r00 (ll parameter)) + + (_.set! x00 (_.+ l00 r00)) + + (_.set! x16 (|> (high_16 x00) + (_.+ l16) + (_.+ r16))) + (_.set! x00 (low_16 x00)) + + (_.set! x32 (|> (high_16 x16) + (_.+ l32) + (_.+ r32))) + (_.set! x16 (low_16 x16)) + + (_.set! x48 (|> (high_16 x32) + (_.+ l48) + (_.+ r48) + low_16)) + (_.set! x32 (low_16 x32)) + + (let [high32 (_.bit_or (up_16 x48) x32) + low32 (_.bit_or (up_16 x16) x00)] + (_.return (|> high32 + (_.bit_shl (_.int +32)) + (_.bit_or low32)))) + )))) + +(runtime + (i64//negate value) + (let [i64//min (_.int (.int (hex "80,00,00,00,00,00,00,00")))] + (_.if (_.=== i64//min value) + (_.return i64//min) + (_.return (..i64//+ (_.int +1) (_.bit_not value)))))) + +(runtime + (i64//- parameter subject) + (_.return (..i64//+ (..i64//negate parameter) subject))) + +(runtime + (i64//* parameter subject) + (let [high_16 (..i64//right_shifted (_.int +16)) + low_16 (_.bit_and (_.int (.int (hex "FFFF")))) + + cap_16 low_16 + hh (..i64//right_shifted (_.int +48)) + hl (|>> (..i64//right_shifted (_.int +32)) cap_16) + lh (|>> (..i64//right_shifted (_.int +16)) cap_16) + ll cap_16 + + up_16 (_.bit_shl (_.int +16))] + (with_vars [l48 l32 l16 l00 + r48 r32 r16 r00 + x48 x32 x16 x00] + (all _.then + (_.set! l48 (hh subject)) + (_.set! l32 (hl subject)) + (_.set! l16 (lh subject)) + (_.set! l00 (ll subject)) + + (_.set! r48 (hh parameter)) + (_.set! r32 (hl parameter)) + (_.set! r16 (lh parameter)) + (_.set! r00 (ll parameter)) + + (_.set! x00 (_.* l00 r00)) + (_.set! x16 (high_16 x00)) + (_.set! x00 (low_16 x00)) + + (_.set! x16 (|> x16 (_.+ (_.* l16 r00)))) + (_.set! x32 (high_16 x16)) (_.set! x16 (low_16 x16)) + (_.set! x16 (|> x16 (_.+ (_.* l00 r16)))) + (_.set! x32 (|> x32 (_.+ (high_16 x16)))) (_.set! x16 (low_16 x16)) + + (_.set! x32 (|> x32 (_.+ (_.* l32 r00)))) + (_.set! x48 (high_16 x32)) (_.set! x32 (low_16 x32)) + (_.set! x32 (|> x32 (_.+ (_.* l16 r16)))) + (_.set! x48 (|> x48 (_.+ (high_16 x32)))) (_.set! x32 (low_16 x32)) + (_.set! x32 (|> x32 (_.+ (_.* l00 r32)))) + (_.set! x48 (|> x48 (_.+ (high_16 x32)))) (_.set! x32 (low_16 x32)) + + (_.set! x48 (|> x48 + (_.+ (_.* l48 r00)) + (_.+ (_.* l32 r16)) + (_.+ (_.* l16 r32)) + (_.+ (_.* l00 r48)) + low_16)) + + (let [high32 (_.bit_or (up_16 x48) x32) + low32 (_.bit_or (up_16 x16) x00)] + (_.return (|> high32 + (_.bit_shl (_.int +32)) + (_.bit_or low32)))) + )))) (def runtime//i64 Statement @@ -502,48 +520,52 @@ @i64//* )) -(runtime: (text//size value) - (_.if ..jphp? - (_.return (_.strlen/1 [value])) - (_.return (_.iconv_strlen/1 [value])))) - -(runtime: (text//index subject param start) - (_.if (_.=== (_.string "") param) - (_.return (..some (_.int +0))) - (with_vars [idx] - (_.if ..jphp? - (all _.then - (_.set! idx (_.strpos/3 [subject param start])) - (_.if (_.=== (_.bool false) idx) - (_.return ..none) - (_.return (..some idx)))) - (all _.then - (_.set! idx (_.iconv_strpos/3 [subject param start])) - (_.if (_.=== (_.bool false) idx) - (_.return ..none) - (_.return (..some idx)))))))) +(runtime + (text//size value) + (_.if ..jphp? + (_.return (_.strlen/1 [value])) + (_.return (_.iconv_strlen/1 [value])))) + +(runtime + (text//index subject param start) + (_.if (_.=== (_.string "") param) + (_.return (..some (_.int +0))) + (with_vars [idx] + (_.if ..jphp? + (all _.then + (_.set! idx (_.strpos/3 [subject param start])) + (_.if (_.=== (_.bool false) idx) + (_.return ..none) + (_.return (..some idx)))) + (all _.then + (_.set! idx (_.iconv_strpos/3 [subject param start])) + (_.if (_.=== (_.bool false) idx) + (_.return ..none) + (_.return (..some idx)))))))) (def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) -(runtime: (text//clip offset length text) - (_.if ..jphp? - (_.return (_.substr/3 [text offset length])) - (_.return (_.iconv_substr/3 [text offset length])))) - -(runtime: (text//char idx text) - (_.if (|> idx (within? (text//size text))) - (_.if ..jphp? - (_.return (_.ord/1 (_.substr/3 [text idx (_.int +1)]))) - (_.return (|> (_.iconv_substr/3 [text idx (_.int +1)]) - [(_.string "UTF-8") (_.string "UTF-32LE")] - _.iconv/3 - [(_.string "V")] - _.unpack/2 - (_.item (_.int +1))))) - (_.throw (_.new (_.constant "Exception") (list (_.string "[Lux Error] Cannot get char from text.")))))) +(runtime + (text//clip offset length text) + (_.if ..jphp? + (_.return (_.substr/3 [text offset length])) + (_.return (_.iconv_substr/3 [text offset length])))) + +(runtime + (text//char idx text) + (_.if (|> idx (within? (text//size text))) + (_.if ..jphp? + (_.return (_.ord/1 (_.substr/3 [text idx (_.int +1)]))) + (_.return (|> (_.iconv_substr/3 [text idx (_.int +1)]) + [(_.string "UTF-8") (_.string "UTF-32LE")] + _.iconv/3 + [(_.string "V")] + _.unpack/2 + (_.item (_.int +1))))) + (_.throw (_.new (_.constant "Exception") (list (_.string "[Lux Error] Cannot get char from text.")))))) (def runtime//text Statement @@ -554,22 +576,23 @@ @text//char )) -(runtime: (f64//decode value) - (with_vars [output] - (all _.then - (_.set! output (_.floatval/1 value)) - (_.if (_.=== (_.float +0.0) output) - (_.if (all _.or - (_.=== (_.string "0.0") output) - (_.=== (_.string "+0.0") output) - (_.=== (_.string "-0.0") output) - (_.=== (_.string "0") output) - (_.=== (_.string "+0") output) - (_.=== (_.string "-0") output)) - (_.return (..some output)) - (_.return ..none)) - (_.return (..some output))) - ))) +(runtime + (f64//decode value) + (with_vars [output] + (all _.then + (_.set! output (_.floatval/1 value)) + (_.if (_.=== (_.float +0.0) output) + (_.if (all _.or + (_.=== (_.string "0.0") output) + (_.=== (_.string "+0.0") output) + (_.=== (_.string "-0.0") output) + (_.=== (_.string "0") output) + (_.=== (_.string "+0") output) + (_.=== (_.string "-0") output)) + (_.return (..some output)) + (_.return ..none)) + (_.return (..some output))) + ))) (def runtime//f64 Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index eba1868c0..f88b023c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [macro ["^" pattern]] [target @@ -32,7 +32,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(exception: .public cannot_recur_as_an_expression) +(exception .public cannot_recur_as_an_expression) (def .public (expression archive synthesis) Phase diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index a9cf3bbaa..40b7ebd56 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -122,7 +122,7 @@ list.together))] (~ body)))))))) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -157,29 +157,32 @@ (function ((~ g!_) (~ g!_)) (..with_vars [(~+ inputsC)] (_.def (~ g!_) (list (~+ inputsC)) - (~ code)))))))))))))) - -(runtime: (lux::try op) - (with_vars [exception] - (_.try (_.return (..right (_.apply (list ..unit) op))) - (list [(list "Exception") exception - (_.return (..left (_.str/1 exception)))])))) - -(runtime: (lux::program_args program_args) - (with_vars [inputs value] - (all _.then - (_.set (list inputs) ..none) - (<| (_.for_in value (_.apply (list program_args) (_.var "reversed"))) - (_.set (list inputs) - (..some (_.list (list value inputs))))) - (_.return inputs)))) - -(runtime: (lux::exec code globals) - (all _.then - (_.exec {.#Some globals} code) - (_.return ..unit))) - -(def runtime::lux + (~ code)))))))))))))) + +(runtime + (lux::try op) + (with_vars [exception] + (_.try (_.return (..right (_.apply (list ..unit) op))) + (list [(list "Exception") exception + (_.return (..left (_.str/1 exception)))])))) + +(runtime + (lux::program_args program_args) + (with_vars [inputs value] + (all _.then + (_.set (list inputs) ..none) + (<| (_.for_in value (_.apply (list program_args) (_.var "reversed"))) + (_.set (list inputs) + (..some (_.list (list value inputs))))) + (_.return inputs)))) + +(runtime + (lux::exec code globals) + (all _.then + (_.exec {.#Some globals} code) + (_.return ..unit))) + +(def runtime//lux (Statement Any) (all _.then @lux::try @@ -187,19 +190,21 @@ @lux::exec )) -(runtime: (io::log! message) - (all _.then - (_.print message) - (|> (_.__import__/1 (_.unicode "sys")) - (_.the "stdout") - (_.do "flush" (list)) - _.statement) - (_.return ..unit))) - -(runtime: (io::throw! message) - (_.raise (_.Exception/1 message))) - -(def runtime::io +(runtime + (io::log! message) + (all _.then + (_.print message) + (|> (_.__import__/1 (_.unicode "sys")) + (_.the "stdout") + (_.do "flush" (list)) + _.statement) + (_.return ..unit))) + +(runtime + (io::throw! message) + (_.raise (_.Exception/1 message))) + +(def runtime//io (Statement Any) (all _.then @io::log! @@ -212,61 +217,64 @@ (with_expansions [<recur> (these (all _.then (_.set (list lefts) (_.- last_index_right lefts)) (_.set (list tuple) (_.item last_index_right tuple))))] - (runtime: (tuple::left lefts tuple) - (with_vars [last_index_right] - (_.while (_.bool true) - (all _.then - (_.set (list last_index_right) (..last_index tuple)) - (_.if (_.> lefts last_index_right) - ... No need for recursion - (_.return (_.item lefts tuple)) - ... Needs recursion - <recur>)) - {.#None}))) - - (runtime: (tuple::right lefts tuple) - (with_vars [last_index_right right_index] - (_.while (_.bool true) - (all _.then - (_.set (list last_index_right) (..last_index tuple)) - (_.set (list right_index) (_.+ (_.int +1) lefts)) - (<| (_.if (_.= last_index_right right_index) - (_.return (_.item right_index tuple))) - (_.if (_.> last_index_right right_index) - ... Needs recursion. - <recur>) - (_.return (_.slice_from right_index tuple)))) - {.#None})))) - -(runtime: (sum::get sum expected::right? expected::lefts) - (let [mismatch! (_.return _.none) - actual::lefts (_.item (_.int +0) sum) - actual::right? (_.item (_.int +1) sum) - actual::value (_.item (_.int +2) sum) - recur! (all _.then - (_.set (list expected::lefts) (|> expected::lefts - (_.- actual::lefts) - (_.- (_.int +1)))) - (_.set (list sum) actual::value))] - (_.while (_.bool true) - (<| (_.if (_.= expected::lefts actual::lefts) - (_.if (_.= expected::right? actual::right?) - (_.return actual::value) - mismatch!)) - (_.if (_.< expected::lefts actual::lefts) - (_.if (_.= ..unit actual::right?) - recur! - mismatch!)) - (_.if (_.= ..unit expected::right?) - (_.return (variant' (|> actual::lefts - (_.- expected::lefts) - (_.- (_.int +1))) - actual::right? - actual::value))) - mismatch!) - {.#None}))) - -(def runtime::adt + (runtime + (tuple::left lefts tuple) + (with_vars [last_index_right] + (_.while (_.bool true) + (all _.then + (_.set (list last_index_right) (..last_index tuple)) + (_.if (_.> lefts last_index_right) + ... No need for recursion + (_.return (_.item lefts tuple)) + ... Needs recursion + <recur>)) + {.#None}))) + + (runtime + (tuple::right lefts tuple) + (with_vars [last_index_right right_index] + (_.while (_.bool true) + (all _.then + (_.set (list last_index_right) (..last_index tuple)) + (_.set (list right_index) (_.+ (_.int +1) lefts)) + (<| (_.if (_.= last_index_right right_index) + (_.return (_.item right_index tuple))) + (_.if (_.> last_index_right right_index) + ... Needs recursion. + <recur>) + (_.return (_.slice_from right_index tuple)))) + {.#None})))) + +(runtime + (sum::get sum expected::right? expected::lefts) + (let [mismatch! (_.return _.none) + actual::lefts (_.item (_.int +0) sum) + actual::right? (_.item (_.int +1) sum) + actual::value (_.item (_.int +2) sum) + recur! (all _.then + (_.set (list expected::lefts) (|> expected::lefts + (_.- actual::lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual::value))] + (_.while (_.bool true) + (<| (_.if (_.= expected::lefts actual::lefts) + (_.if (_.= expected::right? actual::right?) + (_.return actual::value) + mismatch!)) + (_.if (_.< expected::lefts actual::lefts) + (_.if (_.= ..unit actual::right?) + recur! + mismatch!)) + (_.if (_.= ..unit expected::right?) + (_.return (variant' (|> actual::lefts + (_.- expected::lefts) + (_.- (_.int +1))) + actual::right? + actual::value))) + mismatch!) + {.#None}))) + +(def runtime//adt (Statement Any) (all _.then @tuple::left @@ -281,64 +289,70 @@ (def i64::+cap (_.manual "+0x8000000000000000")) (def i64::-cap (_.manual "-0x8000000000000001")) -(runtime: (i64::64 input) - (with_vars [temp] - (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] - [(_.if (|> input <scenario>) - (all _.then - (_.set (list temp) (_.% <iteration> input)) - (_.return (_.? (|> temp <scenario>) - (|> temp (_.- <cap>) (_.+ <entrance>)) - temp))))] - - [(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit] - [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] - )) - (_.return (for @.python input - ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 - (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) +(runtime + (i64::64 input) + (with_vars [temp] + (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] + [(_.if (|> input <scenario>) + (all _.then + (_.set (list temp) (_.% <iteration> input)) + (_.return (_.? (|> temp <scenario>) + (|> temp (_.- <cap>) (_.+ <entrance>)) + temp))))] + + [(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit] + [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] + )) + (_.return (for @.python input + ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 + (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) (def as_nat (_.% ..i64::+iteration)) -(runtime: (i64::left_shifted param subject) - (_.return (|> subject - (_.bit_shl (_.% (_.int +64) param)) - ..i64::64))) - -(runtime: (i64::right_shifted param subject) - (all _.then - (_.set (list param) (_.% (_.int +64) param)) - (_.return (_.? (_.= (_.int +0) param) - subject - (|> subject - ..as_nat - (_.bit_shr param)))))) - -(runtime: (i64#/ param subject) - (with_vars [floored] - (all _.then - (_.set (list floored) (_.// param subject)) - (_.return (let [potentially_floored? (_.< (_.int +0) floored) - inexact? (|> subject - (_.% param) - (_.= (_.int +0)) - _.not)] - (<| (_.? (_.and potentially_floored? - inexact?) - (_.+ (_.int +1) floored)) - (_.? (_.= (_.manual "+9223372036854775808") - floored) - (_.manual "-9223372036854775808")) - floored)))))) - -(runtime: (i64::remainder param subject) - (_.return (_.- (|> subject (..i64#/ param) (_.* param)) - subject))) +(runtime + (i64::left_shifted param subject) + (_.return (|> subject + (_.bit_shl (_.% (_.int +64) param)) + ..i64::64))) + +(runtime + (i64::right_shifted param subject) + (all _.then + (_.set (list param) (_.% (_.int +64) param)) + (_.return (_.? (_.= (_.int +0) param) + subject + (|> subject + ..as_nat + (_.bit_shr param)))))) + +(runtime + (i64#/ param subject) + (with_vars [floored] + (all _.then + (_.set (list floored) (_.// param subject)) + (_.return (let [potentially_floored? (_.< (_.int +0) floored) + inexact? (|> subject + (_.% param) + (_.= (_.int +0)) + _.not)] + (<| (_.? (_.and potentially_floored? + inexact?) + (_.+ (_.int +1) floored)) + (_.? (_.= (_.manual "+9223372036854775808") + floored) + (_.manual "-9223372036854775808")) + floored)))))) + +(runtime + (i64::remainder param subject) + (_.return (_.- (|> subject (..i64#/ param) (_.* param)) + subject))) (with_template [<runtime> <host>] - [(runtime: (<runtime> left right) - (_.return (..i64::64 (<host> (..as_nat left) (..as_nat right)))))] + [(runtime + (<runtime> left right) + (_.return (..i64::64 (<host> (..as_nat left) (..as_nat right)))))] [i64::and _.bit_and] [i64::or _.bit_or] @@ -351,12 +365,13 @@ (_.the "version_info") (_.the "major"))) -(runtime: (i64::char value) - (_.return (_.? (_.= (_.int +3) ..python_version) - (_.chr/1 value) - (_.unichr/1 value)))) +(runtime + (i64::char value) + (_.return (_.? (_.= (_.int +3) ..python_version) + (_.chr/1 value) + (_.unichr/1 value)))) -(def runtime::i64 +(def runtime//i64 (Statement Any) (all _.then @i64::64 @@ -370,35 +385,38 @@ @i64::char )) -(runtime: (f64::/ parameter subject) - (_.return (_.? (_.= (_.float +0.0) parameter) - (<| (_.? (_.> (_.float +0.0) subject) - (_.float f.positive_infinity)) - (_.? (_.< (_.float +0.0) subject) - (_.float f.negative_infinity)) - (_.float f.not_a_number)) - (_./ parameter subject)))) - -(runtime: (f64::decode input) - (with_vars [ex] - (_.try (_.return (..some (_.float/1 input))) - (list [(list "Exception") ex - (_.return ..none)])))) - -(def runtime::f64 +(runtime + (f64::/ parameter subject) + (_.return (_.? (_.= (_.float +0.0) parameter) + (<| (_.? (_.> (_.float +0.0) subject) + (_.float f.positive_infinity)) + (_.? (_.< (_.float +0.0) subject) + (_.float f.negative_infinity)) + (_.float f.not_a_number)) + (_./ parameter subject)))) + +(runtime + (f64::decode input) + (with_vars [ex] + (_.try (_.return (..some (_.float/1 input))) + (list [(list "Exception") ex + (_.return ..none)])))) + +(def runtime//f64 (Statement Any) (all _.then @f64::/ @f64::decode )) -(runtime: (text::index start param subject) - (with_vars [idx] - (all _.then - (_.set (list idx) (|> subject (_.do "find" (list param start)))) - (_.return (_.? (_.= (_.int -1) idx) - ..none - (..some (..i64::64 idx))))))) +(runtime + (text::index start param subject) + (with_vars [idx] + (all _.then + (_.set (list idx) (|> subject (_.do "find" (list param start)))) + (_.return (_.? (_.= (_.int -1) idx) + ..none + (..some (..i64::64 idx))))))) (def ++ (|>> (_.+ (_.int +1)))) @@ -408,15 +426,17 @@ (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) -(runtime: (text::clip @offset @length @text) - (_.return (|> @text (_.slice @offset (_.+ @offset @length))))) +(runtime + (text::clip @offset @length @text) + (_.return (|> @text (_.slice @offset (_.+ @offset @length))))) -(runtime: (text::char idx text) - (_.if (|> idx (within? (_.len/1 text))) - (_.return (|> text (_.slice idx (..++ idx)) _.ord/1 ..i64::64)) - (_.raise (_.Exception/1 (_.unicode "[Lux Error] Cannot get char from text."))))) +(runtime + (text::char idx text) + (_.if (|> idx (within? (_.len/1 text))) + (_.return (|> text (_.slice idx (..++ idx)) _.ord/1 ..i64::64)) + (_.raise (_.Exception/1 (_.unicode "[Lux Error] Cannot get char from text."))))) -(def runtime::text +(def runtime//text (Statement Any) (all _.then @text::index @@ -424,27 +444,28 @@ @text::char )) -(runtime: (array::write idx value array) - (all _.then - (_.set (list (_.item idx array)) value) - (_.return array))) +(runtime + (array::write idx value array) + (all _.then + (_.set (list (_.item idx array)) value) + (_.return array))) -(def runtime::array +(def runtime//array (Statement Any) (all _.then @array::write )) -(def runtime +(def full_runtime (Statement Any) (all _.then - runtime::lux - runtime::io - runtime::adt - runtime::i64 - runtime::f64 - runtime::text - runtime::array + runtime//lux + runtime//io + runtime//adt + runtime//i64 + runtime//f64 + runtime//text + runtime//array )) (def module_id @@ -453,13 +474,13 @@ (def .public generate (Operation [Registry Output]) (do ///////phase.monad - [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id {.#None} ..runtime)] + [_ (/////generation.execute! ..full_runtime) + _ (/////generation.save! ..module_id {.#None} ..full_runtime)] (in [(|> registry.empty (registry.resource true unit.none) product.right) (sequence.sequence [..module_id {.#None} - (|> ..runtime + (|> ..full_runtime _.code (at utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 9f27e9c70..a64f95bc9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -2,7 +2,7 @@ lux (lux (control [library [monad (.only do)]] - ["ex" exception (.only exception:)] + ["ex" exception (.only exception)] ["p" parser]) (data ["e" error] [text] @@ -62,7 +62,7 @@ Unary (runtimeT.lux//try riskyO)) -(exception: .public (Wrong_Syntax [message Text]) +(exception .public (Wrong_Syntax [message Text]) message) (def .public (wrong_syntax procedure args) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index d4a118da0..69fff57bc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -89,7 +89,7 @@ list.together))] (~ body)))))))) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -136,10 +136,11 @@ (_.string "") _.null)) -(runtime: (adt::variant tag last? value) - (_.named_list (list [..variant_tag_field (_.as::integer tag)] - [..variant_flag_field last?] - [..variant_value_field value]))) +(runtime + (adt::variant tag last? value) + (_.named_list (list [..variant_tag_field (_.as::integer tag)] + [..variant_flag_field last?] + [..variant_value_field value]))) (def .public (variant tag last? value) (-> Nat Bit Expression Expression) @@ -166,7 +167,8 @@ (def high_shift (_.bit_shl (_.int +32))) (with_template [<name> <power>] - [(runtime: <name> (|> (_.as::integer (_.int +2)) (_.** (_.as::integer (_.int <power>)))))] + [(runtime + <name> (|> (_.as::integer (_.int +2)) (_.** (_.as::integer (_.int <power>)))))] [f2^32 +32] [f2^63 +63] @@ -179,25 +181,28 @@ (def .public i64_high_field "luxIH") (def .public i64_low_field "luxIL") -(runtime: (i64::unsigned_low input) - (with_vars [low] - (all _.then - (_.set! low (_.item (_.string ..i64_low_field) input)) - (_.if (_.< (_.int +0) low) - (_.+ f2^32 low) - low)))) - -(runtime: (i64::float input) - (let [high (|> input - (_.item (_.string ..i64_high_field)) - high_shift) - low (|> input - i64::unsigned_low)] - (|> high (_.+ low) as_double))) - -(runtime: (i64::new high low) - (_.named_list (list [..i64_high_field (_.as::integer high)] - [..i64_low_field (_.as::integer low)]))) +(runtime + (i64::unsigned_low input) + (with_vars [low] + (all _.then + (_.set! low (_.item (_.string ..i64_low_field) input)) + (_.if (_.< (_.int +0) low) + (_.+ f2^32 low) + low)))) + +(runtime + (i64::float input) + (let [high (|> input + (_.item (_.string ..i64_high_field)) + high_shift) + low (|> input + i64::unsigned_low)] + (|> high (_.+ low) as_double))) + +(runtime + (i64::new high low) + (_.named_list (list [..i64_high_field (_.as::integer high)] + [..i64_low_field (_.as::integer low)]))) (def high_32 (-> Nat Nat) @@ -220,8 +225,9 @@ (i64.or low))) (with_template [<name> <value>] - [(runtime: <name> - (..i64 <value>))] + [(runtime + <name> + (..i64 <value>))] [i64::zero +0] [i64::one +1] @@ -232,153 +238,162 @@ (def .public i64_high (_.item (_.string ..i64_high_field))) (def .public i64_low (_.item (_.string ..i64_low_field))) -(runtime: (i64::not input) - (i64::new (|> input i64_high _.bit_not) - (|> input i64_low _.bit_not))) - -(runtime: (i64::+ param subject) - (with_vars [sH sL pH pL - x00 x16 x32 x48] - (all _.then - (_.set! sH (|> subject i64_high)) - (_.set! sL (|> subject i64_low)) - (_.set! pH (|> param i64_high)) - (_.set! pL (|> param i64_low)) - (let [bits16 (_.manual "0xFFFF") - move_top_16 (_.bit_shl (_.int +16)) - top_16 (_.bit_ushr (_.int +16)) - bottom_16 (_.bit_and bits16) - split_16 (function (_ source) - [(|> source top_16) - (|> source bottom_16)]) - split_int (function (_ high low) - [(split_16 high) - (split_16 low)]) - - [[s48 s32] [s16 s00]] (split_int sH sL) - [[p48 p32] [p16 p00]] (split_int pH pL) - new_half (function (_ top bottom) - (|> top bottom_16 move_top_16 - (_.bit_or (bottom_16 bottom))))] - (all _.then - (_.set! x00 (|> s00 (_.+ p00))) - (_.set! x16 (|> x00 top_16 (_.+ s16) (_.+ p16))) - (_.set! x32 (|> x16 top_16 (_.+ s32) (_.+ p32))) - (_.set! x48 (|> x32 top_16 (_.+ s48) (_.+ p48))) - (i64::new (new_half x48 x32) - (new_half x16 x00))))))) - -(runtime: (i64::= reference sample) - (let [n/a? (function (_ value) - (_.apply (list value) (_.var "is.na"))) - isTRUE? (function (_ value) - (_.apply (list value) (_.var "isTRUE"))) - comparison (is (-> (-> Expression Expression) Expression) - (function (_ field) - (|> (|> (field sample) (_.= (field reference))) - (_.or (|> (n/a? (field sample)) - (_.and (n/a? (field reference))))))))] - (|> (comparison i64_high) - (_.and (comparison i64_low)) - isTRUE?))) - -(runtime: (i64::opposite input) - (_.if (|> input (i64::= i64::min)) - i64::min - (|> input i64::not (i64::+ i64::one)))) - -(runtime: i64::-one - (i64::opposite i64::one)) - -(runtime: (i64::- param subject) - (i64::+ (i64::opposite param) subject)) - -(runtime: (i64::< reference sample) - (with_vars [r_? s_?] - (all _.then - (_.set! s_? (|> sample ..i64_high (_.< (_.int +0)))) - (_.set! r_? (|> reference ..i64_high (_.< (_.int +0)))) - (|> (|> s_? (_.and (_.not r_?))) - (_.or (|> (_.not s_?) (_.and r_?) _.not)) - (_.or (|> sample - (i64::- reference) - ..i64_high - (_.< (_.int +0)))))))) - -(runtime: (i64::of_float input) - (_.cond (list [(_.apply (list input) (_.var "is.nan")) - i64::zero] - [(|> input (_.<= (_.opposite f2^63))) - i64::min] - [(|> input (_.+ (_.float +1.0)) (_.>= f2^63)) - i64::max] - [(|> input (_.< (_.float +0.0))) - (|> input _.opposite i64::of_float i64::opposite)]) - (i64::new (|> input (_./ f2^32)) - (|> input (_.%% f2^32))))) - -(runtime: (i64::* param subject) - (with_vars [sH sL pH pL - x00 x16 x32 x48] - (all _.then - (_.set! sH (|> subject i64_high)) - (_.set! pH (|> param i64_high)) - (let [negative_subject? (|> sH (_.< (_.int +0))) - negative_param? (|> pH (_.< (_.int +0)))] - (_.cond (list [negative_subject? - (_.if negative_param? - (i64::* (i64::opposite param) - (i64::opposite subject)) - (i64::opposite (i64::* param - (i64::opposite subject))))] - - [negative_param? - (i64::opposite (i64::* (i64::opposite param) - subject))]) - (all _.then - (_.set! sL (|> subject i64_low)) - (_.set! pL (|> param i64_low)) - (let [bits16 (_.manual "0xFFFF") - move_top_16 (_.bit_shl (_.int +16)) - top_16 (_.bit_ushr (_.int +16)) - bottom_16 (_.bit_and bits16) - split_16 (function (_ source) - [(|> source top_16) - (|> source bottom_16)]) - split_int (function (_ high low) - [(split_16 high) - (split_16 low)]) - new_half (function (_ top bottom) - (|> top bottom_16 move_top_16 - (_.bit_or (bottom_16 bottom)))) - x16_top (|> x16 top_16) - x32_top (|> x32 top_16)] - (with_vars [s48 s32 s16 s00 - p48 p32 p16 p00] - (let [[[_s48 _s32] [_s16 _s00]] (split_int sH sL) - [[_p48 _p32] [_p16 _p00]] (split_int pH pL) - set_subject_chunks! (all _.then (_.set! s48 _s48) (_.set! s32 _s32) (_.set! s16 _s16) (_.set! s00 _s00)) - set_param_chunks! (all _.then (_.set! p48 _p48) (_.set! p32 _p32) (_.set! p16 _p16) (_.set! p00 _p00))] - (all _.then - set_subject_chunks! - set_param_chunks! - (_.set! x00 (|> s00 (_.* p00))) - (_.set! x16 (|> x00 top_16 (_.+ (|> s16 (_.* p00))))) - (_.set! x32 x16_top) - (_.set! x16 (|> x16 bottom_16 (_.+ (|> s00 (_.* p16))))) - (_.set! x32 (|> x32 (_.+ x16_top) (_.+ (|> s32 (_.* p00))))) - (_.set! x48 x32_top) - (_.set! x32 (|> x32 bottom_16 (_.+ (|> s16 (_.* p16))))) - (_.set! x48 (|> x48 (_.+ x32_top))) - (_.set! x32 (|> x32 bottom_16 (_.+ (|> s00 (_.* p32))))) - (_.set! x48 (|> x48 (_.+ x32_top) - (_.+ (|> s48 (_.* p00))) - (_.+ (|> s32 (_.* p16))) - (_.+ (|> s16 (_.* p32))) - (_.+ (|> s00 (_.* p48))))) - (i64::new (new_half x48 x32) - (new_half x16 x00))))) - ))))))) +(runtime + (i64::not input) + (i64::new (|> input i64_high _.bit_not) + (|> input i64_low _.bit_not))) + +(runtime + (i64::+ param subject) + (with_vars [sH sL pH pL + x00 x16 x32 x48] + (all _.then + (_.set! sH (|> subject i64_high)) + (_.set! sL (|> subject i64_low)) + (_.set! pH (|> param i64_high)) + (_.set! pL (|> param i64_low)) + (let [bits16 (_.manual "0xFFFF") + move_top_16 (_.bit_shl (_.int +16)) + top_16 (_.bit_ushr (_.int +16)) + bottom_16 (_.bit_and bits16) + split_16 (function (_ source) + [(|> source top_16) + (|> source bottom_16)]) + split_int (function (_ high low) + [(split_16 high) + (split_16 low)]) + + [[s48 s32] [s16 s00]] (split_int sH sL) + [[p48 p32] [p16 p00]] (split_int pH pL) + new_half (function (_ top bottom) + (|> top bottom_16 move_top_16 + (_.bit_or (bottom_16 bottom))))] + (all _.then + (_.set! x00 (|> s00 (_.+ p00))) + (_.set! x16 (|> x00 top_16 (_.+ s16) (_.+ p16))) + (_.set! x32 (|> x16 top_16 (_.+ s32) (_.+ p32))) + (_.set! x48 (|> x32 top_16 (_.+ s48) (_.+ p48))) + (i64::new (new_half x48 x32) + (new_half x16 x00))))))) + +(runtime + (i64::= reference sample) + (let [n/a? (function (_ value) + (_.apply (list value) (_.var "is.na"))) + isTRUE? (function (_ value) + (_.apply (list value) (_.var "isTRUE"))) + comparison (is (-> (-> Expression Expression) Expression) + (function (_ field) + (|> (|> (field sample) (_.= (field reference))) + (_.or (|> (n/a? (field sample)) + (_.and (n/a? (field reference))))))))] + (|> (comparison i64_high) + (_.and (comparison i64_low)) + isTRUE?))) + +(runtime + (i64::opposite input) + (_.if (|> input (i64::= i64::min)) + i64::min + (|> input i64::not (i64::+ i64::one)))) + +(runtime + i64::-one + (i64::opposite i64::one)) + +(runtime + (i64::- param subject) + (i64::+ (i64::opposite param) subject)) + +(runtime + (i64::< reference sample) + (with_vars [r_? s_?] + (all _.then + (_.set! s_? (|> sample ..i64_high (_.< (_.int +0)))) + (_.set! r_? (|> reference ..i64_high (_.< (_.int +0)))) + (|> (|> s_? (_.and (_.not r_?))) + (_.or (|> (_.not s_?) (_.and r_?) _.not)) + (_.or (|> sample + (i64::- reference) + ..i64_high + (_.< (_.int +0)))))))) + +(runtime + (i64::of_float input) + (_.cond (list [(_.apply (list input) (_.var "is.nan")) + i64::zero] + [(|> input (_.<= (_.opposite f2^63))) + i64::min] + [(|> input (_.+ (_.float +1.0)) (_.>= f2^63)) + i64::max] + [(|> input (_.< (_.float +0.0))) + (|> input _.opposite i64::of_float i64::opposite)]) + (i64::new (|> input (_./ f2^32)) + (|> input (_.%% f2^32))))) + +(runtime + (i64::* param subject) + (with_vars [sH sL pH pL + x00 x16 x32 x48] + (all _.then + (_.set! sH (|> subject i64_high)) + (_.set! pH (|> param i64_high)) + (let [negative_subject? (|> sH (_.< (_.int +0))) + negative_param? (|> pH (_.< (_.int +0)))] + (_.cond (list [negative_subject? + (_.if negative_param? + (i64::* (i64::opposite param) + (i64::opposite subject)) + (i64::opposite (i64::* param + (i64::opposite subject))))] + + [negative_param? + (i64::opposite (i64::* (i64::opposite param) + subject))]) + (all _.then + (_.set! sL (|> subject i64_low)) + (_.set! pL (|> param i64_low)) + (let [bits16 (_.manual "0xFFFF") + move_top_16 (_.bit_shl (_.int +16)) + top_16 (_.bit_ushr (_.int +16)) + bottom_16 (_.bit_and bits16) + split_16 (function (_ source) + [(|> source top_16) + (|> source bottom_16)]) + split_int (function (_ high low) + [(split_16 high) + (split_16 low)]) + new_half (function (_ top bottom) + (|> top bottom_16 move_top_16 + (_.bit_or (bottom_16 bottom)))) + x16_top (|> x16 top_16) + x32_top (|> x32 top_16)] + (with_vars [s48 s32 s16 s00 + p48 p32 p16 p00] + (let [[[_s48 _s32] [_s16 _s00]] (split_int sH sL) + [[_p48 _p32] [_p16 _p00]] (split_int pH pL) + set_subject_chunks! (all _.then (_.set! s48 _s48) (_.set! s32 _s32) (_.set! s16 _s16) (_.set! s00 _s00)) + set_param_chunks! (all _.then (_.set! p48 _p48) (_.set! p32 _p32) (_.set! p16 _p16) (_.set! p00 _p00))] + (all _.then + set_subject_chunks! + set_param_chunks! + (_.set! x00 (|> s00 (_.* p00))) + (_.set! x16 (|> x00 top_16 (_.+ (|> s16 (_.* p00))))) + (_.set! x32 x16_top) + (_.set! x16 (|> x16 bottom_16 (_.+ (|> s00 (_.* p16))))) + (_.set! x32 (|> x32 (_.+ x16_top) (_.+ (|> s32 (_.* p00))))) + (_.set! x48 x32_top) + (_.set! x32 (|> x32 bottom_16 (_.+ (|> s16 (_.* p16))))) + (_.set! x48 (|> x48 (_.+ x32_top))) + (_.set! x32 (|> x32 bottom_16 (_.+ (|> s00 (_.* p32))))) + (_.set! x48 (|> x48 (_.+ x32_top) + (_.+ (|> s48 (_.* p00))) + (_.+ (|> s32 (_.* p16))) + (_.+ (|> s16 (_.* p32))) + (_.+ (|> s00 (_.* p48))))) + (i64::new (new_half x48 x32) + (new_half x16 x00))))) + ))))))) (def (limit_shift! shift) (-> SVar Expression) @@ -389,157 +404,164 @@ [(|> shift (_.= (_.int +0))) input]) -(runtime: (i64::left_shifted shift input) - (all _.then - (limit_shift! shift) - (_.cond (list (no_shift_clause shift input) - [(|> shift (_.< (_.int +32))) - (let [mid (|> (i64_low input) (_.bit_ushr (|> (_.int +32) (_.- shift)))) - high (|> (i64_high input) - (_.bit_shl shift) - (_.bit_or mid)) - low (|> (i64_low input) - (_.bit_shl shift))] - (i64::new high low))]) - (let [high (|> (i64_high input) - (_.bit_shl (|> shift (_.- (_.int +32)))))] - (i64::new high (_.int +0)))))) - -(runtime: (i64::arithmetic_right_shifted_32 shift input) - (let [top_bit (|> input (_.bit_and (_.as::integer (_.int (hex "+80000000")))))] - (|> input - (_.bit_ushr shift) - (_.bit_or top_bit)))) - -(runtime: (i64::arithmetic_right_shifted shift input) - (all _.then - (limit_shift! shift) - (_.cond (list (no_shift_clause shift input) - [(|> shift (_.< (_.int +32))) - (let [mid (|> (i64_high input) (_.bit_shl (|> (_.int +32) (_.- shift)))) - high (|> (i64_high input) - (i64::arithmetic_right_shifted_32 shift)) - low (|> (i64_low input) - (_.bit_ushr shift) - (_.bit_or mid))] - (i64::new high low))]) - (let [low (|> (i64_high input) - (i64::arithmetic_right_shifted_32 (|> shift (_.- (_.int +32))))) - high (_.if (_.< (_.int +0) - (i64_high input)) - (_.int -1) - (_.int +0))] - (i64::new high low))))) - -(runtime: (i64::/ param subject) - (let [negative? (|>> (i64::< i64::zero)) - valid_division_check [(|> param (i64::= i64::zero)) - (_.stop (_.string "Cannot divide by zero!"))] - short_circuit_check [(|> subject (i64::= i64::zero)) - i64::zero]] - (_.cond (list valid_division_check - short_circuit_check - - [(|> subject (i64::= i64::min)) - (_.cond (list [(|> (|> param (i64::= i64::one)) - (_.or (|> param (i64::= i64::-one)))) - i64::min] - [(|> param (i64::= i64::min)) - i64::one]) - (with_vars [approximation] +(runtime + (i64::left_shifted shift input) + (all _.then + (limit_shift! shift) + (_.cond (list (no_shift_clause shift input) + [(|> shift (_.< (_.int +32))) + (let [mid (|> (i64_low input) (_.bit_ushr (|> (_.int +32) (_.- shift)))) + high (|> (i64_high input) + (_.bit_shl shift) + (_.bit_or mid)) + low (|> (i64_low input) + (_.bit_shl shift))] + (i64::new high low))]) + (let [high (|> (i64_high input) + (_.bit_shl (|> shift (_.- (_.int +32)))))] + (i64::new high (_.int +0)))))) + +(runtime + (i64::arithmetic_right_shifted_32 shift input) + (let [top_bit (|> input (_.bit_and (_.as::integer (_.int (hex "+80000000")))))] + (|> input + (_.bit_ushr shift) + (_.bit_or top_bit)))) + +(runtime + (i64::arithmetic_right_shifted shift input) + (all _.then + (limit_shift! shift) + (_.cond (list (no_shift_clause shift input) + [(|> shift (_.< (_.int +32))) + (let [mid (|> (i64_high input) (_.bit_shl (|> (_.int +32) (_.- shift)))) + high (|> (i64_high input) + (i64::arithmetic_right_shifted_32 shift)) + low (|> (i64_low input) + (_.bit_ushr shift) + (_.bit_or mid))] + (i64::new high low))]) + (let [low (|> (i64_high input) + (i64::arithmetic_right_shifted_32 (|> shift (_.- (_.int +32))))) + high (_.if (_.< (_.int +0) + (i64_high input)) + (_.int -1) + (_.int +0))] + (i64::new high low))))) + +(runtime + (i64::/ param subject) + (let [negative? (|>> (i64::< i64::zero)) + valid_division_check [(|> param (i64::= i64::zero)) + (_.stop (_.string "Cannot divide by zero!"))] + short_circuit_check [(|> subject (i64::= i64::zero)) + i64::zero]] + (_.cond (list valid_division_check + short_circuit_check + + [(|> subject (i64::= i64::min)) + (_.cond (list [(|> (|> param (i64::= i64::one)) + (_.or (|> param (i64::= i64::-one)))) + i64::min] + [(|> param (i64::= i64::min)) + i64::one]) + (with_vars [approximation] + (all _.then + (_.set! approximation + (|> subject + (i64::arithmetic_right_shifted (_.int +1)) + (i64::/ param) + (i64::left_shifted (_.int +1)))) + (_.if (|> approximation (i64::= i64::zero)) + (_.if (negative? param) + i64::one + i64::-one) + (let [remainder (i64::- (i64::* param approximation) + subject)] + (|> remainder + (i64::/ param) + (i64::+ approximation)))))))] + [(|> param (i64::= i64::min)) + i64::zero] + + [(negative? subject) + (_.if (negative? param) + (|> (i64::opposite subject) + (i64::/ (i64::opposite param))) + (|> (i64::opposite subject) + (i64::/ param) + i64::opposite))] + + [(negative? param) + (|> param + i64::opposite + (i64::/ subject) + i64::opposite)]) + (with_vars [result remainder approximate approximate_result log2 approximate_remainder] + (all _.then + (_.set! result i64::zero) + (_.set! remainder subject) + (_.while (|> (|> remainder (i64::< param)) + (_.or (|> remainder (i64::= param)))) + (let [calc_rough_estimate (_.apply (list (|> (i64::float remainder) (_./ (i64::float param)))) + (_.var "floor")) + calc_approximate_result (i64::of_float approximate) + calc_approximate_remainder (|> approximate_result (i64::* param)) + delta (_.if (_.> log2 (_.float +48.0)) + (_.** (|> log2 (_.- (_.float +48.0))) + (_.float +2.0)) + (_.float +1.0))] (all _.then - (_.set! approximation - (|> subject - (i64::arithmetic_right_shifted (_.int +1)) - (i64::/ param) - (i64::left_shifted (_.int +1)))) - (_.if (|> approximation (i64::= i64::zero)) - (_.if (negative? param) - i64::one - i64::-one) - (let [remainder (i64::- (i64::* param approximation) - subject)] - (|> remainder - (i64::/ param) - (i64::+ approximation)))))))] - [(|> param (i64::= i64::min)) - i64::zero] - - [(negative? subject) - (_.if (negative? param) - (|> (i64::opposite subject) - (i64::/ (i64::opposite param))) - (|> (i64::opposite subject) - (i64::/ param) - i64::opposite))] - - [(negative? param) - (|> param - i64::opposite - (i64::/ subject) - i64::opposite)]) - (with_vars [result remainder approximate approximate_result log2 approximate_remainder] - (all _.then - (_.set! result i64::zero) - (_.set! remainder subject) - (_.while (|> (|> remainder (i64::< param)) - (_.or (|> remainder (i64::= param)))) - (let [calc_rough_estimate (_.apply (list (|> (i64::float remainder) (_./ (i64::float param)))) - (_.var "floor")) - calc_approximate_result (i64::of_float approximate) - calc_approximate_remainder (|> approximate_result (i64::* param)) - delta (_.if (_.> log2 (_.float +48.0)) - (_.** (|> log2 (_.- (_.float +48.0))) - (_.float +2.0)) - (_.float +1.0))] - (all _.then - (_.set! approximate (_.apply (list (_.float +1.0) calc_rough_estimate) - (_.var "max"))) - (_.set! log2 (let [log (function (_ input) - (_.apply (list input) (_.var "log")))] - (_.apply (list (|> (log (_.int +2)) - (_./ (log approximate)))) - (_.var "ceil")))) - (_.set! approximate_result calc_approximate_result) - (_.set! approximate_remainder calc_approximate_remainder) - (_.while (|> (negative? approximate_remainder) - (_.or (|> approximate_remainder (i64::< remainder)))) - (all _.then - (_.set! approximate (|> delta (_.- approximate))) - (_.set! approximate_result calc_approximate_result) - (_.set! approximate_remainder calc_approximate_remainder))) - (_.set! result (|> (_.if (|> approximate_result (i64::= i64::zero)) - i64::one - approximate_result) - (i64::+ result))) - (_.set! remainder (|> remainder (i64::- approximate_remainder)))))) - result)) - ))) - -(runtime: (i64::% param subject) - (let [flat (|> subject (i64::/ param) (i64::* param))] - (|> subject (i64::- flat)))) - -(runtime: (lux::try op) - (with_vars [error value] - (_.try (all _.then - (_.set! value (_.apply (list ..unit) op)) - (..right value)) - {.#None} - {.#Some (_.function (list error) - (..left (_.item (_.string "message") - error)))} - {.#None}))) - -(runtime: (lux::program_args program_args) - (with_vars [inputs value] - (all _.then - (_.set! inputs ..none) - (<| (_.for_in value program_args) - (_.set! inputs (..some (_.list (list value inputs))))) - inputs))) - -(def runtime::lux + (_.set! approximate (_.apply (list (_.float +1.0) calc_rough_estimate) + (_.var "max"))) + (_.set! log2 (let [log (function (_ input) + (_.apply (list input) (_.var "log")))] + (_.apply (list (|> (log (_.int +2)) + (_./ (log approximate)))) + (_.var "ceil")))) + (_.set! approximate_result calc_approximate_result) + (_.set! approximate_remainder calc_approximate_remainder) + (_.while (|> (negative? approximate_remainder) + (_.or (|> approximate_remainder (i64::< remainder)))) + (all _.then + (_.set! approximate (|> delta (_.- approximate))) + (_.set! approximate_result calc_approximate_result) + (_.set! approximate_remainder calc_approximate_remainder))) + (_.set! result (|> (_.if (|> approximate_result (i64::= i64::zero)) + i64::one + approximate_result) + (i64::+ result))) + (_.set! remainder (|> remainder (i64::- approximate_remainder)))))) + result)) + ))) + +(runtime + (i64::% param subject) + (let [flat (|> subject (i64::/ param) (i64::* param))] + (|> subject (i64::- flat)))) + +(runtime + (lux::try op) + (with_vars [error value] + (_.try (all _.then + (_.set! value (_.apply (list ..unit) op)) + (..right value)) + {.#None} + {.#Some (_.function (list error) + (..left (_.item (_.string "message") + error)))} + {.#None}))) + +(runtime + (lux::program_args program_args) + (with_vars [inputs value] + (all _.then + (_.set! inputs ..none) + (<| (_.for_in value program_args) + (_.set! inputs (..some (_.list (list value inputs))))) + inputs))) + +(def runtime//lux Expression (all _.then @lux::try @@ -551,12 +573,13 @@ (let [raw_time (_.apply (list) (_.var "Sys.time"))] (_.apply (list raw_time) (_.var "as.numeric")))) -(runtime: (io::current_time! _) - (|> current_time_float - (_.* (_.float +1,000.0)) - i64::of_float)) +(runtime + (io::current_time! _) + (|> current_time_float + (_.* (_.float +1,000.0)) + i64::of_float)) -(def runtime::io +(def runtime//io Expression (all _.then @io::current_time! @@ -578,58 +601,61 @@ (-> Expression Expression Expression) (|> min_length (_.- (_.length product)))) -(runtime: (tuple::left index product) - (let [$index_min_length (_.var "index_min_length")] - (all _.then - (_.set! $index_min_length (minimum_index_length index)) - (_.if (|> (_.length product) (_.> $index_min_length)) - ... No need for recursion - (product_element product index) - ... Needs recursion - (tuple::left (updated_index $index_min_length product) - (product_tail product)))))) - -(runtime: (tuple::right index product) - (let [$index_min_length (_.var "index_min_length")] - (all _.then - (_.set! $index_min_length (minimum_index_length index)) - (_.cond (list [... Last element. - (|> (_.length product) (_.= $index_min_length)) - (product_element product index)] - [... Needs recursion - (|> (_.length product) (_.< $index_min_length)) - (tuple::right (updated_index $index_min_length product) - (product_tail product))]) - ... Must slice - (|> product (_.slice_from index)))))) - -(runtime: (sum::get sum wants_last? wanted_tag) - (let [no_match _.null - sum_tag (|> sum (_.item (_.string ..variant_tag_field))) - sum_flag (|> sum (_.item (_.string ..variant_flag_field))) - sum_value (|> sum (_.item (_.string ..variant_value_field))) - is_last? (|> sum_flag (_.= (_.string ""))) - test_recursion (_.if is_last? - ... Must recurse. - (|> wanted_tag - (_.- sum_tag) - (sum::get sum_value wants_last?)) - no_match)] - (_.cond (list [(_.= sum_tag wanted_tag) - (_.if (_.= wants_last? sum_flag) - sum_value - test_recursion)] - - [(|> wanted_tag (_.> sum_tag)) - test_recursion] - - [(|> (|> wants_last? (_.= (_.string ""))) - (_.and (|> wanted_tag (_.< sum_tag)))) - (adt::variant (|> sum_tag (_.- wanted_tag)) sum_flag sum_value)]) - - no_match))) - -(def runtime::adt +(runtime + (tuple::left index product) + (let [$index_min_length (_.var "index_min_length")] + (all _.then + (_.set! $index_min_length (minimum_index_length index)) + (_.if (|> (_.length product) (_.> $index_min_length)) + ... No need for recursion + (product_element product index) + ... Needs recursion + (tuple::left (updated_index $index_min_length product) + (product_tail product)))))) + +(runtime + (tuple::right index product) + (let [$index_min_length (_.var "index_min_length")] + (all _.then + (_.set! $index_min_length (minimum_index_length index)) + (_.cond (list [... Last element. + (|> (_.length product) (_.= $index_min_length)) + (product_element product index)] + [... Needs recursion + (|> (_.length product) (_.< $index_min_length)) + (tuple::right (updated_index $index_min_length product) + (product_tail product))]) + ... Must slice + (|> product (_.slice_from index)))))) + +(runtime + (sum::get sum wants_last? wanted_tag) + (let [no_match _.null + sum_tag (|> sum (_.item (_.string ..variant_tag_field))) + sum_flag (|> sum (_.item (_.string ..variant_flag_field))) + sum_value (|> sum (_.item (_.string ..variant_value_field))) + is_last? (|> sum_flag (_.= (_.string ""))) + test_recursion (_.if is_last? + ... Must recurse. + (|> wanted_tag + (_.- sum_tag) + (sum::get sum_value wants_last?)) + no_match)] + (_.cond (list [(_.= sum_tag wanted_tag) + (_.if (_.= wants_last? sum_flag) + sum_value + test_recursion)] + + [(|> wanted_tag (_.> sum_tag)) + test_recursion] + + [(|> (|> wants_last? (_.= (_.string ""))) + (_.and (|> wanted_tag (_.< sum_tag)))) + (adt::variant (|> sum_tag (_.- wanted_tag)) sum_flag sum_value)]) + + no_match))) + +(def runtime//adt Expression (all _.then @tuple::left @@ -639,40 +665,42 @@ )) (with_template [<name> <op>] - [(runtime: (<name> mask input) - (i64::new (<op> (i64_high mask) - (i64_high input)) - (<op> (i64_low mask) - (i64_low input))))] + [(runtime + (<name> mask input) + (i64::new (<op> (i64_high mask) + (i64_high input)) + (<op> (i64_low mask) + (i64_low input))))] [i64::and _.bit_and] [i64::or _.bit_or] [i64::xor _.bit_xor] ) -(runtime: (i64::right_shifted shift input) - (all _.then - (limit_shift! shift) - (_.cond (list (no_shift_clause shift input) - [(|> shift (_.< (_.int +32))) - (with_vars [$mid] - (let [mid (|> (i64_high input) (_.bit_shl (|> (_.int +32) (_.- shift)))) - high (|> (i64_high input) (_.bit_ushr shift)) - low (|> (i64_low input) - (_.bit_ushr shift) - (_.bit_or (_.if (_.apply (list $mid) (_.var "is.na")) - (_.as::integer (_.int +0)) - $mid)))] - (all _.then - (_.set! $mid mid) - (i64::new high low))))] - [(|> shift (_.= (_.int +32))) - (let [high (i64_high input)] - (i64::new (_.int +0) high))]) - (let [low (|> (i64_high input) (_.bit_ushr (|> shift (_.- (_.int +32)))))] - (i64::new (_.int +0) low))))) - -(def runtime::i64 +(runtime + (i64::right_shifted shift input) + (all _.then + (limit_shift! shift) + (_.cond (list (no_shift_clause shift input) + [(|> shift (_.< (_.int +32))) + (with_vars [$mid] + (let [mid (|> (i64_high input) (_.bit_shl (|> (_.int +32) (_.- shift)))) + high (|> (i64_high input) (_.bit_ushr shift)) + low (|> (i64_low input) + (_.bit_ushr shift) + (_.bit_or (_.if (_.apply (list $mid) (_.var "is.na")) + (_.as::integer (_.int +0)) + $mid)))] + (all _.then + (_.set! $mid mid) + (i64::new high low))))] + [(|> shift (_.= (_.int +32))) + (let [high (i64_high input)] + (i64::new (_.int +0) high))]) + (let [low (|> (i64_high input) (_.bit_ushr (|> shift (_.- (_.int +32)))))] + (i64::new (_.int +0) low))))) + +(def runtime//i64 Expression (all _.then @f2^32 @@ -707,15 +735,16 @@ @i64::% )) -(runtime: (frac::decode input) - (with_vars [output] - (all _.then - (_.set! output (_.apply (list input) (_.var "as.numeric"))) - (_.if (|> output (_.= _.n/a)) - ..none - (..some output))))) +(runtime + (frac::decode input) + (with_vars [output] + (all _.then + (_.set! output (_.apply (list input) (_.var "as.numeric"))) + (_.if (|> output (_.= _.n/a)) + ..none + (..some output))))) -(def runtime::frac +(def runtime//frac Expression (all _.then @frac::decode @@ -734,48 +763,51 @@ (-> Expression Expression) (_.apply (list text) (_.var "nchar"))) -(runtime: (text::index subject param start) - (with_vars [idx startF subjectL] - (all _.then - (_.set! startF (i64::float start)) - (_.set! subjectL (text_length subject)) - (_.if (_.< subjectL startF) - (all _.then - (_.set! idx (|> (_.apply_kw (list param (_.if (|> startF (_.= (_.int +0))) - subject - (text_clip (++ startF) - (++ subjectL) - subject))) - (list ["fixed" (_.bool #1)]) - (_.var "regexpr")) - (_.item (_.int +1)))) - (_.if (|> idx (_.= (_.int -1))) - ..none - (..some (i64::of_float (|> idx (_.+ startF)))))) - ..none)))) - -(runtime: (text::clip text minimum additional) - (with_vars [length] - (all _.then - (_.set! length (_.length text)) - (_.set! to (_.+ additional minimum)) - (_.if (_.< length to) - (..some (text_clip (++ minimum) (++ to) text)) - ..none)))) +(runtime + (text::index subject param start) + (with_vars [idx startF subjectL] + (all _.then + (_.set! startF (i64::float start)) + (_.set! subjectL (text_length subject)) + (_.if (_.< subjectL startF) + (all _.then + (_.set! idx (|> (_.apply_kw (list param (_.if (|> startF (_.= (_.int +0))) + subject + (text_clip (++ startF) + (++ subjectL) + subject))) + (list ["fixed" (_.bool #1)]) + (_.var "regexpr")) + (_.item (_.int +1)))) + (_.if (|> idx (_.= (_.int -1))) + ..none + (..some (i64::of_float (|> idx (_.+ startF)))))) + ..none)))) + +(runtime + (text::clip text minimum additional) + (with_vars [length] + (all _.then + (_.set! length (_.length text)) + (_.set! to (_.+ additional minimum)) + (_.if (_.< length to) + (..some (text_clip (++ minimum) (++ to) text)) + ..none)))) (def (char_at idx text) (-> Expression Expression Expression) (_.apply (list (text_clip idx idx text)) (_.var "utf8ToInt"))) -(runtime: (text::char text idx) - (_.if (_.< (_.length text) idx) - (all _.then - (_.set! idx (++ idx)) - (..some (i64::of_float (char_at idx text)))) - ..none)) +(runtime + (text::char text idx) + (_.if (_.< (_.length text) idx) + (all _.then + (_.set! idx (++ idx)) + (..some (i64::of_float (char_at idx text)))) + ..none)) -(def runtime::text +(def runtime//text Expression (all _.then @text::index @@ -789,31 +821,34 @@ (_.stop (_.string "Array index out of bounds!")) body)) -(runtime: (array::new size) - (with_vars [output] - (all _.then - (_.set! output (_.list (list))) - (_.set_item! (|> size (_.+ (_.int +1))) - _.null - output) - output))) - -(runtime: (array::get array idx) - (with_vars [temp] - (<| (check_index_out_of_bounds array idx) - (all _.then - (_.set! temp (|> array (_.item (_.+ (_.int +1) idx)))) - (_.if (|> temp (_.= _.null)) - ..none - (..some temp)))))) - -(runtime: (array::put array idx value) - (<| (check_index_out_of_bounds array idx) - (all _.then - (_.set_item! (_.+ (_.int +1) idx) value array) - array))) - -(def runtime::array +(runtime + (array::new size) + (with_vars [output] + (all _.then + (_.set! output (_.list (list))) + (_.set_item! (|> size (_.+ (_.int +1))) + _.null + output) + output))) + +(runtime + (array::get array idx) + (with_vars [temp] + (<| (check_index_out_of_bounds array idx) + (all _.then + (_.set! temp (|> array (_.item (_.+ (_.int +1) idx)))) + (_.if (|> temp (_.= _.null)) + ..none + (..some temp)))))) + +(runtime + (array::put array idx value) + (<| (check_index_out_of_bounds array idx) + (all _.then + (_.set_item! (_.+ (_.int +1) idx) value array) + array))) + +(def runtime//array Expression (all _.then @array::new @@ -821,27 +856,27 @@ @array::put )) -(def runtime +(def full_runtime Expression (all _.then - runtime::lux - runtime::i64 - runtime::adt - runtime::frac - runtime::text - runtime::array - runtime::io + runtime//lux + runtime//i64 + runtime//adt + runtime//frac + runtime//text + runtime//array + runtime//io )) (def .public generate (Operation [Registry Output]) (do ///////phase.monad - [_ (/////generation.execute! ..runtime) - _ (/////generation.save! (%.nat ..module_id) ..runtime)] + [_ (/////generation.execute! ..full_runtime) + _ (/////generation.save! (%.nat ..module_id) ..full_runtime)] (in [(|> artifact.empty artifact.resource product.right) (sequence.sequence [(%.nat ..module_id) - (|> ..runtime + (|> ..full_runtime _.code (at utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index e64b543c1..f46905815 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [macro ["^" pattern]] [target @@ -32,7 +32,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(exception: .public cannot_recur_as_an_expression) +(exception .public cannot_recur_as_an_expression) (def (expression archive synthesis) Phase diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 9e85dd63f..8e22cf563 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -3,8 +3,6 @@ [lux (.except case exec let if symbol) [abstract ["[0]" monad (.only do)]] - [control - [exception (.only exception:)]] [data ["[0]" text (.only) ["%" \\format (.only format)]] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index b1946cee6..4754c861b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -103,7 +103,7 @@ ... (_.do "const_defined?" (list (_.string "Encoding")) {.#None})) ) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -162,39 +162,42 @@ (with_expansions [<recur> (these (all _.then (_.set (list lefts) (_.- last_index_right lefts)) (_.set (list tuple) (_.item last_index_right tuple))))] - (runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (<| (_.while (_.bool true)) - (all _.then - (_.set (list last_index_right) (..last_index tuple)) - (_.if (_.> lefts last_index_right) - ... No need for recursion - (_.return (_.item lefts tuple)) - ... Needs recursion - <recur>))))) - - (runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index] - (<| (_.while (_.bool true)) - (all _.then - (_.set (list last_index_right) (..last_index tuple)) - (_.set (list right_index) (_.+ (_.int +1) lefts)) - (<| (_.if (_.= last_index_right right_index) - (_.return (_.item right_index tuple))) - (_.if (_.> last_index_right right_index) - ... Needs recursion. - <recur>) - (_.return (_.array_range right_index (..tuple_size tuple) tuple))) - ))))) + (runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (<| (_.while (_.bool true)) + (all _.then + (_.set (list last_index_right) (..last_index tuple)) + (_.if (_.> lefts last_index_right) + ... No need for recursion + (_.return (_.item lefts tuple)) + ... Needs recursion + <recur>))))) + + (runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index] + (<| (_.while (_.bool true)) + (all _.then + (_.set (list last_index_right) (..last_index tuple)) + (_.set (list right_index) (_.+ (_.int +1) lefts)) + (<| (_.if (_.= last_index_right right_index) + (_.return (_.item right_index tuple))) + (_.if (_.> last_index_right right_index) + ... Needs recursion. + <recur>) + (_.return (_.array_range right_index (..tuple_size tuple) tuple))) + ))))) (def .public variant_tag_field "_lux_tag") (def .public variant_flag_field "_lux_flag") (def .public variant_value_field "_lux_value") -(runtime: (sum//make tag last? value) - (_.return (_.hash (list [(_.string ..variant_tag_field) tag] - [(_.string ..variant_flag_field) last?] - [(_.string ..variant_value_field) value])))) +(runtime + (sum//make tag last? value) + (_.return (_.hash (list [(_.string ..variant_tag_field) tag] + [(_.string ..variant_flag_field) last?] + [(_.string ..variant_value_field) value])))) (def .public (variant tag last? value) (-> Nat Bit Expression Computation) @@ -216,32 +219,33 @@ (-> Expression Computation) ..right) -(runtime: (sum//get sum expected::right? expected::lefts) - (let [mismatch! (_.return _.nil) - actual::lefts (_.item (_.string ..variant_tag_field) sum) - actual::right? (_.item (_.string ..variant_flag_field) sum) - actual::value (_.item (_.string ..variant_value_field) sum) - recur! (all _.then - (_.set (list expected::lefts) (|> expected::lefts - (_.- actual::lefts) - (_.- (_.int +1)))) - (_.set (list sum) actual::value))] - (<| (_.while (_.bool true)) - (_.if (_.= expected::lefts actual::lefts) - (_.if (_.= expected::right? actual::right?) - (_.return actual::value) - mismatch!)) - (_.if (_.< expected::lefts actual::lefts) - (_.if (_.= ..unit actual::right?) - recur! - mismatch!)) - (_.if (_.= ..unit expected::right?) - (_.return (sum//make (|> actual::lefts - (_.- expected::lefts) - (_.- (_.int +1))) - actual::right? - actual::value))) - mismatch!))) +(runtime + (sum//get sum expected::right? expected::lefts) + (let [mismatch! (_.return _.nil) + actual::lefts (_.item (_.string ..variant_tag_field) sum) + actual::right? (_.item (_.string ..variant_flag_field) sum) + actual::value (_.item (_.string ..variant_value_field) sum) + recur! (all _.then + (_.set (list expected::lefts) (|> expected::lefts + (_.- actual::lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual::value))] + (<| (_.while (_.bool true)) + (_.if (_.= expected::lefts actual::lefts) + (_.if (_.= expected::right? actual::right?) + (_.return actual::value) + mismatch!)) + (_.if (_.< expected::lefts actual::lefts) + (_.if (_.= ..unit actual::right?) + recur! + mismatch!)) + (_.if (_.= ..unit expected::right?) + (_.return (sum//make (|> actual::lefts + (_.- expected::lefts) + (_.- (_.int +1))) + actual::right? + actual::value))) + mismatch!))) (def runtime//adt Statement @@ -252,21 +256,23 @@ @sum//get )) -(runtime: (lux//try risky) - (with_vars [error value] - (_.begin (all _.then - (_.set (list value) (_.apply_lambda (list ..unit) risky)) - (_.return (..right value))) - (list [(list) error - (_.return (..left (_.the "message" error)))])))) - -(runtime: (lux//program_args raw) - (with_vars [tail head] - (all _.then - (_.set (list tail) ..none) - (<| (_.for_in head raw) - (_.set (list tail) (..some (_.array (list head tail))))) - (_.return tail)))) +(runtime + (lux//try risky) + (with_vars [error value] + (_.begin (all _.then + (_.set (list value) (_.apply_lambda (list ..unit) risky)) + (_.return (..right value))) + (list [(list) error + (_.return (..left (_.the "message" error)))])))) + +(runtime + (lux//program_args raw) + (with_vars [tail head] + (all _.then + (_.set (list tail) ..none) + (<| (_.for_in head raw) + (_.set (list tail) (..some (_.array (list head tail))))) + (_.return tail)))) (def runtime//lux Statement @@ -280,24 +286,27 @@ (def i64::+cap (_.manual "+0x8000000000000000")) (def i64::-cap (_.manual "-0x8000000000000001")) -(runtime: i64::+iteration (_.manual "(+1<<64)")) -(runtime: i64::-iteration (_.manual "(-1<<64)")) - -(runtime: (i64::i64 input) - [..mruby? (_.return input)] - (with_vars [temp] - (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] - [(_.if (|> input <scenario>) - (all _.then - (_.set (list temp) (_.% <iteration> input)) - (_.return (_.? (|> temp <scenario>) - (|> temp (_.- <cap>) (_.+ <entrance>)) - temp))))] - - [(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit] - [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] - )) - (_.return input))))) +(runtime + i64::+iteration (_.manual "(+1<<64)")) +(runtime + i64::-iteration (_.manual "(-1<<64)")) + +(runtime + (i64::i64 input) + [..mruby? (_.return input)] + (with_vars [temp] + (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] + [(_.if (|> input <scenario>) + (all _.then + (_.set (list temp) (_.% <iteration> input)) + (_.return (_.? (|> temp <scenario>) + (|> temp (_.- <cap>) (_.+ <entrance>)) + temp))))] + + [(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit] + [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] + )) + (_.return input))))) (def i32::low (|>> (_.bit_and (_.manual "+0xFFFFFFFF")))) @@ -327,13 +336,14 @@ (_.% ..i64::+iteration)) (with_template [<runtime> <host>] - [(runtime: (<runtime> left right) - [..normal_ruby? (_.return (..i64::i64 (<host> (..as_nat left) (..as_nat right))))] - (with_vars [high low] - (all _.then - (_.set (list high) (<host> (i32::high left) (..i32::high right))) - (_.set (list low) (<host> (i32::low left) (..i32::low right))) - (_.return (..i64 high low)))))] + [(runtime + (<runtime> left right) + [..normal_ruby? (_.return (..i64::i64 (<host> (..as_nat left) (..as_nat right))))] + (with_vars [high low] + (all _.then + (_.set (list high) (<host> (i32::high left) (..i32::high right))) + (_.set (list low) (<host> (i32::low left) (..i32::low right))) + (_.return (..i64 high low)))))] [i64::and _.bit_and] [i64::or _.bit_or] @@ -353,71 +363,75 @@ (-> LVar Expression) (|>> (_.< (_.int +32)))) -(runtime: (i64::left_shifted shift input) - [..normal_ruby? (_.return (|> input - (_.bit_shl (_.% (_.int +64) shift)) - ..i64::i64))] - (with_vars [high low] - (all _.then - (..cap_shift! shift) - (<| (..handle_no_shift! shift input) - (_.if (..small_shift? shift) - (all _.then - (_.set (list high) (_.bit_or (|> input i32::high (_.bit_shl shift)) - (|> input i32::low (_.bit_shr (_.- shift (_.int +32)))))) - (_.set (list low) (|> input i32::low (_.bit_shl shift))) - (_.return (..i64 (i32::low high) - (i32::low low))))) - (all _.then - (_.set (list high) (|> input i32::low (_.bit_shl (_.- (_.int +32) shift)))) - (_.return (..i64 (i32::low high) - (_.int +0))))) - ))) - -(runtime: (i64::right_shifted shift input) - [..normal_ruby? (all _.then - (_.set (list shift) (_.% (_.int +64) shift)) - (_.return (_.? (_.= (_.int +0) shift) - input - (|> input - ..as_nat - (_.bit_shr shift)))))] - (with_vars [high low] - (all _.then - (..cap_shift! shift) - (<| (..handle_no_shift! shift input) - (_.if (..small_shift? shift) - (all _.then - (_.set (list high) (|> input i32::high (_.bit_shr shift))) - (_.set (list low) (|> input i32::low (_.bit_shr shift) - (_.bit_or (|> input i32::high (_.bit_shl (_.- shift (_.int +32))))))) - (_.return (..i64 high low)))) - (_.return (_.? (|> shift (_.= (_.int +32))) - (i32::high input) - (|> input i32::high (_.bit_shr (_.- (_.int +32) shift))))))))) - -(runtime: (i64::/ parameter subject) - (_.return (_.? (_.and (_.= (_.int -1) parameter) - (_.= (_.int int#bottom) subject)) - subject - (let [extra (_.do "remainder" (list parameter) {.#None} subject)] - (|> subject - (_.- extra) - (_./ parameter)))))) - -(runtime: (i64::+ parameter subject) - [..normal_ruby? (_.return (i64::i64 (_.+ parameter subject)))] - (with_vars [high low] - (all _.then - (_.set (list low) (_.+ (i32::low subject) - (i32::low parameter))) - (_.set (list high) (|> (i32::high low) - (_.+ (i32::high subject)) - (_.+ (i32::high parameter)) - i32::low)) - - (_.return (..i64 high (i32::low low))) - ))) +(runtime + (i64::left_shifted shift input) + [..normal_ruby? (_.return (|> input + (_.bit_shl (_.% (_.int +64) shift)) + ..i64::i64))] + (with_vars [high low] + (all _.then + (..cap_shift! shift) + (<| (..handle_no_shift! shift input) + (_.if (..small_shift? shift) + (all _.then + (_.set (list high) (_.bit_or (|> input i32::high (_.bit_shl shift)) + (|> input i32::low (_.bit_shr (_.- shift (_.int +32)))))) + (_.set (list low) (|> input i32::low (_.bit_shl shift))) + (_.return (..i64 (i32::low high) + (i32::low low))))) + (all _.then + (_.set (list high) (|> input i32::low (_.bit_shl (_.- (_.int +32) shift)))) + (_.return (..i64 (i32::low high) + (_.int +0))))) + ))) + +(runtime + (i64::right_shifted shift input) + [..normal_ruby? (all _.then + (_.set (list shift) (_.% (_.int +64) shift)) + (_.return (_.? (_.= (_.int +0) shift) + input + (|> input + ..as_nat + (_.bit_shr shift)))))] + (with_vars [high low] + (all _.then + (..cap_shift! shift) + (<| (..handle_no_shift! shift input) + (_.if (..small_shift? shift) + (all _.then + (_.set (list high) (|> input i32::high (_.bit_shr shift))) + (_.set (list low) (|> input i32::low (_.bit_shr shift) + (_.bit_or (|> input i32::high (_.bit_shl (_.- shift (_.int +32))))))) + (_.return (..i64 high low)))) + (_.return (_.? (|> shift (_.= (_.int +32))) + (i32::high input) + (|> input i32::high (_.bit_shr (_.- (_.int +32) shift))))))))) + +(runtime + (i64::/ parameter subject) + (_.return (_.? (_.and (_.= (_.int -1) parameter) + (_.= (_.int int#bottom) subject)) + subject + (let [extra (_.do "remainder" (list parameter) {.#None} subject)] + (|> subject + (_.- extra) + (_./ parameter)))))) + +(runtime + (i64::+ parameter subject) + [..normal_ruby? (_.return (i64::i64 (_.+ parameter subject)))] + (with_vars [high low] + (all _.then + (_.set (list low) (_.+ (i32::low subject) + (i32::low parameter))) + (_.set (list high) (|> (i32::high low) + (_.+ (i32::high subject)) + (_.+ (i32::high parameter)) + i32::low)) + + (_.return (..i64 high (i32::low low))) + ))) (def i64::min (_.manual "-0x8000000000000000")) @@ -427,9 +441,10 @@ i64::min (i64::+ (_.int +1) (_.bit_not value)))) -(runtime: (i64::- parameter subject) - [..normal_ruby? (_.return (i64::i64 (_.- parameter subject)))] - (_.return (i64::+ (i64::opposite parameter) subject))) +(runtime + (i64::- parameter subject) + [..normal_ruby? (_.return (i64::i64 (_.- parameter subject)))] + (_.return (i64::+ (i64::opposite parameter) subject))) (def i16::high (_.bit_shr (_.int +16))) @@ -440,59 +455,61 @@ (def i16::up (_.bit_shl (_.int +16))) -(runtime: (i64::* parameter subject) - [..normal_ruby? (_.return (i64::i64 (_.* parameter subject)))] - (let [hh (|>> i32::high i16::high) - hl (|>> i32::high i16::low) - lh (|>> i32::low i16::high) - ll (|>> i32::low i16::low)] - (with_vars [l48 l32 l16 l00 - r48 r32 r16 r00 - x48 x32 x16 x00 - high low] - (all _.then - (_.set (list l48) (hh subject)) - (_.set (list l32) (hl subject)) - (_.set (list l16) (lh subject)) - (_.set (list l00) (ll subject)) - - (_.set (list r48) (hh parameter)) - (_.set (list r32) (hl parameter)) - (_.set (list r16) (lh parameter)) - (_.set (list r00) (ll parameter)) - - (_.set (list x00) (_.* l00 r00)) - (_.set (list x16) (i16::high x00)) - (_.set (list x00) (i16::low x00)) - - (_.set (list x16) (|> x16 (_.+ (_.* l16 r00)))) - (_.set (list x32) (i16::high x16)) (_.set (list x16) (i16::low x16)) - (_.set (list x16) (|> x16 (_.+ (_.* l00 r16)))) - (_.set (list x32) (|> x32 (_.+ (i16::high x16)))) (_.set (list x16) (i16::low x16)) - - (_.set (list x32) (|> x32 (_.+ (_.* l32 r00)))) - (_.set (list x48) (i16::high x32)) (_.set (list x32) (i16::low x32)) - (_.set (list x32) (|> x32 (_.+ (_.* l16 r16)))) - (_.set (list x48) (|> x48 (_.+ (i16::high x32)))) (_.set (list x32) (i16::low x32)) - (_.set (list x32) (|> x32 (_.+ (_.* l00 r32)))) - (_.set (list x48) (|> x48 (_.+ (i16::high x32)))) (_.set (list x32) (i16::low x32)) - - (_.set (list x48) (|> x48 - (_.+ (_.* l48 r00)) - (_.+ (_.* l32 r16)) - (_.+ (_.* l16 r32)) - (_.+ (_.* l00 r48)) - i16::low)) - - (_.set (list high) (_.bit_or (i16::up x48) x32)) - (_.set (list low) (_.bit_or (i16::up x16) x00)) - (_.return (..i64 high low)) - ))) - ) - -(runtime: (i64::char subject) - [..mruby? (_.return (_.do "chr" (list) {.#None} subject))] - (_.return (_.do "chr" (list (_.string "UTF-8")) {.#None} subject))) +(runtime + (i64::* parameter subject) + [..normal_ruby? (_.return (i64::i64 (_.* parameter subject)))] + (let [hh (|>> i32::high i16::high) + hl (|>> i32::high i16::low) + lh (|>> i32::low i16::high) + ll (|>> i32::low i16::low)] + (with_vars [l48 l32 l16 l00 + r48 r32 r16 r00 + x48 x32 x16 x00 + high low] + (all _.then + (_.set (list l48) (hh subject)) + (_.set (list l32) (hl subject)) + (_.set (list l16) (lh subject)) + (_.set (list l00) (ll subject)) + + (_.set (list r48) (hh parameter)) + (_.set (list r32) (hl parameter)) + (_.set (list r16) (lh parameter)) + (_.set (list r00) (ll parameter)) + + (_.set (list x00) (_.* l00 r00)) + (_.set (list x16) (i16::high x00)) + (_.set (list x00) (i16::low x00)) + + (_.set (list x16) (|> x16 (_.+ (_.* l16 r00)))) + (_.set (list x32) (i16::high x16)) (_.set (list x16) (i16::low x16)) + (_.set (list x16) (|> x16 (_.+ (_.* l00 r16)))) + (_.set (list x32) (|> x32 (_.+ (i16::high x16)))) (_.set (list x16) (i16::low x16)) + + (_.set (list x32) (|> x32 (_.+ (_.* l32 r00)))) + (_.set (list x48) (i16::high x32)) (_.set (list x32) (i16::low x32)) + (_.set (list x32) (|> x32 (_.+ (_.* l16 r16)))) + (_.set (list x48) (|> x48 (_.+ (i16::high x32)))) (_.set (list x32) (i16::low x32)) + (_.set (list x32) (|> x32 (_.+ (_.* l00 r32)))) + (_.set (list x48) (|> x48 (_.+ (i16::high x32)))) (_.set (list x32) (i16::low x32)) + + (_.set (list x48) (|> x48 + (_.+ (_.* l48 r00)) + (_.+ (_.* l32 r16)) + (_.+ (_.* l16 r32)) + (_.+ (_.* l00 r48)) + i16::low)) + + (_.set (list high) (_.bit_or (i16::up x48) x32)) + (_.set (list low) (_.bit_or (i16::up x16) x00)) + (_.return (..i64 high low)) + ))) + ) + +(runtime + (i64::char subject) + [..mruby? (_.return (_.do "chr" (list) {.#None} subject))] + (_.return (_.do "chr" (list (_.string "UTF-8")) {.#None} subject))) (def runtime//i64 Statement @@ -512,18 +529,19 @@ @i64::char )) -(runtime: (f64//decode inputG) - (with_vars [@input @temp] - (all _.then - (_.set (list @input) inputG) - (_.set (list @temp) (_.do "to_f" (list) {.#None} @input)) - (_.if (all _.or - (_.not (_.= (_.float +0.0) @temp)) - (_.= (_.string "0") @input) - (_.= (_.string ".0") @input) - (_.= (_.string "0.0") @input)) - (_.return (..some @temp)) - (_.return ..none))))) +(runtime + (f64//decode inputG) + (with_vars [@input @temp] + (all _.then + (_.set (list @input) inputG) + (_.set (list @temp) (_.do "to_f" (list) {.#None} @input)) + (_.if (all _.or + (_.not (_.= (_.float +0.0) @temp)) + (_.= (_.string "0") @input) + (_.= (_.string ".0") @input) + (_.= (_.string "0.0") @input)) + (_.return (..some @temp)) + (_.return ..none))))) (def runtime//f64 Statement @@ -531,28 +549,31 @@ @f64//decode )) -(runtime: (text//index subject param start) - (with_vars [idx] - (all _.then - (_.set (list idx) (|> subject (_.do "index" (list param start) {.#None}))) - (_.if (_.= _.nil idx) - (_.return ..none) - (_.return (..some idx)))))) +(runtime + (text//index subject param start) + (with_vars [idx] + (all _.then + (_.set (list idx) (|> subject (_.do "index" (list param start) {.#None}))) + (_.if (_.= _.nil idx) + (_.return ..none) + (_.return (..some idx)))))) (def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) -(runtime: (text//clip offset length text) - (_.if (_.= (_.int +0) length) - (_.return (_.string "")) - (_.return (_.array_range offset (_.+ offset (_.- (_.int +1) length)) text)))) +(runtime + (text//clip offset length text) + (_.if (_.= (_.int +0) length) + (_.return (_.string "")) + (_.return (_.array_range offset (_.+ offset (_.- (_.int +1) length)) text)))) -(runtime: (text//char idx text) - (_.if (|> idx (within? (_.the "length" text))) - (_.return (|> text (_.array_range idx idx) (_.do "ord" (list) {.#None}))) - (_.statement (_.raise (_.string "[Lux Error] Cannot get char from text."))))) +(runtime + (text//char idx text) + (_.if (|> idx (within? (_.the "length" text))) + (_.return (|> text (_.array_range idx idx) (_.do "ord" (list) {.#None}))) + (_.statement (_.raise (_.string "[Lux Error] Cannot get char from text."))))) (def runtime//text Statement @@ -562,10 +583,11 @@ @text//char )) -(runtime: (array//write idx value array) - (all _.then - (_.set (list (_.item idx array)) value) - (_.return array))) +(runtime + (array//write idx value array) + (all _.then + (_.set (list (_.item idx array)) value) + (_.return array))) (def runtime//array Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 50cdca756..bbb7db4e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -4,7 +4,6 @@ [abstract ["[0]" monad (.only do)]] [control - ["ex" exception (.only exception:)] [parser ["<[0]>" code]]] [data diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index e923616e4..35e49dc7e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -71,7 +71,7 @@ list.together))] (~ body)))))))) -(def runtime: +(def runtime (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -111,33 +111,35 @@ (-> Expression Computation) (|>> _.length/1 (_.-/2 (_.int +1)))) -(runtime: (tuple//left lefts tuple) - (with_vars [last_index_right] - (_.begin - (list (_.define_constant last_index_right (..last_index tuple)) - (_.if (_.>/2 lefts last_index_right) - ... No need for recursion - (_.vector_ref/2 tuple lefts) - ... Needs recursion - (tuple//left (_.-/2 last_index_right lefts) - (_.vector_ref/2 tuple last_index_right))))))) - -(runtime: (tuple//right lefts tuple) - (with_vars [last_index_right right_index @slice] - (_.begin - (list (_.define_constant last_index_right (..last_index tuple)) - (_.define_constant right_index (_.+/2 (_.int +1) lefts)) - (<| (_.if (_.=/2 last_index_right right_index) - (_.vector_ref/2 tuple right_index)) - (_.if (_.>/2 last_index_right right_index) - ... Needs recursion. - (tuple//right (_.-/2 last_index_right lefts) - (_.vector_ref/2 tuple last_index_right))) - (_.begin - (list (_.define_constant @slice (_.make_vector/1 (_.-/2 right_index (_.length/1 tuple)))) - (_.vector_copy!/5 @slice (_.int +0) tuple right_index (_.length/1 tuple)) - @slice)))) - ))) +(runtime + (tuple//left lefts tuple) + (with_vars [last_index_right] + (_.begin + (list (_.define_constant last_index_right (..last_index tuple)) + (_.if (_.>/2 lefts last_index_right) + ... No need for recursion + (_.vector_ref/2 tuple lefts) + ... Needs recursion + (tuple//left (_.-/2 last_index_right lefts) + (_.vector_ref/2 tuple last_index_right))))))) + +(runtime + (tuple//right lefts tuple) + (with_vars [last_index_right right_index @slice] + (_.begin + (list (_.define_constant last_index_right (..last_index tuple)) + (_.define_constant right_index (_.+/2 (_.int +1) lefts)) + (<| (_.if (_.=/2 last_index_right right_index) + (_.vector_ref/2 tuple right_index)) + (_.if (_.>/2 last_index_right right_index) + ... Needs recursion. + (tuple//right (_.-/2 last_index_right lefts) + (_.vector_ref/2 tuple last_index_right))) + (_.begin + (list (_.define_constant @slice (_.make_vector/1 (_.-/2 right_index (_.length/1 tuple)))) + (_.vector_copy!/5 @slice (_.int +0) tuple right_index (_.length/1 tuple)) + @slice)))) + ))) (def (variant' tag last? value) (-> Expression Expression Expression Computation) @@ -146,35 +148,37 @@ last? value)) -(runtime: (sum//make tag last? value) - (variant' tag last? value)) +(runtime + (sum//make tag last? value) + (variant' tag last? value)) (def .public (variant [lefts right? value]) (-> (Variant Expression) Computation) (..sum//make (_.int (.int lefts)) (_.bool right?) value)) -(runtime: (sum//get sum last? wanted_tag) - (with_vars [sum_tag sum_flag sum_value sum_temp sum_dump] - (let [no_match _.nil - test_recursion (_.if sum_flag - ... Must recurse. - (sum//get sum_value - last? - (|> wanted_tag (_.-/2 sum_tag))) - no_match)] - (<| (_.let (list [sum_tag (_.car/1 sum)] - [sum_temp (_.cdr/1 sum)])) - (_.let (list [sum_flag (_.car/1 sum_temp)] - [sum_value (_.cdr/1 sum_temp)])) - (_.if (_.=/2 wanted_tag sum_tag) - (_.if (_.eqv?/2 last? sum_flag) - sum_value - test_recursion)) - (_.if (_.</2 wanted_tag sum_tag) - test_recursion) - (_.if last? - (variant' (|> sum_tag (_.-/2 wanted_tag)) sum_flag sum_value)) - no_match)))) +(runtime + (sum//get sum last? wanted_tag) + (with_vars [sum_tag sum_flag sum_value sum_temp sum_dump] + (let [no_match _.nil + test_recursion (_.if sum_flag + ... Must recurse. + (sum//get sum_value + last? + (|> wanted_tag (_.-/2 sum_tag))) + no_match)] + (<| (_.let (list [sum_tag (_.car/1 sum)] + [sum_temp (_.cdr/1 sum)])) + (_.let (list [sum_flag (_.car/1 sum_temp)] + [sum_value (_.cdr/1 sum_temp)])) + (_.if (_.=/2 wanted_tag sum_tag) + (_.if (_.eqv?/2 last? sum_flag) + sum_value + test_recursion)) + (_.if (_.</2 wanted_tag sum_tag) + test_recursion) + (_.if last? + (variant' (|> sum_tag (_.-/2 wanted_tag)) sum_flag sum_value)) + no_match)))) (def runtime//adt Computation @@ -199,35 +203,38 @@ (-> Expression Computation) (|>> [1 #1] ..variant)) -(runtime: (slice offset length list) - (<| (_.if (_.null?/1 list) - list) - (_.if (|> offset (_.>/2 (_.int +0))) - (slice (|> offset (_.-/2 (_.int +1))) - length - (_.cdr/1 list))) - (_.if (|> length (_.>/2 (_.int +0))) - (_.cons/2 (_.car/1 list) - (slice offset - (|> length (_.-/2 (_.int +1))) - (_.cdr/1 list)))) - _.nil)) - -(runtime: (lux//try op) - (with_vars [error] - (_.with_exception_handler - (_.lambda [(list error) {.#None}] - (..left error)) - (_.lambda [(list) {.#None}] - (..right (_.apply (list ..unit) op)))))) - -(runtime: (lux//program_args program_args) - (with_vars [@loop @input @output] - (_.letrec (list [@loop (_.lambda [(list @input @output) {.#None}] - (_.if (_.null?/1 @input) - @output - (_.apply/2 @loop (_.cdr/1 @input) (..some (_.vector/* (list (_.car/1 @input) @output))))))]) - (_.apply/2 @loop (_.reverse/1 program_args) ..none)))) +(runtime + (slice offset length list) + (<| (_.if (_.null?/1 list) + list) + (_.if (|> offset (_.>/2 (_.int +0))) + (slice (|> offset (_.-/2 (_.int +1))) + length + (_.cdr/1 list))) + (_.if (|> length (_.>/2 (_.int +0))) + (_.cons/2 (_.car/1 list) + (slice offset + (|> length (_.-/2 (_.int +1))) + (_.cdr/1 list)))) + _.nil)) + +(runtime + (lux//try op) + (with_vars [error] + (_.with_exception_handler + (_.lambda [(list error) {.#None}] + (..left error)) + (_.lambda [(list) {.#None}] + (..right (_.apply (list ..unit) op)))))) + +(runtime + (lux//program_args program_args) + (with_vars [@loop @input @output] + (_.letrec (list [@loop (_.lambda [(list @input @output) {.#None}] + (_.if (_.null?/1 @input) + @output + (_.apply/2 @loop (_.cdr/1 @input) (..some (_.vector/* (list (_.car/1 @input) @output))))))]) + (_.apply/2 @loop (_.reverse/1 program_args) ..none)))) (def runtime//lux Computation @@ -235,65 +242,70 @@ @lux//program_args))) (def i64//+limit (_.manual "+9223372036854775807" - ... "+0x7FFFFFFFFFFFFFFF" - )) + ... "+0x7FFFFFFFFFFFFFFF" + )) (def i64//-limit (_.manual "-9223372036854775808" - ... "-0x8000000000000000" - )) + ... "-0x8000000000000000" + )) (def i64//+iteration (_.manual "+18446744073709551616" - ... "+0x10000000000000000" - )) + ... "+0x10000000000000000" + )) (def i64//-iteration (_.manual "-18446744073709551616" - ... "-0x10000000000000000" - )) + ... "-0x10000000000000000" + )) (def i64//+cap (_.manual "+9223372036854775808" - ... "+0x8000000000000000" - )) + ... "+0x8000000000000000" + )) (def i64//-cap (_.manual "-9223372036854775809" - ... "-0x8000000000000001" - )) - -(runtime: (i64//64 input) - (with_vars [temp] - (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] - [(_.if (|> input <scenario>) - (_.let (list [temp (_.remainder/2 <iteration> input)]) - (_.if (|> temp <scenario>) - (|> temp (_.-/2 <cap>) (_.+/2 <entrance>)) - temp)))] - - [(_.>/2 ..i64//+limit) ..i64//+iteration ..i64//+cap ..i64//-limit] - [(_.</2 ..i64//-limit) ..i64//-iteration ..i64//-cap ..i64//+limit] - )) - input)))) - -(runtime: (i64//left_shifted param subject) - (|> subject - (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) - ..i64//64)) + ... "-0x8000000000000001" + )) + +(runtime + (i64//64 input) + (with_vars [temp] + (`` (<| (~~ (with_template [<scenario> <iteration> <cap> <entrance>] + [(_.if (|> input <scenario>) + (_.let (list [temp (_.remainder/2 <iteration> input)]) + (_.if (|> temp <scenario>) + (|> temp (_.-/2 <cap>) (_.+/2 <entrance>)) + temp)))] + + [(_.>/2 ..i64//+limit) ..i64//+iteration ..i64//+cap ..i64//-limit] + [(_.</2 ..i64//-limit) ..i64//-iteration ..i64//-cap ..i64//+limit] + )) + input)))) + +(runtime + (i64//left_shifted param subject) + (|> subject + (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) + ..i64//64)) (def as_nat (_.remainder/2 ..i64//+iteration)) -(runtime: (i64//right_shifted shift subject) - (_.let (list [shift (_.remainder/2 (_.int +64) shift)]) - (_.if (_.=/2 (_.int +0) shift) - subject - (|> subject - ..as_nat - (_.arithmetic_shift/2 (_.-/2 shift (_.int +0))))))) +(runtime + (i64//right_shifted shift subject) + (_.let (list [shift (_.remainder/2 (_.int +64) shift)]) + (_.if (_.=/2 (_.int +0) shift) + subject + (|> subject + ..as_nat + (_.arithmetic_shift/2 (_.-/2 shift (_.int +0))))))) (with_template [<runtime> <host>] - [(runtime: (<runtime> left right) - (..i64//64 (<host> (..as_nat left) (..as_nat right))))] + [(runtime + (<runtime> left right) + (..i64//64 (<host> (..as_nat left) (..as_nat right))))] [i64//or _.bitwise_ior/2] [i64//xor _.bitwise_xor/2] [i64//and _.bitwise_and/2] ) -(runtime: (i64//division param subject) - (|> subject (_.//2 param) _.truncate/1 ..i64//64)) +(runtime + (i64//division param subject) + (|> subject (_.//2 param) _.truncate/1 ..i64//64)) (def runtime//i64 Computation @@ -305,41 +317,46 @@ @i64//and @i64//division))) -(runtime: (f64//decode input) - (with_vars [@output] - (let [output_is_not_a_number? (_.not/1 (_.=/2 @output @output)) - input_is_not_a_number? (_.string=?/2 (_.string "+nan.0") input)] - (_.let (list [@output (_.string->number/1 input)]) - (_.if (_.and (list output_is_not_a_number? - (_.not/1 input_is_not_a_number?))) - ..none - (..some @output)))))) +(runtime + (f64//decode input) + (with_vars [@output] + (let [output_is_not_a_number? (_.not/1 (_.=/2 @output @output)) + input_is_not_a_number? (_.string=?/2 (_.string "+nan.0") input)] + (_.let (list [@output (_.string->number/1 input)]) + (_.if (_.and (list output_is_not_a_number? + (_.not/1 input_is_not_a_number?))) + ..none + (..some @output)))))) (def runtime//f64 Computation (_.begin (list @f64//decode))) -(runtime: (text//index offset sub text) - (with_vars [index] - (_.let (list [index (_.string_contains/3 text sub offset)]) - (_.if index - (..some index) - ..none)))) +(runtime + (text//index offset sub text) + (with_vars [index] + (_.let (list [index (_.string_contains/3 text sub offset)]) + (_.if index + (..some index) + ..none)))) -(runtime: (text//clip offset length text) - (_.substring/3 text offset (_.+/2 offset length))) +(runtime + (text//clip offset length text) + (_.substring/3 text offset (_.+/2 offset length))) -(runtime: (text//char index text) - (_.char->integer/1 (_.string_ref/2 text index))) +(runtime + (text//char index text) + (_.char->integer/1 (_.string_ref/2 text index))) (def runtime//text (_.begin (list @text//index @text//clip @text//char))) -(runtime: (array//write idx value array) - (_.begin (list (_.vector_set!/3 array idx value) - array))) +(runtime + (array//write idx value array) + (_.begin (list (_.vector_set!/3 array idx value) + array))) (def runtime//array Computation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 1ab4fbd2b..e58b8f6fd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -7,7 +7,7 @@ [control ["[0]" pipe] ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [text ["%" \\format (.only format)]] @@ -30,8 +30,8 @@ ["[1][0]" reference (.only) ["[1]/[0]" variable (.only Register Variable)]]]]]) -(exception: .public (cannot_find_foreign_variable_in_environment [foreign Register - environment (Environment Synthesis)]) +(exception .public (cannot_find_foreign_variable_in_environment [foreign Register + environment (Environment Synthesis)]) (exception.report "Foreign" (%.nat foreign) "Environment" (exception.listing /.%synthesis environment))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 43d6faefb..7f2be3cf5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -6,7 +6,7 @@ [control ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" text (.only) @@ -217,7 +217,7 @@ {.#Item head tail}]))))) (with_template [<name>] - [(exception: .public (<name> [register Register]) + [(exception .public (<name> [register Register]) (exception.report "Register" (%.nat register)))] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index 509994009..162f4c147 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -6,7 +6,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [text @@ -28,7 +28,7 @@ Text "") -(exception: .public (cannot_find_program [modules (List descriptor.Module)]) +(exception .public (cannot_find_program [modules (List descriptor.Module)]) (exception.report "Modules" (exception.listing %.text modules))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 36daec361..1e1e062eb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -32,7 +32,7 @@ [monad (.only do)]] [control ["[0]" maybe] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code]]] [data @@ -161,7 +161,7 @@ [symbol.separator symbol_separator] ) -(exception: .public (end_of_file [module Text]) +(exception .public (end_of_file [module Text]) (exception.report "Module" (%.text module))) @@ -172,10 +172,10 @@ (let [end (|> start (!n/+ amount_of_input_shown) (n.min ("lux text size" input)))] (!clip start end input))) -(exception: .public (unrecognized_input [[file line column] Location - context Text - input Text - offset Offset]) +(exception .public (unrecognized_input [[file line column] Location + context Text + input Text + offset Offset]) (exception.report "File" file "Line" (%.nat line) @@ -183,7 +183,7 @@ "Context" (%.text context) "Input" (input_at offset input))) -(exception: .public (text_cannot_contain_new_lines [text Text]) +(exception .public (text_cannot_contain_new_lines [text Text]) (exception.report "Text" (%.text text))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 2740b6bce..03fd9d860 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -6,8 +6,7 @@ [equivalence (.only Equivalence)] [hash (.only Hash)]] [control - ["[0]" maybe] - ["[0]" exception (.only exception:)]] + ["[0]" maybe]] [data ["[0]" sum] ["[0]" product] diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index b762d8c85..0b4e012cc 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -8,7 +8,7 @@ ["<>" parser] ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" function]] [data ["[0]" product] @@ -41,22 +41,22 @@ (type .public Output (Sequence [artifact.ID (Maybe Text) Binary])) -(exception: .public (unknown_document [module descriptor.Module - known_modules (List descriptor.Module)]) +(exception .public (unknown_document [module descriptor.Module + known_modules (List descriptor.Module)]) (exception.report "Module" (%.text module) "Known Modules" (exception.listing %.text known_modules))) -(exception: .public (cannot_replace_document [module descriptor.Module - old (Document Any) - new (Document Any)]) +(exception .public (cannot_replace_document [module descriptor.Module + old (Document Any) + new (Document Any)]) (exception.report "Module" (%.text module) "Old key" (signature.description (document.signature old)) "New key" (signature.description (document.signature new)))) (with_template [<name>] - [(exception: .public (<name> [it descriptor.Module]) + [(exception .public (<name> [it descriptor.Module]) (exception.report "Module" (%.text it)))] @@ -245,8 +245,8 @@ [version /#next] (\\format.result ..writer)))) - (exception: .public (version_mismatch [expected Version - actual Version]) + (exception .public (version_mismatch [expected Version + actual Version]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux index d7ccc2a33..4653591a7 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux @@ -6,7 +6,7 @@ [control ["<>" parser] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [collection ["[0]" dictionary (.only Dictionary)]] @@ -19,8 +19,8 @@ ["[0]" signature (.only Signature) (.use "[1]#[0]" equivalence)] ["[0]" key (.only Key)]]) -(exception: .public (invalid_signature [expected Signature - actual Signature]) +(exception .public (invalid_signature [expected Signature + actual Signature]) (exception.report "Expected" (signature.description expected) "Actual" (signature.description actual))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux index 7949df255..9c889fada 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux @@ -7,7 +7,7 @@ ["<>" parser] ["[0]" pipe] ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" binary @@ -144,7 +144,7 @@ dependencies])) artifacts))) - (exception: .public (invalid_category [tag Nat]) + (exception .public (invalid_category [tag Nat]) (exception.report "Tag" (%.nat tag))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux index b261c7c04..5900e0362 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux @@ -7,7 +7,7 @@ [control ["[0]" pipe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data [binary (.only Binary)] ["[0]" product] @@ -24,9 +24,9 @@ [archive ["[0]" module]]]]) -(exception: .public (cannot_enable [archive file.Path - @module module.ID - error Text]) +(exception .public (cannot_enable [archive file.Path + @module module.ID + error Text]) (exception.report "Archive" archive "Module ID" (%.nat @module) diff --git a/stdlib/source/library/lux/tool/compiler/meta/import.lux b/stdlib/source/library/lux/tool/compiler/meta/import.lux index b18de6f44..903412749 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/import.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/import.lux @@ -6,7 +6,7 @@ [control ["<>" parser] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" async (.only Async)]]] [data @@ -29,10 +29,10 @@ (def Action (type_literal (All (_ a) (Async (Try a))))) -(exception: .public useless_tar_entry) +(exception .public useless_tar_entry) -(exception: .public (duplicate [library Library - module Module]) +(exception .public (duplicate [library Library + module Module]) (exception.report "Module" (%.text module) "Library" (%.text library))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 83cec862d..35b5aaf50 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -8,7 +8,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]] [data @@ -30,13 +30,13 @@ [module [descriptor (.only Module)]]]]]) -(exception: .public (cannot_find_module [importer Module - module Module]) +(exception .public (cannot_find_module [importer Module + module Module]) (exception.report "Module" (%.text module) "Importer" (%.text importer))) -(exception: .public (cannot_read_module [module Module]) +(exception .public (cannot_read_module [module Module]) (exception.report "Module" (%.text module))) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 3b08f9ac2..ed08ed73f 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -4,7 +4,7 @@ [control [monad (.only Monad do)] ["[0]" try (.only Try)] - ["ex" exception (.only exception:)]] + ["ex" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]]] @@ -29,7 +29,7 @@ ["[0]" console (.only Console)]]]] ["[0]" /type]) -(exception: .public (error [message Text]) +(exception .public (error [message Text]) message) (def .public module "<INTERPRETER>") diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 256029a84..ac1e01df2 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -8,7 +8,6 @@ [control ["[0]" function] ["[0]" maybe] - ["[0]" exception (.only exception:)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 09e496cec..527292c47 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -9,7 +9,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only Exception exception:)]] + ["[0]" exception (.only Exception exception)]] [data ["[0]" product] ["[0]" text (.use "[1]#[0]" monoid equivalence)] @@ -31,30 +31,30 @@ (template (_ reference subject) [("lux text =" reference subject)])) -(exception: .public (unknown_type_var [id Nat]) +(exception .public (unknown_type_var [id Nat]) (exception.report "ID" (n#encoded id))) -(exception: .public (unbound_type_var [id Nat]) +(exception .public (unbound_type_var [id Nat]) (exception.report "ID" (n#encoded id))) -(exception: .public (invalid_type_application [funcT Type - argT Type]) +(exception .public (invalid_type_application [funcT Type + argT Type]) (exception.report "Type function" (//.format funcT) "Type argument" (//.format argT))) -(exception: .public (cannot_rebind_var [id Nat - type Type - bound Type]) +(exception .public (cannot_rebind_var [id Nat + type Type + bound Type]) (exception.report "Var" (n#encoded id) "Wanted Type" (//.format type) "Current Type" (//.format bound))) -(exception: .public (type_check_failed [expected Type - actual Type]) +(exception .public (type_check_failed [expected Type + actual Type]) (exception.report "Expected" (//.format expected) "Actual" (//.format actual))) @@ -337,7 +337,7 @@ (set.member? it @1)) (..ring @0))) -(exception: .public (cannot_identify [var Var]) +(exception .public (cannot_identify [var Var]) (exception.report "Var" (n#encoded var))) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 0ae433481..9afa8f395 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -4,7 +4,7 @@ ["[0]" debug] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [parser ["<[0]>" code]]] [data @@ -15,8 +15,8 @@ ["[0]" type (.only) ["[0]" primitive (.only primitive)]]]]) -(exception: .public (wrong_type [expected Type - actual Type]) +(exception .public (wrong_type [expected Type + actual Type]) (exception.report "Expected" (%.type expected) "Actual" (%.type actual))) diff --git a/stdlib/source/library/lux/type/primitive.lux b/stdlib/source/library/lux/type/primitive.lux index 4ab0e4e3d..c7d4a147a 100644 --- a/stdlib/source/library/lux/type/primitive.lux +++ b/stdlib/source/library/lux/type/primitive.lux @@ -5,7 +5,6 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception:)] ["<>" parser (.use "[1]#[0]" monad) ["<[0]>" code (.only Parser)]]] [data diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 0cc8df8bc..6a35b1567 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -7,7 +7,7 @@ [indexed (.only IxMonad)]]] [control ["[0]" maybe] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["<>" parser (.only) ["<[0]>" code (.only Parser)]]] [data @@ -101,11 +101,11 @@ (at monad in [keys (representation resource)]))) ) -(exception: .public (index_cannot_be_repeated [index Nat]) +(exception .public (index_cannot_be_repeated [index Nat]) (exception.report "Index" (%.nat index))) -(exception: .public amount_cannot_be_zero) +(exception .public amount_cannot_be_zero) (def indices (Parser (List Nat)) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 5c6285bd3..ac50d96e0 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -8,7 +8,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io) (.use "[1]#[0]" functor)] [concurrency ["[0]" async (.only Async) (.use "[1]#[0]" monad)] @@ -40,7 +40,7 @@ [write] [close]))))) -(exception: .public cannot_close) +(exception .public cannot_close) (with_expansions [<jvm> (these (import java/lang/String "[1]::[0]") @@ -63,7 +63,7 @@ ("read_only" "static" in java/io/InputStream) ("read_only" "static" out java/io/PrintStream)) - (exception: .public cannot_open) + (exception .public cannot_open) (def .public default (IO (Try (Console IO))) @@ -116,7 +116,7 @@ ("static" stdout Writable_Stream) ("static" stdin Readable_Stream)) - (exception: .public cannot_read) + (exception .public cannot_read) (def !read (template (_ <type> <query>) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index cbaeb56a0..9db2c4547 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -8,7 +8,7 @@ ["[0]" pipe] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO) (.use "[1]#[0]" functor)] ["[0]" function] [concurrency @@ -145,7 +145,7 @@ (format parent (at fs separator) child)) (with_template [<name>] - [(exception: .public (<name> [file Path]) + [(exception .public (<name> [file Path]) (exception.report "Path" file))] @@ -811,7 +811,7 @@ ... (def default_separator (..DIRECTORY_SEPARATOR)) ... (with_template [<name>] - ... [(exception: .public (<name> [file Path]) + ... [(exception .public (<name> [file Path]) ... (exception.report ... "Path" file))] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index a5279d324..e0f253259 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -10,7 +10,7 @@ ["[0]" io (.only IO)] ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" async (.only Async)] ["[0]" stm (.only STM Var)]]] @@ -93,7 +93,7 @@ poll))) (with_template [<name>] - [(exception: .public (<name> [path //.Path]) + [(exception .public (<name> [path //.Path]) (exception.report "Path" (%.text path)))] diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 84b6eaf15..9923535c9 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -9,7 +9,7 @@ ["[0]" io (.only IO)] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" atom] ["[0]" async (.only Async)]] @@ -36,7 +36,7 @@ [file (.only Path)] [shell (.only Exit)]]))) -(exception: .public (unknown_environment_variable [name Text]) +(exception .public (unknown_environment_variable [name Text]) (exception.report "Name" (%.text name))) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index a2eaccadc..9c6b37c12 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -8,7 +8,7 @@ [control ["[0]" function] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO)] [security ["?" policy (.only Context Safety Safe)]] @@ -229,7 +229,7 @@ (destroy [] "io" "try" void) (waitFor [] "io" "try" int)) - (exception: .public no_more_output) + (exception .public no_more_output) (def (default_process process) (-> java/lang/Process (IO (Try (Process IO)))) diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux index 3539323c5..1e1ac7704 100644 --- a/stdlib/source/parser/lux/data/binary.lux +++ b/stdlib/source/parser/lux/data/binary.lux @@ -9,7 +9,7 @@ [control ["//" parser (.use "[1]#[0]" monad)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["/" binary ["[1]" \\unsafe (.only Binary)]] @@ -37,8 +37,8 @@ (.type .public Parser (//.Parser [Offset Binary])) -(exception: .public (binary_was_not_fully_read [binary_length Nat - bytes_read Nat]) +(exception .public (binary_was_not_fully_read [binary_length Nat + bytes_read Nat]) (exception.report "Binary length" (%.nat binary_length) "Bytes read" (%.nat bytes_read))) @@ -88,9 +88,9 @@ (def .public size_32 Size (n.* 2 size_16)) (def .public size_64 Size (n.* 2 size_32)) -(exception: .public (range_out_of_bounds [length Nat - start Nat - end Nat]) +(exception .public (range_out_of_bounds [length Nat + start Nat + end Nat]) (exception.report "Length" (%.nat length) "Range start" (%.nat start) @@ -125,8 +125,8 @@ (Parser Frac) (//#each frac.of_bits ..bits_64)) -(exception: .public (invalid_tag [range Nat - byte Nat]) +(exception .public (invalid_tag [range Nat + byte Nat]) (exception.report "Tag range" (%.nat range) "Tag value" (%.nat byte))) @@ -159,7 +159,7 @@ (Parser Any) (//#in [])) -(exception: .public (not_a_bit [value Nat]) +(exception .public (not_a_bit [value Nat]) (exception.report "Expected values" "either 0 or 1" "Actual value" (%.nat value))) @@ -250,7 +250,7 @@ (|>> (//.and value) (..or ..any)))) -(exception: .public set_elements_are_not_unique) +(exception .public set_elements_are_not_unique) (def .public (set hash value) (All (_ a) (-> (Hash a) (Parser a) (Parser (Set a)))) diff --git a/stdlib/source/parser/lux/data/format/json.lux b/stdlib/source/parser/lux/data/format/json.lux index d579b9060..c78f8132c 100644 --- a/stdlib/source/parser/lux/data/format/json.lux +++ b/stdlib/source/parser/lux/data/format/json.lux @@ -6,7 +6,7 @@ [control ["//" parser (.use "[1]#[0]" functor)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" bit] ["[0]" text (.use "[1]#[0]" equivalence monoid)] @@ -25,11 +25,11 @@ (type .public (Parser a) (//.Parser (List JSON) a)) -(exception: .public (unconsumed_input [input (List JSON)]) +(exception .public (unconsumed_input [input (List JSON)]) (exception.report "Input" (exception.listing /.format input))) -(exception: .public empty_input) +(exception .public empty_input) (def .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) @@ -55,7 +55,7 @@ {.#Item head tail} {try.#Success [tail head]}))) -(exception: .public (unexpected_value [value JSON]) +(exception .public (unexpected_value [value JSON]) (exception.report "Value" (/.format value))) @@ -77,8 +77,8 @@ [string /.String /.#String] ) -(exception: .public [a] (value_mismatch [reference JSON - sample JSON]) +(exception .public [a] (value_mismatch [reference JSON + sample JSON]) (exception.report "Reference" (/.format reference) "Sample" (/.format sample))) diff --git a/stdlib/source/parser/lux/data/format/xml.lux b/stdlib/source/parser/lux/data/format/xml.lux index 44cfa8fdd..70376d2c6 100644 --- a/stdlib/source/parser/lux/data/format/xml.lux +++ b/stdlib/source/parser/lux/data/format/xml.lux @@ -6,7 +6,7 @@ [control ["//" parser] ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text ["%" \\format (.only format)]] @@ -21,22 +21,22 @@ (type .public (Parser a) (//.Parser [Attrs (List XML)] a)) -(exception: .public empty_input) -(exception: .public unexpected_input) +(exception .public empty_input) +(exception .public unexpected_input) -(exception: .public (wrong_tag [expected Tag - actual Tag]) +(exception .public (wrong_tag [expected Tag + actual Tag]) (exception.report "Expected" (%.text (/.tag expected)) "Actual" (%.text (/.tag actual)))) -(exception: .public (unknown_attribute [expected Attribute - available (List Attribute)]) +(exception .public (unknown_attribute [expected Attribute + available (List Attribute)]) (exception.report "Expected" (%.text (/.attribute expected)) "Available" (exception.listing (|>> /.attribute %.text) available))) -(exception: .public (unconsumed_inputs [inputs (List XML)]) +(exception .public (unconsumed_inputs [inputs (List XML)]) (exception.report "Inputs" (exception.listing (at /.codec encoded) inputs))) @@ -124,7 +124,7 @@ {.#Item head tail} {try.#Success [[attrs tail] head]}))) -(exception: .public nowhere) +(exception .public nowhere) (def .public (somewhere parser) (All (_ a) (-> (Parser a) (Parser a))) diff --git a/stdlib/source/parser/lux/data/text.lux b/stdlib/source/parser/lux/data/text.lux index 3cc4dd8da..3cd4076f5 100644 --- a/stdlib/source/parser/lux/data/text.lux +++ b/stdlib/source/parser/lux/data/text.lux @@ -7,7 +7,7 @@ ["//" parser] ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["/" text (.only Char) (.use "[1]#[0]" monoid)] ["[0]" product] @@ -28,8 +28,8 @@ Offset 0) -(exception: .public cannot_parse) -(exception: .public cannot_slice) +(exception .public cannot_parse) +(exception .public cannot_slice) (type .public Parser (//.Parser [Offset Text])) @@ -55,15 +55,15 @@ (-> Offset Text Text) (|> tape (/.clip_since offset) maybe.trusted)) -(exception: .public (unconsumed_input [offset Offset - tape Text]) +(exception .public (unconsumed_input [offset Offset + tape Text]) (exception.report "Offset" (n#encoded offset) "Input size" (n#encoded (/.size tape)) "Remaining input" (..left_over offset tape))) -(exception: .public (expected_to_fail [offset Offset - tape Text]) +(exception .public (expected_to_fail [offset Offset + tape Text]) (exception.report "Offset" (n#encoded offset) "Input" (..left_over offset tape))) @@ -133,7 +133,7 @@ [not! Slice ..any!] ) -(exception: .public (cannot_match [reference Text]) +(exception .public (cannot_match [reference Text]) (exception.report "Reference" (/.format reference))) @@ -229,8 +229,8 @@ (..range! (char "A") (char "F")))) (with_template [<name>] - [(exception: .public (<name> [options Text - character Char]) + [(exception .public (<name> [options Text + character Char]) (exception.report "Options" (/.format options) "Character" (/.format (/.of_char character))))] @@ -277,7 +277,7 @@ [none_of! .not ..character_should_not_be] ) -(exception: .public (character_does_not_satisfy_predicate [character Char]) +(exception .public (character_does_not_satisfy_predicate [character Char]) (exception.report "Character" (/.format (/.of_char character)))) diff --git a/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux index 99a2f3e8e..32ee998eb 100644 --- a/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux @@ -6,7 +6,7 @@ [control ["//" parser] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" bit] ["[0]" text (.only) @@ -38,11 +38,11 @@ (list#each /.format) (text.interposed " ")))) -(exception: .public (cannot_parse [input (List Analysis)]) +(exception .public (cannot_parse [input (List Analysis)]) (exception.report "Input" (exception.listing /.format input))) -(exception: .public (unconsumed_input [input (List Analysis)]) +(exception .public (unconsumed_input [input (List Analysis)]) (exception.report "Input" (exception.listing /.format input))) diff --git a/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux index c5f44f784..de0c5d1ac 100644 --- a/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux @@ -6,7 +6,7 @@ [control ["//" parser] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" bit] ["[0]" text (.only) @@ -31,25 +31,25 @@ [\\library ["[0]" / (.only Synthesis Abstraction)]]) -(exception: .public (cannot_parse [input (List Synthesis)]) +(exception .public (cannot_parse [input (List Synthesis)]) (exception.report "Input" (exception.listing /.%synthesis input))) -(exception: .public (unconsumed_input [input (List Synthesis)]) +(exception .public (unconsumed_input [input (List Synthesis)]) (exception.report "Input" (exception.listing /.%synthesis input))) -(exception: .public (expected_empty_input [input (List Synthesis)]) +(exception .public (expected_empty_input [input (List Synthesis)]) (exception.report "Input" (exception.listing /.%synthesis input))) -(exception: .public (wrong_arity [expected Arity - actual Arity]) +(exception .public (wrong_arity [expected Arity + actual Arity]) (exception.report "Expected" (%.nat expected) "Actual" (%.nat actual))) -(exception: .public empty_input) +(exception .public empty_input) (type .public Parser (//.Parser (List Synthesis))) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 734a31c7c..72473bbe9 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -9,7 +9,7 @@ ["[0]" io (.only IO)] ["[0]" maybe] ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [parser [environment (.only Environment)]] [concurrency @@ -96,8 +96,8 @@ (in {try.#Failure ""})))] (in output))) -(exception: (cannot_find_repository [repository Text - options (Dictionary Text Address)]) +(exception (cannot_find_repository [repository Text + options (Dictionary Text Address)]) (exception.report "Repository" (%.text repository) "Options" (exception.listing (function (_ [name repo]) @@ -128,7 +128,7 @@ (..fail! error)))) (at io.monad in []))) -(exception: .public invalid_operation) +(exception .public invalid_operation) (`` (def write_only (Console IO) diff --git a/stdlib/source/program/aedifex/artifact/snapshot/time.lux b/stdlib/source/program/aedifex/artifact/snapshot/time.lux index b039dd2e2..9acb04c63 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/time.lux @@ -5,7 +5,6 @@ [equivalence (.only Equivalence)] [monad (.only do)]] [control - ["[0]" exception (.only exception:)] ["<>" parser]] [data ["[0]" text diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux index f6ffea4d6..02b0d97f2 100644 --- a/stdlib/source/program/aedifex/artifact/time/date.lux +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -7,7 +7,7 @@ [control ["<>" parser] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text ["%" \\format] @@ -32,7 +32,7 @@ (def min_year +1,000) (def max_year +9,999) -(exception: .public (year_is_out_of_range [year year.Year]) +(exception .public (year_is_out_of_range [year year.Year]) (exception.report "Minimum" (%.int ..min_year) "Maximum" (%.int ..max_year) diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux index 82dffcd61..53e6824f0 100644 --- a/stdlib/source/program/aedifex/artifact/versioning.lux +++ b/stdlib/source/program/aedifex/artifact/versioning.lux @@ -5,7 +5,6 @@ [equivalence (.only Equivalence)] [monad (.only do)]] [control - ["[0]" exception (.only exception:)] ["<>" parser]] [data ["[0]" product] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 2f1931c0e..69b5f9e40 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -7,7 +7,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO)] [concurrency ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]] @@ -81,8 +81,8 @@ ["lux-ruby" ruby_lux_name] ) -(exception: .public no_available_lux) -(exception: .public no_specified_program) +(exception .public no_available_lux) +(exception .public no_specified_program) (type .public Lux (Variant diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index d8c46d98c..eaefb1831 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -12,7 +12,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only Exception exception:)] + ["[0]" exception (.only Exception exception)] [concurrency ["[0]" async (.only Async)]]] [data @@ -58,9 +58,9 @@ ["[1]/[0]" snapshot]]]]) (with_template [<name>] - [(exception: .public (<name> [artifact Artifact - extension Extension - hash Text]) + [(exception .public (<name> [artifact Artifact + extension Extension + hash Text]) (exception.report "Artifact" (///artifact.format artifact) "Extension" (%.text extension) @@ -154,7 +154,7 @@ (Equivalence Resolution) (dictionary.equivalence ///package.equivalence)) -(exception: .public (cannot_resolve [dependency Dependency]) +(exception .public (cannot_resolve [dependency Dependency]) (exception.report "Artifact" (%.text (///artifact.format (the //.#artifact dependency))) "Type" (%.text (the //.#type dependency)))) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index d114b957e..3f7376286 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -8,7 +8,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" binary (.only Binary)] ["[0]" text @@ -80,15 +80,15 @@ (def hex_per_chunk (n.* hex_per_byte i64.bytes_per_i64)) - (exception: .public (not_a_hash [size Nat - value Text]) + (exception .public (not_a_hash [size Nat + value Text]) (exception.report "Pseudo hash" (%.text value) "Expected size" (%.nat size) "Actual size" (%.nat (text.size value)))) (with_template [<name> <size>] - [(exception: .public (<name> [data Binary]) + [(exception .public (<name> [data Binary]) (exception.report "Pseudo hash" (%.text (..encoded data)) "Expected size" (%.nat <size>) diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 8898385f7..c524ddefb 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -5,10 +5,9 @@ [monad (.only do)] [equivalence (.only Equivalence)]] [control + ["<>" parser] ["[0]" pipe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] - ["<>" parser] [concurrency ["[0]" async (.only Async)]]] [data diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 3017defcd..ff8710893 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -6,7 +6,7 @@ [equivalence (.only Equivalence)]] [control ["[0]" maybe (.use "[1]#[0]" monoid)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" text (.use "[1]#[0]" equivalence)] @@ -277,4 +277,4 @@ #lua (!runtime #lua runtime.default_lua) #ruby (!runtime #ruby runtime.default_ruby)])))) -(exception: .public no_identity) +(exception .public no_identity) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index ae6a4acdf..7be915cb1 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -7,7 +7,7 @@ ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.only) ["%" \\format (.only format)]] @@ -41,12 +41,12 @@ (def composite (dictionary.composite_with (at //.monoid composite))))) -(exception: .public (unknown_profile [name Name]) +(exception .public (unknown_profile [name Name]) (exception.report "Name" (%.text name))) -(exception: .public (circular_dependency [dependee Name - dependent Name]) +(exception .public (circular_dependency [dependee Name + dependent Name]) (exception.report "Dependent" (%.text dependent) "Dependee" (%.text dependee))) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 2414e25d8..75d9a3468 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -6,7 +6,7 @@ [control ["[0]" io (.only IO)] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] [text @@ -35,8 +35,8 @@ URL) (with_template [<name>] - [(exception: .public (<name> [url URL - status Nat]) + [(exception .public (<name> [url URL + status Nat]) (exception.report "URL" (%.text url) "Status Code" (%.nat status)))] diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index 4873cf31e..983262270 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -7,7 +7,7 @@ [control ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] [concurrency ["[0]" async (.only Async)]]] [data @@ -27,7 +27,7 @@ [\\program ["[0]" /]]) -(exception: .public console_is_closed!) +(exception .public console_is_closed!) (def mock (Mock [Bit Text]) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 1602fab49..a3caba277 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -9,7 +9,7 @@ [control ["[0]" io] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" product] ["[0]" binary (.only Binary)] @@ -42,11 +42,11 @@ (-> Version Artifact) (|>> ["com.github.luxlang" "test-artifact"])) -(exception: (not_found [uri URI]) +(exception (not_found [uri URI]) (exception.report "URI" (%.text uri))) -(exception: (cannot_upload [uri URI]) +(exception (cannot_upload [uri URI]) (exception.report "URI" (%.text uri))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index ecc435a72..218dfcb3d 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -6,7 +6,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO io)]] [data [text @@ -25,7 +25,7 @@ ["[0]" async (.only Async Resolver) (.use "[1]#[0]" monad)] ["[0]" frp]]]]) -(exception: got_wrecked) +(exception got_wrecked) (def counter (/.Behavior Nat) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index ec1a460c8..eeaac1f53 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -10,7 +10,7 @@ ["[0]" io] ["[0]" maybe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception] [concurrency ["[0]" async (.only Async)] ["[0]" atom (.only Atom)]]] diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index e36deb494..c31a78b65 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -12,15 +12,15 @@ [number ["n" nat]]]]] [\\library - ["[0]" / (.only exception:) + ["[0]" / (.only) [// ["[0]" try (.only Try)]]]]) -(exception: an_exception) -(exception: another_exception) +(/.exception an_exception) +(/.exception another_exception) (def label "YOLO") -(exception: (custom_exception [value Nat]) +(/.exception (custom_exception [value Nat]) (/.report label (%.nat value))) (def .public test @@ -103,7 +103,7 @@ {try.#Failure message} (and (text.contains? (/.error ..an_exception []) message) (text.contains? (/.error ..another_exception []) message))))) - (_.coverage [/.exception:] + (_.coverage [/.exception] (case (/.except ..custom_exception [expected]) {try.#Success _} false diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 37969d317..54dde9289 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -26,9 +26,9 @@ ["[0]" / (.only Region) [// ["[0]" thread (.only Thread)] - ["[0]" exception (.only Exception exception:)]]]]) + ["[0]" exception (.only Exception exception)]]]]) -(exception: oops) +(exception oops) (def (success? result) (All (_ a) (-> (Try a) Bit)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux index 4e0aa40a5..6fb6ebd02 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux @@ -11,7 +11,7 @@ ["<>" parser] ["[0]" pipe] ["[0]" try] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" function] ["[0]" maybe]] [data @@ -373,7 +373,7 @@ (with_expansions [<id> (static.random_nat) <exception> (template.symbol ["exception_" <id>])] - (exception: <exception>) + (exception <exception>) (def test|phase Test diff --git a/stdlib/source/test/lux/tool/compiler/phase.lux b/stdlib/source/test/lux/tool/compiler/phase.lux index adad18aac..39ee0604b 100644 --- a/stdlib/source/test/lux/tool/compiler/phase.lux +++ b/stdlib/source/test/lux/tool/compiler/phase.lux @@ -10,7 +10,7 @@ [control ["[0]" pipe] ["[0]" try (.use "[1]#[0]" functor)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]]] @@ -42,7 +42,7 @@ _ false))) -(exception: oops) +(exception oops) (def test|error Test diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 3c45d4db4..89aa98285 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -13,7 +13,7 @@ ["[0]" pipe] ["[0]" function] ["[0]" try] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" product] @@ -127,7 +127,7 @@ (Random Type) (primitive_type 2)) -(exception: yolo) +(exception yolo) (def error_handling Test diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index acc05df1f..9dd7975c7 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -7,7 +7,7 @@ [control ["[0]" io] ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)]] + ["[0]" exception (.only exception)]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]]] @@ -18,7 +18,7 @@ [\\specification ["$[0]" /]]) -(exception: dead) +(exception dead) (def mock (/.Mock [Bit Text]) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index 6a3679e3d..c8738d3a3 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -6,7 +6,7 @@ [monad (.only do)]] [control ["[0]" try (.only Try)] - ["[0]" exception (.only exception:)] + ["[0]" exception (.only exception)] ["[0]" io (.only IO)] [concurrency ["[0]" async (.only Async)]] @@ -28,7 +28,7 @@ [\\specification ["$[0]" /]]) -(exception: dead) +(exception dead) (def (mock [environment working_directory command arguments]) (-> [Environment Path /.Command (List /.Argument)] |