From a296af389bef18e949803645064a04c8ad6d7d4d Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 14 May 2024 19:47:41 -0400 Subject: [PATCH] Better type coercions. --- .../bookmark/tool/text_editor/structural.md | 1 + lux-jvm/source/program.lux | 40 +- stdlib/source/library/lux.lux | 301 ++--- .../library/lux/compiler/default/platform.lux | 7 +- .../language/lux/phase/analysis/when.lux | 19 +- .../language/lux/phase/declaration.lux | 3 +- .../lux/phase/extension/analysis/jvm.lux | 11 +- .../lux/phase/extension/analysis/lux.lux | 38 +- .../lux/phase/extension/declaration/lux.lux | 4 +- .../lux/compiler/language/lux/syntax.lux | 8 +- .../source/library/lux/concurrency/atom.lux | 42 +- stdlib/source/library/lux/concurrency/frp.lux | 19 +- stdlib/source/library/lux/concurrency/stm.lux | 11 +- stdlib/source/library/lux/control/region.lux | 79 +- .../library/lux/control/scope/dynamic.lux | 2 +- stdlib/source/library/lux/control/thread.lux | 80 +- .../lux/data/collection/queue/priority.lux | 4 +- .../library/lux/data/format/markdown.lux | 4 +- stdlib/source/library/lux/data/text.lux | 59 +- .../source/library/lux/data/text/buffer.lux | 2 +- stdlib/source/library/lux/debug.lux | 53 +- stdlib/source/library/lux/ffi.jvm.lux | 63 +- .../library/lux/finance/money/currency.lux | 2 +- stdlib/source/library/lux/function/mutual.lux | 6 +- .../lux/function/polymorphism/aspect.lux | 4 +- .../lux/function/polymorphism/context.lux | 8 +- stdlib/source/library/lux/macro.lux | 4 +- stdlib/source/library/lux/macro/context.lux | 10 +- stdlib/source/library/lux/macro/expansion.lux | 6 +- stdlib/source/library/lux/macro/local.lux | 2 +- .../source/library/lux/macro/vocabulary.lux | 13 +- .../library/lux/math/geometry/circle.lux | 49 +- .../library/lux/math/number/decimal.lux | 70 +- stdlib/source/library/lux/meta.lux | 5 +- stdlib/source/library/lux/meta/binding.lux | 11 +- stdlib/source/library/lux/meta/extension.lux | 4 +- stdlib/source/library/lux/meta/label.lux | 6 +- stdlib/source/library/lux/meta/static.lux | 18 +- .../library/lux/target/jvm/bytecode.lux | 113 +- .../source/library/lux/target/jvm/loader.lux | 66 +- .../library/lux/target/jvm/reflection.lux | 19 +- stdlib/source/library/lux/target/jvm/type.lux | 26 +- stdlib/source/library/lux/target/lua.lux | 3 +- stdlib/source/library/lux/target/php.lux | 3 +- stdlib/source/library/lux/target/python.lux | 9 +- stdlib/source/library/lux/target/ruby.lux | 23 +- stdlib/source/library/lux/test/inline.lux | 2 +- stdlib/source/library/lux/time/date.lux | 4 +- stdlib/source/library/lux/time/instant.lux | 41 +- stdlib/source/library/lux/type.lux | 20 +- stdlib/source/library/lux/type/dynamic.lux | 14 +- stdlib/source/library/lux/type/function.lux | 2 +- stdlib/source/library/lux/type/nominal.lux | 9 +- stdlib/source/library/lux/type/poly.lux | 2 +- stdlib/source/library/lux/type/quotient.lux | 2 +- stdlib/source/library/lux/type/record.lux | 4 +- stdlib/source/library/lux/type/refinement.lux | 2 +- stdlib/source/library/lux/type/row.lux | 2 +- stdlib/source/library/lux/web/css/value.lux | 7 +- stdlib/source/library/lux/web/html.lux | 30 +- .../source/library/lux/world/environment.lux | 172 +-- .../source/library/lux/world/file/watch.lux | 168 +-- .../library/lux/world/net/http/client.lux | 145 +-- stdlib/source/library/lux/world/shell.lux | 4 +- stdlib/source/test/lux.lux | 3 +- .../lux/phase/translation/jvm/complex.lux | 4 +- .../lux/phase/translation/jvm/function.lux | 6 +- .../translation/jvm/function/abstract.lux | 22 +- .../jvm/function/field/variable/count.lux | 9 +- .../jvm/function/field/variable/foreign.lux | 2 +- .../jvm/function/field/variable/partial.lux | 2 +- .../translation/jvm/function/method/apply.lux | 2 +- .../jvm/function/method/implementation.lux | 12 +- .../translation/jvm/function/method/reset.lux | 14 +- .../lux/phase/translation/jvm/host.lux | 2 +- .../lux/phase/translation/jvm/loop.lux | 6 +- .../lux/phase/translation/jvm/primitive.lux | 2 +- .../lux/phase/translation/jvm/reference.lux | 2 +- .../lux/phase/translation/jvm/value.lux | 2 +- .../lux/phase/translation/jvm/when.lux | 46 +- stdlib/source/test/lux/control/region.lux | 43 +- stdlib/source/test/lux/ffi.jvm.lux | 43 +- stdlib/source/test/lux/ffi/export.jvm.lux | 144 +-- stdlib/source/test/lux/meta/binding.lux | 6 +- stdlib/source/test/lux/meta/label.lux | 14 +- stdlib/source/test/lux/program.lux | 6 +- stdlib/source/test/lux/target/jvm.lux | 1045 ++++++++++------- .../test/lux/target/jvm/type/projection.lux | 2 +- stdlib/source/test/lux/type.lux | 9 - stdlib/source/test/lux/type/variance.lux | 2 +- stdlib/source/unsafe/lux/data/binary.lux | 82 +- .../unsafe/lux/data/collection/array.lux | 43 +- 92 files changed, 1879 insertions(+), 1656 deletions(-) diff --git a/documentation/bookmark/tool/text_editor/structural.md b/documentation/bookmark/tool/text_editor/structural.md index dee87f1a4c..e0c116b7fe 100644 --- a/documentation/bookmark/tool/text_editor/structural.md +++ b/documentation/bookmark/tool/text_editor/structural.md @@ -1,5 +1,6 @@ # Reference +0. [Pushing CSS :has() to its limits - hover-highlighted parentheses, variable bindings, and more](https://blog.mjgrzymek.com/blog/css-has) 0. [Tree-edit: Structural editing in Emacs for any™ language!](https://github.com/ethan-leba/tree-edit) 0. [Awesome Structure Editors](https://github.com/yairchu/awesome-structure-editors) 0. [Restructuring Structure Editing](https://tylr.fun/essay/) diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux index 7137ffa01b..5c0205a436 100644 --- a/lux-jvm/source/program.lux +++ b/lux-jvm/source/program.lux @@ -91,15 +91,15 @@ Expander (do try.monad [apply_method (|> macro - (as java/lang/Object) + (as (-> Macro java/lang/Object)) (java/lang/Object::getClass []) (java/lang/Class::getMethod [(ffi.as_string "apply") _apply2_args]))] - (as (Try (Try [analysis.State (List @type.Code)])) + (as (-> (Try java/lang/Object) (Try (Try [analysis.State (List @type.Code)]))) (java/lang/reflect/Method::invoke - [(as java/lang/Object macro) + [(as (-> Macro java/lang/Object) macro) (ffi.array java/lang/Object - [(as java/lang/Object inputs) - (as java/lang/Object lux)])] + [(as (-> (List Code) java/lang/Object) inputs) + (as (-> Lux java/lang/Object) lux)])] apply_method)))) (the phase_wrapper @@ -126,29 +126,25 @@ (the extender extension.Extender ... TODO: Stop relying on coercions ASAP. - (<| (as extension.Extender) - (function (@self handler)) - (as extension.Handler) - (function (@self phase)) - (as phase.Phase) - (function (@self archive parameters)) - (as phase.Operation) - (function (@self state)) - (as Try) + (<| (function (@self handler + phase + archive parameters + state)) + (as (-> Any Try)) try.trusted - (as Try) + (as (-> Any Try)) (do try.monad [method (|> handler - (as java/lang/Object) + (as (-> Any java/lang/Object)) (java/lang/Object::getClass []) (java/lang/Class::getMethod [(ffi.as_string "apply") _apply4_args]))] (java/lang/reflect/Method::invoke - [(as java/lang/Object handler) + [(as (-> Any java/lang/Object) handler) (ffi.array java/lang/Object - [(as java/lang/Object (phase_wrapper phase)) - (as java/lang/Object archive) - (as java/lang/Object parameters) - (as java/lang/Object state)])] + [(as (-> Any java/lang/Object) (phase_wrapper phase)) + (as (-> Any java/lang/Object) archive) + (as (-> Any java/lang/Object) parameters) + (as (-> Any java/lang/Object) state)])] method)))) (the (declare_success! _) @@ -161,7 +157,7 @@ (exec (do future.monad [[loader host platform] (future.soon ..platform) - _ (compositor.compiler (|>> (as platform.Custom)) + _ (compositor.compiler (|>> (as (-> Any platform.Custom))) context ..expander (extension/analysis.bundle loader host) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 2ac8b90dca..ca50a1c6b9 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -240,13 +240,13 @@ (.def# tag (.is# (Function Label Tag) - (.function# _ it (.as# Tag it))) + (.function# _ it (.as# (Function Label Tag) it))) ..private) (.def# slot (.is# (Function Label Slot) - (.function# _ it (.as# Slot it))) + (.function# _ it (.as# (Function Label Slot) it))) ..private) (.def# List @@ -837,7 +837,7 @@ .private) (.def# list - (.as# Macro + (.as# (Function Macro' Macro) (.function# _ tokens (meta#in (.list# (code#form (.list_composite# (.list# (code#name [..prelude "list#"])) tokens)))))) @@ -871,15 +871,14 @@ .private) (.def# let'' - (.as# Macro - (.is# Macro' - (.function# _ tokens - (.when# tokens - (.list# lhs rhs body) - (meta#in (list (code#form (list (code#name [..prelude "when#"]) rhs lhs body)))) - - _ - (failure ..wrong_syntax))))) + (.as# (Function Macro' Macro) + (.function# _ tokens + (.when# tokens + (.list# lhs rhs body) + (meta#in (list (code#form (list (code#name [..prelude "when#"]) rhs lhs body)))) + + _ + (failure ..wrong_syntax)))) ..private) (.def# code#function @@ -899,21 +898,20 @@ ..private) (.def# function' - (.as# Macro - (.is# Macro' - (.function# _ tokens - (.when# tokens - (.list# {#Form _ self,arguments} - body) - (.when# (list#as_stack self,arguments) - {#Top self arguments} - (meta#in (list (code#function self arguments body))) - - else - (failure ..wrong_syntax)) - - _ - (failure ..wrong_syntax))))) + (.as# (Function Macro' Macro) + (.function# _ tokens + (.when# tokens + (.list# {#Form _ self,arguments} + body) + (.when# (list#as_stack self,arguments) + {#Top self arguments} + (meta#in (list (code#function self arguments body))) + + else + (failure ..wrong_syntax)) + + _ + (failure ..wrong_syntax)))) ..private) (.def# code#def @@ -938,61 +936,70 @@ value)))) ..private) +(.def# the' + (.as# (Function Macro' Macro) + (function' (_ tokens) + (.when# tokens + (.list# export_policy + {#Form _ name,arguments} + type + body) + (.when# (list#as_stack name,arguments) + {#Top name arguments} + (meta#in (list (code#def name + (code#is type + (code#function name arguments + body)) + export_policy))) + + else + (failure ..wrong_syntax)) + + (.list# export_policy name type body) + (meta#in (list (code#def name + (code#is type + body) + export_policy))) + + _ + (failure ..wrong_syntax)))) + ..private) + +(.def# 'Function + (.is# (Function Code (Function Code Code)) + (function' (_ domain co_domain) + (code#variant (list (code#name [..prelude "#Nominal"]) + (code#text (.type_name# "function")) + (code#list (list (code#tuple (list (code#bit ..contra_variant) + domain)) + (code#tuple (list (code#bit ..co_variant) + co_domain)))))))) + ..private) + (.def# code#macro (.is# (Function Code Code) (function' (_ expression) (code#form (list (code#name [..prelude "as#"]) - (code#name [..prelude "Macro"]) - (code#is (code#name [..prelude "Macro'"]) - expression))))) - ..private) - -(.def# the' - (.as# Macro - (.is# Macro' - (function' (_ tokens) - (.when# tokens - (.list# export_policy - {#Form _ name,arguments} - type - body) - (.when# (list#as_stack name,arguments) - {#Top name arguments} - (meta#in (list (code#def name - (code#is type - (code#function name arguments - body)) - export_policy))) - - else - (failure ..wrong_syntax)) - - (.list# export_policy name type body) - (meta#in (list (code#def name - (code#is type - body) - export_policy))) - - _ - (failure ..wrong_syntax))))) + ('Function (code#name [..prelude "Macro'"]) + (code#name [..prelude "Macro"])) + expression)))) ..private) (.def# macro - (.as# Macro - (.is# Macro' - (function' (_ tokens) - (.when# tokens - (.list# {#Form _ name,arguments} body) - (.when# (list#as_stack name,arguments) - {#Top name arguments} - (meta#in (list (code#macro (code#function name arguments body)))) - - else - (failure ..wrong_syntax)) - - _ - (failure ..wrong_syntax))))) + (.as# (Function Macro' Macro) + (function' (_ tokens) + (.when# tokens + (.list# {#Form _ name,arguments} body) + (.when# (list#as_stack name,arguments) + {#Top name arguments} + (meta#in (list (code#macro (code#function name arguments body)))) + + else + (failure ..wrong_syntax)) + + _ + (failure ..wrong_syntax)))) ..public) (the' .public comment @@ -1212,8 +1219,8 @@ (Function {#Reification {#Parameter ..argument 0} List} {#Parameter ..argument 1}))))}} (function' (list#mix item mix complete partial) - (.when# (.int_<# (.as# Integer limit) - (.as# Integer item)) + (.when# (.int_<# (.as# (Function Natural Integer) limit) + (.as# (Function Natural Integer) item)) #1 (list#mix (.i64_+# 1 item) mix @@ -1331,15 +1338,7 @@ (macro (_ tokens) (.when# (stack#reversed (list#as_stack tokens)) {#Top output inputs} - (meta#in (list (stack#mix (function' (_ domain co_domain) - (code#variant (list (code#name [..prelude "#Nominal"]) - (code#text (.type_name# "function")) - (code#list (list (code#tuple (list (code#bit ..contra_variant) - domain)) - (code#tuple (list (code#bit ..co_variant) - co_domain))))))) - output - inputs))) + (meta#in (list (stack#mix ..'Function output inputs))) _ (failure ..wrong_syntax)))) @@ -1736,8 +1735,8 @@ ($ Maybe it))) (function' (_ it) (function' (property#value item) - (if (.int_<# (.as# Integer limit) - (.as# Integer item)) + (if (.int_<# (.as# (-> Natural Integer) limit) + (.as# (-> Natural Integer) item)) (let' [[actual value] (.list_item# item it)] (if (.text_=# expected actual) {#Some value} @@ -1800,12 +1799,12 @@ (the' .public (unquote it) (-> Macro UnQuote) - (.as# UnQuote it)) + (.as# (-> Macro UnQuote) it)) (the' .public (unquote_macro it) (-> UnQuote Macro') - (.as# Macro' it)) + (.as# (-> UnQuote Macro') it)) (the' .public Spliced_UnQuote Type @@ -1815,12 +1814,12 @@ (the' .public (spliced_unquote it) (-> Macro Spliced_UnQuote) - (.as# Spliced_UnQuote it)) + (.as# (-> Macro Spliced_UnQuote) it)) (the' .public (spliced_unquote_macro it) (-> Spliced_UnQuote Macro') - (.as# Macro' it)) + (.as# (-> Spliced_UnQuote Macro') it)) (the' .private (stack#one f xs) (for_any (_ input output) @@ -2156,7 +2155,7 @@ {#Some [type value]} (if (type#= Spliced_UnQuote type) (do meta#monad - [.let' [it (spliced_unquote_macro (.as# Spliced_UnQuote value))] + [.let' [it (spliced_unquote_macro (.as# (-> Any Spliced_UnQuote) value))] output (one_expansion (it (.list_composite# (list tail) (list#of_stack parameters))))] (in (with_provenance @composite output))) (expanded_list head tail)) @@ -2259,7 +2258,7 @@ {#Some [type value]} (if (type#= UnQuote type) (do meta#monad - [.let' [it (unquote_macro (.as# UnQuote value))] + [.let' [it (unquote_macro (.as# (-> Any UnQuote) value))] output (one_expansion (it (list#of_stack parameters)))] (in (with_provenance @composite output))) @@ -2642,16 +2641,16 @@ (the' .private (n#/ param subject) (-> Natural Natural Natural) - (if (.int_<# +0 (.as# Integer param)) + (if (.int_<# +0 (.as# (-> Natural Integer) param)) (if (n#< param subject) 0 1) (let' [quotient (|> subject (.i64_right# 1) - (.int_/# (.as# Integer param)) + (.int_/# (.as# (-> Natural Integer) param)) (.i64_left# 1)) - flat (.int_*# (.as# Integer param) - (.as# Integer quotient)) + flat (.int_*# (.as# (-> Natural Integer) param) + (.as# (-> Natural Integer) quotient)) remainder (.i64_-# flat subject)] (if (n#< param remainder) quotient @@ -2660,8 +2659,8 @@ (the' .private (n#% param subject) (-> Natural Natural Natural) - (let' [flat (.int_*# (.as# Integer param) - (.as# Integer (n#/ param subject)))] + (let' [flat (.int_*# (.as# (-> Natural Integer) param) + (.as# (-> Natural Integer) (n#/ param subject)))] (.i64_-# flat subject))) (the' .private (bit#as_text x) @@ -2713,10 +2712,10 @@ (if (.i64_=# +0 input) (.text_composite# sign output) (again (.int_/# +10 input) - (.text_composite# (|> input (.int_%# +10) (.as# Natural) digit::injection) + (.text_composite# (|> input (.int_%# +10) (.as# (-> Integer Natural)) digit::injection) output))))) (|> value (.int_/# +10) integer#abs) - (|> value (.int_%# +10) integer#abs (.as# Natural) digit::injection))))) + (|> value (.int_%# +10) integer#abs (.as# (-> Integer Natural)) digit::injection))))) (the' .private (named_macro' modules current_module module name) (-> ($ Property_List Module) Text Text Text @@ -2733,9 +2732,9 @@ {#Definition [def_type def_value]} (if (type#= ..Macro def_type) (if exported? - {#Some (.as# Macro def_value)} + {#Some (.as# (-> Any Macro) def_value)} (if (.text_=# module current_module) - {#Some (.as# Macro def_value)} + {#Some (.as# (-> Any Macro) def_value)} {#None})) {#None}) @@ -2859,7 +2858,7 @@ (meta#let lux [?macro (named_macro name')]) (.when# ?macro {#Some macro} - (((.as# Macro' macro) (list#of_stack args)) lux) + (((.as# (-> Macro Macro') macro) (list#of_stack args)) lux) {#None} (meta#return lux (list token)))) @@ -2882,7 +2881,7 @@ (meta#let lux [?macro (named_macro name')]) (.when# ?macro {#Some macro} - (<| (meta#let lux [maximum_level_expansion ((.as# Macro' macro) (list#of_stack args))]) + (<| (meta#let lux [maximum_level_expansion ((.as# (-> Macro Macro') macro) (list#of_stack args))]) (meta#let lux [recursive_expansion (monad#each#meta complete_expansion (list#as_stack maximum_level_expansion))]) (meta#return lux (list#of_stack (stack#conjoint (stack#each list#as_stack recursive_expansion))))) @@ -2940,7 +2939,7 @@ (meta#let lux [?macro (named_macro binding)]) (.when# ?macro {#Some macro} - (<| (meta#let lux [expansion ((.as# Macro' macro) parameters)]) + (<| (meta#let lux [expansion ((.as# (-> Macro Macro') macro) parameters)]) (.when# expansion (.list# singular) (meta#return lux (` (..type (, singular)))) @@ -2952,8 +2951,7 @@ ((normal_type_reification normal_type {#Name @ binding} (list#as_stack parameters)) lux)))) (the' .private (normal_type type' it) - (-> (-> Code ($ Meta Code)) - (-> Code ($ Meta Code))) + ($ Change (-> Code ($ Meta Code))) (.when# it {#Variant _ (.list# {#Name _ ["library/lux" "#Named"]} name @@ -3050,8 +3048,7 @@ (meta#in it))) (the' .private (with_quantification' body lux) - (-> ($ Meta Code) - ($ Meta Code)) + ($ Change ($ Meta Code)) (let' [[..#info info/pre ..#source source/pre ..#current_module current_module/pre @@ -3067,7 +3064,7 @@ ..#current_module current_module/pre ..#modules modules/pre ..#scopes (stack#partial [#locals [#counter 0 - #mappings (list [..quantification_level [.Natural (.as# Natural -1)]])] + #mappings (list [..quantification_level [.Natural (.as# (-> Integer Natural) -1)]])] #captured [#counter 0 #mappings (list)]] scopes/pre) @@ -3284,13 +3281,13 @@ (.when# (anonymous_type type) {#Nominal name_of_type (.list#)} (if (.text_=# name_of_type (.type_name# "bit")) - (in (code#bit (as Bit value))) + (in (code#bit (as (-> Any Bit) value))) (.text_=# name_of_type (.type_name# "decimal")) - (in (code#decimal (as Decimal value))) + (in (code#decimal (as (-> Any Decimal) value))) (.text_=# name_of_type (.type_name# "text")) - (in (code#text (as Text value))) + (in (code#text (as (-> Any Text) value))) (if (.text_=# name_of_type (.type_name# "tag")) #1 @@ -3304,13 +3301,13 @@ {#Nominal name_of_type (.list# [#1 {#Nominal name_of_specialization (.list#)}])} (if (.text_=# name_of_type (.type_name# "i64")) (if (.text_=# name_of_specialization (.type_name# "natural")) - (in (code#natural (as Natural value))) + (in (code#natural (as (-> Any Natural) value))) (.text_=# name_of_specialization (.type_name# "integer")) - (in (code#integer (as Integer value))) + (in (code#integer (as (-> Any Integer) value))) (.text_=# name_of_specialization (.type_name# "revolution")) - (in (code#revolution (as Revolution value))) + (in (code#revolution (as (-> Any Revolution) value))) ... else (failure ..not_a_static_value)) @@ -3371,12 +3368,12 @@ (the' .public (pattern it) (-> Macro Pattern) - (as Pattern it)) + (as (-> Macro Pattern) it)) (the' .public (pattern_macro it) (-> Pattern Macro') - (as Macro' it)) + (as (-> Pattern Macro') it)) (the' .private (total_expansion' total_expansion @name name args) (-> (-> Code ($ Meta ($ List Code))) Provenance Name ($ List Code) @@ -3386,7 +3383,7 @@ (meta#let lux [?macro (named_macro name')]) (.when# ?macro {#Some macro} - (<| (meta#let lux [expansion ((as Macro' macro) args)]) + (<| (meta#let lux [expansion ((as (-> Macro Macro') macro) args)]) (meta#let lux [expansion' (monad#each#meta total_expansion (list#as_stack expansion))]) (meta#return lux (list#of_stack (stack#conjoint (stack#each list#as_stack expansion'))))) @@ -3448,7 +3445,7 @@ {#Some [type value]} (if (type#= Pattern type) (do meta#monad - [branches'' ((pattern_macro (as Pattern value)) + [branches'' ((pattern_macro (as (-> Any Pattern) value)) (list#of_stack (stack#partial (code#form (list#of_stack parameters)) body branches')))] (when_expansion (list#as_stack branches''))) @@ -4079,7 +4076,7 @@ ..#module_state _] =module]] (when (property#value name definitions) {#Some [exported {#Definition [type value]}]} - (meta#in [exported (as Label value)]) + (meta#in [exported (as (-> Any Label) value)]) _ (failure (.text_composite# "Unknown slot: " (name#as [module name])))))) @@ -4105,7 +4102,7 @@ (if (and (type#= Slot type) (or exported? (.text_=# expected_module actual_module))) - (let [[label actual_record] (as Label value)] + (let [[label actual_record] (as (-> Any Label) value)] (if (type#= expected_record actual_record) {#Some (when label {#Some [lefts right? family]} @@ -4145,8 +4142,8 @@ {#Some [exported? {#Definition [type value]}]} (if (type#= Type type) (do meta#monad - [slots (slot_family module (as Type value))] - (when [slots (interface_methods (as Type value))] + [slots (slot_family module (as (-> Any Type) value))] + (when [slots (interface_methods (as (-> Any Type) value))] [{#Some slots} {#Some members}] (in {#Some [slots members]}) @@ -4163,12 +4160,19 @@ (the expected_type (Meta Type) (function (_ state) - (let [[..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#seed seed - ..#expected expected ..#provenance provenance ..#eval _eval] state] + (let [[..#info info + ..#source source + ..#current_module _ + ..#modules modules + ..#scopes scopes + ..#type_context types + ..#seed seed + ..#expected expected + ..#provenance provenance + ..#eval _eval] state] (when expected {#Some type} - {#Right state type} + {#Right [state type]} {#None} {#Left "Not expecting any type."})))) @@ -4440,8 +4444,7 @@ (when (stack#reversed labels) (stack single) (stack (` (the (, export_policy) (, (code#local single)) - (<| (as (, label_type)) - (is Label) + (<| (as (-> Label (, label_type))) [{#None} (, associated_type)])))) (stack#partial right lefts) @@ -4452,13 +4455,11 @@ (` [(, (code#text module)) (, (code#text it))])) labels)))))) (` (the (, export_policy) (, (code#local right)) - (<| (as (, label_type)) - (is Label) + (<| (as (-> Label (, label_type))) [{#Some [(, (code#natural (.i64_-# 1 (stack#size lefts)))) #1 (, family)]} (, associated_type)]))) (stack#each (function (_ [lefts it]) (` (the (, export_policy) (, (code#local it)) - (<| (as (, label_type)) - (is Label) + (<| (as (-> Label (, label_type))) [{#Some [(, (code#natural lefts)) #0 (, family)]} (, associated_type)])))) (enumeration (stack#reversed lefts)))) @@ -4915,8 +4916,8 @@ ((is (-> Natural (Maybe Type)) (function (type_variable item) - (if (.int_<# (as Integer limit) - (as Integer item)) + (if (.int_<# (as (-> Natural Integer) limit) + (as (-> Natural Integer) item)) (let [[actual bound] (.list_item# item context)] (if (.i64_=# expected actual) bound @@ -5753,7 +5754,7 @@ (list expr) (do meta#monad [type ..expected_type] - (in (list (` (.as# (, (type_code type)) + (in (list (` (.as# (-> Any (, (type_code type))) (, expr)))))) _ @@ -5873,10 +5874,9 @@ (with_template [ ] [(the .public (template#macro - ( it) - [(..|> it - (..is (..I64 ..Any)) - (..as ))]))] + ( ,it) + [(..as (-> (..I64 ..Any) ) + ,it)]))] [i64 ..I64] [natural ..Natural] @@ -5901,13 +5901,16 @@ _ {#Left ..wrong_syntax}))) +(the Eval + (.type# "eval")) + (the (eval type code) (-> Type Code (Meta Any)) (do meta#monad [eval (function (_ lux) - {#Right [lux (.as# (.type# "eval") - (its #eval lux))]})] + {#Right [lux (as (-> Any Eval) + (its #eval lux))]})] (eval type code))) (every .public Target @@ -5940,7 +5943,7 @@ (function (_ it) (do meta#monad [it (eval Target it)] - (in (as Target it))))) + (in (as (-> Any Target) it))))) target_pick (is (-> Text (Stack [Code Code]) (Maybe Code) (Meta (List Code))) (function (target_pick target options default) @@ -6003,12 +6006,12 @@ (the immediate_unquote (-> Macro Immediate_UnQuote) - (|>> (as Immediate_UnQuote))) + (|>> (as (-> Macro Immediate_UnQuote)))) (the immediate_unquote_macro (-> Immediate_UnQuote Macro') - (|>> (as Macro'))) + (|>> (as (-> Immediate_UnQuote Macro')))) (the .public ,, (..immediate_unquote @@ -6058,7 +6061,7 @@ {#Right [type value]} (if (type#= ..Immediate_UnQuote type) (do meta#monad - [bound ((immediate_unquote_macro (as Immediate_UnQuote value)) (list#of_stack parameters)) + [bound ((immediate_unquote_macro (as (-> Any Immediate_UnQuote) value)) (list#of_stack parameters)) 'expansion (..generated_name "'expansion")] (in [(.list_composite# (list 'expansion) bound) 'expansion])) @@ -6084,7 +6087,7 @@ (do meta#monad [=raw (..embedded_expansions raw) .let [[labels labelled] =raw]] - ((as Macro' ..expansion#let) + ((as (-> Macro Macro') ..expansion#let) (list (code#tuple labels) labelled))) diff --git a/stdlib/source/library/lux/compiler/default/platform.lux b/stdlib/source/library/lux/compiler/default/platform.lux index 4097db4fc2..2e6c4bcf2d 100644 --- a/stdlib/source/library/lux/compiler/default/platform.lux +++ b/stdlib/source/library/lux/compiler/default/platform.lux @@ -97,8 +97,7 @@ ... TODO: Get rid of this (the monad - (as (Monad Action) - (try.with future.monad))) + (try.with future.monad)) (expansion.let [ (these (Platform )) (these (///declaration.State ))] @@ -672,7 +671,9 @@ (console.write_line module console))) )) .let [entry (has [archive.#module moduleM.#descriptor descriptor.#references] all_dependencies entry)] - _ (..cache_module context platform @module $.key $.as_binary (as (archive.Entry @type.Module) entry))] + _ (..cache_module context platform @module $.key $.as_binary (as (-> (archive.Entry Any) + (archive.Entry @type.Module)) + entry))] (future#in (do try.monad [archive (archive.has module entry archive)] (in [archive state]))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux index 32396a89dc..64a70eac0d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux @@ -224,7 +224,8 @@ (by check.monad in [(stack) (..quantified envs type)])))) (the (simple_pattern_analysis type :input: provenance output next) - (for_any (_ a) (-> Type Type Provenance Pattern (Operation a) (Operation [Pattern a]))) + (for_any (_ a) + (-> Type Type Provenance Pattern (Operation a) (Operation [Pattern a]))) (/.with_provenance provenance (do phase.monad [_ (/type.check (check.check :input: type)) @@ -232,9 +233,9 @@ (in [output outputA])))) (the (tuple_pattern_analysis pattern_analysis :input: sub_patterns next) - (for_any (_ a) - (-> (-> Type @type.Code (Operation a) (Operation [Pattern a])) - Type (Stack @type.Code) (Operation a) (Operation [Pattern a]))) + (for_any (_ it) + (-> (-> Type @type.Code (Operation it) (Operation [Pattern it])) + (-> Type (Stack @type.Code) (Operation it) (Operation [Pattern it])))) (do [! phase.monad] [[@ex_var+ :input:'] (/type.check (..tuple :input:))] (.when :input:' @@ -267,7 +268,10 @@ (Operation [(Stack Pattern) a]))) (function (_ [memberT memberC] then) (do ! - [[memberP [memberP+ thenA]] ((as (for_any (_ a) (-> Type @type.Code (Operation a) (Operation [Pattern a]))) + [[memberP [memberP+ thenA]] ((as (-> Any + (for_any (_ a) + (-> Type @type.Code (Operation a) + (Operation [Pattern a])))) pattern_analysis) memberT memberC then)] (in [(stack.partial memberP memberP+) thenA])))) @@ -301,7 +305,10 @@ (Operation [(Stack Pattern) it]))) (function (_ item then) (do ! - [[head [tail thenA]] ((as (for_any (_ a) (-> Type @type.Code (Operation a) (Operation [Pattern a]))) + [[head [tail thenA]] ((as (-> Any + (for_any (_ a) + (-> Type @type.Code (Operation a) + (Operation [Pattern a])))) pattern_analysis) type_of_item item then)] (in [(stack.partial head tail) thenA])))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux index c165c44639..ea85a4c3eb 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux @@ -116,7 +116,8 @@ [(its [/.#translation /.#state] state) (its [/.#translation /.#phase] state)]) archive) - extension_eval (as @type.Eval (wrapper (as_expected compiler_eval))) + extension_eval (as (-> Any @type.Eval) + (wrapper (as_expected compiler_eval))) failure (do ! [here (<| /.of_analysis module.current_name)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux index dfa4bcb721..d5ece38774 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -968,7 +968,8 @@ (java/lang/Class::getModifiers []) [] java/lang/reflect/Modifier::isInterface ffi.of_boolean) - (list#composite (list (as java/lang/reflect/Type (ffi.class_for java/lang/Object))) + (list#composite (list (as (-> Any java/lang/reflect/Type) + (ffi.class_for java/lang/Object))) (list.of_array {.#None} (java/lang/Class::getGenericInterfaces [] from_class))) (list.of_array {.#None} (java/lang/Class::getGenericInterfaces [] from_class))))))) @@ -1175,8 +1176,8 @@ {#Interface})) (the (de_aliased aliasing) - (-> Aliasing (Type Value) - (Type Value)) + (-> Aliasing + (Change (Type Value))) (function (again it) (`` (<| (when (projection.var? it) {.#Some name} @@ -1189,14 +1190,14 @@ (when (projection.class? it) {.#Some [parameters name]} (|> parameters - (list#each (|>> again (as (Type Parameter)))) + (list#each (|>> again (as (-> (Type Value) (Type Parameter))))) (|.let parameters (jvm.class parameters name))) {.#None}) (,, (template.with [ ] [(when ( it) {.#Some :sub:} - ( (as (Type ) (again :sub:))) + ( (as (-> (Type Value) (Type )) (again :sub:))) {.#None})] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux index 8f943f0b41..06e5ed712c 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux @@ -220,8 +220,8 @@ (.function (_ extension_name analysis archive [module 'expression]) (do [! phase.monad] [module (eval archive @type.Text module)] - (analysis.with_current_module (as Text module) - (analysis archive (code.with [(as Text module) 0 0] 'expression)))))])) + (analysis.with_current_module (as (-> Any Text) module) + (analysis archive (code.with [(as (-> Any Text) module) 0 0] 'expression)))))])) (the .public (is#_extension eval) (-> Eval @@ -230,7 +230,7 @@ [(?.and ?list.any ?list.any) (.function (_ extension_name analysis archive [typeC valueC]) (do [! phase.monad] - [actualT (by ! each (|>> (as @type.Type)) + [actualT (by ! each (|>> (as (-> Any @type.Type))) (eval archive @type.Type typeC)) _ (typeA.inference actualT)] (<| (typeA.expecting actualT) @@ -241,29 +241,17 @@ Handler) (..custom [(?.and ?list.any ?list.any) - (.function (_ extension_name analysis archive [typeC valueC]) + (.function (_ extension_name analysis archive [typeC it]) (do [! phase.monad] - [actualT (eval archive @type.Type typeC) - _ (typeA.inference (as @type.Type actualT)) - [valueT valueA] (typeA.inferring (analysis archive valueC))] - (in valueA)))])) - -... (the .public (as#_extension eval) -... (-> Eval -... Handler) -... (..custom -... [(?.and ?list.any ?list.any) -... (.function (_ extension_name analysis archive [typeC it]) -... (do [! phase.monad] -... [coercion (eval archive @type.Type typeC) -... [actual_type it] (inference.general archive analysis (as @type.Type coercion) (stack it)) -... _ (typeA.inference actual_type)] -... (.when it -... (stack it) -... (in it) - -... _ -... (undefined))))])) + [coercion (eval archive @type.Type typeC) + [actual_type it] (inference.general archive analysis (as (-> Any @type.Type) coercion) (stack it)) + _ (typeA.inference actual_type)] + (.when it + (stack it) + (in it) + + _ + (undefined))))])) (exception.the .public (cannot_access_global [from global]) (Exception [Text Name]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux index 463655f633..370371c27f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux @@ -209,7 +209,7 @@ _ (undefined))] _ (<| /////declaration.of_analysis - (module.define short_name [(as .Bit exported?) {@type.#Alias original}]))] + (module.define short_name [(as (-> Any .Bit) exported?) {@type.#Alias original}]))] (in /////declaration.no_requirements)) _ @@ -221,7 +221,7 @@ [type valueT value] (..definition archive full_name valueC) [_ _ exported?] (evaluate! archive @type.Bit exported?C) _ (<| /////declaration.of_analysis - (module.define short_name [(as Bit exported?) {@type.#Definition [type value]}]))] + (module.define short_name [(as (-> Any Bit) exported?) {@type.#Definition [type value]}]))] (in /////declaration.no_requirements))))])) (the imports diff --git a/stdlib/source/library/lux/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/compiler/language/lux/syntax.lux index 9908ca6325..2e87311509 100644 --- a/stdlib/source/library/lux/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/compiler/language/lux/syntax.lux @@ -112,10 +112,11 @@ (template.with [ ] [(the (template.macro (_ expected actual) - [( expected actual)]))] + [( (as (-> Natural Integer) expected) + (as (-> Natural Integer) actual))]))] [!n/= .i64_=#] - [!i/< .int_<#] + [!n/< .int_<#] ) (template.with [ ] @@ -350,8 +351,7 @@ (the with_character (template.macro (_ the_globals offset character else body) - [(if (!i/< (as Integer @size) - (as Integer offset)) + [(if (!n/< @size offset) (let [character (.text_char# offset @code)] body) else)])) diff --git a/stdlib/source/library/lux/concurrency/atom.lux b/stdlib/source/library/lux/concurrency/atom.lux index 53543ce3cc..1316748dac 100644 --- a/stdlib/source/library/lux/concurrency/atom.lux +++ b/stdlib/source/library/lux/concurrency/atom.lux @@ -19,32 +19,36 @@ ["[0]" nominal] ["[0]" variance (.only Mutable)]]]]) -(for .jvm (ffi.import (java/util/concurrent/atomic/AtomicReference a) - "[1]::[0]" - (new [a]) - (get [] a) - (compareAndSet [a a] boolean)) +(for .jvm (ffi.import (java/util/concurrent/atomic/AtomicReference it) + "[1]::[0]" + (new [it]) + (get [] it) + (compareAndSet [it it] boolean)) (these)) -(nominal.every .public (Atom'' a) - (for .jvm (java/util/concurrent/atomic/AtomicReference a) - (array.Array a)) +(nominal.every .public (Atom'' it) + (for .jvm (java/util/concurrent/atomic/AtomicReference it) + (array.Array it)) (every .public (Atom' r w) (Atom'' (Mutable r w))) - (every .public (Atom a) - (Atom'' (Mutable a a))) + (every .public (Atom it) + (Atom' it it)) (the .public (atom value) - (for_any (_ a) (-> a (Atom a))) + (for_any (_ it) + (-> it + (Atom it))) (nominal.abstraction (for .jvm (as_expected (java/util/concurrent/atomic/AtomicReference::new [value])) (array.has! 0 (variance.write value) (array.empty 1))))) (the .public (read! atom) - (for_any (_ r w) (-> (Atom' r w) (IO r))) - (io.io (for .jvm (java/util/concurrent/atomic/AtomicReference::get [] (nominal.reification atom)) + (for_any (_ r w) + (-> (Atom' r w) + (IO r))) + (io.io (for .jvm (as_expected (java/util/concurrent/atomic/AtomicReference::get [] (nominal.reification atom))) (variance.read (array.item 0 (nominal.reification atom)))))) (the .public (compare_and_swap! current new atom) @@ -55,10 +59,10 @@ (array.item 0) variance.read (same? current)) - (exec - (array.has! 0 (variance.write new) (nominal.reification atom)) - true) - false)))) + (exec + (array.has! 0 (variance.write new) (nominal.reification atom)) + true) + false)))) ) (the .public (update! f atom) @@ -69,8 +73,8 @@ .let [new (f old)] swapped? (compare_and_swap! old new atom)] (if swapped? - (in [old new]) - (again []))))) + (in [old new]) + (again []))))) (the .public (write! value atom) (for_any (_ r w) (-> w (Atom' r w) (IO r))) diff --git a/stdlib/source/library/lux/concurrency/frp.lux b/stdlib/source/library/lux/concurrency/frp.lux index ab0d4f5fbc..39feeaa3ba 100644 --- a/stdlib/source/library/lux/concurrency/frp.lux +++ b/stdlib/source/library/lux/concurrency/frp.lux @@ -20,7 +20,7 @@ [math [number ["n" natural]]] - ["[0]" type (.only sharing)]]] + [type (.only sharing)]]] [// [thread (.only Delay)] ["[0]" atom (.only Atom)] @@ -148,17 +148,20 @@ (in (is Any (io.value (by sink close)))))))) output))))) -(every .public (Subscriber a) - (-> a (IO (Maybe Any)))) +(every .public (Subscriber it) + (-> it + (IO (Maybe Any)))) (the .public (subscribe! subscriber it) - (for_any (_ r w) (-> (Subscriber r) (Channel' r w) (IO Any))) + (for_any (_ r w) + (-> (Subscriber r) (Channel' r w) + (IO Any))) (io (exec (is (Future Any) - (loop (again [it (type.as [r w] - (Channel' r w) - (Channel r) - it)]) + (loop (again [it (as (for_any (_ r w) + (-> (Channel' r w) + (Channel r))) + it)]) (do future.monad [item it] (when item diff --git a/stdlib/source/library/lux/concurrency/stm.lux b/stdlib/source/library/lux/concurrency/stm.lux index 34e46d58d0..ead493c208 100644 --- a/stdlib/source/library/lux/concurrency/stm.lux +++ b/stdlib/source/library/lux/concurrency/stm.lux @@ -125,8 +125,8 @@ (Maybe read))) (|> tx (stack.example (function (_ [_var _original _current]) - (same? (as (Var Any) var) - (as (Var Any) _var)))) + (same? (as (-> Any (Var Any)) var) + (as (-> Any (Var Any)) _var)))) (by maybe.monad each (function (_ [_var _original _current]) _current)) as_expected)) @@ -157,8 +157,8 @@ {.#Empty} {.#Top [_var _original _current] tx'} - (if (same? (as (Var Any) var) - (as (Var Any) _var)) + (if (same? (as (-> Any (Var Any)) var) + (as (-> Any (Var Any)) _var)) {.#Top [#var _var #original _original #current (as_expected value)] @@ -214,7 +214,8 @@ (-> (for_some (_ read write) (Tx_Frame read write)) (IO Any)) - (if (same? (as Any _original) (as Any _current)) + (if (same? (as (-> Any Any) _original) + (as (-> Any Any) _current)) (io []) (..write! _current _var))) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 707ccc957e..ed91b009cb 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -16,25 +16,30 @@ [collection ["[0]" list (.use "[1]#[0]" mix monoid)]]]]]) -(every (Cleaner r !) - (-> r - (! (Try Any)))) +(every (Cleaner context + region) + (-> region + (context (Try Any)))) -(every .public (Region r ! a) - (-> [r (List (Cleaner r !))] - (! [(List (Cleaner r !)) - (Try a)]))) +(every .public (Region context it + region) + (-> [region (List (Cleaner context region))] + (context [(List (Cleaner context region)) + (Try it)]))) ... https://en.wikipedia.org/wiki/Delimiter (the delimiter Text - (text \n "-----------------------------------------" - \n "-----------------------------------------" - \n "-----------------------------------------" - \n \n)) + (let [line (text \n "-----------------------------------------") + space (text \n \n)] + (text line + line + line + space))) (exception.the .public (clean_up_error [error output]) - (for_any (_ a) (Exception [Text (Try a)])) + (for_any (_ it) + (Exception [Text (Try it)])) (text error (when output {try.#Success _} @@ -45,7 +50,9 @@ error|output)))) (the (clean clean_up output) - (for_any (_ a) (-> (Try Any) (Try a) (Try a))) + (for_any (_ it) + (-> (Try Any) + (Change (Try it)))) (when clean_up {try.#Success _} output @@ -54,9 +61,9 @@ (exception.except ..clean_up_error [error output]))) (the .public (value monad computation) - (for_any (_ ! a) - (-> (Monad !) (for_any (_ r) (Region r ! a)) - (! (Try a)))) + (for_any (_ context it) + (-> (Monad context) (Region context it) + (context (Try it)))) (do [! monad] [[cleaners output] (computation [[] (list)])] (|> cleaners @@ -64,18 +71,18 @@ (by ! each (list#mix clean output))))) (the .public (acquire! monad cleaner value) - (for_any (_ ! it) - (-> (Monad !) (-> it (! (Try Any))) it - (for_any (_ %) (Region % ! it)))) + (for_any (_ context it) + (-> (Monad context) (-> it (context (Try Any))) it + (Region context it))) (function (_ [region cleaners]) (by monad in [(list#composite cleaners (list (function (_ region) (cleaner value)))) {try.#Success value}]))) (the .public (functor super) - (for_any (_ !) - (-> (Functor !) - (for_any (_ r) (Functor (Region r !))))) + (for_any (_ context) + (-> (Functor context) + (Functor (Region context)))) (implementation (the (each f) (function (_ fa) @@ -91,9 +98,9 @@ (fa region+cleaners))))))) (the .public (monad super) - (for_any (_ !) - (-> (Monad !) - (for_any (_ r) (Monad (Region r !))))) + (for_any (_ context) + (-> (Monad context) + (Monad (Region context)))) (implementation (the functor (..functor (its monad.functor super))) @@ -114,24 +121,24 @@ (in [cleaners {try.#Failure error}]))))))) (the .public (failure monad error) - (for_any (_ !) - (-> (Monad !) Text - (for_any (_ r) - (Region r !)))) + (for_any (_ context) + (-> (Monad context) Text + (Region context))) (function (_ [region cleaners]) (by monad in [cleaners {try.#Failure error}]))) (the .public (except monad exception message) - (for_any (_ ! e a) - (-> (Monad !) (Exception e) e - (for_any (_ r) (Region r ! a)))) + (for_any (_ context e it) + (-> (Monad context) (Exception e) e + (Region context it))) (failure monad (exception.error exception message))) (the .public (lifted monad operation) - (for_any (_ ! a) - (-> (Monad !) (! a) - (for_any (_ r) (Region r ! a)))) + (for_any (_ context it) + (-> (Monad context) (context it) + (Region context it))) (function (_ [region cleaners]) (by monad each - (|>> {try.#Success} [cleaners]) + (|>> {try.#Success} + [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/scope/dynamic.lux b/stdlib/source/library/lux/control/scope/dynamic.lux index 1d329061b7..f6b96b21dd 100644 --- a/stdlib/source/library/lux/control/scope/dynamic.lux +++ b/stdlib/source/library/lux/control/scope/dynamic.lux @@ -63,7 +63,7 @@ [(, (code.text here)) (, (code.text name))])] (|>> ((debug.private ..of_bindings)) (dictionary.value (, 'token)) - (as (Maybe (, type))) + (as (-> Any (Maybe (, type)))) (maybe.else (, 'default))))))))))) (.the (let' name value _ term) diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index ee814a95e9..eb3a5356f5 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -17,36 +17,43 @@ ["[0]" nominal] ["[0]" variance (.only Mutable)]]]]) -(every .public (Thread ! a) - (-> ! a)) +(every .public (Thread thread it) + (-> thread + it)) -(nominal.every (Box'' t a) - (Array a) +(nominal.every (Box' thread r w) + (Array (Mutable r w)) - (every .public (Box' t r w) - (Box'' t (Mutable r w))) - - (every .public (Box t a) - (Box'' t (Mutable a a))) + (every .public (Box thread it) + (Box' thread it it)) (the .public (box init) - (for_any (_ a) (-> a (for_any (_ !) (Thread ! (Box ! a))))) - (function (_ !) + (for_any (_ it) + (-> it + (for_any (_ thread) + (Thread thread (Box thread it))))) + (function (_ thread) (|> (array.empty 1) (array.has! 0 (variance.write init)) nominal.abstraction))) (the .public (read! box) - (for_any (_ ! r w) (-> (Box' ! r w) (Thread ! r))) - (function (_ !) + (for_any (_ thread to_read to_write) + (-> (Box' thread to_read to_write) + (Thread thread to_read))) + (function (_ thread) (|> box nominal.reification (array.item 0) variance.read))) (the .public (write! value box) - (for_any (_ r w) (-> w (for_any (_ !) (-> (Box' ! r w) (Thread ! Any))))) - (function (_ !) + (for_any (_ to_read to_write) + (-> to_write + (for_any (_ thread) + (-> (Box' thread to_read to_write) + (Thread thread Any))))) + (function (_ thread) (|> box nominal.reification (array.has! 0 (variance.write value)) @@ -54,42 +61,49 @@ ) (the .public (value thread) - (for_any (_ a) - (-> (for_any (_ !) (Thread ! a)) - a)) - (thread [])) + (for_any (_ it thread) + (-> (Thread thread it) + it)) + (thread (as_expected []))) (the .public io - (for_any (_ a) - (-> (for_any (_ !) (Thread ! a)) - (IO a))) - (|>> ..value io.io)) + (for_any (_ it thread) + (-> (Thread thread it) + (IO it))) + (|>> ..value + io.io)) (the .public functor - (for_any (_ !) (Functor (Thread !))) + (for_any (_ thread) + (Functor (Thread thread))) (implementation (the (each f) (function (_ fa) - (function (_ !) - (f (fa !))))))) + (function (_ thread) + (f (fa thread))))))) (the .public monad - (for_any (_ !) (Monad (Thread !))) + (for_any (_ thread) + (Monad (Thread thread))) (implementation (the functor ..functor) (the (in value) - (function (_ !) + (function (_ thread) value)) (the (conjoint ffa) - (function (_ !) - ((ffa !) !))))) + (function (_ thread) + ((ffa thread) thread))))) -(the .public (update! f box) - (for_any (_ ! r w) (-> (-> r w) (Box' ! r w) (Thread ! [r w]))) +(the .public (update! change box) + (for_any (_ to_read to_write) + (-> (-> to_read to_write) + (for_any (_ thread) + (-> (Box' thread to_read to_write) + (Thread thread [to_read to_write]))))) (do ..monad [old (read! box) - .let [new (f old)] + .let [new (change old)] _ (write! new box)] (in [old new]))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index b6f56f8e58..e777cbad4f 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -48,7 +48,9 @@ (the .public empty Queue - (nominal.abstraction {.#None})) + (|> {.#None} + nominal.abstraction + (as (-> (Queue Any) Queue)))) (the .public it_is_empty Error diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 4627f7fbb0..3d226c9543 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -45,7 +45,9 @@ (the .public empty Markdown - (nominal.abstraction "")) + (|> "" + nominal.abstraction + (as (-> (Markdown Any) Markdown)))) (the .public text (-> Text diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 160192bcde..bdd198e42b 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -272,26 +272,26 @@ {.#None} (.text_composite# left right)))]) (for .jvm - (as Text + (as (-> (Nominal "java.lang.String") Text) (.jvm_member_invoke_virtual# [] "java.lang.String" "replace" [] - (as (Nominal "java.lang.String") template) - ["Ljava/lang/CharSequence;" (as (Nominal "java.lang.CharSequence") pattern)] - ["Ljava/lang/CharSequence;" (as (Nominal "java.lang.CharSequence") replacement)])) + (as (-> Text (Nominal "java.lang.String")) template) + ["Ljava/lang/CharSequence;" (as (-> Text (Nominal "java.lang.CharSequence")) pattern)] + ["Ljava/lang/CharSequence;" (as (-> Text (Nominal "java.lang.CharSequence")) replacement)])) .js ... TODO: Remove this when Nashorn is no longer being used. (..if_nashorn - (as Text + (as (-> Any Text) (.js_object_do# "replaceAll" template [pattern replacement]))) .python - (as Text + (as (-> Any Text) (.python_object_do# "replace" template [pattern replacement])) ... TODO .lua .ruby - (as Text + (as (-> Any Text) (.ruby_object_do# "gsub" template [pattern replacement])) .php - (as Text + (as (-> Any Text) ("php apply" (as_expected ("php constant" "str_replace")) pattern replacement template)) ... TODO .common_lisp @@ -335,12 +335,11 @@ (the (hash input) (for .jvm (|> input - (as (Nominal "java.lang.Object")) + (as (-> Any (Nominal "java.lang.Object"))) (.jvm_member_invoke_virtual# [] "java.lang.Object" "hashCode" []) .jvm_conversion_int_to_long# .jvm_object_cast# - (is (Nominal "java.lang.Long")) - (as Natural)) + (as (-> (Nominal "java.lang.Long") Natural))) ... Platform-independent default. (let [length (.text_size# input)] (loop (again [index 0 @@ -406,37 +405,47 @@ (the .public (lower_cased value) (Change Text) (for .jvm - (as Text - (.jvm_member_invoke_virtual# [] "java.lang.String" "toLowerCase" [] - (as (Nominal "java.lang.String") value))) + (|> value + (as (-> Text (Nominal "java.lang.String"))) + (.jvm_member_invoke_virtual# [] "java.lang.String" "toLowerCase" []) + (as (-> (Nominal "java.lang.String") Text))) + .js - (as Text + (as (-> Any Text) (.js_object_do# "toLowerCase" value [])) + .python - (as Text + (as (-> Any Text) (.python_object_do# "lower" value [])) + .lua - (as Text + (as (-> Any Text) (.lua_apply# (.lua_constant# "string.lower") [value])) + .ruby - (as Text + (as (-> Any Text) (.ruby_object_do# "downcase" value [])))) (the .public (upper_cased value) (Change Text) (for .jvm - (as Text - (.jvm_member_invoke_virtual# [] "java.lang.String" "toUpperCase" [] - (as (Nominal "java.lang.String") value))) + (|> value + (as (-> Text (Nominal "java.lang.String"))) + (.jvm_member_invoke_virtual# [] "java.lang.String" "toUpperCase" []) + (as (-> (Nominal "java.lang.String") Text))) + .js - (as Text + (as (-> Any Text) (.js_object_do# "toUpperCase" value [])) + .python - (as Text + (as (-> Any Text) (.python_object_do# "upper" value [])) + .lua - (as Text + (as (-> Any Text) (.lua_apply# (.lua_constant# "string.upper") [value])) + .ruby - (as Text + (as (-> Any Text) (.ruby_object_do# "upcase" value [])))) diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index 3e34ef9ba5..459f854ae0 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -87,7 +87,7 @@ then! (is (-> Text java/lang/StringBuilder java/lang/StringBuilder) (function (_ chunk builder) (exec - (java/lang/Appendable::append [(as java/lang/CharSequence chunk)] + (java/lang/Appendable::append [(as (-> Text java/lang/CharSequence) chunk)] builder) builder)))] (nominal.abstraction diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index c78cd28dcf..64e6825a72 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -118,8 +118,7 @@ (.type (text.Injection Any))) (for .lua (the (tuple_array tuple) - (-> (array.Array Any) - (array.Array Any)) + (Change (array.Array Any)) (array.of_stack (loop (again [idx 0]) (let [member (.lua_array_read# idx tuple)] @@ -129,11 +128,10 @@ (these)) (the (tuple_inspection inspection) - (-> Inspector - Inspector) + (Change Inspector) (expansion.let [ (for .lua (,, (these ..tuple_array)) (,, (these)))] - (`` (|>> (as (array.Array Any)) + (`` (|>> (as (-> Any (array.Array Any))) (list.of_array {.#None}) (list#each inspection) @@ -150,7 +148,7 @@ (-> Any (Try ,lux_type)) (if (for .jvm - (when (ffi.as ,jvm_class (as java/lang/Object it)) + (when (ffi.as ,jvm_class (as (-> Any java/lang/Object) it)) {.#Some it} true @@ -193,7 +191,7 @@ (expansion.let [,constants (template.spliced ,ruby_constants)] (template.let [(class ) [(|> - (as ..Object) + (as (-> Any ..Object)) (Object::class []))]] (let [it_class (class it)] (`` (or (,, (template.with [] @@ -204,7 +202,7 @@ .php (text.= ,php_type (php_type it))) - {try.#Success (as ,lux_type it)} + {try.#Success (as (-> Any ,lux_type) it)} (exception.except ..not_of_type [,lux_type])))] [bit .Bit java/lang/Boolean "boolean" [] [[""] [""]] "boolean" [] [[#0] [#1]] "boolean"] @@ -220,7 +218,7 @@ (for .jvm (when (ffi.as [java/lang/Object] it) {.#Some it} - (let [it (as (array.Array java/lang/Object) it)] + (let [it (as (-> Any (array.Array java/lang/Object)) it)] (when (array.item 0 it) (^.multi {try.#Success tag} [(ffi.as java/lang/Integer tag) @@ -248,7 +246,7 @@ (if (not (or (.js_object_undefined?# lefts) (.js_object_undefined?# right?) (.js_object_undefined?# choice))) - {try.#Success [(.natural (d.integer (as Decimal lefts))) + {try.#Success [(.natural (d.integer (as (-> Any Decimal) lefts))) (not (.js_object_null?# right?)) choice]} @@ -262,7 +260,7 @@ (let [tag (python_text (python_type it))] (if (or (text.= "" tag) (text.= "" tag)) - (let [variant (as (array.Array Any) it)] + (let [variant (as (-> Any (array.Array Any)) it)] (when (array.size variant) 3 (let [lefts (.python_array_read# 0 variant) @@ -270,7 +268,7 @@ choice (.python_array_read# 2 variant)] (if (not (or (.python_object_none?# lefts) (.python_object_none?# choice))) - {try.#Success [(as .Natural lefts) + {try.#Success [(as (-> Any .Natural) lefts) (|> right? .python_object_none?# not) choice]} ,failure)) @@ -287,7 +285,7 @@ choice (`` (.lua_object_get# (,, (static script.variant_choice)) it))] (if (not (or (.lua_object_nil?# lefts) (.lua_object_nil?# choice))) - {try.#Success [(as .Natural lefts) + {try.#Success [(as (-> Any .Natural) lefts) (|> right? .lua_object_nil?# not) choice]} ,failure)) @@ -298,7 +296,7 @@ .ruby (template.let [(class_of ) [(|> - (as ..Object) + (as (-> Any ..Object)) (Object::class []))] (field ,field) @@ -310,7 +308,7 @@ choice (field script.variant_choice)] (if (not (or (.ruby_object_nil?# lefts) (.ruby_object_nil?# choice))) - {try.#Success [(as .Natural lefts) + {try.#Success [(as (-> Any .Natural) lefts) (|> right? .ruby_object_nil?# not) choice]} ,failure)) @@ -324,7 +322,7 @@ choice (`` (.php_object_get# (,, (static script.variant_choice)) it))] (if (not (or (.php_object_null?# lefts) (.php_object_null?# choice))) - {try.#Success [(as .Natural lefts) + {try.#Success [(as (-> Any .Natural) lefts) (|> right? .php_object_null?# not) choice]} ,failure)) @@ -337,7 +335,7 @@ (-> Any (Try ,type)) (if (for .jvm - (when (ffi.as [java/lang/Object] (as java/lang/Object it)) + (when (ffi.as [java/lang/Object] (as (-> Any java/lang/Object) it)) {.#Some _} (when (variant it) {try.#Failure _} @@ -378,14 +376,14 @@ .ruby (template.let [(class_of ) [(|> - (as ..Object) + (as (-> Any ..Object)) (Object::class []))]] (same? (class_of [[] []]) (class_of it))) .php (text.= "array" (php_type it))) - {try.#Success (as ,type it)} + {try.#Success (as (-> Any ,type) it)} (exception.except ..not_of_type [(type ,type)])))) (the .public (inspection it) @@ -418,7 +416,7 @@ ... else (for .jvm (|> it - (as java/lang/Object) + (as (-> Any java/lang/Object)) (java/lang/Object::toString []) ffi.of_string) @@ -433,7 +431,7 @@ .ruby (|> it - (as ..Object) + (as (-> Any ..Object)) (Object::to_s [])) .php @@ -457,7 +455,8 @@ (,, (template.with [ ] [(do <>.monad [_ (.sub )] - (in (|>> (as ) )))] + (in (|>> (as (-> Any )) + )))] [Bit bit.as_text] [Natural %.natural] @@ -474,7 +473,7 @@ (,, (template.with [ ] [(do <>.monad [_ (.sub )] - (in (|>> (as ) + (in (|>> (as (-> Any )) )))] [Fraction fraction.as_text] @@ -486,13 +485,13 @@ (do <>.monad [[_ elemT] (.reified (<>.and (.exactly List) .any)) elemR (.local (list elemT) representation)] - (in (|>> (as (List Any)) + (in (|>> (as (-> Any (List Any))) (list.as_text elemR)))) (do <>.monad [[_ elemT] (.reified (<>.and (.exactly Maybe) .any)) elemR (.local (list elemT) representation)] - (in (|>> (as (Maybe Any)) + (in (|>> (as (-> Any (Maybe Any))) (%.maybe elemR))))))) (the (variant_representation representation) @@ -506,7 +505,7 @@ variantV variantV]) (when representations {.#Top leftR {.#Top rightR extraR+}} - (when (as (Or Any Any) variantV) + (when (as (-> Any (Or Any Any)) variantV) {.#Left left} [lefts #0 (leftR left)] @@ -538,7 +537,7 @@ (lastR tupleV) {.#Top headR tailR} - (let [[leftV rightV] (as [Any Any] tupleV)] + (let [[leftV rightV] (as (-> Any (And Any Any)) tupleV)] (.text (headR leftV) " " (again tailR rightV)))))] (.text "[" tuple_body "]")))))) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 4aacd9d15f..2c34229722 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -1458,7 +1458,7 @@ class_type (` (.Nominal (, (code.text class_name)))) check_type (` (.Maybe (, class_type))) check_code (` (if (.jvm_object_instance?# (, (code.text class_name)) (, 'unchecked)) - {.#Some (.as (, class_type) + {.#Some (.as (-> Any (, class_type)) (, 'unchecked))} {.#None}))] (when unchecked @@ -1557,7 +1557,7 @@ ... else (let ['temp (` ((,' ,') (, (code.name ["" " Ω "]))))] (` (let [(, 'temp) (, return_term)] - (if (not (..null? (.as (.Nominal "java.lang.Object") + (if (not (..null? (.as (-> Any (.Nominal "java.lang.Object")) (, 'temp)))) (, 'temp) (halt! "Cannot produce null references from method calls.")))))) @@ -1620,14 +1620,14 @@ (` (.|> (, unboxed/boxed) (,* post))))))] [#1 with_automatic_input_conversion ..unbox - [[jvm.boolean (list (` (.as (.Nominal (, (code.text box.boolean)))))) []] - [jvm.byte (list (` (.as (.Nominal (, (code.text box.byte)))))) []] - [jvm.short (list (` (.as (.Nominal (, (code.text box.short)))))) []] + [[jvm.boolean (list (` (.as (-> Any (.Nominal (, (code.text box.boolean))))))) []] + [jvm.byte (list (` (.as (-> Any (.Nominal (, (code.text box.byte))))))) []] + [jvm.short (list (` (.as (-> Any (.Nominal (, (code.text box.short))))))) []] [jvm.int (list (` (.is (.Nominal (, (code.text box.int)))))) []] - [jvm.long (list (` (.as (.Nominal (, (code.text box.long)))))) []] - [jvm.char (list (` (.as (.Nominal (, (code.text box.char)))))) []] - [jvm.float (list (` (.as (.Nominal (, (code.text box.float)))))) []] - [jvm.double (list (` (.as (.Nominal (, (code.text box.double)))))) []]]] + [jvm.long (list (` (.as (-> Any (.Nominal (, (code.text box.long))))))) []] + [jvm.char (list (` (.as (-> Any (.Nominal (, (code.text box.char))))))) []] + [jvm.float (list (` (.as (-> Any (.Nominal (, (code.text box.float))))))) []] + [jvm.double (list (` (.as (-> Any (.Nominal (, (code.text box.double))))))) []]]] [#0 with_automatic_output_conversion ..box [[jvm.boolean (list) [(` (.is (.Nominal (, (code.text box.boolean)))))]] [jvm.byte (list) [(` (.is (.Nominal (, (code.text box.byte)))))]] @@ -1858,12 +1858,12 @@ Bit)) (|>> (.jvm_member_invoke_virtual# [] "java.lang.Class" "isInterface" []) .jvm_object_cast# - (.is ..Boolean) - (.as Bit))) + (.as (-> ..Boolean Bit)))) (the load_class - (-> external.Name (Try (.Nominal "java.lang.Class" [[#1 Any]]))) - (|>> (.as (.Nominal "java.lang.String")) + (-> external.Name + (Try (.Nominal "java.lang.Class" [[#1 Any]]))) + (|>> (.as (-> Any (.Nominal "java.lang.String"))) ["Ljava/lang/String;"] (.jvm_member_invoke_static# [] "java.lang.Class" "forName" []) try)) @@ -2027,8 +2027,8 @@ (in (list (` (.|> ((, 'extension) (, array)) .jvm_conversion_int_to_long# .jvm_object_cast# - (.is (.Nominal (, (code.text box.long)))) - (.as .Natural)))))) + (.as (-> (.Nominal (, (code.text box.long))) + .Natural))))))) _ (with_names ['array] @@ -2045,8 +2045,8 @@ context meta.type_context array_jvm_type (lux_type->jvm_type context array_type) .let ['idx (` (.|> (, idx) - (.is .Natural) - (.as (.Nominal (, (code.text box.long)))) + (.as (-> .Natural + (.Nominal (, (code.text box.long))))) .jvm_object_cast# .jvm_conversion_long_to_int#))]] (`` (if (,, (template.with [ ] @@ -2085,8 +2085,8 @@ context meta.type_context array_jvm_type (lux_type->jvm_type context array_type) .let ['idx (` (.|> (, idx) - (.is .Natural) - (.as (.Nominal (, (code.text box.long)))) + (.as (-> .Natural + (.Nominal (, (code.text box.long))))) .jvm_object_cast# .jvm_conversion_long_to_int#))]] (`` (if (,, (template.with [ ] @@ -2094,7 +2094,8 @@ (jvm.array ) array_jvm_type) (let ['value (` (.|> (, value) - (.as (.Nominal (, (code.text )))) + (.as (-> Any + (.Nominal (, (code.text ))))) .jvm_object_cast#))] (in (list (` ( (, 'idx) (, 'value) (, array))))))] @@ -2128,8 +2129,8 @@ [size (list)]) 'size (` (|> (, 'size) - (.is .Natural) - (.as (.Nominal (, (code.text box.long)))) + (.as (-> .Natural + (.Nominal (, (code.text box.long))))) .jvm_object_cast# .jvm_conversion_long_to_int#))] (in (list (list#mix (function (_ [index 'value] 'it) @@ -2147,9 +2148,9 @@ [jvm.double .jvm_array_new_double#] [jvm.char .jvm_array_new_char#])) ... else - (` (.as (array.Array (, (value_type {#ManualPrM} type))) - (.is (, (value_type {#ManualPrM} (jvm.array type))) - (.jvm_array_new_object# (, 'size))))))) + (` (.as (-> (, (value_type {#ManualPrM} (jvm.array type))) + (array.Array (, (value_type {#ManualPrM} type)))) + (.jvm_array_new_object# (, 'size)))))) (list.enumeration '*elements))))))) (the .public class_for @@ -2180,12 +2181,12 @@ (template.with [ ] [(the .public - (template.macro ( it) - [(|> it (.is ) (.as ))])) + (template.macro ( ,it) + [(.as (-> ) ,it)])) (the .public - (template.macro ( it) - [(|> it (.is ) (.as ))]))] + (template.macro ( ,it) + [(.as (-> ) ,it)]))] [as_boolean .Bit ..Boolean of_boolean] [as_long .Integer ..Long of_long] @@ -2196,11 +2197,11 @@ (template.with [ <$> <$'> ] [(the .public (template.macro ( it) - [(|> it (.is ) (.as ) <$> (.is ))])) + [(|> it (.as (-> )) <$> (.is ))])) (the .public (template.macro ( it) - [(|> it (.is ) <$'> (.is ) (.as ))]))] + [(|> it (.is ) <$'> (.as (-> )))]))] [as_byte .Integer ..long_to_byte ..Long ..byte_to_long ..Byte of_byte] [as_short .Integer ..long_to_short ..Long ..short_to_long ..Short of_short] diff --git a/stdlib/source/library/lux/finance/money/currency.lux b/stdlib/source/library/lux/finance/money/currency.lux index 19362415b0..4d5f70b258 100644 --- a/stdlib/source/library/lux/finance/money/currency.lux +++ b/stdlib/source/library/lux/finance/money/currency.lux @@ -79,7 +79,7 @@ (..Currency (, 'it)))) (|>>)) (, it))))) - it (|> (as Type it) + it (|> (as (-> Any Type) it) (?type.value (?type.reified (?.after (?type.exactly ..Currency) ?type.any))) meta.of_try)] diff --git a/stdlib/source/library/lux/function/mutual.lux b/stdlib/source/library/lux/function/mutual.lux index 45e481a7f3..b303ecb395 100644 --- a/stdlib/source/library/lux/function/mutual.lux +++ b/stdlib/source/library/lux/function/mutual.lux @@ -48,9 +48,9 @@ (, (its #body mutual))))))) (.the (macro 'context 'self) - (-> Code Code Macro) - (<| (as Macro) - (is Macro') + (-> Code Code + Macro) + (<| (as (-> Macro' Macro)) (function (_ parameters) (by meta.monad in (list (` (((, 'self) (, 'context)) (,* parameters)))))))) diff --git a/stdlib/source/library/lux/function/polymorphism/aspect.lux b/stdlib/source/library/lux/function/polymorphism/aspect.lux index 740ec6ff69..dc3ab55cbc 100644 --- a/stdlib/source/library/lux/function/polymorphism/aspect.lux +++ b/stdlib/source/library/lux/function/polymorphism/aspect.lux @@ -294,7 +294,7 @@ body ?list.any]) (do [! phase.monad] [aspect (meta.eval Aspect aspect) - .let [aspect (as Aspect aspect)]] + .let [aspect (as (-> Any Aspect) aspect)]] (list#mix (function (_ [original value] then) (<| (with_cached_analysis original) (function (_ ['original original_global])) @@ -311,7 +311,7 @@ (do [! phase.monad] [aspect (declaration.of_analysis (meta.eval Aspect aspect)) - .let [aspect (as Aspect aspect)]] + .let [aspect (as (-> Any Aspect) aspect)]] (list#mix (function (_ [original value] then) (<| (with_cached_analysis' original) (function (_ ['original original_global])) diff --git a/stdlib/source/library/lux/function/polymorphism/context.lux b/stdlib/source/library/lux/function/polymorphism/context.lux index 227f193edc..d35d1bd4a4 100644 --- a/stdlib/source/library/lux/function/polymorphism/context.lux +++ b/stdlib/source/library/lux/function/polymorphism/context.lux @@ -43,9 +43,9 @@ (|>> alteration scope)) -(expansion.let [ Name] +(expansion.let [ Name] (nominal.every .public Layer - + (.the .public layer (syntax.macro (_ [[export_policy name] (export.with ?code.local)]) @@ -53,8 +53,8 @@ [[@ _] module.current] (in (list (` (.the (, export_policy) (, (code.local name)) Layer - (<| (as Layer) - (is ) + (<| (as (-> + Layer)) [(, (code.text @)) (, (code.text name))])))))))) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 6b4d5dc74f..a88ef0d6c2 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -88,9 +88,9 @@ (the .public function (-> Macro Macro') - (|>> (as Macro'))) + (|>> (as (-> Macro Macro')))) (the .public macro (-> Macro' Macro) - (|>> (as Macro))) + (|>> (as (-> Macro' Macro)))) diff --git a/stdlib/source/library/lux/macro/context.lux b/stdlib/source/library/lux/macro/context.lux index 8c02a6fb19..60212d0d2f 100644 --- a/stdlib/source/library/lux/macro/context.lux +++ b/stdlib/source/library/lux/macro/context.lux @@ -79,7 +79,7 @@ (do meta.monad [stack (..global context)] (when (|> stack - (as (Stack Any)) + (as (-> Any (Stack Any))) stack.head) {try.#Success top} (in (as_expected top)) @@ -98,8 +98,8 @@ (do meta.monad [stack (..global context)] (when (|> stack - (as (Stack Any)) - (stack.example (as (Predicate Any) ?))) + (as (-> Any (Stack Any))) + (stack.example (as (-> Any (Predicate Any)) ?))) {try.#Success it} (in (as_expected it)) @@ -165,7 +165,7 @@ (Meta Any))) (alter (function (_ _ [type stack]) (|> stack - (as (.Stack Any)) + (as (-> Any (.Stack Any))) {.#Top top} (is (.Stack Any)) [type] @@ -228,7 +228,7 @@ (Meta Any))) (alter (function (_ _ [type value]) (|> value - (as (.Stack Any)) + (as (-> Any (.Stack Any))) stack.tail (try.else value) [type] diff --git a/stdlib/source/library/lux/macro/expansion.lux b/stdlib/source/library/lux/macro/expansion.lux index 14f8e896a6..051a2e7f70 100644 --- a/stdlib/source/library/lux/macro/expansion.lux +++ b/stdlib/source/library/lux/macro/expansion.lux @@ -29,7 +29,7 @@ [?macro (meta.try (binding.macro name))] (when ?macro {try.#Success macro} - ((as Macro' macro) (list.of_stack args)) + ((as (-> Macro Macro') macro) (list.of_stack args)) {try.#Failure _} (by meta.monad in (list syntax)))) @@ -52,7 +52,7 @@ (when ?macro {try.#Success macro} (do [! meta.monad] - [top_level_complete ((as Macro' macro) (list.of_stack args))] + [top_level_complete ((as (-> Macro Macro') macro) (list.of_stack args))] (|> top_level_complete (list.each' meta.monad complete) (by ! each list#conjoint))) @@ -78,7 +78,7 @@ (when ?macro {try.#Success macro} (do meta.monad - [complete ((as Macro' macro) (list.of_stack args)) + [complete ((as (-> Macro Macro') macro) (list.of_stack args)) complete' (list.each' meta.monad total complete)] (in (list#conjoint complete'))) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index d157897dea..bcb74ad375 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -153,7 +153,7 @@ locals (list.each' ! (function (_ [name value]) (|> value (meta.eval .Macro) - (by ! each (|>> (as .Macro) + (by ! each (|>> (as (-> Any .Macro)) [[here name]])))) locals) expression? (is (Meta Bit) diff --git a/stdlib/source/library/lux/macro/vocabulary.lux b/stdlib/source/library/lux/macro/vocabulary.lux index fdad6ca02f..1f8d8682c5 100644 --- a/stdlib/source/library/lux/macro/vocabulary.lux +++ b/stdlib/source/library/lux/macro/vocabulary.lux @@ -40,17 +40,20 @@ Macro (.the (, public|private@micro) (, micro) - (-> Macro (, type)) + (-> Macro + (, type)) (|>> nominal.abstraction)) (.the (, public|private@macro) (, macro) - (-> (, type) Macro) + (-> (, type) + Macro) (|>> nominal.reification)))) (` (.the (, public|private@by_name) ((, by_name) (, '_)) - (-> Name (Meta Macro)) + (-> Name + (Meta Macro)) (do meta.monad [[(, 'type) (, 'value)] (binding.export (, '_))] (if (by type.equivalence (,' =) (, type) (, 'type)) - ((,' in) ((, macro) (as (, type) (, 'value)))) - (meta.failure (exception.error ..invalid_type [(, type) (, 'type)]))))))))))) + ((,' in) ((, macro) (as (-> Any (, type)) (, 'value)))) + (meta.failure (exception.error ..invalid_type [(, type) (, 'type)]))))))))))) diff --git a/stdlib/source/library/lux/math/geometry/circle.lux b/stdlib/source/library/lux/math/geometry/circle.lux index 5c867a03f4..f3a87567fd 100644 --- a/stdlib/source/library/lux/math/geometry/circle.lux +++ b/stdlib/source/library/lux/math/geometry/circle.lux @@ -52,15 +52,14 @@ (these (the !double (template.macro (_ value) [(|> value - (as (Nominal "java.lang.Double")) + (as (-> Decimal (Nominal "java.lang.Double"))) .jvm_object_cast#)])) (the !decimal (template.macro (_ value) [(|> value .jvm_object_cast# - (is (Nominal "java.lang.Double")) - (as Decimal))])) + (as (-> (Nominal "java.lang.Double") Decimal)))])) (template.with [ ] [(the .public @@ -87,7 +86,7 @@ ) (|>> [] (.js_apply# (.js_constant# )) - (as Decimal)))] + (as (-> Any Decimal))))] [Angle Decimal cos "Math.cos"] [Angle Decimal sin "Math.sin"] @@ -105,7 +104,7 @@ ) (|>> [] (.python_object_do# (.python_import# "math")) - (as Decimal)))] + (as (-> Any Decimal))))] [Angle Decimal cos "cos"] [Angle Decimal sin "sin"] @@ -123,7 +122,7 @@ ) (|>> [] (.lua_apply# (.lua_constant# )) - (as Decimal)))] + (as (-> Any Decimal))))] [Angle Decimal cos "math.cos"] [Angle Decimal sin "math.sin"] @@ -141,7 +140,7 @@ ) (|>> [] (.ruby_apply# (.ruby_constant# )) - (as Decimal)))] + (as (-> Any Decimal))))] [Angle Decimal cos "Math.cos"] [Angle Decimal sin "Math.sin"] @@ -158,7 +157,7 @@ (-> ) (|>> ("php apply" ("php constant" )) - (as Decimal)))] + (as (-> Any Decimal))))] [Angle Decimal cos "cos"] [Angle Decimal sin "sin"] @@ -174,23 +173,23 @@ (-> Decimal Decimal Decimal) (if (d.< x +0.0) - (..atan (d./ x y)) - - (d.< +0.0 x) - (if (or (d.< y +0.0) - (d.= +0.0 y)) - (|> y (d./ x) atan (d.+ pi)) - (|> y (d./ x) atan (d.- pi))) - - ... (d.= +0.0 x) - (if (d.< y +0.0) - (|> pi (d./ +2.0)) - - (d.< +0.0 y) - (|> pi (d./ -2.0)) - - ... (d.= +0.0 y) - (d./ +0.0 +0.0)))) + (..atan (d./ x y)) + + (d.< +0.0 x) + (if (or (d.< y +0.0) + (d.= +0.0 y)) + (|> y (d./ x) atan (d.+ pi)) + (|> y (d./ x) atan (d.- pi))) + + ... (d.= +0.0 x) + (if (d.< y +0.0) + (|> pi (d./ +2.0)) + + (d.< +0.0 y) + (|> pi (d./ -2.0)) + + ... (d.= +0.0 y) + (d./ +0.0 +0.0)))) (the .public (hypotenuse catA catB) (-> Decimal Decimal diff --git a/stdlib/source/library/lux/math/number/decimal.lux b/stdlib/source/library/lux/math/number/decimal.lux index 167c6ce00c..5cef2ed511 100644 --- a/stdlib/source/library/lux/math/number/decimal.lux +++ b/stdlib/source/library/lux/math/number/decimal.lux @@ -54,7 +54,7 @@ (template#macro (_ value) [(|> value - (as (Nominal "java.lang.Double")) + (as (-> It (Nominal "java.lang.Double"))) .jvm_object_cast#)])) (the !decimal @@ -62,13 +62,11 @@ (_ value) [(|> value .jvm_object_cast# - (is (Nominal "java.lang.Double")) - (as It))])) + (as (-> (Nominal "java.lang.Double") It)))])) (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> !double ["D"] (.jvm_member_invoke_static# [] "java.lang.Math" []) @@ -94,11 +92,10 @@ .js (these (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> [] (.js_apply# (.js_constant# )) - (as It)))] + (as (-> Any It))))] [exp "Math.exp"] [log "Math.log"] @@ -113,16 +110,16 @@ (the .public (pow param subject) (-> It It It) - (as It (.js_apply# (.js_constant# "Math.pow") [subject param])))) + (as (-> Any It) + (.js_apply# (.js_constant# "Math.pow") [subject param])))) .python (these (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> [] (.python_object_do# (.python_import# "math")) - (as It)))] + (as (-> Any It))))] [exp "exp"] [log "log"] @@ -136,7 +133,8 @@ (the .public (pow param subject) (-> It It It) - (as It (.python_object_do# "pow" (.python_import# "math") [subject param]))) + (as (-> Any It) + (.python_object_do# "pow" (.python_import# "math") [subject param]))) (the .public (root_3 it) (-> It @@ -152,11 +150,10 @@ .lua (these (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> [] (.lua_apply# (.lua_constant# )) - (as It)))] + (as (-> Any It))))] [exp "math.exp"] [log "math.log"] @@ -186,11 +183,10 @@ .ruby (these (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> [] (.ruby_apply# (.ruby_constant# )) - (as It)))] + (as (-> Any It))))] [exp "Math.exp"] [log "Math.log"] @@ -201,10 +197,9 @@ (with_template' [,name ] [(the .public (,name it) - (-> It - It) + (Change It) (|> (.ruby_object_do# it []) - (as Integer) + (as (-> Any Integer)) (.int_f64#)))] [ceil "ceil"] @@ -214,15 +209,15 @@ (the .public (pow param subject) (-> It It It) - (as It (.ruby_object_do# "**" subject [param])))) + (as (-> Any It) + (.ruby_object_do# "**" subject [param])))) .php (these (with_template' [,name ] [(the .public ,name - (-> It - It) + (Change It) (|>> ("php apply" ("php constant" )) - (as It)))] + (as (-> Any It))))] [exp "exp"] [log "log"] @@ -236,7 +231,8 @@ (the .public (pow param subject) (-> It It It) - (as It ("php apply" ("php constant" "pow") subject param))) + (as (-> Any It) + ("php apply" ("php constant" "pow") subject param))) (the .public root_3 (-> It @@ -486,24 +482,24 @@ ..!double ["D"] (.jvm_member_invoke_static# [] "java.lang.Double" "toString" []) - (as Text) + (as (-> (Nominal "java.lang.String") Text)) (text.replaced "E-" "e-") (text.replaced "E" "e+")) .js - (let [raw (as Text (.js_object_do# "toString" it []))] + (let [raw (as (-> Any Text) (.js_object_do# "toString" it []))] (if (text.contains? ..delimiter raw) raw (.text_composite# raw ".0"))) .lua - (as Text (.lua_apply# (.lua_constant# "string.format") ["%.17g" it])) + (as (-> Any Text) (.lua_apply# (.lua_constant# "string.format") ["%.17g" it])) .python - (as Text (.python_apply# (.python_constant# "repr") [it])) + (as (-> Any Text) (.python_apply# (.python_constant# "repr") [it])) .ruby - (as Text (.ruby_object_do# "to_s" it [])))) + (as (-> Any Text) (.ruby_object_do# "to_s" it [])))) (the with_projection_error (template#macro @@ -533,7 +529,7 @@ (the (of it) (for .jvm (|> it - (as (Nominal "java.lang.String")) + (as (-> Text (Nominal "java.lang.String"))) .jvm_object_cast# ["Ljava/lang/String;"] (.jvm_member_invoke_static# [] "java.lang.Double" "parseDouble" []) @@ -542,21 +538,21 @@ .js (|> (.js_apply# (.js_constant# "parseFloat") [it]) - (as It) + (as (-> Any It)) with_projection_error) .lua (|> (.lua_apply# (.lua_constant# "tonumber") [it]) - (as It) + (as (-> Any It)) with_projection_error) .python (|> (.python_apply# (.python_constant# "float") [it]) - (as It) + (as (-> Any It)) with_projection_error) .ruby - (let [projection (as It (.ruby_object_do# "to_f" it []))] + (let [projection (as (-> Any It) (.ruby_object_do# "to_f" it []))] (<| (_expansion#let [,success {try.#Success projection}]) (if (..= +0.0 projection) (when it diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index aa70e03947..6b845b484c 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -187,11 +187,14 @@ {.#None} {try.#Failure ..not_expecting_any_type}))) +(the Eval + (.type# "eval")) + (the .public (eval type code) (-> Type Code (Meta Any)) (do [! ..monad] [eval (by ! each (|>> (its .#eval) - (.as# (.type# "eval"))) + (as (-> Any Eval))) ..compiler_state)] (eval type code))) diff --git a/stdlib/source/library/lux/meta/binding.lux b/stdlib/source/library/lux/meta/binding.lux index d51517362c..8de4278d6a 100644 --- a/stdlib/source/library/lux/meta/binding.lux +++ b/stdlib/source/library/lux/meta/binding.lux @@ -260,7 +260,7 @@ (by code.equivalence = (type_code .Type) (type_code def_type))) - (in (as Type def_value)) + (in (as (-> Any Type) def_value)) (//.failure (text "Definition is not a type: " (name#as name))))) {.#Default _} @@ -377,10 +377,10 @@ (the .public (macro full_name) (-> Name - (Meta Macro)) + (Meta @type.Macro)) (do //.monad [full_name (..normal full_name)] - (is (Meta Macro) + (is (Meta @type.Macro) (function (_ lux) (when (module.current lux) {try.#Success [_ [this_module _]]} @@ -397,9 +397,8 @@ (macro de_aliased) {.#Definition [def_type def_value]} - (if (or (type#= @type.Macro def_type) - (type#= .Macro def_type)) - {try.#Success [lux (as Macro def_value)]} + (if (type#= @type.Macro def_type) + {try.#Success [lux (as (-> Any @type.Macro) def_value)]} {try.#Failure ..not_a_macro}) {.#Default _} diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux index 0e096da097..2f5a075d02 100644 --- a/stdlib/source/library/lux/meta/extension.lux +++ b/stdlib/source/library/lux/meta/extension.lux @@ -64,8 +64,8 @@ 'phase (code.local phase) 'archive (code.local archive)] (with_names ['inputs 'error '_] - (in (list (` (<| (as ) - (is ) + (in (list (` (<| (as (-> + )) (.function ((, 'handler) (, 'phase) (, 'archive) (, 'inputs)) (.when (|> (monad.do <>.monad [(,* inputs)] diff --git a/stdlib/source/library/lux/meta/label.lux b/stdlib/source/library/lux/meta/label.lux index 6ae0532b79..48ccea1a63 100644 --- a/stdlib/source/library/lux/meta/label.lux +++ b/stdlib/source/library/lux/meta/label.lux @@ -61,7 +61,7 @@ (if (.or (text.= this_module_name (name.module it)) exported?) (if (type.= ,type def_type) - (in (as Label def_value)) + (in (as (-> Any Label) def_value)) (//.of_try (exception.except ,not_a [it]))) (//.of_try (exception.except ,cannot_access [it this_module_name]))) @@ -83,7 +83,7 @@ (when global {.#Definition [type value]} (if (type.= ,type type) - (let [[label type] (as Label value)] + (let [[label type] (as (-> Any Label) value)] (when type {.#Named actual_name anonymous} (if (name.= type_name actual_name) @@ -126,7 +126,7 @@ (if (and (type.= .Slot type) (or exported? (text.= this_module_name module))) - (let [[label type] (as Label value)] + (let [[label type] (as (-> Any Label) value)] (when label {.#Some [lefts right? family]} (when (list.item 0 family) diff --git a/stdlib/source/library/lux/meta/static.lux b/stdlib/source/library/lux/meta/static.lux index 80826f0253..5665f81532 100644 --- a/stdlib/source/library/lux/meta/static.lux +++ b/stdlib/source/library/lux/meta/static.lux @@ -26,7 +26,9 @@ [(the .public (syntax.macro (_ [expression ?list.any]) (by meta.monad each - (|>> (as ) list) + (|>> (as (-> Any )) + + list) (meta.eval expression))))] [bit .Bit code.bit] @@ -49,7 +51,7 @@ (do meta.monad [pair (meta.eval (type ) (` [(, injection) (, expression)])) - .let [[as_code expression] (as pair)]] + .let [[as_code expression] (as (-> Any ) pair)]] (in (list (as_code expression))))))) (expansion.let [ (Meta (List Code))] @@ -57,7 +59,7 @@ (syntax.macro (_ [expression ?list.any]) (do meta.monad [expression (meta.eval (type ) expression)] - (as expression))))) + (as (-> Any ) expression))))) (expansion.let [ (for_some (_ a) [(-> a Code) @@ -68,7 +70,7 @@ (do meta.monad [pair (meta.eval (type ) (` [(, injection) (, expression)])) - .let [[injection expression] (as pair)]] + .let [[injection expression] (as (-> Any ) pair)]] (in (list#each injection expression)))))) (the .public seed @@ -103,7 +105,7 @@ (do meta.monad [pair (meta.eval (type ) (` [(, injection) (, random)])) - .let [[injection random] (as pair)] + .let [[injection random] (as (-> Any ) pair)] seed meta.seed .let [[_ value] (random.value random.pcg_32 [random.#increase ..pcg_32_magic_inc @@ -120,7 +122,7 @@ (do meta.monad [pair (meta.eval (type ) (` [(, injection) (, random)])) - .let [[injection random] (as pair)] + .let [[injection random] (as (-> Any ) pair)] seed meta.seed .let [[_ value] (random.value random.pcg_32 [random.#increase ..pcg_32_magic_inc @@ -141,7 +143,7 @@ {.#Left [when then else]} (do meta.monad [when (meta.eval .Bit when)] - (in (list (.if (as .Bit when) + (in (list (.if (as (-> Any .Bit) when) then (` (..if (,* else)))))))))) @@ -150,6 +152,6 @@ then ?list.any]) (do meta.monad [test (meta.eval .Bit test)] - (in (.if (as .Bit test) + (in (.if (as (-> Any .Bit) test) (list then) (list)))))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 2056ac9c67..ea65678a5e 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -120,17 +120,17 @@ (-> Relative Relative Relative) (if (same? ..relative#identity left) - right + right - (same? ..relative#identity right) - left + (same? ..relative#identity right) + left - ... else - (function (_ resolver) - (<| (try|do [left_exceptions left_instruction] (left resolver)) - (try|do [right_exceptions right_instruction] (right resolver)) - (try|in [(by sequence.monoid composite left_exceptions right_exceptions) - (/#composite left_instruction right_instruction)]))))) + ... else + (function (_ resolver) + (<| (try|do [left_exceptions left_instruction] (left resolver)) + (try|do [right_exceptions right_instruction] (right resolver)) + (try|in [(by sequence.monoid composite left_exceptions right_exceptions) + (/#composite left_instruction right_instruction)]))))) (the relative_monoid (Monoid Relative) @@ -613,8 +613,8 @@ Small_Index))) (let [it' (|> it //index.value n/16.as)] (if (n/08.valid? it') - {.#Right (n/08.of it')} - {.#Left it}))) + {.#Right (n/08.of it')} + {.#Left it}))) (the .public (string value) (-> UTF8 @@ -628,13 +628,16 @@ {.#Left index} (..bytecode $0 $1 @_ /.ldc_w/string [index])))) +(import java/lang/Long + "[1]::[0]") + (import java/lang/Float - "[1]::[0]" - ("static" floatToRawIntBits "manual" [float] int)) + "[1]::[0]" + ("static" floatToRawIntBits "manual" [float] int)) (import java/lang/Double - "[1]::[0]" - ("static" doubleToRawLongBits "manual" [double] long)) + "[1]::[0]" + ("static" doubleToRawLongBits "manual" [double] long)) (template.with [ ] [(the .public ( value) @@ -705,11 +708,11 @@ .Integer) (|>> [] java/lang/Float::floatToRawIntBits ffi.int_to_long - (as .Integer))) + (as (-> java/lang/Long .Integer)))) (the negative_zero_float_bits (|> -0.0 - (as java/lang/Double) + (as (-> Decimal java/lang/Double)) ffi.double_to_float ..float_bits)) @@ -718,17 +721,19 @@ (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) - (..arbitrary_float value) - (`` (when (|> value ffi.float_to_double (as Decimal)) - (,, (template.with [ ] - [ (..bytecode $0 $1 @_ [])] - - [+0.0 /.fconst_0] - [+1.0 /.fconst_1] - [+2.0 /.fconst_2])) - - _ - (..arbitrary_float value))))) + (..arbitrary_float value) + (`` (when (|> value + ffi.float_to_double + (as (-> java/lang/Double Decimal))) + (,, (template.with [ ] + [ (..bytecode $0 $1 @_ [])] + + [+0.0 /.fconst_0] + [+1.0 /.fconst_1] + [+2.0 /.fconst_2])) + + _ + (..arbitrary_float value))))) (the (arbitrary_double value) (-> Decimal @@ -740,9 +745,9 @@ (the double_bits (-> Decimal .Integer) - (|>> (as java/lang/Double) + (|>> (as (-> Decimal java/lang/Double)) [] java/lang/Double::doubleToRawLongBits - (as .Integer))) + (as (-> java/lang/Long .Integer)))) (the negative_zero_double_bits (..double_bits -0.0)) @@ -752,15 +757,15 @@ (Bytecode Any)) (if (i.= ..negative_zero_double_bits (..double_bits value)) - (..arbitrary_double value) - (`` (when (as Decimal value) - (,, (template.with [ ] - [ (..bytecode $0 $2 @_ [])] + (..arbitrary_double value) + (`` (when value + (,, (template.with [ ] + [ (..bytecode $0 $2 @_ [])] - [+0.0 /.dconst_0] - [+1.0 /.dconst_1])) - - _ (..arbitrary_double value))))) + [+0.0 /.dconst_0] + [+1.0 /.dconst_1])) + + _ (..arbitrary_double value))))) (exception.the .public (invalid_register id) (exception.Exception Natural) @@ -771,8 +776,8 @@ (-> Natural (Bytecode Register)) (if (n/08.valid? id) - (by ..monad in (n/08.of id)) - (..except ..invalid_register [id]))) + (by ..monad in (n/08.of id)) + (..except ..invalid_register [id]))) (template.with [ ] [(the .public ( local) @@ -886,8 +891,8 @@ (i.< (//signed.value //signed.minimum/2) jump))] (if big? - {try.#Success {.#Left (/32.of jump)}} - (try#each (|>> {.#Right}) (//signed.s2 jump))))) + {try.#Success {.#Left (/32.of jump)}} + (try#each (|>> {.#Right}) (//signed.s2 jump))))) (exception.the .public (unset_label label) (exception.Exception Label) @@ -1150,14 +1155,14 @@ (-> (Type Return) Natural) (if (same? type.void type) - 0 + 0 - (or (same? type.long type) - (same? type.double type)) - 2 + (or (same? type.long type) + (same? type.double type)) + 2 - ... else - 1)) + ... else + 1)) (template.with [ ] [(the .public ( class method type) @@ -1196,8 +1201,8 @@ pool.#descriptor (type.descriptor type)])] (if (or (same? type.long type) (same? type.double type)) - (..bytecode $2 @_ <2> [index]) - (..bytecode $1 @_ <1> [index]))))] + (..bytecode $2 @_ <2> [index]) + (..bytecode $1 @_ <1> [index]))))] [$0 getstatic /.getstatic/1 /.getstatic/2] [$1 getfield /.getfield/1 /.getfield/2] @@ -1214,8 +1219,8 @@ pool.#descriptor (type.descriptor type)])] (if (or (same? type.long type) (same? type.double type)) - (..bytecode $0 @_ <2> [index]) - (..bytecode $0 @_ <1> [index]))))] + (..bytecode $0 @_ <2> [index]) + (..bytecode $0 @_ <1> [index]))))] [putstatic $1 /.putstatic/1 $2 /.putstatic/2] [putfield $2 /.putfield/1 $3 /.putfield/2] @@ -1241,8 +1246,8 @@ (<| (try|do [_ @start] (..resolve_label @start resolver)) (try|do [_ @end] (..resolve_label @end resolver)) (try|do _ (if (/address.> @start @end) - (try|in []) - (exception.except ..invalid_range_for_try [@start @end]))) + (try|in []) + (exception.except ..invalid_range_for_try [@start @end]))) (try|do [_ @handler] (..resolve_label @handler resolver)) (try|in [(sequence.sequence [//exception.#start @start diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index ab7decb8f6..15f823b9c4 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -43,43 +43,43 @@ ["Error" error]))) (import java/lang/Object - "[1]::[0]" - (getClass [] (java/lang/Class java/lang/Object))) + "[1]::[0]" + (getClass [] (java/lang/Class java/lang/Object))) (import java/lang/String - "[1]::[0]") + "[1]::[0]") (import java/lang/reflect/Method - "[1]::[0]" - (invoke [java/lang/Object [java/lang/Object]] "try" java/lang/Object)) + "[1]::[0]" + (invoke [java/lang/Object [java/lang/Object]] "try" java/lang/Object)) (import (java/lang/Class a) - "[1]::[0]" - (getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method)) + "[1]::[0]" + (getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method)) (import java/lang/Integer - "[1]::[0]" - ("read_only" "static" TYPE (java/lang/Class java/lang/Integer))) + "[1]::[0]" + ("read_only" "static" TYPE (java/lang/Class java/lang/Integer))) (import java/lang/reflect/AccessibleObject - "[1]::[0]" - (setAccessible [boolean] void)) + "[1]::[0]" + (setAccessible [boolean] void)) (import java/lang/ClassLoader - "[1]::[0]" - (loadClass [java/lang/String] - "io" "try" (java/lang/Class java/lang/Object))) + "[1]::[0]" + (loadClass [java/lang/String] + "io" "try" (java/lang/Class java/lang/Object))) (expansion.let [ (these (java/lang/Class java/lang/Object))] (the java/lang/ClassLoader::defineClass java/lang/reflect/Method (let [signature (|> (ffi.array 4) - (ffi.write! 0 (as + (ffi.write! 0 (as (-> (java/lang/Class java/lang/String) ) (ffi.class_for java/lang/String))) (ffi.write! 1 (java/lang/Object::getClass [] (ffi.array byte 0))) - (ffi.write! 2 (as + (ffi.write! 2 (as (-> (java/lang/Class java/lang/Integer) ) (java/lang/Integer::TYPE))) - (ffi.write! 3 (as + (ffi.write! 3 (as (-> (java/lang/Class java/lang/Integer) ) (java/lang/Integer::TYPE))))] (to (java/lang/Class::getDeclaredMethod [(ffi.as_string "defineClass") signature] @@ -87,35 +87,39 @@ (java/lang/reflect/AccessibleObject::setAccessible [true]))))) (the .public (define class_name bytecode loader) - (-> Text Binary java/lang/ClassLoader (Try java/lang/Object)) - (let [signature (array.of_stack (stack (as java/lang/Object + (-> Text Binary java/lang/ClassLoader + (Try java/lang/Object)) + (let [signature (array.of_stack (stack (as (-> Any java/lang/Object) class_name) - (as java/lang/Object + (as (-> Any java/lang/Object) bytecode) - (as java/lang/Object + (as (-> Any java/lang/Object) (|> 0 - (as (Nominal "java.lang.Long")) + (as (-> Natural (Nominal "java.lang.Long"))) ffi.long_to_int)) - (as java/lang/Object + (as (-> Any java/lang/Object) (|> bytecode binary.size - (as (Nominal "java.lang.Long")) + (as (-> Natural (Nominal "java.lang.Long"))) ffi.long_to_int))))] (java/lang/reflect/Method::invoke [loader signature] java/lang/ClassLoader::defineClass))) (the .public (new_library _) - (-> Any Library) + (-> Any + Library) (atom.atom (dictionary.empty text.hash))) (the .public (memory library) - (-> Library java/lang/ClassLoader) + (-> Library + java/lang/ClassLoader) (<| .jvm_object_cast# (object [] java/lang/ClassLoader [] [] (java/lang/ClassLoader (findClass self [class_name java/lang/String]) (java/lang/Class [? < java/lang/Object]) "throws" [java/lang/ClassNotFoundException] - (let [class_name (as Text class_name) + (let [class_name (as (-> java/lang/String Text) + class_name) classes (|> library atom.read! io.value)] (when (dictionary.value class_name classes) {try.#Success bytecode} @@ -134,10 +138,10 @@ (do [! io.monad] [library' (atom.read! library)] (if (dictionary.key? library' name) - (in (exception.except ..already_stored name)) - (do ! - [_ (atom.update! (dictionary.has name bytecode) library)] - (in {try.#Success []}))))) + (in (exception.except ..already_stored name)) + (do ! + [_ (atom.update! (dictionary.has name bytecode) library)] + (in {try.#Success []}))))) (the .public (load name loader) (-> Text java/lang/ClassLoader diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 2b396ef11e..76798ee629 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -142,7 +142,9 @@ [super (..load class_loader super) sub (..load class_loader sub)] (in (ffi.of_boolean (java/lang/Class::isAssignableFrom [sub] - (as java/lang/Class super)))))) + (as (-> (java/lang/Class java/lang/Object) + java/lang/Class) + super)))))) (the (class' parameter reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type @@ -150,7 +152,8 @@ (<| (when (ffi.as java/lang/Class reflection) {.#Some class} (let [class_name (|> class - (as (java/lang/Class java/lang/Object)) + (as (-> Any + (java/lang/Class java/lang/Object))) (java/lang/Class::getName []) ffi.of_string)] (`` (if (or (,, (template.with [] @@ -181,7 +184,8 @@ (list.each' ! parameter) (by ! each (function (_ parameters) (|> raw' - (as (java/lang/Class java/lang/Object)) + (as (-> Any + (java/lang/Class java/lang/Object))) (java/lang/Class::getName []) ffi.of_string (/.class parameters)))) @@ -232,7 +236,8 @@ _) (when (ffi.as java/lang/Class reflection) {.#Some class} - (let [class (as (java/lang/Class java/lang/Object) + (let [class (as (-> Any + (java/lang/Class java/lang/Object)) class)] (if (ffi.of_boolean (java/lang/Class::isArray [] class)) (|> class @@ -250,7 +255,8 @@ (<| (when (ffi.as java/lang/Class reflection) {.#Some reflection} (let [class_name (|> reflection - (as (java/lang/Class java/lang/Object)) + (as (-> Any + (java/lang/Class java/lang/Object))) (java/lang/Class::getName []) ffi.of_string)] (`` (if (,, (template.with [ ] @@ -285,7 +291,8 @@ (when (ffi.as java/lang/Class reflection) {.#Some class} (let [class_name (|> reflection - (as (java/lang/Class java/lang/Object)) + (as (-> Any + (java/lang/Class java/lang/Object))) (java/lang/Class::getName []) ffi.of_string)] (if (text.= (/reflection.reflection /reflection.void) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index 38d6f8305a..ce8d9e5c3b 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -225,8 +225,8 @@ [..float] [..double] [..char])))) - (|> type (as ..Primitive) {.#Right}) - (|> type (as ..Object) {.#Left}))) + (|> type (as (-> ..Value ..Primitive)) {.#Right}) + (|> type (as (-> ..Value ..Object)) {.#Left}))) (the .public (void? type) (-> ..Return @@ -236,8 +236,8 @@ [(by ..equivalence = (is ..Return ) type)] [..void])))) - (|> type (as ..Void) {.#Right}) - (|> type (as ..Value) {.#Left}))) + (|> type (as (-> ..Return ..Void)) {.#Right}) + (|> type (as (-> ..Return ..Value)) {.#Left}))) ) (the .public (class? type) @@ -246,15 +246,15 @@ (let [repr (|> type ..descriptor /descriptor.descriptor)] (if (and (text.starts_with? /descriptor.class_prefix repr) (text.ends_with? /descriptor.class_suffix repr)) - (let [prefix_size (text.size /descriptor.class_prefix) - suffix_size (text.size /descriptor.class_suffix) - name_size (|> (text.size repr) - (n.- prefix_size) - (n.- suffix_size))] - (|> repr - (text.clip prefix_size name_size) - (by maybe.monad each (|>> internal.name internal.external)))) - {.#None}))) + (let [prefix_size (text.size /descriptor.class_prefix) + suffix_size (text.size /descriptor.class_suffix) + name_size (|> (text.size repr) + (n.- prefix_size) + (n.- suffix_size))] + (|> repr + (text.clip prefix_size name_size) + (by maybe.monad each (|>> internal.name internal.external)))) + {.#None}))) (the .public as_text (for_any (_ it) diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 4485706d7f..72a968580b 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -66,7 +66,8 @@ (the .public manual (-> Text Code) - (|>> nominal.abstraction)) + (|>> nominal.abstraction + (as (-> (Code Any) Code)))) (the .public code (-> (Code Any) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index b0509a162c..a362fd0528 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -76,7 +76,8 @@ (the .public manual (-> Text Code) - (|>> nominal.abstraction)) + (|>> nominal.abstraction + (as (-> (Code Any) Code)))) (the .public code (-> (Code Any) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 2f983a016a..893dde15f9 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -71,7 +71,8 @@ (the .public manual (-> Text Code) - (|>> nominal.abstraction)) + (|>> nominal.abstraction + (as (-> (Code Any) Code)))) (the .public code (-> (Code Any) @@ -154,9 +155,9 @@ [(d.= d.negative_infinity) "-inf"] [d.not_a_number? "nan"] )) - - ... else - [%.decimal]) + + ... else + [%.decimal]) nominal.abstraction))) (the safe diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index 776b8b277b..fd739be869 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -61,7 +61,8 @@ (the .public manual (-> Text Code) - (|>> nominal.abstraction)) + (|>> nominal.abstraction + (as (-> (Code Any) Code)))) (the .public code (-> (Code Any) @@ -212,16 +213,16 @@ (-> Decimal Literal) (|>> (pipe.if [(d.= d.positive_infinity)] - [(pipe.new "(+1.0/0.0)" [])] - - [(d.= d.negative_infinity)] - [(pipe.new "(-1.0/0.0)" [])] - - [(d.= d.not_a_number)] - [(pipe.new "(+0.0/-0.0)" [])] - - ... else - [%.decimal]) + [(pipe.new "(+1.0/0.0)" [])] + + [(d.= d.negative_infinity)] + [(pipe.new "(-1.0/0.0)" [])] + + [(d.= d.not_a_number)] + [(pipe.new "(+0.0/-0.0)" [])] + + ... else + [%.decimal]) nominal.abstraction)) (the $ nominal.reification) diff --git a/stdlib/source/library/lux/test/inline.lux b/stdlib/source/library/lux/test/inline.lux index 9226137425..3aa4b7a4af 100644 --- a/stdlib/source/library/lux/test/inline.lux +++ b/stdlib/source/library/lux/test/inline.lux @@ -62,7 +62,7 @@ .let [[_ success?] (random.value random.pcg_32 [random.#increase ..pcg_32_magic_inc random.#seed seed] - (as Test test))]] + (as (-> Any Test) test))]] (if success? (in (list)) (meta.failure (exception.error ..failure [term])))))) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 530b4fff15..5572f82738 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -311,7 +311,7 @@ (-> Civil_Month Year Civil_Year) (let [... Coercing, because the year is already in external form. - utc_year (as Civil_Year utc_year)] + utc_year (as (-> Year Civil_Year) utc_year)] (if (n.< ..first_month_of_civil_year utc_month) (-- utc_year) utc_year))) @@ -372,7 +372,7 @@ year)] ... Coercing, because the year is already in internal form. (try.trusted - (..date (as Year year) + (..date (as (-> Civil_Year Year) year) (maybe.trusted (dictionary.value month ..month_by_number)) day)))) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 28cbf6a105..789db89f63 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -146,11 +146,11 @@ (let [offset (..millis instant) bce? (i.< +0 offset) [days day_time] (if bce? - (let [[days millis] (i./% ..millis_per_day offset)] - (when millis - +0 [days millis] - _ [(-- days) (i.+ ..millis_per_day millis)])) - (i./% ..millis_per_day offset))] + (let [[days millis] (i./% ..millis_per_day offset)] + (when millis + +0 [days millis] + _ [(-- days) (i.+ ..millis_per_day millis)])) + (i./% ..millis_per_day offset))] [(date.of_days days) (duration.of_millis day_time)])) @@ -167,8 +167,8 @@ (-> Duration Time) (|> (if (by duration.order < duration.empty duration) - (duration.composite duration.day duration) - duration) + (duration.composite duration.day duration) + duration) duration.millis .natural //.of_millis @@ -189,10 +189,10 @@ time (by ! each //.millis //.of_text) _ (.this ..time_suffix)] (in (|> (if (i.< +0 days) - (|> duration.day - (duration.up (.natural (i.* -1 days))) - duration.inverse) - (duration.up (.natural days) duration.day)) + (|> duration.day + (duration.up (.natural (i.* -1 days))) + duration.inverse) + (duration.up (.natural days) duration.day)) (duration.composite (duration.up time duration.milli_second)) ..absolute)))) @@ -206,33 +206,32 @@ (IO Instant) (io (..of_millis (for .jvm (|> (.jvm_member_invoke_static# [] "java.lang.System" "currentTimeMillis" []) .jvm_object_cast# - (is (Nominal "java.lang.Long")) - (as Integer)) + (as (-> (Nominal "java.lang.Long") Integer))) .js (let [date (.js_object_new# (.js_constant# "Date") [])] (|> (.js_object_do# "getTime" date []) - (as Decimal) + (as (-> Any Decimal)) .f64_int#)) .python (let [time (.python_import# "time")] (|> (.python_object_do# "time" time []) - (as Decimal) + (as (-> Any Decimal)) (d.* +1,000.0) .f64_int#)) .lua (|> (.lua_apply# (.lua_constant# "os.time") []) - (as Integer) + (as (-> Any Integer)) (i.* +1,000)) .ruby (let [% (.ruby_constant# "Time") % (.ruby_object_do# "now" % [])] (|> (.ruby_object_do# "to_f" % []) - (as Decimal) + (as (-> Any Decimal)) (d.* +1,000.0) .f64_int#)) .php (|> ("php constant" "time") "php apply" - (as Integer) + (as (-> Any Integer)) (i.* +1,000)) .common_lisp (|> ("common_lisp constant" "get-universal-time") "common_lisp apply" - (as Integer) + (as (-> Any Integer)) (i.* +1,000)) )))) @@ -255,8 +254,8 @@ day_time (duration.framed duration.day offset) days (if (and (duration.negative? offset) (not (duration.neutral? day_time))) - (-- days) - days) + (-- days) + days) ... 1970/01/01 was a Thursday y1970m0d0 +4] (when (|> y1970m0d0 diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index fbe3cfeae8..9039cb67ef 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except function as let variant tuple) + [lux (.except function let variant tuple) [abstract [equivalence (.only Equivalence)] [format (.only Format)] @@ -528,22 +528,6 @@ (Projection (List Text)) (?code.tuple (?.some ?code.local))) -(the .public as - (syntax.macro (_ [type_vars type_parameters - input ?list.any - output ?list.any - value (?.maybe ?list.any)]) - (macro.with_names ['_] - (.let [casterC (` (is (for_any ((, '_) (,* (list#each code.local type_vars))) - (-> (, input) (, output))) - (|>> as_expected)))] - (when value - {.#None} - (in (list casterC)) - - {.#Some value} - (in (list (` ((, casterC) (, value)))))))))) - (every Typed (Record [#type Code @@ -583,7 +567,7 @@ (, (its #term exemplar))) (is (, extraction) ... The value of this expression will never be relevant, so it doesn't matter what it is. - (.as .Nothing []))))))))) + (as (-> Any .Nothing) []))))))))) (`` (the .public (replaced before after) (-> Type Type diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index ce61d38f9a..3ecca42b8c 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -29,28 +29,28 @@ (list ["Expected" (//.as_text expected)] ["Actual" (//.as_text actual)]))) -(expansion.let [ [Type Any]] +(expansion.let [ [Type Any]] (nominal.every .public Dynamic - + (the .public dynamic (syntax.macro (_ [value ?list.any]) (with_names ['value] (in (list (` (.let [(, 'value) (, value)] - (as Dynamic [(.type_of (, 'value)) (, 'value)])))))))) + (as (-> Dynamic) + [(.type_of (, 'value)) (, 'value)])))))))) (the .public static (syntax.macro (_ [type ?list.any value ?list.any]) (with_names ['type 'value] - (in (list (` (.let [[(, 'type) (, 'value)] (|> (, value) - (is Dynamic) - (as ))] + (in (list (` (.let [[(, 'type) (, 'value)] (as (-> Dynamic ) + (, value))] (.is (try.Try (, type)) (.if (.by //.equivalence (,' =) (.type (, type)) (, 'type)) - {try.#Success (.as (, type) (, 'value))} + {try.#Success (.as (-> Any (, type)) (, 'value))} (exception.except ..wrong_type [(.type (, type)) (, 'type)])))))))))) (the .public (as_text value) diff --git a/stdlib/source/library/lux/type/function.lux b/stdlib/source/library/lux/type/function.lux index f0fb30604a..1fead9cd50 100644 --- a/stdlib/source/library/lux/type/function.lux +++ b/stdlib/source/library/lux/type/function.lux @@ -30,7 +30,7 @@ (do [! meta.monad] [[it _] (binding.export it) parameters (list.each' ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) + (by ! each (|>> (.as (-> Any Type))))) parameters) it (when (//.reified parameters it) {.#Some it} diff --git a/stdlib/source/library/lux/type/nominal.lux b/stdlib/source/library/lux/type/nominal.lux index d154fc9824..f542054c62 100644 --- a/stdlib/source/library/lux/type/nominal.lux +++ b/stdlib/source/library/lux/type/nominal.lux @@ -57,7 +57,8 @@ [(.the .public (syntax.macro (_ [[frame value] ..cast]) (do [! meta.monad] - [[name type_vars abstraction reification] (when frame + ['_ (macro.name "'_") + [name type_vars abstraction reification] (when frame {.#Some frame} (do ! [frame (binding.normal frame)] @@ -65,8 +66,10 @@ {.#None} ..current)] - (in (list (` (//.as [(,* type_vars)] (, ) (, ) - (, value))))))))] + (in (list (` (as (for_any ((, '_) (,* type_vars)) + (-> (, ) + (, ))) + (, value))))))))] [abstraction reification abstraction] [reification abstraction reification] diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index f2f9cab7f2..b864eeb36d 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -274,6 +274,6 @@ (macro.with_names ['recursive] (do meta.monad [type (meta.eval Type type) - .let [type (as Type type)] + .let [type (as (-> Any Type) type)] implementation (meta.of_try (poly 0 'recursive ..empty type))] (in (list implementation))))))) diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index 74e01ac180..84641384b5 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -69,7 +69,7 @@ (..Class (, 'super) (, 'sub) (, '%)))) (|>>)) (, it))))) - [super sub %] (|> (as Type it) + [super sub %] (|> (as (-> Any Type) it) (?//.value (?//.reified (?.after (?//.exactly ..Class) (all ?.and ?//.any ?//.any ?//.any)))) meta.of_try)] diff --git a/stdlib/source/library/lux/type/record.lux b/stdlib/source/library/lux/type/record.lux index d8c522f7fe..599af82e87 100644 --- a/stdlib/source/library/lux/type/record.lux +++ b/stdlib/source/library/lux/type/record.lux @@ -42,7 +42,7 @@ label (meta.or (label.tag full_label) (label.slot full_label)) parameters (list.each' ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) + (by ! each (|>> (.as (-> Any Type))))) parameters) .let [[flat context it] (when label {.#Left [context it]} @@ -103,7 +103,7 @@ (in []) (meta.failure ..slots_belong_to_different_types)) parameters (list.each' ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) + (by ! each (|>> (.as (-> Any Type))))) parameters) it (when (//.reified parameters general_type) {.#Some it} diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 5ae94b8745..47c821ecf2 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -118,7 +118,7 @@ (..Refiner (, 'super) (, '%)))) (|>>)) (, it))))) - [super %] (|> (as Type it) + [super %] (|> (as (-> Any Type) it) (?//.value (?//.reified (?.after (?//.exactly ..Refiner) (all ?.and ?//.any ?//.any)))) meta.of_try)] diff --git a/stdlib/source/library/lux/type/row.lux b/stdlib/source/library/lux/type/row.lux index 1c8440302e..58b2693379 100644 --- a/stdlib/source/library/lux/type/row.lux +++ b/stdlib/source/library/lux/type/row.lux @@ -129,7 +129,7 @@ (do ! [super (meta.eval Type (` (.type (, super))))] - (in {.#Some (as Type super)})) + (in {.#Some (as (-> Any Type) super)})) _ (in {.#None}))] diff --git a/stdlib/source/library/lux/web/css/value.lux b/stdlib/source/library/lux/web/css/value.lux index aa3efe6b98..70174a77c0 100644 --- a/stdlib/source/library/lux/web/css/value.lux +++ b/stdlib/source/library/lux/web/css/value.lux @@ -75,7 +75,9 @@ (template.with [ ] [(the .public Value - (nominal.abstraction ))] + (|> + nominal.abstraction + (as (-> (Value Any) Value))))] [initial "initial"] [inherit "inherit"] @@ -796,7 +798,8 @@ (text.interposed ..value_delimiter) (text.enclosed ["(" ")"]) (.text name) - nominal.abstraction)) + nominal.abstraction + (as (-> (Value Any) Value)))) (enumeration Step diff --git a/stdlib/source/library/lux/web/html.lux b/stdlib/source/library/lux/web/html.lux index 81e8154c64..a47a7da3d7 100644 --- a/stdlib/source/library/lux/web/html.lux +++ b/stdlib/source/library/lux/web/html.lux @@ -153,32 +153,36 @@ (the (empty_tag name attributes) (-> tag.Name Attributes HTML) - (nominal.abstraction - (.text (..open name attributes) - (..close name)))) + (|> (.text (..open name attributes) + (..close name)) + nominal.abstraction + (as (-> (HTML Any) HTML)))) (the (simple tag attributes) (-> tag.Name Attributes HTML) (|> attributes (..open tag) - nominal.abstraction)) + nominal.abstraction + (as (-> (HTML Any) HTML)))) (the (tag name attributes content) (-> tag.Name Attributes (HTML Any) HTML) - (nominal.abstraction - (.text (..open name attributes) - (nominal.reification content) - (..close name)))) + (|> (.text (..open name attributes) + (nominal.reification content) + (..close name)) + nominal.abstraction + (as (-> (HTML Any) HTML)))) (the (raw tag attributes content) (-> Text Attributes Text HTML) - (nominal.abstraction - (.text (..open tag attributes) - content - (..close tag)))) + (|> (.text (..open tag attributes) + content + (..close tag)) + nominal.abstraction + (as (-> (HTML Any) HTML)))) (template.with [ ] [(the .public @@ -620,7 +624,7 @@ content {.#Some caption} - (..and (as HTML caption) + (..and (as (-> Content HTML) caption) content))] (..tag tag.table attributes content))) diff --git a/stdlib/source/library/lux/world/environment.lux b/stdlib/source/library/lux/world/environment.lux index 41e42ff562..b5a4920ca0 100644 --- a/stdlib/source/library/lux/world/environment.lux +++ b/stdlib/source/library/lux/world/environment.lux @@ -118,45 +118,45 @@ ... https://wiki.sei.cmu.edu/confluence/display/java/ENV02-J.+Do+not+trust+the+values+of+environment+variables (for .jvm (these (import java/lang/String - "[1]::[0]") + "[1]::[0]") - (import (java/util/Iterator a) - "[1]::[0]" - (hasNext [] boolean) - (next [] a)) + (import (java/util/Iterator it) + "[1]::[0]" + (hasNext [] boolean) + (next [] it)) - (import (java/util/Set a) - "[1]::[0]" - (iterator [] (java/util/Iterator a))) + (import (java/util/Set it) + "[1]::[0]" + (iterator [] (java/util/Iterator it))) (import (java/util/Map k v) - "[1]::[0]" - (keySet [] (java/util/Set k))) + "[1]::[0]" + (keySet [] (java/util/Set k))) (import java/lang/System - "[1]::[0]" - ("static" getenv [] (java/util/Map java/lang/String java/lang/String)) - ("static" getenv "as" resolveEnv [java/lang/String] "io" "?" java/lang/String) - ("static" getProperty [java/lang/String] "?" java/lang/String) - ("static" exit [int] "io" void)) + "[1]::[0]" + ("static" getenv [] (java/util/Map java/lang/String java/lang/String)) + ("static" getenv "as" resolveEnv [java/lang/String] "io" "?" java/lang/String) + ("static" getProperty [java/lang/String] "?" java/lang/String) + ("static" exit [int] "io" void)) (the (jvm::consume value iterator) (for_any (_ it) (-> (List it) (java/util/Iterator it) (List it))) (if (ffi.of_boolean (java/util/Iterator::hasNext [] iterator)) - (jvm::consume (list#composite value (list (java/util/Iterator::next [] iterator))) - iterator) - value)) + (jvm::consume (list#composite value (list (as_expected (java/util/Iterator::next [] iterator)))) + iterator) + value)) ) .js (these (the default_exit! (-> Exit (IO Nothing)) (|>> %.integer halt! io.io)) (import NodeJs_Process - "[1]::[0]" - (exit [ffi.Number] "io" Nothing) - (cwd [] "io" Path)) + "[1]::[0]" + (exit [ffi.Number] "io" Nothing) + (cwd [] "io" Path)) (the (exit_node_js! code) (-> Exit (IO Nothing)) @@ -168,12 +168,12 @@ (..default_exit! code))) (import Browser_Window - "[1]::[0]" - (close [] Nothing)) + "[1]::[0]" + (close [] Nothing)) (import Browser_Location - "[1]::[0]" - (reload [] Nothing)) + "[1]::[0]" + (reload [] Nothing)) (the (exit_browser! code) (-> Exit (IO Nothing)) @@ -199,32 +199,32 @@ (..default_exit! code))) (import Object - "[1]::[0]" - ("static" entries [Object] (Array (Array ffi.String)))) + "[1]::[0]" + ("static" entries [Object] (Array (Array ffi.String)))) (import NodeJs_OS - "[1]::[0]" - (homedir [] "io" Path))) + "[1]::[0]" + (homedir [] "io" Path))) .python (these (import os/path - "[1]::[0]" - (expanduser [ffi.String] "io" ffi.String)) + "[1]::[0]" + (expanduser [ffi.String] "io" ffi.String)) (import os/environ - "[1]::[0]" - (keys [] "io" (Array ffi.String)) - (get [ffi.String] "io" "?" ffi.String)) + "[1]::[0]" + (keys [] "io" (Array ffi.String)) + (get [ffi.String] "io" "?" ffi.String)) (import os - "[1]::[0]" - ("static" getcwd [] "io" ffi.String) - ("static" _exit [ffi.Integer] "io" Nothing) + "[1]::[0]" + ("static" getcwd [] "io" ffi.String) + ("static" _exit [ffi.Integer] "io" Nothing) - ("static" path os/path) - ("static" environ os/environ))) + ("static" path os/path) + ("static" environ os/environ))) .lua (these (ffi.import LuaFile - "[1]::[0]" - (read [ffi.String] "io" "?" ffi.String) - (close [] "io" ffi.Boolean)) + "[1]::[0]" + (read [ffi.String] "io" "?" ffi.String) + (close [] "io" ffi.Boolean)) (ffi.import (io/popen [ffi.String] "io" "try" "?" LuaFile)) (ffi.import (os/getenv [ffi.String] "io" "?" ffi.String)) @@ -249,21 +249,21 @@ {try.#Failure _} (in default))))) .ruby (these (ffi.import Env - "[1]::[0]" - ("static" keys [] (Array Text)) - ("static" fetch [Text] "io" "?" Text)) + "[1]::[0]" + ("static" keys [] (Array Text)) + ("static" fetch [Text] "io" "?" Text)) (ffi.import "fileutils" FileUtils - "[2]/[1]::[0]" - ("static" pwd Path)) + "[2]/[1]::[0]" + ("static" pwd Path)) (ffi.import Dir - "[1]::[0]" - ("static" home Path)) + "[1]::[0]" + ("static" home Path)) (ffi.import Kernel - "[1]::[0]" - ("static" exit [Int] "io" Nothing))) + "[1]::[0]" + ("static" exit [Int] "io" Nothing))) ... .php ... (these (ffi.import (exit [Int] "io" Nothing)) @@ -290,15 +290,15 @@ (list#each (|>> ffi.of_string)) io.io) .js (io.io (if ffi.on_node_js? - (when (ffi.global Object [process env]) - {.#Some process/env} - (|> (Object::entries [process/env]) - (array.list {.#None}) - (list#each (|>> (array.item 0) maybe.trusted))) + (when (ffi.global Object [process env]) + {.#Some process/env} + (|> (Object::entries [process/env]) + (array.list {.#None}) + (list#each (|>> (array.item 0) maybe.trusted))) - {.#None} - (list)) - (list))) + {.#None} + (list)) + (list))) .python (do [! io.monad] [it (os::environ)] (by ! each @@ -330,16 +330,16 @@ (exception.except ..unknown_environment_variable [name]))))]] (for .jvm (!fetch (<| java/lang/System::resolveEnv [] ffi.as_string) ffi.of_string) .js (io.io (if ffi.on_node_js? - (when (do maybe.monad - [process/env (ffi.global Object [process env])] - (array.item (as Natural name) - (as (Array Text) process/env))) - {.#Some value} - {try.#Success value} + (when (do maybe.monad + [process/env (ffi.global (Array Text) [process env])] + (array.item (as (-> Text Natural) name) + process/env)) + {.#Some value} + {try.#Success value} - {.#None} - (exception.except ..unknown_environment_variable [name])) - (exception.except ..unknown_environment_variable [name]))) + {.#None} + (exception.except ..unknown_environment_variable [name])) + (exception.except ..unknown_environment_variable [name]))) .python (do io.monad [it (os::environ) value (os/environ::get [name] it)] @@ -361,11 +361,11 @@ (maybe.else "") io.io) .js (if ffi.on_node_js? - (|> (node_js.require "os") - maybe.trusted - (as NodeJs_OS) - (NodeJs_OS::homedir [])) - ) + (|> (node_js.require "os") + maybe.trusted + (as NodeJs_OS) + (NodeJs_OS::homedir [])) + ) .python (do io.monad [it (os::path)] (os/path::expanduser ["~"] it)) @@ -388,20 +388,20 @@ (maybe.else "") io.io) .js (if ffi.on_node_js? - (when (ffi.global ..NodeJs_Process [process]) - {.#Some process} - (NodeJs_Process::cwd [] process) - - {.#None} + (when (ffi.global ..NodeJs_Process [process]) + {.#Some process} + (NodeJs_Process::cwd [] process) + + {.#None} + (io.io )) (io.io )) - (io.io )) .python (os::getcwd []) .lua (do io.monad [.let [default ] on_windows (..run_command default "cd")] (if (same? default on_windows) - (..run_command default "pwd") - (in on_windows))) + (..run_command default "pwd") + (in on_windows))) .ruby (fileutils/FileUtils::pwd) ... .php (do io.monad ... [output (..getcwd [])] @@ -417,13 +417,13 @@ [_ (java/lang/System::exit [(ffi.as_int code)])] (in (undefined))) .js (if ffi.on_node_js? - (..exit_node_js! code) + (..exit_node_js! code) - ffi.on_browser? - (..exit_browser! code) + ffi.on_browser? + (..exit_browser! code) - ... else - (..default_exit! code)) + ... else + (..default_exit! code)) .python (os::_exit [code]) .lua (os/exit [code]) .ruby (Kernel::exit code) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 76abb3c957..ce855f68fa 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -169,17 +169,17 @@ (do [! (try.with future.monad)] [current_files (..available_files fs directory) .let [creations (if (..creation? the_concern) - (list.only (|>> product.left (dictionary.key? file_tracker) not) - current_files) - (list)) + (list.only (|>> product.left (dictionary.key? file_tracker) not) + current_files) + (list)) available (|> current_files (list#each product.left) (set.of_list text.hash)) deletions (if (..deletion? the_concern) - (|> (dictionary.entries file_tracker) - (list#each product.left) - (list.only (|>> (set.member? available) not))) - (list)) + (|> (dictionary.entries file_tracker) + (list#each product.left) + (list.only (|>> (set.member? available) not))) + (list)) modifications (list.all (function (_ [path current_modification]) (do maybe.monad [previous_modification (dictionary.value path file_tracker)] @@ -211,16 +211,16 @@ (do [! future.monad] [exists? (by fs directory? path)] (if exists? - (do ! - [updated? (stm.commit! (..update_watch! new_concern path tracker))] - (if updated? - (in {try.#Success []}) - (do (try.with !) - [file_tracker (..file_tracker fs path)] - (do ! - [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] - (in {try.#Success []}))))) - (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) + (do ! + [updated? (stm.commit! (..update_watch! new_concern path tracker))] + (if updated? + (in {try.#Success []}) + (do (try.with !) + [file_tracker (..file_tracker fs path)] + (do ! + [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] + (in {try.#Success []}))))) + (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) (the (concern path) (stm.commit! (do stm.monad @@ -286,15 +286,15 @@ (for .jvm (these (import java/lang/Object - "[1]::[0]") + "[1]::[0]") (import java/lang/String - "[1]::[0]") + "[1]::[0]") - (import (java/util/List a) - "[1]::[0]" - (size [] int) - (get [int] a)) + (import (java/util/List it) + "[1]::[0]" + (size [] int) + (get [int] it)) (the (default_list it) (for_any (_ it) @@ -308,60 +308,61 @@ (is (List it) (list)))]) (if (n.< size idx) - (again (++ idx) - (list#composite output - (list (java/util/List::get [(ffi.as_int (.integer idx))] it)))) - output)))) + (again (++ idx) + (list#composite output + (list (as_expected (java/util/List::get [(ffi.as_int (.integer idx))] it))))) + output)))) (import (java/nio/file/WatchEvent$Kind it) - "[1]::[0]") + "[1]::[0]") (import (java/nio/file/WatchEvent it) - "[1]::[0]" - (kind [] (java/nio/file/WatchEvent$Kind it))) + "[1]::[0]" + (kind [] (java/nio/file/WatchEvent$Kind it))) (import java/nio/file/Watchable - "[1]::[0]") + "[1]::[0]") (import java/nio/file/Path - "[1]::[0]" - (register [java/nio/file/WatchService [(java/nio/file/WatchEvent$Kind [? < java/lang/Object])]] "io" "try" java/nio/file/WatchKey) - (toString [] java/lang/String)) + "[1]::[0]" + (register [java/nio/file/WatchService [(java/nio/file/WatchEvent$Kind [? < java/lang/Object])]] "io" "try" java/nio/file/WatchKey) + (toString [] java/lang/String)) (import java/nio/file/StandardWatchEventKinds - "[1]::[0]" - ("read_only" "static" ENTRY_CREATE (java/nio/file/WatchEvent$Kind java/nio/file/Path)) - ("read_only" "static" ENTRY_MODIFY (java/nio/file/WatchEvent$Kind java/nio/file/Path)) - ("read_only" "static" ENTRY_DELETE (java/nio/file/WatchEvent$Kind java/nio/file/Path))) + "[1]::[0]" + ("read_only" "static" ENTRY_CREATE (java/nio/file/WatchEvent$Kind java/nio/file/Path)) + ("read_only" "static" ENTRY_MODIFY (java/nio/file/WatchEvent$Kind java/nio/file/Path)) + ("read_only" "static" ENTRY_DELETE (java/nio/file/WatchEvent$Kind java/nio/file/Path))) (the (default_event_concern event) (for_any (_ it) (-> (java/nio/file/WatchEvent it) Concern)) - (let [kind (as (java/nio/file/WatchEvent$Kind java/nio/file/Path) + (let [kind (as (-> (java/nio/file/WatchEvent$Kind Any) + (java/nio/file/WatchEvent$Kind java/nio/file/Path)) (java/nio/file/WatchEvent::kind [] event))] (if (same? (java/nio/file/StandardWatchEventKinds::ENTRY_CREATE) kind) - ..creation - - (same? (java/nio/file/StandardWatchEventKinds::ENTRY_MODIFY) - kind) - ..modification - - (same? (java/nio/file/StandardWatchEventKinds::ENTRY_DELETE) - kind) - ..deletion - - ... else - ..none - ))) + ..creation + + (same? (java/nio/file/StandardWatchEventKinds::ENTRY_MODIFY) + kind) + ..modification + + (same? (java/nio/file/StandardWatchEventKinds::ENTRY_DELETE) + kind) + ..deletion + + ... else + ..none + ))) (import java/nio/file/WatchKey - "[1]::[0]" - (reset [] "io" boolean) - (cancel [] "io" void) - (watchable [] java/nio/file/Watchable) - (pollEvents [] "io" (java/util/List (java/nio/file/WatchEvent ?)))) + "[1]::[0]" + (reset [] "io" boolean) + (cancel [] "io" void) + (watchable [] java/nio/file/Watchable) + (pollEvents [] "io" (java/util/List (java/nio/file/WatchEvent ?)))) (the default_key_concern (-> java/nio/file/WatchKey @@ -372,21 +373,21 @@ (list#mix ..and ..none))))) (import java/nio/file/WatchService - "[1]::[0]" - (poll [] "io" "try" "?" java/nio/file/WatchKey)) + "[1]::[0]" + (poll [] "io" "try" "?" java/nio/file/WatchKey)) (import java/nio/file/FileSystem - "[1]::[0]" - (newWatchService [] "io" "try" java/nio/file/WatchService)) + "[1]::[0]" + (newWatchService [] "io" "try" java/nio/file/WatchService)) (import java/nio/file/FileSystems - "[1]::[0]" - ("static" getDefault [] java/nio/file/FileSystem)) + "[1]::[0]" + ("static" getDefault [] java/nio/file/FileSystem)) (import java/io/File - "[1]::[0]" - (new [java/lang/String]) - (toPath [] java/nio/file/Path)) + "[1]::[0]" + (new [java/lang/String]) + (toPath [] java/nio/file/Path)) (every Watch_Event (java/nio/file/WatchEvent$Kind java/lang/Object)) @@ -416,16 +417,16 @@ (do [! io.monad] [valid? (java/nio/file/WatchKey::reset [] key)] (if (ffi.of_boolean valid?) - (do ! - [.let [path (|> key - (java/nio/file/WatchKey::watchable []) - (as java/nio/file/Path) - (java/nio/file/Path::toString []) - ffi.of_string - (as //.Path))] - the_concern (..default_key_concern key)] - (again (list#composite output (list [the_concern path])))) - (again output))) + (do ! + [.let [path (|> key + (java/nio/file/WatchKey::watchable []) + (as (-> java/nio/file/Watchable java/nio/file/Path)) + (java/nio/file/Path::toString []) + ffi.of_string + (as (-> Text //.Path)))] + the_concern (..default_key_concern key)] + (again (list#composite output (list [the_concern path])))) + (again output))) {.#None} (in output))))) @@ -435,14 +436,17 @@ (List Watch_Event)) (.all list#composite (if (..creation? concern) - (list (as Watch_Event (java/nio/file/StandardWatchEventKinds::ENTRY_CREATE))) - (list)) + (list (as (-> (java/nio/file/WatchEvent$Kind java/nio/file/Path) Watch_Event) + (java/nio/file/StandardWatchEventKinds::ENTRY_CREATE))) + (list)) (if (..modification? concern) - (list (as Watch_Event (java/nio/file/StandardWatchEventKinds::ENTRY_MODIFY))) - (list)) + (list (as (-> (java/nio/file/WatchEvent$Kind java/nio/file/Path) Watch_Event) + (java/nio/file/StandardWatchEventKinds::ENTRY_MODIFY))) + (list)) (if (..deletion? concern) - (list (as Watch_Event (java/nio/file/StandardWatchEventKinds::ENTRY_DELETE))) - (list)) + (list (as (-> (java/nio/file/WatchEvent$Kind java/nio/file/Path) Watch_Event) + (java/nio/file/StandardWatchEventKinds::ENTRY_DELETE))) + (list)) )) (the .public default diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 1ee7abb05a..4804aa5b0a 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -96,43 +96,43 @@ {//.#Trace} "TRACE"))) (for .jvm (these (ffi.import java/lang/String - "[1]::[0]") + "[1]::[0]") (ffi.import java/lang/AutoCloseable - "[1]::[0]" - (close [] "io" "try" void)) + "[1]::[0]" + (close [] "io" "try" void)) (ffi.import java/io/InputStream - "[1]::[0]") + "[1]::[0]") (ffi.import java/io/OutputStream - "[1]::[0]" - (flush [] "io" "try" void) - (write [[byte]] "io" "try" void)) + "[1]::[0]" + (flush [] "io" "try" void) + (write [[byte]] "io" "try" void)) (ffi.import java/net/URLConnection - "[1]::[0]" - (setDoOutput [boolean] "io" "try" void) - (setRequestProperty [java/lang/String java/lang/String] "io" "try" void) - (getInputStream [] "io" "try" java/io/InputStream) - (getOutputStream [] "io" "try" java/io/OutputStream) - (getHeaderFieldKey [int] "io" "try" "?" java/lang/String) - (getHeaderField [int] "io" "try" "?" java/lang/String)) + "[1]::[0]" + (setDoOutput [boolean] "io" "try" void) + (setRequestProperty [java/lang/String java/lang/String] "io" "try" void) + (getInputStream [] "io" "try" java/io/InputStream) + (getOutputStream [] "io" "try" java/io/OutputStream) + (getHeaderFieldKey [int] "io" "try" "?" java/lang/String) + (getHeaderField [int] "io" "try" "?" java/lang/String)) (ffi.import java/net/HttpURLConnection - "[1]::[0]" - (setRequestMethod [java/lang/String] "io" "try" void) - (getResponseCode [] "io" "try" int)) + "[1]::[0]" + (setRequestMethod [java/lang/String] "io" "try" void) + (getResponseCode [] "io" "try" int)) (ffi.import java/net/URL - "[1]::[0]" - (new [java/lang/String]) - (openConnection [] "io" "try" java/net/URLConnection)) + "[1]::[0]" + (new [java/lang/String]) + (openConnection [] "io" "try" java/net/URLConnection)) (ffi.import java/io/BufferedInputStream - "[1]::[0]" - (new [java/io/InputStream]) - (read [[byte] int int] "io" "try" int)) + "[1]::[0]" + (new [java/io/InputStream]) + (read [[byte] int int] "io" "try" int)) (the (default_body input) (-> java/io/BufferedInputStream @@ -148,42 +148,42 @@ [partial? buffer_size] (let [buffer (binary.empty buffer_size)] (if partial? - (loop (again [so_far +0]) - (do [! (try.with io.monad)] - [.let [remaining (i.- so_far (.integer buffer_size))] - bytes_read (by ! each (|>> ffi.of_int) - (java/io/BufferedInputStream::read [buffer (ffi.as_int so_far) (ffi.as_int remaining)] input))] - (when bytes_read - -1 (do ! - [_ (java/lang/AutoCloseable::close [] input)] - (in [(.natural so_far) buffer])) - +0 (again so_far) - _ (if (i.= remaining bytes_read) - (in [buffer_size buffer]) - (again (i.+ bytes_read so_far)))))) - (loop (again [so_far +0 - output (by binary.monoid identity)]) - (do [! (try.with io.monad)] - [.let [remaining (i.- so_far (.integer buffer_size))] - bytes_read (by ! each (|>> ffi.of_int) - (java/io/BufferedInputStream::read [buffer (ffi.as_int so_far) (ffi.as_int remaining)] input))] - (when bytes_read - -1 (do ! - [_ (java/lang/AutoCloseable::close [] input)] - (when so_far - +0 (in (..body_of output)) - _ (|> buffer - (binary.slice 0 (.natural so_far)) - (by try.functor each - (|>> (by binary.monoid composite output) - ..body_of)) - (by io.monad in)))) - +0 (again so_far output) - _ (if (i.= remaining bytes_read) - (again +0 - (by binary.monoid composite output buffer)) - (again (i.+ bytes_read so_far) - output)))))))))) + (loop (again [so_far +0]) + (do [! (try.with io.monad)] + [.let [remaining (i.- so_far (.integer buffer_size))] + bytes_read (by ! each (|>> ffi.of_int) + (java/io/BufferedInputStream::read [buffer (ffi.as_int so_far) (ffi.as_int remaining)] input))] + (when bytes_read + -1 (do ! + [_ (java/lang/AutoCloseable::close [] input)] + (in [(.natural so_far) buffer])) + +0 (again so_far) + _ (if (i.= remaining bytes_read) + (in [buffer_size buffer]) + (again (i.+ bytes_read so_far)))))) + (loop (again [so_far +0 + output (by binary.monoid identity)]) + (do [! (try.with io.monad)] + [.let [remaining (i.- so_far (.integer buffer_size))] + bytes_read (by ! each (|>> ffi.of_int) + (java/io/BufferedInputStream::read [buffer (ffi.as_int so_far) (ffi.as_int remaining)] input))] + (when bytes_read + -1 (do ! + [_ (java/lang/AutoCloseable::close [] input)] + (when so_far + +0 (in (..body_of output)) + _ (|> buffer + (binary.slice 0 (.natural so_far)) + (by try.functor each + (|>> (by binary.monoid composite output) + ..body_of)) + (by io.monad in)))) + +0 (again so_far output) + _ (if (i.= remaining bytes_read) + (again +0 + (by binary.monoid composite output buffer)) + (again (i.+ bytes_read so_far) + output)))))))))) (the (default_headers connection) (-> java/net/HttpURLConnection @@ -209,7 +209,8 @@ (is (IO (Try (Response IO))) (do [! (try.with io.monad)] [connection (|> url ffi.as_string [] java/net/URL::new (java/net/URL::openConnection [])) - .let [connection (as java/net/HttpURLConnection connection)] + .let [connection (as (-> java/net/URLConnection java/net/HttpURLConnection) + connection)] _ (java/net/HttpURLConnection::setRequestMethod [(ffi.as_string (..method_name method))] connection) _ (list.each' ! (function (_ [name value]) (java/net/URLConnection::setRequestProperty [(ffi.as_string name) (ffi.as_string value)] connection)) @@ -235,8 +236,8 @@ [//.#headers headers //.#body (..default_body input)]]))))))) .python (these (ffi.import Dict - "[1]#[0]" - (setdefault [Text Text] Text)) + "[1]#[0]" + (setdefault [Text Text] Text)) (ffi.import (dict [] Dict)) @@ -260,18 +261,18 @@ header.empty))) (ffi.import http/client/HTTPResponse - "[1]#[0]" - (status Natural) - (read ["?" Natural] "io" "try" Binary) - (getheaders [] "io" "try" (Array (Array Text)))) + "[1]#[0]" + (status Natural) + (read ["?" Natural] "io" "try" Binary) + (getheaders [] "io" "try" (Array (Array Text)))) (ffi.import urllib/request/Request - "[1]#[0]") + "[1]#[0]") (ffi.import urllib/request - "[1]#[0]" - ("static" Request [URL "?" Binary Dict "?" Any Bit Text] urllib/request/Request) - ("static" urlopen [urllib/request/Request] "io" "try" http/client/HTTPResponse)) + "[1]#[0]" + ("static" Request [URL "?" Binary Dict "?" Any Bit Text] urllib/request/Request) + ("static" urlopen [urllib/request/Request] "io" "try" http/client/HTTPResponse)) (the (default_body input) (-> http/client/HTTPResponse @@ -286,8 +287,8 @@ [partial? buffer_size] (do ! [it (http/client/HTTPResponse#read [(if partial? - {.#Some buffer_size} - {.#None})] + {.#Some buffer_size} + {.#None})] input)] (in (body_of it))))))) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index b4cdb6c3c1..98296d9842 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -209,8 +209,8 @@ (java/util/Map java/lang/String java/lang/String)) (list#mix (function (_ [key value] target') (exec - (java/util/Map::put [(as java/lang/String key) - (as java/lang/String value)] + (java/util/Map::put [(as (-> Text java/lang/String) key) + (as (-> Text java/lang/String) value)] target') target')) target diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index ab39147d4c..599072a0d0 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -619,8 +619,7 @@ (same? (/.is Any expected)))) (_.coverage [/.as] (|> expected - (/.is Any) - (/.as /.Natural) + (/.as (-> Any /.Natural)) (same? expected))) (_.coverage [/.as_expected] (|> expected diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux index 373b0395ff..1499159c4f 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux @@ -93,7 +93,7 @@ [ ( provenance.dummy )])] (in (when (by host evaluate [{.#None} it]) {try.#Success actual} - (when (as Variant/3 actual) + (when (as (-> Any Variant/3) actual) { actual} (<=> actual) @@ -122,7 +122,7 @@ (synthesis.text provenance.dummy expected_text)))] (in (when (by host evaluate [{.#None} it]) {try.#Success actual} - (let [[actual_bit actual_i64 actual_text] (as Tuple/3 actual)] + (let [[actual_bit actual_i64 actual_text] (as (-> Any Tuple/3) actual)] (and (bit.= expected_bit actual_bit) (i64.= expected_i64 actual_i64) (text.= expected_text actual_text))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux index 2abd05823b..c908abf6ce 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux @@ -85,7 +85,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as (-> [] I64)) + (try#each (|>> (as (-> Any (-> [] I64))) (function.on []) (i64.= expected_i64))) (try.else false)))))) @@ -107,7 +107,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false)) @@ -144,7 +144,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux index 6c84816f90..bdfa086077 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux @@ -11,6 +11,8 @@ ["[0]" io]] [error ["[0]" try (.use "[1]#[0]" functor)]] + [function + [predicate (.only Predicate)]] [math ["[0]" random (.only Random)] [number @@ -41,26 +43,26 @@ ["[0]T" complex]]) (ffi.import java/lang/String - "[1]::[0]") + "[1]::[0]") (ffi.import (java/lang/Class of) - "[1]::[0]" - (getCanonicalName [] java/lang/String)) + "[1]::[0]" + (getCanonicalName [] java/lang/String)) (ffi.import java/lang/Object - "[1]::[0]" - (getClass [] (java/lang/Class [? < java/lang/Object]))) + "[1]::[0]" + (getClass [] (java/lang/Class [? < java/lang/Object]))) (ffi.import java/lang/ClassLoader - "[1]::[0]" - ("static" getSystemClassLoader [] java/lang/ClassLoader)) + "[1]::[0]" + ("static" getSystemClassLoader [] java/lang/ClassLoader)) (the (function? loader it) - (-> java/lang/ClassLoader Any - Bit) + (-> java/lang/ClassLoader + (Predicate Any)) (let [super (type/reflection.reflection (type.reflection /.class)) sub (|> it - (as java/lang/Object) + (as (-> Any java/lang/Object)) (java/lang/Object::getClass []) (java/lang/Class::getCanonicalName []) ffi.of_string)] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux index c1a0ce2518..4b4cfc16f8 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux @@ -81,7 +81,8 @@ (value.boxed type.long)) [{.#None}] (by host evaluate) - (try#each (|>> (as Natural) (n.= 0))) + (try#each (|>> (as (-> Any Natural)) + (n.= 0))) (try.else false)))) (_.coverage [/.value] (let [fresh_abstraction! @@ -103,7 +104,8 @@ (value.boxed type.long)) [{.#None}] (by host evaluate) - (try#each (|>> (as Natural) (n.= 0))) + (try#each (|>> (as (-> Any Natural)) + (n.= 0))) (try.else false)))))) (try.else false)) @@ -129,7 +131,8 @@ (value.boxed type.long)) [{.#None}] (by host evaluate) - (try#each (|>> (as Natural) (n.= partial_application))) + (try#each (|>> (as (-> Any Natural)) + (n.= partial_application))) (try.else false)))))) (try.else false))] (and fresh_abstraction! diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux index ae6343d7b8..cb8f22c099 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux @@ -78,7 +78,7 @@ [{.#None}] (by host evaluate) (try#each (function (_ it) - (let [it (as (-> I64 I64 I64) + (let [it (as (-> Any (-> I64 I64 I64)) it) it' (it expected_i64)] (same? expected_i64 diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux index 5c214b7bfc..f37dc98dc6 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux @@ -74,7 +74,7 @@ (by host evaluate) (try#each (function (_ it) (same? expected_i64 - (let [it (as (-> I64 I64 I64) + (let [it (as (-> Any (-> I64 I64 I64)) it) it' (it expected_i64)] (it' dummy_i64))))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux index c919f77b6b..7763fcf637 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux @@ -68,7 +68,7 @@ (in (|> actual [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux index b9eb5ff7bf..e08c9e8600 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux @@ -46,12 +46,12 @@ ["[0]T" complex]]) (ffi.import (java/lang/Class of) - "[1]::[0]" - (getCanonicalName [] java/lang/String)) + "[1]::[0]" + (getCanonicalName [] java/lang/String)) (ffi.import java/lang/Object - "[1]::[0]" - (getClass [] (java/lang/Class java/lang/Object))) + "[1]::[0]" + (getClass [] (java/lang/Class java/lang/Object))) (the .public (test valid_modifier?) (-> (-> (Modifier Method) Bit) @@ -91,7 +91,7 @@ (by host evaluate) phase.of_try) .let [class (|> it - (as java/lang/Object) + (as (-> Any java/lang/Object)) (java/lang/Object::getClass []) (java/lang/Class::getCanonicalName []) ffi.of_string @@ -102,7 +102,7 @@ (/.call class 1)) [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false) ))))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux index bb5dbd67c2..d57a4f993e 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux @@ -46,12 +46,12 @@ ["[0]T" complex]]) (ffi.import (java/lang/Class of) - "[1]::[0]" - (getCanonicalName [] java/lang/String)) + "[1]::[0]" + (getCanonicalName [] java/lang/String)) (ffi.import java/lang/Object - "[1]::[0]" - (getClass [] (java/lang/Class java/lang/Object))) + "[1]::[0]" + (getClass [] (java/lang/Class java/lang/Object))) (the .public test Test @@ -91,7 +91,7 @@ (by host evaluate) phase.of_try) .let [class (|> it - (as java/lang/Object) + (as (-> Any java/lang/Object)) (java/lang/Object::getClass []) (java/lang/Class::getCanonicalName []) ffi.of_string @@ -102,7 +102,7 @@ (by host evaluate) (try#each (function (_ it) (i64.= dummy_i64 - ((as (-> I64 I64) + ((as (-> Any (Change I64)) it) expected_i64)))) (try.else false)) @@ -116,7 +116,7 @@ (by host evaluate) (try#each (function (_ it) (i64.= expected_i64 - ((as (-> I64 I64 I64) + ((as (-> Any (-> I64 I64 I64)) it) expected_i64 expected_i64)))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/host.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/host.lux index ddf2919f52..b61e5a742a 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/host.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/host.lux @@ -34,7 +34,7 @@ [[class_loader host] /.host] (in (when (by host evaluate [{.#None} (bytecode.string expected)]) {try.#Success actual} - (text.= expected (as Text actual)) + (text.= expected (as (-> Any Text) actual)) {try.#Failure error} false))))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux index e92fd28464..270ed7937d 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux @@ -64,7 +64,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false)) @@ -84,7 +84,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))] @@ -113,7 +113,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/primitive.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/primitive.lux index 61327f8aba..62beee79a7 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/primitive.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/primitive.lux @@ -42,7 +42,7 @@ [[class_loader host] host.host] (in (when (by host evaluate [{.#None} ( )]) {try.#Success actual} - (<=> (as actual)) + (<=> (as (-> Any ) actual)) {try.#Failure error} false)))))] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux index 97c7c2277e..dfdcf59e51 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux @@ -78,7 +78,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected))) (try.else false)))))) (try.else false))) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/value.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/value.lux index ce4c440d14..b1c75d372f 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/value.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/value.lux @@ -54,7 +54,7 @@ (/.boxed ) )]) {try.#Success actual} - (<=> (as actual)) + (<=> (as (-> Any ) actual)) {try.#Failure error} false))))] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux index 3909658dfc..aa6d59e455 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux @@ -63,19 +63,19 @@ state (is runtime.State (translation.state host module)) [then else] (if expected_bit - [expected_i64 dummy_i64] - [dummy_i64 expected_i64])]] + [expected_i64 dummy_i64] + [dummy_i64 expected_i64])]] (<| (phase.value state) (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.if next archive - [(synthesis.bit @ expected_bit) - (synthesis.i64 @ then) - (synthesis.i64 @ else)])] + [(synthesis.bit @ expected_bit) + (synthesis.i64 @ then) + (synthesis.i64 @ else)])] (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))))) @@ -111,7 +111,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))))) @@ -145,7 +145,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))) (try.else false))))) @@ -192,8 +192,8 @@ [nested_tuple nested_access] (is [(List synthesis.Term) Member] (if nested_choice - [middle_tuple middle_access] - [right_tuple right_access])) + [middle_tuple middle_access] + [right_tuple right_access])) nested_tuple (is (List synthesis.Term) (all list#composite (list.repeated right_siblings (synthesis.i64 @ dummy_i64)) @@ -208,7 +208,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) right! (<| (phase.value state) @@ -221,7 +221,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) nested! (<| (phase.value state) @@ -235,7 +235,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false)))))] (in (and middle! @@ -280,7 +280,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) pop! (<| (phase.value state) @@ -295,7 +295,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) bind! (<| (phase.value state) @@ -310,7 +310,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) bit! (<| (phase.value state) @@ -325,7 +325,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) i64! (<| (phase.value state) @@ -339,7 +339,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) f64! (<| (phase.value state) @@ -353,7 +353,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) text! (<| (phase.value state) @@ -367,7 +367,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) alt! (<| (phase.value state) @@ -383,7 +383,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))) .let [access!|member (is (-> Member (List I64) @@ -404,7 +404,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))))) access!|side (is (-> Side @@ -425,7 +425,7 @@ (in (|> it [{.#None}] (by host evaluate) - (try#each (|>> (as I64) + (try#each (|>> (as (-> Any I64)) (i64.= expected_i64))) (try.else false))))))) access! (and (access!|member [lefts false] (list#composite (list.repeated lefts dummy_i64) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 79e5c506ee..f36be61249 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -18,22 +18,25 @@ [data [collection ["[0]" stack]]] + ["[0]" type (.only sharing)] + [function + [predicate (.only Predicate)]] [math ["[0]" random] [number ["n" natural]]] - [type (.only sharing)] [test ["_" property (.only Test)]]]] [\\library - ["[0]" / (.only Region) + ["[0]" / (.only) [// - ["[0]" thread (.only Thread)]]]]) + ["[0]" thread]]]]) (exception.the oops) (the (success? it) - (for_any (_ a) (-> (Try a) Bit)) + (for_any (_ it) + (Predicate (Try it))) (when it {try.#Success _} true @@ -42,7 +45,9 @@ false)) (the (throws? exception it) - (for_any (_ e a) (-> (Exception e) (Try a) Bit)) + (for_any (_ e it) + (-> (Exception e) + (Predicate (Try it)))) (when it {try.#Success _} false @@ -51,25 +56,19 @@ (exception.is? exception error))) (the (injection value) - (Injection (for_any (_ a) (for_any (_ ! r) (Region r (Thread !) a)))) + (Injection (for_any (_ it thread) + (/.Region (thread.Thread thread) it))) (function (_ [region scope]) - (function (_ !) + (function (_ thread) [scope {try.#Success value}]))) (the comparison - (Comparison (for_any (_ a) (for_any (_ ! r) (Region r (Thread !) a)))) + (Comparison (for_any (_ it thread) + (/.Region (thread.Thread thread) it))) (function (_ == left right) - (when [(sharing [a] - (is (Equivalence a) - ==) - (is (Try a) - (thread.value (as_expected (/.value thread.monad left))))) - (sharing [a] - (is (Equivalence a) - ==) - (is (Try a) - (thread.value (as_expected (/.value thread.monad right)))))] + (when [(thread.value (/.value thread.monad left)) + (thread.value (/.value thread.monad right))] [{try.#Success left} {try.#Success right}] (== left right) @@ -84,12 +83,12 @@ [expected_clean_ups (|> random.natural (by ! each (|>> (n.% 100) (n.major 1))))] (all _.and (_.for [/.functor] - (functorT.spec ..injection ..comparison (is (for_any (_ ! r) - (Functor (Region r (thread.Thread !)))) + (functorT.spec ..injection ..comparison (is (for_any (_ thread) + (Functor (/.Region (thread.Thread thread)))) (/.functor thread.functor)))) (_.for [/.monad] - (monadT.spec ..injection ..comparison (is (for_any (_ ! r) - (Monad (Region r (thread.Thread !)))) + (monadT.spec ..injection ..comparison (is (for_any (_ thread) + (Monad (/.Region (thread.Thread thread)))) (/.monad thread.monad)))) (_.coverage [/.value] diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index e1bd87407d..c596b078ce 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -62,20 +62,21 @@ "[1]::[0]" (getName [] java/lang/String)) -(template.with [ <=>] +(template.with [ <=>] [(the ( left right) - (-> Bit) - (<=> (as ( left)) - (as ( right))))] - - [boolean#= /.Boolean <| Bit bit.=] - [byte#= /.Byte /.byte_to_long Integer i.=] - [short#= /.Short /.short_to_long Int i.=] - [integer#= /.Integer /.int_to_long Integer i.=] - [long#= /.Long <| Integer i.=] - [float#= /.Float /.float_to_double Decimal d.=] - [double#= /.Double <| Decimal d.=] - [character#= /.Character /.char_to_long Integer i.=] + (-> + Bit) + (<=> (as (-> ) ( left)) + (as (-> ) ( right))))] + + [boolean#= /.Boolean <| /.Boolean Bit bit.=] + [byte#= /.Byte /.byte_to_long /.Long Integer i.=] + [short#= /.Short /.short_to_long /.Long Int i.=] + [integer#= /.Integer /.int_to_long /.Long Integer i.=] + [long#= /.Long <| /.Long Integer i.=] + [float#= /.Float /.float_to_double /.Double Decimal d.=] + [double#= /.Double <| /.Double Decimal d.=] + [character#= /.Character /.char_to_long /.Long Integer i.=] ) (the macro_error @@ -144,7 +145,8 @@ /.of_long (i.= (/.of_long value)))) (_.coverage [/.cannot_convert_to_jvm_type] - (let [array (as (Array Nothing) + (let [array (as (-> (Array Any) + (Array Nothing)) (array.empty 1))] (|> array /.length @@ -154,7 +156,7 @@ (the for_miscellaneous Test (`` (do [! random.monad] - [sample (by ! each (|>> (as java/lang/Object)) + [sample (by ! each (|>> (as (-> Text java/lang/Object))) (random.ascii 1)) boolean (by ! each (|>> /.as_boolean) random.bit) byte (by ! each (|>> /.as_byte) random.integer) @@ -255,7 +257,8 @@ (_.coverage [/.is] (|> string (/.is java/lang/Object) - (same? (as java/lang/Object string)))) + (same? (as (-> java/lang/String java/lang/Object) + string)))) (_.coverage [/.type] (and (and (type.= /.Boolean (/.type java/lang/Boolean)) (type.= /.Boolean (/.type boolean))) @@ -594,13 +597,13 @@ object/2 (test/TestClass2::new []) example/2! (n.= expected - (.natural (/.of_long (test/TestInterface2::actual2 [(/.as_long (.integer expected))] object/2)))) + (.natural (/.of_long (as (-> Any /.Long) (test/TestInterface2::actual2 [(/.as_long (.integer expected))] object/2))))) object/3 (is (test/TestClass3 java/lang/Long) (test/TestClass3::new [(/.as_long (.integer expected))])) example/3! (n.= expected - (.natural (/.of_long (test/TestInterface3::actual3 [] object/3)))) + (.natural (/.of_long (as (-> Any /.Long) (test/TestInterface3::actual3 [] object/3))))) object/4 (test/TestClass4::new []) example/4! @@ -635,6 +638,7 @@ example/9! (|> object/9 (test/TestClass9::get_actual9 []) + (as (-> Any Integer)) /.as_long (same? dummy/2)) @@ -644,12 +648,14 @@ (and (|> object/10 test/TestClass10::value10 io.value + (as (-> Any /.Long)) (same? dummy/0)) (|> object/10 (test/TestClass10::value10 dummy/1) io.value test/TestClass10::value10 io.value + (as (-> Any /.Long)) (same? dummy/1))) object/11 (is (test/TestClass11 java/lang/Long) @@ -657,6 +663,7 @@ example/11! (and (|> object/11 test/TestClass11::value11 + (as (-> Any /.Long)) (same? dummy/0)) (|> object/11 (test/TestClass11::value11 dummy/1) diff --git a/stdlib/source/test/lux/ffi/export.jvm.lux b/stdlib/source/test/lux/ffi/export.jvm.lux index 22e1cde676..bf063b2d09 100644 --- a/stdlib/source/test/lux/ffi/export.jvm.lux +++ b/stdlib/source/test/lux/ffi/export.jvm.lux @@ -40,80 +40,86 @@ (the expected_string (//.as_string (static.random code.text (random.lower_cased 2)))) (`` (`` (/.export Primitives - ... Constants - (actual_boolean boolean ..expected_boolean) - (actual_byte byte ..expected_byte) - (actual_short short ..expected_short) - (actual_int int ..expected_int) - (actual_long long ..expected_long) - (actual_char char ..expected_char) - (actual_float float ..expected_float) - (actual_double double ..expected_double) - - ... Methods - (,, (template.with [ <+>] - [(((,, (template.name [ "_method"])) - [left - right ]) - - ((,, (template.name [//._] ["as_" ])) - (<+> ((,, (template.name [//._] ["of_" ])) left) - ((,, (template.name [//._] ["of_" ])) right))))] - - [boolean and] - [byte integer.+] - [short integer.+] - [int integer.+] - [long integer.+] - [char integer.+] - [float decimal.+] - [double decimal.+] - )) - ))) + ... Constants + (actual_boolean boolean ..expected_boolean) + (actual_byte byte ..expected_byte) + (actual_short short ..expected_short) + (actual_int int ..expected_int) + (actual_long long ..expected_long) + (actual_char char ..expected_char) + (actual_float float ..expected_float) + (actual_double double ..expected_double) + + ... Methods + (,, (template.with [ <+>] + [(((,, (template.name [ "_method"])) + [left + right ]) + + ((,, (template.name [//._] ["as_" ])) + (<+> ((,, (template.name [//._] ["of_" ])) left) + ((,, (template.name [//._] ["of_" ])) right))))] + + [boolean and] + [byte integer.+] + [short integer.+] + [int integer.+] + [long integer.+] + [char integer.+] + [float decimal.+] + [double decimal.+] + )) + ))) (`` (`` (//.import Primitives - "[1]::[0]" - ("read_only" "static" actual_boolean boolean) - ("read_only" "static" actual_byte byte) - ("read_only" "static" actual_short short) - ("read_only" "static" actual_int int) - ("read_only" "static" actual_long long) - ("read_only" "static" actual_char char) - ("read_only" "static" actual_float float) - ("read_only" "static" actual_double double) - - (,, (template.with [] - [("static" (,, (template.name [ "_method"])) [ ] )] - - [boolean] - [byte] - [short] - [int] - [long] - [char] - [float] - [double] - )) - ))) + "[1]::[0]" + ("read_only" "static" actual_boolean boolean) + ("read_only" "static" actual_byte byte) + ("read_only" "static" actual_short short) + ("read_only" "static" actual_int int) + ("read_only" "static" actual_long long) + ("read_only" "static" actual_char char) + ("read_only" "static" actual_float float) + ("read_only" "static" actual_double double) + + (,, (template.with [] + [("static" (,, (template.name [ "_method"])) [ ] )] + + [boolean] + [byte] + [short] + [int] + [long] + [char] + [float] + [double] + )) + ))) + +(//.import java/lang/Long + "[1]::[0]") + +(//.import java/lang/String + "[1]::[0]") (/.export Objects - (actual_string java/lang/String ..expected_string) + (actual_string java/lang/String ..expected_string) - ((string_method [left java/lang/String right java/lang/String]) - java/lang/String - (//.as_string (text (//.of_string left) (//.of_string right)))) + ((string_method [left java/lang/String right java/lang/String]) + java/lang/String + (//.as_string (text (//.of_string left) (//.of_string right)))) - (([a] left [left a right a]) a left) - (([a] right [left a right a]) a right)) + (([a] left [left a right a]) a left) + (([a] right [left a right a]) a right)) (//.import Objects - "[1]::[0]" - ("read_only" "static" actual_string java/lang/String) + "[1]::[0]" + ("read_only" "static" actual_string java/lang/String) - ("static" string_method [java/lang/String java/lang/String] java/lang/String) - - ("static" [a] left [a a] a) - ("static" [a] right [a a] a)) + ("static" string_method [java/lang/String java/lang/String] java/lang/String) + + ("static" [a] left [a a] a) + ("static" [a] right [a a] a)) (the tiny_integer (Random Integer) @@ -180,12 +186,12 @@ (//.of_string (Objects::string_method [left_string right_string]))) (text.= (//.of_string left_string) - (//.of_string (Objects::left [left_string right_string]))) + (//.of_string (as (-> Any java/lang/String) (Objects::left [left_string right_string])))) (text.= (//.of_string right_string) - (//.of_string (Objects::right [left_string right_string]))) + (//.of_string (as (-> Any java/lang/String) (Objects::right [left_string right_string])))) (integer.= (//.of_long left_long) - (//.of_long (Objects::left [left_long right_long]))) + (//.of_long (as (-> Any java/lang/Long) (Objects::left [left_long right_long])))) (integer.= (//.of_long right_long) - (//.of_long (Objects::right [left_long right_long]))) + (//.of_long (as (-> Any java/lang/Long) (Objects::right [left_long right_long])))) )) )))))) diff --git a/stdlib/source/test/lux/meta/binding.lux b/stdlib/source/test/lux/meta/binding.lux index aef4f7d3f2..7eca337dce 100644 --- a/stdlib/source/test/lux/meta/binding.lux +++ b/stdlib/source/test/lux/meta/binding.lux @@ -362,7 +362,7 @@ (!expect (^.multi {try.#Success [actual_exported? {.#Definition [actual_type actual_value]}]} (and (bit.= expected_exported? actual_exported?) (same? expected_type actual_type) - (same? (as Any expected_value) actual_value))))) + (same? (as (-> Macro Any) expected_value) actual_value))))) alias! (|> (/.definition [expected_current_module expected_proper]) @@ -397,13 +397,13 @@ (|> (/.type_definition [expected_macro_module expected_proper]) (//.value expected_lux) (!expect (^.multi {try.#Success actual_value} - (same? (as .Type expected_value) actual_value)))) + (same? (as (-> Any .Type) expected_value) actual_value)))) alias! (|> (/.type_definition [expected_current_module expected_proper]) (//.value expected_lux) (!expect (^.multi {try.#Success actual_value} - (same? (as .Type expected_value) actual_value))))] + (same? (as (-> Any .Type) expected_value) actual_value))))] (and definition! alias!))) ))) diff --git a/stdlib/source/test/lux/meta/label.lux b/stdlib/source/test/lux/meta/label.lux index 2efc6d8f2b..66c6ca7cb3 100644 --- a/stdlib/source/test/lux/meta/label.lux +++ b/stdlib/source/test/lux/meta/label.lux @@ -67,20 +67,20 @@ (and (static.expansion (do //.monad [it (/.tag (name ,tag_0))] - (in (list (code.bit (same? (as Label ,tag_0) it)))))) + (in (list (code.bit (same? (as (-> Tag Label) ,tag_0) it)))))) (static.expansion (do //.monad [it (/.tag (name ,tag_1))] - (in (list (code.bit (same? (as Label ,tag_1) it)))))))) + (in (list (code.bit (same? (as (-> Tag Label) ,tag_1) it)))))))) (_.coverage [.Slot /.slot] (and (static.expansion (do //.monad [it (/.slot (name ,slot_0))] - (in (list (code.bit (same? (as Label ,slot_0) it)))))) + (in (list (code.bit (same? (as (-> Slot Label) ,slot_0) it)))))) (static.expansion (do //.monad [it (/.slot (name ,slot_1))] - (in (list (code.bit (same? (as Label ,slot_1) it))))))))))) + (in (list (code.bit (same? (as (-> Slot Label) ,slot_1) it))))))))))) (the plural Test @@ -163,8 +163,7 @@ (stack#each (function (_ [index proper]) [proper [true {.#Definition [.Tag (|> [{.#Some [(lefts index) (right? index) (list.of_stack cohort)]} type_0] - (is Label) - (as .Tag))]}]])) + (as (-> Label .Tag)))]}]])) list.of_stack)) (let [cohort (is (Stack Name) (stack#each (|>> [label_module]) @@ -181,8 +180,7 @@ (stack#each (function (_ [index proper]) [proper [true {.#Definition [.Slot (|> [{.#Some [(lefts index) (right? index) (list.of_stack cohort)]} type_1] - (is Label) - (as .Slot))]}]])) + (as (-> Label .Slot)))]}]])) list.of_stack))) .#imports (list) .#module_state {.#Active}]]) diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux index 7e1a47235f..454560470d 100644 --- a/stdlib/source/test/lux/program.lux +++ b/stdlib/source/test/lux/program.lux @@ -111,7 +111,7 @@ (io.io (list.of_stack all_arguments)))) (list.as_stack inputs))] (list#= inputs - (as (List Text) (io.value outcome)))) + (as (-> Any (List Text)) (io.value outcome)))) (let [outcome ((is /.Program (/.program [arg/0 \\projection.any arg/1 \\projection.any @@ -121,13 +121,13 @@ (io.io (list arg/4 arg/3 arg/2 arg/1 arg/0)))) (list.as_stack inputs))] (list#= (list.reversed inputs) - (as (List Text) (io.value outcome)))) + (as (-> Any (List Text)) (io.value outcome)))) (let [outcome ((is /.Program (/.program [all_arguments (<>.many \\projection.any)] (io.io all_arguments))) (list.as_stack inputs))] (list#= inputs - (as (List Text) (io.value outcome)))) + (as (-> Any (List Text)) (io.value outcome)))) (when (try ((is /.Program (/.program [arg/0 \\projection.any arg/1 \\projection.any diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 540d904a9d..9dbe0a9952 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -15,7 +15,7 @@ ["[0]" io] ["[0]" maybe]] [error - ["[0]" try (.only Try)] + ["[0]" try (.only Try) (.use "[1]#[0]" functor)] ["[0]" exception]] ["[0]" function] [data @@ -92,42 +92,42 @@ )) (import java/lang/Boolean - "[1]::[0]") + "[1]::[0]") (import java/lang/Byte - "[1]::[0]") + "[1]::[0]") (import java/lang/Short - "[1]::[0]") + "[1]::[0]") (import java/lang/Integer - "[1]::[0]") + "[1]::[0]") (import java/lang/Long - "[1]::[0]") + "[1]::[0]") (import java/lang/Float - "[1]::[0]") + "[1]::[0]") (import java/lang/Double - "[1]::[0]") + "[1]::[0]") (import java/lang/Character - "[1]::[0]") + "[1]::[0]") (import java/lang/String - "[1]::[0]") + "[1]::[0]") (import java/lang/reflect/Method - "[1]::[0]" - (invoke [java/lang/Object [java/lang/Object]] "try" java/lang/Object)) + "[1]::[0]" + (invoke [java/lang/Object [java/lang/Object]] "try" java/lang/Object)) (import (java/lang/Class c) - "[1]::[0]" - (getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method)) + "[1]::[0]" + (getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method)) (import java/lang/Object - "[1]::[0]") + "[1]::[0]") (the class_name (Random Text) @@ -154,19 +154,19 @@ method_name (random.upper_cased 10)] (in (when (do try.monad [class (class.class version.v6_0 class.public - (internal.name class_name) - {.#None} - (internal.name "java.lang.Object") - (.list) - (.list) - (.list (/method.method ..method_modifier - method_name - false (type.method [(.list) (.list) ..$Object (.list)]) - (.list) - {.#Some (do /.monad - [_ bytecode] - /.areturn)})) - (.list)) + (internal.name class_name) + {.#None} + (internal.name "java.lang.Object") + (.list) + (.list) + (.list (/method.method ..method_modifier + method_name + false (type.method [(.list) (.list) ..$Object (.list)]) + (.list) + {.#Some (do /.monad + [_ bytecode] + /.areturn)})) + (.list)) .let [bytecode (binary.value class.as_binary class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) @@ -187,165 +187,272 @@ #random (Random a) #literal (-> a (Bytecode Any))])) -(the $Boolean - (type.class (.list) "java.lang.Boolean")) -(the $Boolean::wrap - (/.invokestatic ..$Boolean "valueOf" (type.method [(.list) (.list type.boolean) ..$Boolean (.list)]))) -(the $Boolean::random (as (Random java/lang/Boolean) random.bit)) -(the !false (|> 0 .i64 /32.of /.int)) -(the !true (|> 1 .i64 /32.of /.int)) -(the ($Boolean::literal value) - (-> java/lang/Boolean (Bytecode Any)) - (if (as Bit value) - ..!true - ..!false)) -(the $Boolean::primitive - (Primitive java/lang/Boolean) - [#unboxed type.boolean - #boxed ..$Boolean - #wrap ..$Boolean::wrap - #random ..$Boolean::random - #literal ..$Boolean::literal]) - -(the $Byte - (type.class (.list) "java.lang.Byte")) -(the $Byte::wrap - (/.invokestatic ..$Byte "valueOf" (type.method [(.list) (.list type.byte) ..$Byte (.list)]))) -(the $Byte::random - (Random java/lang/Byte) - (by random.monad each (|>> (as java/lang/Long) ffi.long_to_byte) random.integer)) -(the $Byte::literal - (-> java/lang/Byte (Bytecode Any)) - (|>> ffi.byte_to_long (as I64) /32.of /.int)) -(the $Byte::primitive - (Primitive java/lang/Byte) - [#unboxed type.byte - #boxed ..$Byte - #wrap ..$Byte::wrap - #random ..$Byte::random - #literal ..$Byte::literal]) - -(the $Short - (type.class (.list) "java.lang.Short")) -(the $Short::wrap - (/.invokestatic ..$Short "valueOf" (type.method [(.list) (.list type.short) ..$Short (.list)]))) -(the $Short::random - (Random java/lang/Short) - (by random.monad each (|>> (as java/lang/Long) ffi.long_to_short) random.integer)) -(the $Short::literal - (-> java/lang/Short (Bytecode Any)) - (|>> ffi.short_to_long (as I64) /32.of /.int)) -(the $Short::primitive - (Primitive java/lang/Short) - [#unboxed type.short - #boxed ..$Short - #wrap ..$Short::wrap - #random ..$Short::random - #literal ..$Short::literal]) - -(the $Integer - (type.class (.list) "java.lang.Integer")) -(the $Integer::wrap - (/.invokestatic ..$Integer "valueOf" (type.method [(.list) (.list type.int) ..$Integer (.list)]))) -(the $Integer::random - (Random java/lang/Integer) - (by random.monad each (|>> (as java/lang/Long) ffi.long_to_int) random.integer)) -(the $Integer::literal - (-> java/lang/Integer (Bytecode Any)) - (|>> ffi.int_to_long (as I64) /32.of /.int)) -(the $Integer::primitive - (Primitive java/lang/Integer) - [#unboxed type.int - #boxed ..$Integer - #wrap ..$Integer::wrap - #random ..$Integer::random - #literal ..$Integer::literal]) - -(the $Long (type.class (.list) "java.lang.Long")) -(the $Long::wrap (/.invokestatic ..$Long "valueOf" (type.method [(.list) (.list type.long) ..$Long (.list)]))) -(the $Long::random (as (Random java/lang/Long) random.integer)) -(the $Long::literal (-> java/lang/Long (Bytecode Any)) (|>> (as Integer) /.long)) -(the $Long::primitive - (Primitive java/lang/Long) - [#unboxed type.long - #boxed ..$Long - #wrap ..$Long::wrap - #random ..$Long::random - #literal ..$Long::literal]) - -(the $Float (type.class (.list) "java.lang.Float")) -(the $Float::wrap (/.invokestatic ..$Float "valueOf" (type.method [(.list) (.list type.float) ..$Float (.list)]))) -(the $Float::random - (Random java/lang/Float) - (by random.monad each - (|>> (as java/lang/Double) ffi.double_to_float) - random.decimal)) -(the valid_float - (Random java/lang/Float) - (random.only (|>> ffi.float_to_double (as Decimal) d.not_a_number? not) - ..$Float::random)) -(the $Float::primitive - (Primitive java/lang/Float) - [#unboxed type.float - #boxed ..$Float - #wrap ..$Float::wrap - #random ..valid_float - #literal /.float]) - -(the $Double (type.class (.list) "java.lang.Double")) -(the $Double::wrap (/.invokestatic ..$Double "valueOf" (type.method [(.list) (.list type.double) ..$Double (.list)]))) -(the $Double::random (as (Random java/lang/Double) random.decimal)) -(the $Double::literal - (-> java/lang/Double (Bytecode Any)) - (|>> (as Decimal) /.double)) -(the valid_double - (Random java/lang/Double) - (random.only (|>> (as Decimal) d.not_a_number? not) - ..$Double::random)) -(the $Double::primitive - (Primitive java/lang/Double) - [#unboxed type.double - #boxed ..$Double - #wrap ..$Double::wrap - #random ..valid_double - #literal ..$Double::literal]) - -(the $Character - (type.class (.list) "java.lang.Character")) -(the $Character::wrap - (/.invokestatic ..$Character "valueOf" (type.method [(.list) (.list type.char) ..$Character (.list)]))) -(the $Character::random - (Random java/lang/Character) - (by random.monad each (|>> (as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.integer)) -(the $Character::literal - (-> java/lang/Character (Bytecode Any)) - (|>> ffi.char_to_long (as I64) /32.of /.int)) -(the $Character::primitive - (Primitive java/lang/Character) - [#unboxed type.char - #boxed ..$Character - #wrap ..$Character::wrap - #random ..$Character::random - #literal ..$Character::literal]) - -(the $String - (type.class (.list) "java.lang.String")) - -(the $String::random - (as (Random java/lang/String) - (random.alphabetic 10))) - -(the $String::literal - (-> java/lang/String (Bytecode Any)) - (|>> (as Text) /.string)) - -(the $String::primitive - (Primitive java/lang/String) - [#unboxed ..$String - #boxed ..$String - #wrap /.nop - #random ..$String::random - #literal ..$String::literal]) +(these (the $Boolean + (type.class (.list) "java.lang.Boolean")) + + (the $Boolean::wrap + (/.invokestatic ..$Boolean "valueOf" (type.method [(.list) (.list type.boolean) ..$Boolean (.list)]))) + + (the $Boolean::random (as (-> (Random Bit) + (Random java/lang/Boolean)) + random.bit)) + + (the !false (|> 0 .i64 /32.of /.int)) + + (the !true (|> 1 .i64 /32.of /.int)) + + (the ($Boolean::literal value) + (-> java/lang/Boolean + (Bytecode Any)) + (if (as (-> java/lang/Boolean Bit) + value) + ..!true + ..!false)) + + (the $Boolean::primitive + (Primitive java/lang/Boolean) + [#unboxed type.boolean + #boxed ..$Boolean + #wrap ..$Boolean::wrap + #random ..$Boolean::random + #literal ..$Boolean::literal])) + +(these (the $Byte + (type.class (.list) "java.lang.Byte")) + + (the $Byte::wrap + (/.invokestatic ..$Byte "valueOf" + (type.method [(.list) + (.list type.byte) + ..$Byte + (.list)]))) + + (the $Byte::random + (Random java/lang/Byte) + (by random.monad each + (|>> (as (-> Integer java/lang/Long)) + ffi.long_to_byte) + random.integer)) + + (the $Byte::literal + (-> java/lang/Byte + (Bytecode Any)) + (|>> ffi.byte_to_long + (as (-> java/lang/Long I64)) + /32.of + /.int)) + + (the $Byte::primitive + (Primitive java/lang/Byte) + [#unboxed type.byte + #boxed ..$Byte + #wrap ..$Byte::wrap + #random ..$Byte::random + #literal ..$Byte::literal])) + +(these (the $Short + (type.class (.list) "java.lang.Short")) + + (the $Short::wrap + (/.invokestatic ..$Short "valueOf" (type.method [(.list) (.list type.short) ..$Short (.list)]))) + + (the $Short::random + (Random java/lang/Short) + (by random.monad each + (|>> (as (-> Integer java/lang/Long)) + ffi.long_to_short) + random.integer)) + + (the $Short::literal + (-> java/lang/Short + (Bytecode Any)) + (|>> ffi.short_to_long + (as (-> java/lang/Long I64)) + /32.of + /.int)) + + (the $Short::primitive + (Primitive java/lang/Short) + [#unboxed type.short + #boxed ..$Short + #wrap ..$Short::wrap + #random ..$Short::random + #literal ..$Short::literal])) + +(these (the $Integer + (type.class (.list) "java.lang.Integer")) + + (the $Integer::wrap + (/.invokestatic ..$Integer "valueOf" (type.method [(.list) (.list type.int) ..$Integer (.list)]))) + + (the $Integer::random + (Random java/lang/Integer) + (by random.monad each + (|>> (as (-> Integer java/lang/Long)) + ffi.long_to_int) + random.integer)) + + (the $Integer::literal + (-> java/lang/Integer + (Bytecode Any)) + (|>> ffi.int_to_long + (as (-> java/lang/Long I64)) + /32.of + /.int)) + + (the $Integer::primitive + (Primitive java/lang/Integer) + [#unboxed type.int + #boxed ..$Integer + #wrap ..$Integer::wrap + #random ..$Integer::random + #literal ..$Integer::literal])) + +(these (the $Long (type.class (.list) "java.lang.Long")) + + (the $Long::wrap (/.invokestatic ..$Long "valueOf" (type.method [(.list) (.list type.long) ..$Long (.list)]))) + + (the $Long::random + (as (-> (Random Integer) + (Random java/lang/Long)) + random.integer)) + + (the $Long::literal + (-> java/lang/Long + (Bytecode Any)) + (|>> (as (-> java/lang/Long Integer)) + /.long)) + + (the $Long::primitive + (Primitive java/lang/Long) + [#unboxed type.long + #boxed ..$Long + #wrap ..$Long::wrap + #random ..$Long::random + #literal ..$Long::literal])) + +(these (the $Float (type.class (.list) "java.lang.Float")) + + (the $Float::wrap + (/.invokestatic ..$Float "valueOf" + (type.method [(.list) + (.list type.float) + ..$Float + (.list)]))) + + (the $Float::random + (Random java/lang/Float) + (by random.monad each + (|>> (as (-> Decimal java/lang/Double)) + ffi.double_to_float) + random.decimal)) + + (the valid_float + (Random java/lang/Float) + (random.only (|>> ffi.float_to_double + (as (-> java/lang/Double Decimal)) + d.not_a_number? + not) + ..$Float::random)) + + (the $Float::primitive + (Primitive java/lang/Float) + [#unboxed type.float + #boxed ..$Float + #wrap ..$Float::wrap + #random ..valid_float + #literal /.float])) + +(these (the $Double (type.class (.list) "java.lang.Double")) + + (the $Double::wrap + (/.invokestatic ..$Double "valueOf" + (type.method [(.list) + (.list type.double) + ..$Double + (.list)]))) + + (the $Double::random + (as (-> (Random Decimal) + (Random java/lang/Double)) + random.decimal)) + + (the $Double::literal + (-> java/lang/Double + (Bytecode Any)) + (|>> (as (-> java/lang/Double Decimal)) + /.double)) + + (the valid_double + (Random java/lang/Double) + (random.only (|>> (as (-> java/lang/Double Decimal)) + d.not_a_number? + not) + ..$Double::random)) + + (the $Double::primitive + (Primitive java/lang/Double) + [#unboxed type.double + #boxed ..$Double + #wrap ..$Double::wrap + #random ..valid_double + #literal ..$Double::literal])) + +(these (the $Character + (type.class (.list) "java.lang.Character")) + + (the $Character::wrap + (/.invokestatic ..$Character "valueOf" + (type.method [(.list) + (.list type.char) + ..$Character + (.list)]))) + + (the $Character::random + (Random java/lang/Character) + (by random.monad each + (|>> (as (-> Integer java/lang/Long)) + ffi.long_to_int + ffi.int_to_char) + random.integer)) + + (the $Character::literal + (-> java/lang/Character + (Bytecode Any)) + (|>> ffi.char_to_long + (as (-> java/lang/Long I64)) + /32.of + /.int)) + + (the $Character::primitive + (Primitive java/lang/Character) + [#unboxed type.char + #boxed ..$Character + #wrap ..$Character::wrap + #random ..$Character::random + #literal ..$Character::literal])) + +(these (the $String + (type.class (.list) "java.lang.String")) + + (the $String::random + (as (-> (Random Text) + (Random java/lang/String)) + (random.alphabetic 10))) + + (the $String::literal + (-> java/lang/String + (Bytecode Any)) + (|>> (as (-> java/lang/String Text)) + /.string)) + + (the $String::primitive + (Primitive java/lang/String) + [#unboxed ..$String + #boxed ..$String + #wrap /.nop + #random ..$String::random + #literal ..$String::literal])) (the coverage (template.macro (_ ,coverage ,condition) @@ -361,7 +468,10 @@ (do [! random.monad] [expected (by ! each (i64.and (i64.mask )) random.natural)] (<| (..coverage []) - (..bytecode (|>> (as ) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (as java/lang/Long expected))))) + (..bytecode (|>> (as (-> Any )) + + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# (as (-> Natural java/lang/Long) expected))))) (do /.monad [_ ( (|> expected .integer try.trusted))] ))))] @@ -397,7 +507,9 @@ Test (let [int (is (-> java/lang/Integer (Bytecode Any) (Random Bit)) (function (_ expected bytecode) - (<| (..bytecode (|>> (as java/lang/Integer) .jvm_object_cast# (.jvm_int_=# (.jvm_object_cast# expected)))) + (<| (..bytecode (|>> (as (-> Any java/lang/Integer)) + .jvm_object_cast# + (.jvm_int_=# (.jvm_object_cast# expected)))) (do /.monad [_ bytecode] ..$Integer::wrap)))) @@ -424,7 +536,10 @@ shift (is (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do [! random.monad] - [parameter (by ! each (|>> (n.% 32) .integer (as java/lang/Long) ffi.long_to_int) random.natural) + [parameter (by ! each (|>> (n.% 32) + (as (-> Natural java/lang/Long)) + ffi.long_to_int) + random.natural) subject ..$Integer::random] (int (reference parameter subject) (do /.monad @@ -432,13 +547,13 @@ _ (..$Integer::literal parameter)] instruction))))) literal (all _.and - (..coverage [/.iconst_m1] (int (ffi.long_to_int (as java/lang/Long -1)) /.iconst_m1)) - (..coverage [/.iconst_0] (int (ffi.long_to_int (as java/lang/Long +0)) /.iconst_0)) - (..coverage [/.iconst_1] (int (ffi.long_to_int (as java/lang/Long +1)) /.iconst_1)) - (..coverage [/.iconst_2] (int (ffi.long_to_int (as java/lang/Long +2)) /.iconst_2)) - (..coverage [/.iconst_3] (int (ffi.long_to_int (as java/lang/Long +3)) /.iconst_3)) - (..coverage [/.iconst_4] (int (ffi.long_to_int (as java/lang/Long +4)) /.iconst_4)) - (..coverage [/.iconst_5] (int (ffi.long_to_int (as java/lang/Long +5)) /.iconst_5)) + (..coverage [/.iconst_m1] (int (ffi.long_to_int (as (-> Integer java/lang/Long) -1)) /.iconst_m1)) + (..coverage [/.iconst_0] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +0)) /.iconst_0)) + (..coverage [/.iconst_1] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +1)) /.iconst_1)) + (..coverage [/.iconst_2] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +2)) /.iconst_2)) + (..coverage [/.iconst_3] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +3)) /.iconst_3)) + (..coverage [/.iconst_4] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +4)) /.iconst_4)) + (..coverage [/.iconst_5] (int (ffi.long_to_int (as (-> Integer java/lang/Long) +5)) /.iconst_5)) (..coverage [/.int] (do random.monad [expected ..$Integer::random] @@ -452,7 +567,7 @@ (..coverage [/.ineg] (unary (function (_ value) ((int/2 "jvm isub" .jvm_int_-#) value - (ffi.long_to_int (as java/lang/Long +0)))) + (ffi.long_to_int (as (-> Integer java/lang/Long) +0)))) /.ineg))) bitwise (all _.and (..coverage [/.iand] (binary (int/2 "jvm iand" .jvm_int_and#) /.iand)) @@ -471,7 +586,9 @@ Test (let [long (is (-> java/lang/Long (Bytecode Any) (Random Bit)) (function (_ expected bytecode) - (<| (..bytecode (|>> (as java/lang/Long) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# expected)))) + (<| (..bytecode (|>> (as (-> Any java/lang/Long)) + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# expected)))) (do /.monad [_ bytecode] ..$Long::wrap)))) @@ -496,7 +613,9 @@ shift (is (-> (-> java/lang/Integer java/lang/Long java/lang/Long) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do [! random.monad] - [parameter (by ! each (|>> (n.% 64) (as java/lang/Long)) random.natural) + [parameter (by ! each (|>> (n.% 64) + (as (-> Natural java/lang/Long))) + random.natural) subject ..$Long::random] (long (reference (ffi.long_to_int parameter) subject) (do /.monad @@ -504,8 +623,8 @@ _ (..$Integer::literal (ffi.long_to_int parameter))] instruction))))) literal (all _.and - (..coverage [/.lconst_0] (long (as java/lang/Long +0) /.lconst_0)) - (..coverage [/.lconst_1] (long (as java/lang/Long +1) /.lconst_1)) + (..coverage [/.lconst_0] (long (as (-> Integer java/lang/Long) +0) /.lconst_0)) + (..coverage [/.lconst_1] (long (as (-> Integer java/lang/Long) +1) /.lconst_1)) (..coverage [/.long] (do random.monad [expected ..$Long::random] @@ -519,7 +638,7 @@ (..coverage [/.lneg] (unary (function (_ value) ((long/2 "jvm lsub" .jvm_long_-#) value - (as java/lang/Long +0))) + (as (-> Integer java/lang/Long) +0))) /.lneg))) bitwise (all _.and (..coverage [/.land] (binary (long/2 "jvm land" .jvm_long_and#) /.land)) @@ -531,18 +650,20 @@ comparison (do random.monad [reference ..$Long::random subject ..$Long::random - .let [expected (<| (as java/lang/Long) - (if (i.< (as Integer reference) (as Integer subject)) - -1 + .let [expected (<| (as (-> Integer java/lang/Long)) + (if (i.< (as (-> java/lang/Long Integer) reference) + (as (-> java/lang/Long Integer) subject)) + -1 - (i.> (as Integer reference) (as Integer subject)) - +1 + (i.> (as (-> java/lang/Long Integer) reference) + (as (-> java/lang/Long Integer) subject)) + +1 - ... (i.= (as Integer expected) (as Integer subject)) - +0))]] + ... (i.= (as (-> java/lang/Long Integer) expected) (as (-> java/lang/Long Integer) subject)) + +0))]] (<| (..bytecode (function (_ actual) (|> actual - (as java/lang/Long) + (as (-> Any java/lang/Long)) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# expected))))) (do /.monad @@ -563,9 +684,12 @@ (let [float (is (-> java/lang/Float (Bytecode Any) (Random Bit)) (function (_ expected bytecode) (<| (..bytecode (function (_ actual) - (or (|> actual (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# expected))) - (and (d.not_a_number? (as Decimal (ffi.float_to_double expected))) - (d.not_a_number? (as Decimal (ffi.float_to_double (as java/lang/Float actual)))))))) + (or (|> actual + (as (-> Any java/lang/Float)) + .jvm_object_cast# + (.jvm_float_=# (.jvm_object_cast# expected))) + (and (d.not_a_number? (as (-> java/lang/Double Decimal) (ffi.float_to_double expected))) + (d.not_a_number? (as (-> java/lang/Double Decimal) (ffi.float_to_double (as (-> Any java/lang/Float) actual)))))))) (do /.monad [_ bytecode] ..$Float::wrap)))) @@ -592,9 +716,9 @@ _ (/.float parameter)] instruction))))) literal (all _.and - (..coverage [/.fconst_0] (float (ffi.double_to_float (as java/lang/Double +0.0)) /.fconst_0)) - (..coverage [/.fconst_1] (float (ffi.double_to_float (as java/lang/Double +1.0)) /.fconst_1)) - (..coverage [/.fconst_2] (float (ffi.double_to_float (as java/lang/Double +2.0)) /.fconst_2)) + (..coverage [/.fconst_0] (float (ffi.double_to_float (as (-> Decimal java/lang/Double) +0.0)) /.fconst_0)) + (..coverage [/.fconst_1] (float (ffi.double_to_float (as (-> Decimal java/lang/Double) +1.0)) /.fconst_1)) + (..coverage [/.fconst_2] (float (ffi.double_to_float (as (-> Decimal java/lang/Double) +2.0)) /.fconst_2)) (..coverage [/.float] (do random.monad [expected ..$Float::random] @@ -608,21 +732,22 @@ (..coverage [/.fneg] (unary (function (_ value) ((float/2 "jvm fsub" .jvm_float_-#) value - (ffi.double_to_float (as java/lang/Double +0.0)))) + (ffi.double_to_float (as (-> Decimal java/lang/Double) +0.0)))) /.fneg))) comparison (is (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit)) (function (_ instruction standard) (do random.monad - [.let [valid_float (random.only (|>> ffi.float_to_double (as Decimal) d.not_a_number? not) + [.let [valid_float (random.only (|>> ffi.float_to_double (as (-> java/lang/Double Decimal)) d.not_a_number? not) ..$Float::random)] expected valid_float actual valid_float .let [expected_result (if (.jvm_float_=# (.jvm_object_cast# expected) (.jvm_object_cast# actual)) - +0 - (if (standard expected actual) - +1 - -1))]] - (<| (..bytecode (|>> (as Integer) (i.= expected_result))) + +0 + (if (standard expected actual) + +1 + -1))]] + (<| (..bytecode (|>> (as (-> Any Integer)) + (i.= expected_result))) (do /.monad [_ (/.float actual) _ (/.float expected) @@ -646,9 +771,12 @@ (let [double (is (-> java/lang/Double (Bytecode Any) (Random Bit)) (function (_ expected bytecode) (<| (..bytecode (function (_ actual) - (or (|> actual (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# expected))) - (and (d.not_a_number? (as Decimal expected)) - (d.not_a_number? (as Decimal actual)))))) + (or (|> actual + (as (-> Any java/lang/Double)) + .jvm_object_cast# + (.jvm_double_=# (.jvm_object_cast# expected))) + (and (d.not_a_number? (as (-> java/lang/Double Decimal) expected)) + (d.not_a_number? (as (-> Any Decimal) actual)))))) (do /.monad [_ bytecode] ..$Double::wrap)))) @@ -671,8 +799,8 @@ _ (..$Double::literal parameter)] instruction))))) literal (all _.and - (..coverage [/.dconst_0] (double (as java/lang/Double +0.0) /.dconst_0)) - (..coverage [/.dconst_1] (double (as java/lang/Double +1.0) /.dconst_1)) + (..coverage [/.dconst_0] (double (as (-> Decimal java/lang/Double) +0.0) /.dconst_0)) + (..coverage [/.dconst_1] (double (as (-> Decimal java/lang/Double) +1.0) /.dconst_1)) (..coverage [/.double] (do random.monad [expected ..$Double::random] @@ -686,7 +814,7 @@ (..coverage [/.dneg] (unary (function (_ value) ((double/2 "jvm dsub" .jvm_double_-#) value - (as java/lang/Double +0.0))) + (as (-> Decimal java/lang/Double) +0.0))) /.dneg))) comparison (is (-> (Bytecode Any) (-> java/lang/Double java/lang/Double Bit) (Random Bit)) (function (_ instruction standard) @@ -694,11 +822,12 @@ [expected ..valid_double actual ..valid_double .let [expected_result (if (.jvm_double_=# (.jvm_object_cast# expected) (.jvm_object_cast# actual)) - +0 - (if (standard expected actual) - +1 - -1))]] - (<| (..bytecode (|>> (as Integer) (i.= expected_result))) + +0 + (if (standard expected actual) + +1 + -1))]] + (<| (..bytecode (|>> (as (-> Any Integer)) + (i.= expected_result))) (do /.monad [_ (..$Double::literal actual) _ (..$Double::literal expected) @@ -738,7 +867,8 @@ (/.invokespecial ..$Object "" (type.method [(.list) (.list) type.void (.list)]))))] (all _.and (<| (..coverage [/.aconst_null]) - (..bytecode (|>> (as Bit) not)) + (..bytecode (|>> (as (-> Any Bit)) + not)) (do /.monad [_ /.aconst_null _ (/.instanceof ..$String)] @@ -746,19 +876,19 @@ (<| (..coverage [/.instanceof]) (do random.monad [value ..$String::random]) - (..bytecode (|>> (as Bit))) + (..bytecode (|>> (as (-> Any Bit)))) (do /.monad - [_ (/.string (as Text value)) + [_ (/.string (as (-> java/lang/String Text) value)) _ (/.instanceof ..$String)] ..$Boolean::wrap)) (<| (..coverage [/.new]) - (..bytecode (|>> (as Bit))) + (..bytecode (|>> (as (-> Any Bit)))) (do /.monad [_ !object _ ..!true] ..$Boolean::wrap)) (<| (..coverage [/.checkcast]) - (..bytecode (|>> (as Bit))) + (..bytecode (|>> (as (-> Any Bit)))) (do /.monad [_ !object _ (/.checkcast ..$Object) @@ -767,9 +897,9 @@ (<| (..coverage [/.monitorenter /.monitorexit]) (do random.monad [value ..$String::random]) - (..bytecode (|>> (as Bit))) + (..bytecode (|>> (as (-> Any Bit)))) (do /.monad - [_ (/.string (as Text value)) + [_ (/.string (as (-> java/lang/String Text) value)) _ /.dup _ /.monitorenter _ /.dup _ /.monitorexit _ (/.instanceof ..$String)] @@ -781,37 +911,47 @@ (all _.and (<| (..coverage [/.invokestatic]) (do random.monad - [expected (random.only (|>> (as Decimal) d.not_a_number? not) + [expected (random.only (|>> (as (-> java/lang/Double Decimal)) + d.not_a_number? + not) ..$Double::random)]) - (..bytecode (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# expected)))) + (..bytecode (|>> (as (-> Any java/lang/Double)) + .jvm_object_cast# + (.jvm_double_=# (.jvm_object_cast# expected)))) (do /.monad - [_ (/.double (as Decimal expected))] + [_ (/.double (as (-> java/lang/Double Decimal) expected))] (/.invokestatic ..$Double "valueOf" (type.method [(.list) (.list type.double) ..$Double (.list)])))) (<| (..coverage [/.invokevirtual]) (do random.monad [expected ..$Double::random]) - (..bytecode (|>> (as Bit) (bit.= (d.not_a_number? (as Decimal expected))))) + (..bytecode (|>> (as (-> Any Bit)) + (bit.= (d.not_a_number? (as (-> java/lang/Double Decimal) expected))))) (do /.monad - [_ (/.double (as Decimal expected)) + [_ (/.double (as (-> java/lang/Double Decimal) expected)) _ ..$Double::wrap _ (/.invokevirtual ..$Double "isNaN" (type.method [(.list) (.list) type.boolean (.list)]))] ..$Boolean::wrap)) (<| (..coverage [/.invokespecial]) (do random.monad - [expected (random.only (|>> (as Decimal) d.not_a_number? not) + [expected (random.only (|>> (as (-> java/lang/Double Decimal)) + d.not_a_number? + not) ..$Double::random)]) - (..bytecode (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# expected)))) + (..bytecode (|>> (as (-> Any java/lang/Double)) + .jvm_object_cast# + (.jvm_double_=# (.jvm_object_cast# expected)))) (do /.monad [_ (/.new ..$Double) _ /.dup - _ (/.double (as Decimal expected))] + _ (/.double (as (-> java/lang/Double Decimal) expected))] (/.invokespecial ..$Double "" (type.method [(.list) (.list type.double) type.void (.list)])))) (<| (..coverage [/.invokeinterface]) (do random.monad [subject ..$String::random]) - (..bytecode (|>> (as Natural) (n.= (text.size (as Text subject))))) + (..bytecode (|>> (as (-> Any Natural)) + (n.= (text.size (as (-> java/lang/String Text) subject))))) (do /.monad - [_ (/.string (as Text subject)) + [_ (/.string (as (-> java/lang/String Text) subject)) _ (/.invokeinterface (type.class (.list) "java.lang.CharSequence") "length" (type.method [(.list) (.list) type.int (.list)])) _ /.i2l] ..$Long::wrap)) @@ -833,42 +973,42 @@ constructor::type (type.method [(.list) (.list type.long) type.void (.list)]) static_method "static_method" bytecode (|> (class.class version.v6_0 class.public - (internal.name class_name) - {.#None} - (internal.name "java.lang.Object") - (.list) - (.list (/field.field /field.static class_field false type.long (sequence.sequence)) - (/field.field /field.public object_field false type.long (sequence.sequence))) - (.list (/method.method /method.private - constructor - false constructor::type - (.list) - {.#Some (do /.monad - [_ /.aload_0 - _ (/.invokespecial ..$Object constructor (type.method [(.list) (.list) type.void (.list)])) - _ (..$Long::literal part0) - _ (/.putstatic $Self class_field type.long) - _ /.aload_0 - _ /.lload_1 - _ (/.putfield $Self object_field type.long)] - /.return)}) - (/method.method (all /modifier#composite - /method.public - /method.static) - static_method - false (type.method [(.list) (.list) ..$Long (.list)]) - (.list) - {.#Some (do /.monad - [_ (/.new $Self) - _ /.dup - _ (..$Long::literal part1) - _ (/.invokespecial $Self constructor constructor::type) - _ (/.getfield $Self object_field type.long) - _ (/.getstatic $Self class_field type.long) - _ /.ladd - _ ..$Long::wrap] - /.areturn)})) - (.list)) + (internal.name class_name) + {.#None} + (internal.name "java.lang.Object") + (.list) + (.list (/field.field /field.static class_field false type.long (sequence.sequence)) + (/field.field /field.public object_field false type.long (sequence.sequence))) + (.list (/method.method /method.private + constructor + false constructor::type + (.list) + {.#Some (do /.monad + [_ /.aload_0 + _ (/.invokespecial ..$Object constructor (type.method [(.list) (.list) type.void (.list)])) + _ (..$Long::literal part0) + _ (/.putstatic $Self class_field type.long) + _ /.aload_0 + _ /.lload_1 + _ (/.putfield $Self object_field type.long)] + /.return)}) + (/method.method (all /modifier#composite + /method.public + /method.static) + static_method + false (type.method [(.list) (.list) ..$Long (.list)]) + (.list) + {.#Some (do /.monad + [_ (/.new $Self) + _ /.dup + _ (..$Long::literal part1) + _ (/.invokespecial $Self constructor constructor::type) + _ (/.getfield $Self object_field type.long) + _ (/.getstatic $Self class_field type.long) + _ /.ladd + _ ..$Long::wrap] + /.areturn)})) + (.list)) try.trusted (binary.value class.as_binary)) loader (/loader.memory (/loader.new_library []))]] @@ -879,19 +1019,27 @@ class (io.value (/loader.load class_name loader)) method (try (get_method static_method class)) output (java/lang/reflect/Method::invoke [(ffi.null) (ffi.array java/lang/Object 0)] method)] - (in (as Integer output))) + (in (as (-> Any Integer) output))) {try.#Success actual} - (i.= (as Integer expected) (as Integer actual)) + (i.= (as (-> java/lang/Long Integer) expected) actual) {try.#Failure error} false)))) +(the !::= + (template.macro (_ ,=) + [(is (-> Any Bit) + (function (_ expected) + (|>> (as (-> Any )) + .jvm_object_cast# + (,= (.jvm_object_cast# expected)))))])) + (the array Test (let [!length (is (-> Natural (Bytecode Any)) (function (_ size) (do /.monad - [_ ($Long::literal (as java/lang/Long size))] + [_ ($Long::literal (as (-> Natural java/lang/Long) size))] /.l2i))) ?length (is (Bytecode Any) (do /.monad @@ -899,7 +1047,8 @@ /.i2l)) length (is (-> Natural (Bytecode Any) (Random Bit)) (function (_ size constructor) - (<| (..bytecode (|>> (as Natural) (n.= size))) + (<| (..bytecode (|>> (as (-> Any Natural)) + (n.= size))) (do /.monad [_ (!length size) _ constructor @@ -912,7 +1061,7 @@ (-> a Any Bit) (Random Bit))) (function (_ size constructor value literal [*store *load *wrap] test) - (let [!index ($Integer::literal (ffi.long_to_int (as java/lang/Long +0)))] + (let [!index ($Integer::literal (ffi.long_to_int (as (-> Integer java/lang/Long) +0)))] (<| (..bytecode (test value)) (do /.monad [_ (!length size) @@ -938,39 +1087,44 @@ (all _.and (..coverage [/.bastore /.baload] (array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap] - (function (_ expected) (|>> (as Bit) (bit.= (as Bit expected)))))) + (function (_ expected) + (|>> (as (-> Any Bit)) + (bit.= (as (-> java/lang/Boolean Bit) expected)))))) (..coverage [/.bastore /.baload] (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] (function (_ expected) - (|>> (as java/lang/Byte) ffi.byte_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long (as java/lang/Byte expected)))))))) + (|>> (as (-> Any java/lang/Byte)) + ffi.byte_to_long + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long expected))))))) (..coverage [/.sastore /.saload] (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] (function (_ expected) - (|>> (as java/lang/Short) ffi.short_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long (as java/lang/Short expected)))))))) + (|>> (as (-> Any java/lang/Short)) + ffi.short_to_long + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long expected))))))) (..coverage [/.iastore /.iaload] (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] - (function (_ expected) - (|>> (as java/lang/Integer) .jvm_object_cast# (.jvm_int_=# (.jvm_object_cast# (as java/lang/Integer expected))))))) + (!::= java/lang/Integer .jvm_int_=#))) (..coverage [/.lastore /.laload] (array (/.newarray /instruction.t_long) $Long::random $Long::literal [/.lastore /.laload $Long::wrap] - (function (_ expected) - (|>> (as java/lang/Long) .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (as java/lang/Long expected))))))) + (!::= java/lang/Long .jvm_long_=#))) (..coverage [/.fastore /.faload] (array (/.newarray /instruction.t_float) ..valid_float /.float [/.fastore /.faload $Float::wrap] - (function (_ expected) - (|>> (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# (as java/lang/Float expected))))))) + (!::= java/lang/Float .jvm_float_=#))) (..coverage [/.dastore /.daload] (array (/.newarray /instruction.t_double) ..valid_double $Double::literal [/.dastore /.daload $Double::wrap] - (function (_ expected) - (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# (as java/lang/Double expected))))))) + (!::= java/lang/Double .jvm_double_=#))) (..coverage [/.castore /.caload] (array (/.newarray /instruction.t_char) $Character::random $Character::literal [/.castore /.caload $Character::wrap] - (function (_ expected) - (|>> (as java/lang/Character) .jvm_object_cast# (.jvm_char_=# (.jvm_object_cast# (as java/lang/Character expected))))))) + (!::= java/lang/Character .jvm_char_=#))) )) (..coverage [/.anewarray /.aastore /.aaload] (array (/.anewarray ..$String) $String::random $String::literal [/.aastore /.aaload /.nop] - (function (_ expected) (|>> (as Text) (text.= (as Text expected)))))) + (function (_ expected) + (|>> (as (-> Any Text)) + (text.= (as (-> java/lang/String Text) expected)))))) (<| (_.context "multi") (do [! random.monad] [.let [size (is (Random Natural) @@ -986,21 +1140,18 @@ 0 type _ (again (-- dimensions) (type.array type))))]] (<| (..coverage [/.multianewarray /.arraylength]) - (..bytecode (|>> (as Natural) (n.= sizesH))) + (..bytecode (|>> (as (-> Any Natural)) + (n.= sizesH))) (do [! /.monad] - [_ (stack.each' ! (|>> (as java/lang/Long) ffi.long_to_int ..$Integer::literal) + [_ (stack.each' ! (|>> (as (-> Natural java/lang/Long)) + ffi.long_to_int + ..$Integer::literal) {.#Top sizesH sizesT}) _ (/.multianewarray type (n/08.of dimensions)) _ ?length] $Long::wrap)))) ))) -(the !::= - (template.macro (_ ) - [(is (-> Any Bit) - (function (_ expected) - (|>> (as ) .jvm_object_cast# ( (.jvm_object_cast# (as expected))))))])) - (the conversion Test (let [conversion (is (for_any (_ a z) @@ -1024,12 +1175,18 @@ (..coverage [/.i2d] (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=)) (..coverage [/.i2b] (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte) (function (_ expected) - (|>> (as java/lang/Byte) ffi.byte_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long (as java/lang/Byte expected)))))))) + (|>> (as (-> Any java/lang/Byte)) + ffi.byte_to_long + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# (ffi.byte_to_long expected))))))) (..coverage [/.i2c] (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char) (!::= java/lang/Character .jvm_char_=#))) (..coverage [/.i2s] (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short) (function (_ expected) - (|>> (as java/lang/Short) ffi.short_to_long .jvm_object_cast# (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long (as java/lang/Short expected)))))))) + (|>> (as (-> Any java/lang/Short)) + ffi.short_to_long + .jvm_object_cast# + (.jvm_long_=# (.jvm_object_cast# (ffi.short_to_long expected))))))) (..coverage [/.l2i] (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=)) (..coverage [/.l2f] (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=)) @@ -1093,8 +1250,9 @@ .let [expected (is java/lang/Long (.jvm_object_cast# (.jvm_long_+# (.jvm_object_cast# (ffi.byte_to_long base)) - (.jvm_object_cast# (as java/lang/Long (n/08.as increment))))))]] - (..bytecode (|>> (as Integer) (i.= (as Integer expected))) + (.jvm_object_cast# (as (-> Natural java/lang/Long) (n/08.as increment))))))]] + (..bytecode (|>> (as (-> Any Integer)) + (i.= (as (-> java/lang/Long Integer) expected))) (do /.monad [_ (..$Byte::literal base) _ /.istore_0 @@ -1139,8 +1297,9 @@ (..coverage [/.dstore /.dload] (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [/.dstore /.dload] test)))) (let [test (is (-> java/lang/String Any Bit) - (function (_ expected actual) - (|> actual (as Text) (text.= (as Text expected)))))] + (function (_ expected) + (|>> (as (-> Any Text)) + (text.= (as (-> java/lang/String Text) expected)))))] (all _.and (..coverage [/.astore_0 /.aload_0] (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_0) (function.constant /.aload_0)] test)) @@ -1159,7 +1318,8 @@ (do random.monad [expected/1 $String::random .let [object_test (is (-> Any Bit) - (|>> (as Text) (text.= (as Text expected/1))))] + (|>> (as (-> Any Text)) + (text.= (as (-> java/lang/String Text) expected/1))))] dummy/1 $String::random .let [single (all _.and (<| (..coverage [/.dup /.pop]) @@ -1194,7 +1354,8 @@ )] expected/2 $Long::random .let [long_test (is (-> Any Bit) - (|>> (as Integer) (i.= (as Integer expected/2))))] + (|>> (as (-> Any Integer)) + (i.= (as (-> java/lang/Long Integer) expected/2))))] dummy/2 $Long::random .let [double (all _.and (<| (..coverage [/.dup2]) @@ -1251,33 +1412,33 @@ .let [$Self (type.class (.list) class_name)]] (in (when (do try.monad [class (class.class version.v6_0 class.public - (internal.name class_name) - {.#None} - (internal.name "java.lang.Object") - (.list) - (.list) - (.list (/method.method ..method_modifier - primitive_method_name - false primitive_method_type - (.list) - {.#Some (do /.monad - [_ ((its #literal primitive) expected)] - return)}) - (/method.method ..method_modifier - object_method_name - false (type.method [(.list) (.list) (its #boxed primitive) (.list)]) - (.list) - {.#Some (do /.monad - [_ (/.invokestatic $Self primitive_method_name primitive_method_type) - _ (when substitute - {.#None} - (in []) - - {.#Some substitute} - (substitute expected)) - _ (its #wrap primitive)] - /.areturn)})) - (.list)) + (internal.name class_name) + {.#None} + (internal.name "java.lang.Object") + (.list) + (.list) + (.list (/method.method ..method_modifier + primitive_method_name + false primitive_method_type + (.list) + {.#Some (do /.monad + [_ ((its #literal primitive) expected)] + return)}) + (/method.method ..method_modifier + object_method_name + false (type.method [(.list) (.list) (its #boxed primitive) (.list)]) + (.list) + {.#Some (do /.monad + [_ (/.invokestatic $Self primitive_method_name primitive_method_type) + _ (when substitute + {.#None} + (in []) + + {.#Some substitute} + (substitute expected)) + _ (its #wrap primitive)] + /.areturn)})) + (.list)) .let [bytecode (binary.value class.as_binary class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) @@ -1301,7 +1462,9 @@ (..coverage [/.dreturn] (primitive_return ..$Double::primitive /.dreturn {.#None} (!::= java/lang/Double .jvm_double_=#))) (..coverage [/.areturn] - (primitive_return ..$String::primitive /.areturn {.#None} (function (_ expected actual) (text.= (as Text expected) (as Text actual))))) + (primitive_return ..$String::primitive /.areturn {.#None} (function (_ expected actual) + (text.= (as (-> java/lang/String Text) expected) + (as (-> Any Text) actual))))) (..coverage [/.return] (primitive_return (is (Primitive java/lang/String) [#unboxed type.void @@ -1311,7 +1474,9 @@ #literal (function.constant /.nop)]) /.return {.#Some ..$String::literal} - (function (_ expected actual) (text.= (as Text expected) (as Text actual))))) + (function (_ expected actual) + (text.= (as (-> java/lang/String Text) expected) + (as (-> Any Text) actual))))) ))) (the branching @@ -1347,8 +1512,8 @@ actual (|> ..$Integer::random (random.only (|>> ((!::= java/lang/Integer .jvm_int_=#) expected) not))) .let [[lesser greater] (if (.jvm_int_<# (.jvm_object_cast# actual) (.jvm_object_cast# expected)) - [expected actual] - [actual expected]) + [expected actual] + [actual expected]) int_comparison (all _.and (..coverage [/.if_icmpeq] (if! /.if_icmpeq (do /.monad [_ (..$Integer::literal expected)] /.dup))) (..coverage [/.if_icmpne] (if! /.if_icmpne (do /.monad [_ (..$Integer::literal expected)] (..$Integer::literal actual)))) @@ -1484,7 +1649,10 @@ random.natural) choice (by ! each (n.% options) random.natural) options (|> random.integer - (by ! each (|>> (as java/lang/Long) ffi.long_to_int ffi.int_to_long (as Integer))) + (by ! each (|>> (as (-> Integer java/lang/Long)) + ffi.long_to_int + ffi.int_to_long + (as (-> java/lang/Long Integer)))) (random.set i.hash options) (by ! each set.as_list)) .let [choice (maybe.trusted (list.item choice options))] @@ -1495,7 +1663,7 @@ [@right /.new_label @wrong /.new_label @return /.new_label - _ (..$Integer::literal (ffi.long_to_int (as java/lang/Long choice))) + _ (..$Integer::literal (ffi.long_to_int (as (-> Integer java/lang/Long) choice))) _ (/.lookupswitch @wrong (list#each (function (_ option) [(/32.of option) (if (i.= choice option) @right @wrong)]) @@ -1574,11 +1742,11 @@ part3 ..$Long::random part4 ..$Long::random .let [expected (all i.+ - (as Integer part0) - (as Integer part1) - (as Integer part2) - (as Integer part3) - (as Integer part4)) + (as (-> java/lang/Long Integer) part0) + (as (-> java/lang/Long Integer) part1) + (as (-> java/lang/Long Integer) part2) + (as (-> java/lang/Long Integer) part3) + (as (-> java/lang/Long Integer) part4)) $Concrete (type.class (.list) concrete_class) $Abstract (type.class (.list) abstract_class) $Interface (type.class (.list) interface_class) @@ -1604,35 +1772,35 @@ /.lreturn)}))) interface_bytecode (|> (class.class version.v6_0 (all /modifier#composite class.public class.abstract class.interface) - (internal.name interface_class) - {.#None} - (internal.name "java.lang.Object") - (.list) - (.list) - (.list (/method.method (all /modifier#composite /method.public /method.abstract) - interface_method false method::type (.list) {.#None})) - (.list)) + (internal.name interface_class) + {.#None} + (internal.name "java.lang.Object") + (.list) + (.list) + (.list (/method.method (all /modifier#composite /method.public /method.abstract) + interface_method false method::type (.list) {.#None})) + (.list)) try.trusted (binary.value class.as_binary)) abstract_bytecode (|> (class.class version.v6_0 (all /modifier#composite class.public class.abstract) - (internal.name abstract_class) - {.#None} - (internal.name "java.lang.Object") - (.list) - (.list) - (.list (/method.method /method.public - "" - false constructor::type - (.list) - {.#Some (do /.monad - [_ /.aload_0 - _ (/.invokespecial ..$Object "" constructor::type)] - /.return)}) - (method inherited_method part0) - (method overriden_method fake_part2) - (/method.method (all /modifier#composite /method.public /method.abstract) - abstract_method false method::type (.list) {.#None})) - (.list)) + (internal.name abstract_class) + {.#None} + (internal.name "java.lang.Object") + (.list) + (.list) + (.list (/method.method /method.public + "" + false constructor::type + (.list) + {.#Some (do /.monad + [_ /.aload_0 + _ (/.invokespecial ..$Object "" constructor::type)] + /.return)}) + (method inherited_method part0) + (method overriden_method fake_part2) + (/method.method (all /modifier#composite /method.public /method.abstract) + abstract_method false method::type (.list) {.#None})) + (.list)) try.trusted (binary.value class.as_binary)) invoke (is (-> (Type Class) Text (Bytecode Any)) @@ -1641,63 +1809,60 @@ [_ /.aload_0] (/.invokevirtual class method method::type)))) concrete_bytecode (|> (class.class version.v6_0 class.public - (internal.name concrete_class) - {.#None} - (internal.name abstract_class) - (.list (internal.name interface_class)) - (.list) - (.list (/method.method /method.public - "" - false constructor::type - (.list) - {.#Some (do /.monad - [_ /.aload_0 - _ (/.invokespecial $Abstract "" constructor::type)] - /.return)}) - (method virtual_method part1) - (method overriden_method part2) - (method abstract_method part3) - (method interface_method part4) - (/method.method (all /modifier#composite - /method.public - /method.static) - static_method - false (type.method [(.list) (.list) ..$Long (.list)]) - (.list) - {.#Some (do /.monad - [_ (/.new $Concrete) - _ /.dup - _ (/.invokespecial $Concrete "" constructor::type) - _ /.astore_0 - _ (invoke $Abstract inherited_method) - _ (invoke $Concrete virtual_method) - _ /.ladd - _ (invoke $Abstract overriden_method) - _ /.ladd - _ /.aload_0 _ (/.invokeinterface $Interface interface_method method::type) - _ /.ladd - _ (invoke $Abstract abstract_method) - _ /.ladd - _ ..$Long::wrap] - /.areturn)})) - (.list)) + (internal.name concrete_class) + {.#None} + (internal.name abstract_class) + (.list (internal.name interface_class)) + (.list) + (.list (/method.method /method.public + "" + false constructor::type + (.list) + {.#Some (do /.monad + [_ /.aload_0 + _ (/.invokespecial $Abstract "" constructor::type)] + /.return)}) + (method virtual_method part1) + (method overriden_method part2) + (method abstract_method part3) + (method interface_method part4) + (/method.method (all /modifier#composite + /method.public + /method.static) + static_method + false (type.method [(.list) (.list) ..$Long (.list)]) + (.list) + {.#Some (do /.monad + [_ (/.new $Concrete) + _ /.dup + _ (/.invokespecial $Concrete "" constructor::type) + _ /.astore_0 + _ (invoke $Abstract inherited_method) + _ (invoke $Concrete virtual_method) + _ /.ladd + _ (invoke $Abstract overriden_method) + _ /.ladd + _ /.aload_0 _ (/.invokeinterface $Interface interface_method method::type) + _ /.ladd + _ (invoke $Abstract abstract_method) + _ /.ladd + _ ..$Long::wrap] + /.areturn)})) + (.list)) try.trusted (binary.value class.as_binary)) loader (/loader.memory (/loader.new_library []))]] (_.test "Class & interface inheritance" - (when (do try.monad - [_ (/loader.define abstract_class abstract_bytecode loader) - _ (/loader.define interface_class interface_bytecode loader) - _ (/loader.define concrete_class concrete_bytecode loader) - class (io.value (/loader.load concrete_class loader)) - method (try (get_method static_method class)) - output (java/lang/reflect/Method::invoke [(ffi.null) (ffi.array java/lang/Object 0)] method)] - (in (as Integer output))) - {try.#Success actual} - (i.= (as Integer expected) (as Integer actual)) - - {try.#Failure error} - false)))) + (|> (do try.monad + [_ (/loader.define abstract_class abstract_bytecode loader) + _ (/loader.define interface_class interface_bytecode loader) + _ (/loader.define concrete_class concrete_bytecode loader) + class (io.value (/loader.load concrete_class loader)) + method (try (get_method static_method class)) + output (java/lang/reflect/Method::invoke [(ffi.null) (ffi.array java/lang/Object 0)] method)] + (in (as (-> Any Integer) output))) + (try#each (i.= expected)) + (try.else false))))) (the (equivalence super) (for_any (_ super) diff --git a/stdlib/source/test/lux/target/jvm/type/projection.lux b/stdlib/source/test/lux/target/jvm/type/projection.lux index c5d7c76316..b9cb016884 100644 --- a/stdlib/source/test/lux/target/jvm/type/projection.lux +++ b/stdlib/source/test/lux/target/jvm/type/projection.lux @@ -220,7 +220,7 @@ //.signature signature.signature (?text.value ,name) - (try#each (//.= (as //.Type type))) + (try#each (//.= (as (-> Any //.Type) type))) (try.else false))) ,types))] diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 1b49c6b8e4..b2afc993d2 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -551,15 +551,6 @@ (exec (/.log! sample) true))) - (do random.monad - [left random.natural - right (random.lower_cased 1) - .let [left,right [left right]]] - (_.coverage [/.as] - (|> left,right - (/.as [l r] (And l r) (Or l r)) - (/.as [l r] (Or l r) (And l r)) - (same? left,right)))) (do random.monad [expected random.natural] (_.coverage [/.sharing] diff --git a/stdlib/source/test/lux/type/variance.lux b/stdlib/source/test/lux/type/variance.lux index bf11aa0343..bfd087bbf8 100644 --- a/stdlib/source/test/lux/type/variance.lux +++ b/stdlib/source/test/lux/type/variance.lux @@ -60,6 +60,6 @@ (is (/.Write_Only Natural)) /.read (is Any) - (same? (as Any expected)))) + (same? (as (-> Natural Any) expected)))) )) ))) diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux index 3d4f9e6b75..500045844d 100644 --- a/stdlib/source/unsafe/lux/data/binary.lux +++ b/stdlib/source/unsafe/lux/data/binary.lux @@ -23,22 +23,22 @@ (ffi.type [byte])) (ffi.import java/lang/Object - "[1]::[0]") + "[1]::[0]") (ffi.import java/lang/System - "[1]::[0]" - ("static" arraycopy [java/lang/Object int java/lang/Object int int] void)) + "[1]::[0]" + ("static" arraycopy [java/lang/Object int java/lang/Object int int] void)) (ffi.import java/util/Arrays - "[1]::[0]" - ("static" copyOfRange [[byte] int int] [byte]) - ("static" equals [[byte] [byte]] boolean))) + "[1]::[0]" + ("static" copyOfRange [[byte] int int] [byte]) + ("static" equals [[byte] [byte]] boolean))) .js (these (ffi.import ArrayBuffer - "[1]::[0]") + "[1]::[0]") (ffi.import Uint8Array - "[1]::[0]") + "[1]::[0]") (every .public Binary Uint8Array)) @@ -69,13 +69,13 @@ (.js_object_new# (.js_constant# "ArrayBuffer")) [] (.js_object_new# (.js_constant# "Uint8Array")) - (.as ..Binary)) + (.as (-> Any ..Binary))) .python (.|> [] - (.python_apply# (.as ffi.Function (.python_constant# "bytearray"))) - (.as ..Binary)) + (.python_apply# (.as (-> Any ffi.Function) (.python_constant# "bytearray"))) + (.as (-> Any ..Binary))) ... Default (array.empty )))])))) @@ -90,13 +90,13 @@ .js (.|> (.js_object_get# "length") - (.as .Decimal) + (.as (-> Any .Decimal)) .f64_int# .natural) .python (.|> - (.as (array.Array (.I64 .Any))) + (.as (-> Any (array.Array (.I64 .Any)))) .python_array_length#) ... Default @@ -111,39 +111,37 @@ (.is ..Index index)] (the .public bits_08 (template.macro (bits_08 index it) - [(.<| (.as .I64) - (.is (.I64 .Any)) + [(.<| (.as (-> (.I64 .Any) .I64)) (`` (.for .jvm (.|> (ffi.read! ) ffi.byte_to_long - (.as .I64) + (.as (-> (.Nominal "java.lang.Long") .I64)) (.i64_and# )) .js (.|> - (.as (array.Array .Decimal)) + (.as (-> Any (array.Array .Decimal))) (.js_array_read# ) - (.as .Decimal) + (.as (-> Any .Decimal)) .f64_int# .i64) .python (.|> - (.as (array.Array .I64)) + (.as (-> Any (array.Array .I64))) (.python_array_read# )) ... Default (.if (array.lacks? ) - (.i64 0) - (array.item )))))]))) + (.i64 0) + (array.item )))))]))) (the .public bits_16 (template.macro (bits_16 index' it') [(.<| (.let [index (.is ..Index index') it (.is ..Binary it')]) - (.as .I64) - (.is (.I64 .Any)) + (.as (-> (.I64 .Any) .I64)) (.all .i64_or# (.i64_left# 08 (..bits_08 index it)) (..bits_08 (.i64_+# 1 index) it)))])) @@ -152,8 +150,7 @@ (template.macro (bits_32 index' it') [(.<| (.let [index (.is ..Index index') it (.is ..Binary it')]) - (.as .I64) - (.is (.I64 .Any)) + (.as (-> (.I64 .Any) .I64)) (.all .i64_or# (.i64_left# 24 (..bits_08 index it)) (.i64_left# 16 (..bits_08 (.i64_+# 1 index) it)) @@ -164,8 +161,7 @@ (template.macro (bits_64 index' it') [(.<| (.let [index (.is ..Index index') it (.is ..Binary it')]) - (.as .I64) - (.is (.I64 .Any)) + (.as (-> (.I64 .Any) .I64)) (.all .i64_or# (.i64_left# 56 (..bits_08 index it)) (.i64_left# 48 (..bits_08 (.i64_+# 1 index) it)) @@ -186,28 +182,26 @@ (.for .jvm (ffi.write! (|> - (.as (.Nominal "java.lang.Long")) + (.as (-> (.I64 .Any) (.Nominal "java.lang.Long"))) ffi.long_to_byte) ) .js (.|> - (.is ..Binary) - (.as (array.Array .Decimal)) + (.as (-> ..Binary (array.Array .Decimal))) (.js_array_write# (.|> .integer (.i64_and# (.integer )) .int_f64# .as_expected)) - (.as ..Binary)) + (.as (-> Any ..Binary))) .python (.|> - (.is ..Binary) - (.as (array.Array (.I64 .Any))) + (.as (-> ..Binary (array.Array (.I64 .Any)))) (.python_array_write# (.|> (.i64_and# ) (.is (.I64 .Any)))) - (.as ..Binary)) + (.as (-> Any ..Binary))) ... Default (array.has! (.|> .integer (.i64_and# (.integer ))) )))])))) @@ -258,10 +252,10 @@ (.and (.i64_=# limit (..size sample)) (.loop (again [index 0]) (.if (.i64_=# limit index) - .true - (.and (.i64_=# (..bits_08 index reference) - (..bits_08 index sample)) - (again (.i64_+# 1 index))))))))])))) + .true + (.and (.i64_=# (..bits_08 index reference) + (..bits_08 index sample)) + (again (.i64_+# 1 index))))))))])))) ... TODO: Turn into a template ASAP. (`` (the .public copy! @@ -278,12 +272,12 @@ ... Default (.loop (again [index 0]) (.if (.int_<# (.integer bytes) (.integer index)) - (.exec - (..has_08! (.i64_+# target_offset index) - (..bits_08 (.i64_+# source_offset index) source) - target) - (again (.i64_+# 1 index))) - target)))))) + (.exec + (..has_08! (.i64_+# target_offset index) + (..bits_08 (.i64_+# source_offset index) source) + target) + (again (.i64_+# 1 index))) + target)))))) ... TODO: Turn into a template ASAP. (the .public slice diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux index 3f1cf8549f..21b711db3b 100644 --- a/stdlib/source/unsafe/lux/data/collection/array.lux +++ b/stdlib/source/unsafe/lux/data/collection/array.lux @@ -43,7 +43,7 @@ (template#macro (jvm_integer value) [(.|> value - (.as ) + (.as (-> (I64 Any) )) .jvm_object_cast# .jvm_conversion_long_to_int#)])) (these)) @@ -89,8 +89,8 @@ .jvm_array_length_object# .jvm_conversion_int_to_long# .jvm_object_cast# - (.is ) - (.as ..Index)) + (.as (-> + ..Index))) .js (.js_array_length# array) @@ -156,24 +156,23 @@ (.-> ..Index (..Array' read write) read)) (.function (item index array) - (.as_expected - (.for .jvm - (.jvm_array_read_object# (,, (jvm_integer index)) array) + (.for .jvm + (.jvm_array_read_object# (,, (jvm_integer index)) array) - .js - (.js_array_read# index array) - - .python - (.python_array_read# index array) - - .lua - (.lua_array_read# index array) - - .ruby - (.ruby_array_read# index array) - - .php - ("php array read" index array))))) + .js + (.js_array_read# index array) + + .python + (.python_array_read# index array) + + .lua + (.lua_array_read# index array) + + .ruby + (.ruby_array_read# index array) + + .php + ("php array read" index array)))) )]))) (`` (the .public has! @@ -265,13 +264,13 @@ (template#macro (_ ,it) [(|> ,it - (as (Nominal "java.lang.Object")))])) + (as (-> Any (Nominal "java.lang.Object"))))])) (the !int (template#macro (_ ,it) [(|> ,it - (as (Nominal "java.lang.Long")) + (as (-> Natural (Nominal "java.lang.Long"))) .jvm_object_cast# .jvm_conversion_long_to_int#)])))