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 51d14f0299..687271c598 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 @@ -35,8 +35,8 @@ [math [number ["n" natural] - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [macro ["^" pattern] ["[0]" template]] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux index 86a213787a..f04a4f3293 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux @@ -30,8 +30,8 @@ [math [number ["n" natural] - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template]] [type diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux index 5cb7ff5a23..343812e436 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux @@ -20,8 +20,8 @@ ["[0]" dictionary]]] [math [number - [integer - ["[0]" /32]]]] + ["[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template]] [target diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux index 0a4ff75886..e990492f57 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -29,8 +29,8 @@ [math [number ["n" natural] - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [macro ["^" pattern] ["[0]" template] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux index 6980d4b871..9f14a0f82f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux @@ -14,8 +14,8 @@ ["[0]" list]]] [math [number - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [target [jvm ["_" bytecode (.only Bytecode)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/of.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/of.lux index 4d48e11dc9..9de78aedd0 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/of.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/of.lux @@ -13,8 +13,8 @@ [number ["n" natural] ["i" integer] - [integer - ["[0]" /32]]]] + ["[0]" /32 + ["[1]" integer]]]] [target [jvm ["_" bytecode (.only Label Bytecode) (.use "[1]#[0]" monad)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux index 271ff99e3f..3e71f3f18e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux @@ -23,8 +23,8 @@ [number ["n" natural] ["[0]" i64] - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template]] [target diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux index 74f02d3f47..847079895f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux @@ -14,8 +14,8 @@ [math [number ["n" natural] - [integer - ["i[0]" /32]]]] + ["i[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template]] [target diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 30365e7725..c8f7b0aa3f 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -84,3 +84,10 @@ _ {try.#Failure ..not_valid})))) + +(the .public (xor left right) + (-> Bit Bit + Bit) + (if left + (not right) + right)) diff --git a/stdlib/source/library/lux/math/number/integer/08.lux b/stdlib/source/library/lux/math/number/08/integer.lux similarity index 97% rename from stdlib/source/library/lux/math/number/integer/08.lux rename to stdlib/source/library/lux/math/number/08/integer.lux index e579bf74a2..7f53f09331 100644 --- a/stdlib/source/library/lux/math/number/integer/08.lux +++ b/stdlib/source/library/lux/math/number/08/integer.lux @@ -19,10 +19,10 @@ ["[0]" nominal]] [macro ["[0]" template]]]] - ["[0]" // (.only) - [// - ["[0]" natural] - ["[0]" i64]]]) + [/// + ["//" integer] + ["[0]" natural] + ["[0]" i64]]) (the .public for (template.macro (_ ,size ,injection) diff --git a/stdlib/source/library/lux/math/number/natural/08.lux b/stdlib/source/library/lux/math/number/08/natural.lux similarity index 98% rename from stdlib/source/library/lux/math/number/natural/08.lux rename to stdlib/source/library/lux/math/number/08/natural.lux index 762d23213f..a0942dcf25 100644 --- a/stdlib/source/library/lux/math/number/natural/08.lux +++ b/stdlib/source/library/lux/math/number/08/natural.lux @@ -19,9 +19,9 @@ ["[0]" nominal]] [macro ["[0]" template]]]] - ["[0]" // (.only) - [// - ["[0]" i64]]]) + [/// + ["//" natural] + ["[0]" i64]]) (the .public for (template.macro (_ ,size ,injection) diff --git a/stdlib/source/library/lux/math/number/integer/16.lux b/stdlib/source/library/lux/math/number/16/integer.lux similarity index 86% rename from stdlib/source/library/lux/math/number/integer/16.lux rename to stdlib/source/library/lux/math/number/16/integer.lux index b32cd24c6a..4b0b96b620 100644 --- a/stdlib/source/library/lux/math/number/integer/16.lux +++ b/stdlib/source/library/lux/math/number/16/integer.lux @@ -7,10 +7,10 @@ [data ["[0]" binary ["[1]" \\injection]]]]] - [// - ["[0]" /08] - [// - ["[0]" natural]]]) + [/// + ["[0]" /08 + ["[1]" integer]] + ["[0]" natural]]) (/08.for (natural.+ /08.size /08.size) binary.bits_16) diff --git a/stdlib/source/library/lux/math/number/natural/16.lux b/stdlib/source/library/lux/math/number/16/natural.lux similarity index 86% rename from stdlib/source/library/lux/math/number/natural/16.lux rename to stdlib/source/library/lux/math/number/16/natural.lux index 2663b8cb01..f0329c8af7 100644 --- a/stdlib/source/library/lux/math/number/natural/16.lux +++ b/stdlib/source/library/lux/math/number/16/natural.lux @@ -7,8 +7,10 @@ [data ["[0]" binary ["[1]" \\injection]]]]] - ["[0]" // (.only) - ["[0]" /08]]) + [/// + ["//" natural] + ["[0]" /08 + ["[1]" natural]]]) (/08.for (//.+ /08.size /08.size) binary.bits_16) diff --git a/stdlib/source/library/lux/math/number/integer/32.lux b/stdlib/source/library/lux/math/number/32/integer.lux similarity index 80% rename from stdlib/source/library/lux/math/number/integer/32.lux rename to stdlib/source/library/lux/math/number/32/integer.lux index 7ead899cc3..2fcfc9feee 100644 --- a/stdlib/source/library/lux/math/number/integer/32.lux +++ b/stdlib/source/library/lux/math/number/32/integer.lux @@ -7,11 +7,12 @@ [data ["[0]" binary ["[1]" \\injection]]]]] - [// - ["[0]" /08] - ["[0]" /16] - [// - ["[0]" natural]]]) + [/// + ["[0]" /08 + ["[1]" integer]] + ["[0]" /16 + ["[1]" integer]] + ["[0]" natural]]) (/08.for (natural.+ /16.size /16.size) binary.bits_32) diff --git a/stdlib/source/library/lux/math/number/natural/32.lux b/stdlib/source/library/lux/math/number/32/natural.lux similarity index 80% rename from stdlib/source/library/lux/math/number/natural/32.lux rename to stdlib/source/library/lux/math/number/32/natural.lux index b3c558c3ea..e0ac2faf39 100644 --- a/stdlib/source/library/lux/math/number/natural/32.lux +++ b/stdlib/source/library/lux/math/number/32/natural.lux @@ -7,9 +7,12 @@ [data ["[0]" binary ["[1]" \\injection]]]]] - ["[0]" // (.only) - ["[0]" /08] - ["[0]" /16]]) + [/// + ["//" natural] + ["[0]" /08 + ["[1]" natural]] + ["[0]" /16 + ["[1]" natural]]]) (/08.for (//.+ /16.size /16.size) binary.bits_32) diff --git a/stdlib/source/library/lux/math/number/big/integer.lux b/stdlib/source/library/lux/math/number/big/integer.lux index 319ed9f16e..7cbf483784 100644 --- a/stdlib/source/library/lux/math/number/big/integer.lux +++ b/stdlib/source/library/lux/math/number/big/integer.lux @@ -25,22 +25,28 @@ [// ["//_64" natural] ["/_64" integer] + ["[0]" signum] [// [arithmetic (.only Arithmetic)]]]]) (the with_template (.in_module# .prelude .with_template)) (the macro (.in_module# .prelude .template#macro)) -(every .public Signum - Bit) +(with_template [,value ,character ,signum] + [(the ,value + (its signum.#value ,signum)) -(the .public positive 0b) -(the .public negative 1b) + (the ,character + (its signum.#character ,signum))] + + [positive positive_signum signum.positive] + [negative negative_signum signum.negative] + ) (every .public Number (Record [... https://en.wikipedia.org/wiki/Sign_function - #signum Signum + #signum signum.Value ... https://en.wikipedia.org/wiki/Absolute_value #absolute //.Number])) @@ -217,7 +223,7 @@ (when [origin it] [[signum_of_origin origin] [signum_of_it it]] - [#signum (bit.= signum_of_origin signum_of_it) + [#signum (signum.x signum_of_origin signum_of_it) #absolute (,// origin it)]))] [x //.x] @@ -387,9 +393,6 @@ [multiplication ..x ..positive_one] ) -(the positive_signum "+") -(the negative_signum "-") - (the not_valid (error "Not an integer.")) diff --git a/stdlib/source/library/lux/math/number/integer.lux b/stdlib/source/library/lux/math/number/integer.lux index c02fba7cf9..109704c066 100644 --- a/stdlib/source/library/lux/math/number/integer.lux +++ b/stdlib/source/library/lux/math/number/integer.lux @@ -21,6 +21,7 @@ ["[0]" // ["[1][0]" natural] ["[1][0]" i64] + ["[0]" signum] [// [arithmetic (.only Arithmetic)]]]) @@ -267,8 +268,13 @@ [minimum ..minor (by ..interval maximum)] ) -(the -sign "-") -(the +sign "+") +(with_template [,character ,signum] + [(the ,character + (its signum.#character ,signum))] + + [+sign signum.positive] + [-sign signum.negative] + ) (with_template [ ] [(the .public diff --git a/stdlib/source/library/lux/math/number/signum.lux b/stdlib/source/library/lux/math/number/signum.lux new file mode 100644 index 0000000000..64586f434c --- /dev/null +++ b/stdlib/source/library/lux/math/number/signum.lux @@ -0,0 +1,34 @@ +... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +(.using + [library + [lux (.except) + [data + ["[0]" bit]]]]) + +(the with_template (.in_module# .prelude .with_template)) + +... https://en.wikipedia.org/wiki/Sign_function +(every .public Value + Bit) + +(the .public x + (-> Value Value + Value) + bit.xor) + +(every .public Signum + (Record + [#character Text + #value Value])) + +(with_template [,name ,character ,value] + [(the .public ,name + Signum + [#character ,character + #value ,value])] + + [positive "+" 0b] + [negative "-" 1b] + ) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 86ce5f9df3..fe622cdb64 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -18,9 +18,10 @@ [math [number ["n" natural] - [natural - ["[0]" /16] - ["[0]" /32]]]] + ["[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" natural]]]] [macro ["[0]" expansion] ["[0]" template]]]] diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 8834663f15..ca9e46f4ae 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -16,9 +16,10 @@ [math [number ["n" natural] - [natural - ["[0]" /16] - ["[0]" /32]]]]]] + ["[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" natural]]]]]] ["[0]" /// [bytecode [environment diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index f4ecc0aa94..7b8f2a5bb6 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -13,8 +13,8 @@ [math [number ["n" natural] - [natural - ["[0]" /16]]]]]] + ["[0]" /16 + ["[1]" natural]]]]]] ["[0]" // ["//[1]" /// ["[1][0]" index (.only Index)] diff --git a/stdlib/source/library/lux/target/jvm/attribute/line_number_table.lux b/stdlib/source/library/lux/target/jvm/attribute/line_number_table.lux index 25066b25ba..28b4723194 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/line_number_table.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/line_number_table.lux @@ -16,8 +16,8 @@ [math [number ["n" natural] - [natural - ["[0]" /16]]]]]]) + ["[0]" /16 + ["[1]" natural]]]]]]) (every .public Entry (Record diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 98c548b649..8948c86af9 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -31,11 +31,12 @@ [number ["n" natural] ["i" integer] - [natural - ["n[0]" /08] - ["n[0]" /16]] - [integer - ["[0]" /32]]]] + ["n[0]" /08 + ["[1]" natural]] + ["n[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template] ["[0]" expansion]] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index 4c1e653ec0..05c88a6ce4 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -17,10 +17,10 @@ [math [number ["n" natural] - [natural - ["[0]" /16]] - [integer - ["[0]" /32]]]] + ["[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" integer]]]] [type ["[0]" nominal]]]] [// diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 8f13310a79..e20fef5e14 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -15,8 +15,8 @@ ["[0]" template]] [math [number - [natural - ["[0]" /16]]]]]] + ["[0]" /16 + ["[1]" natural]]]]]] [/ ["/[0]" limit (.only Limit) ["/[0]" stack (.only Stack)] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/datum.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/datum.lux index 748610df84..567415fec2 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/datum.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/datum.lux @@ -11,8 +11,8 @@ [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)] [number - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [macro ["[0]" template]]]] [///// diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index 83c8fbc282..2852c770a3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -19,9 +19,10 @@ ["[0]" random (.only Random) (.use "[1]#[0]" monad)] [number ["n" natural] - [natural - ["[0]" /08] - ["[0]" /16]]]] + ["[0]" /08 + ["[1]" natural]] + ["[0]" /16 + ["[1]" natural]]]] [macro ["[0]" template]] [type diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index 92dc4c7486..c50ea89de6 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -18,8 +18,8 @@ [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)] [number - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [macro ["[0]" template]] [type diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 013982739d..1bd44f7de5 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -23,11 +23,12 @@ [math [number (.only hex) ["n" natural] - [natural - ["n[0]" /08] - ["n[0]" /16]] - [integer - ["[0]" /32]]]] + ["n[0]" /08 + ["[1]" natural]] + ["n[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template] ["[0]" expansion]] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 4abb9bc33d..e4826b7e3f 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -11,8 +11,8 @@ [\\injection (.only Injection)]]] [math [number - [integer - ["[0]" /32]]]]]] + ["[0]" /32 + ["[1]" integer]]]]]] [/// [encoding ["[0]" signed]]]) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index 1ea2922eb8..ca0822c66a 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -23,9 +23,10 @@ ["[0]" template]] [math [number - [natural - ["[0]" /16] - ["[0]" /32]]]]]] + ["[0]" /16 + ["[1]" natural]] + ["[0]" /32 + ["[1]" natural]]]]]] ["[0]" // ["[1][0]" modifier (.only Modifier modifiers)] ["[1][0]" version (.only Version Minor Major)] diff --git a/stdlib/source/library/lux/target/jvm/constant/integer.lux b/stdlib/source/library/lux/target/jvm/constant/integer.lux index 86436ef7af..f6ef7801c3 100644 --- a/stdlib/source/library/lux/target/jvm/constant/integer.lux +++ b/stdlib/source/library/lux/target/jvm/constant/integer.lux @@ -10,8 +10,8 @@ [math [random (.only Random)] [number - [integer - ["i[0]" /32]]]]]]) + ["i[0]" /32 + ["[1]" integer]]]]]]) (every .public Integer i/32.Number) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 379bdc6472..a221423c6f 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -25,8 +25,8 @@ [number ["[0]" integer] ["[0]" decimal] - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [macro ["[0]" expansion] ["[0]" template]]]] diff --git a/stdlib/source/library/lux/target/jvm/constant/tag.lux b/stdlib/source/library/lux/target/jvm/constant/tag.lux index bc608d6a26..1b54fff8de 100644 --- a/stdlib/source/library/lux/target/jvm/constant/tag.lux +++ b/stdlib/source/library/lux/target/jvm/constant/tag.lux @@ -15,8 +15,8 @@ [\\injection (.only Injection)]]] [math [number - [natural - ["[0]" /08]]]] + ["[0]" /08 + ["[1]" natural]]]] [macro ["[0]" template]] [type diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index 772df1b139..4da8416a9d 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -13,8 +13,8 @@ ["[0]" random (.only Random) (.use "[1]#[0]" functor)] [number ["n" natural] - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [type ["[0]" nominal]]]]) diff --git a/stdlib/source/library/lux/target/jvm/magic.lux b/stdlib/source/library/lux/target/jvm/magic.lux index 69c5cc3890..f97eac408a 100644 --- a/stdlib/source/library/lux/target/jvm/magic.lux +++ b/stdlib/source/library/lux/target/jvm/magic.lux @@ -8,8 +8,8 @@ ["[0]" try]] [math [number (.only hex) - [natural - ["[0]" /32]]]]]]) + ["[0]" /32 + ["[1]" natural]]]]]]) (every .public Magic /32.Number) diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index 8bb64967c9..ea125b3158 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -19,8 +19,8 @@ [math ["[0]" number (.only hex) ["[0]" i64] - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [macro (.only with_names) ["[0]" syntax] ["[0]" template]] diff --git a/stdlib/source/library/lux/target/jvm/version.lux b/stdlib/source/library/lux/target/jvm/version.lux index ae1a35ed29..6e0602fab3 100644 --- a/stdlib/source/library/lux/target/jvm/version.lux +++ b/stdlib/source/library/lux/target/jvm/version.lux @@ -10,8 +10,8 @@ ["[0]" template]] [math [number - [natural - ["[0]" /16]]]]]]) + ["[0]" /16 + ["[1]" natural]]]]]]) (every .public Version /16.Number) (every .public Minor Version) diff --git a/stdlib/source/test/lux/math/number.lux b/stdlib/source/test/lux/math/number.lux index fed957ce2c..2753c8ad8c 100644 --- a/stdlib/source/test/lux/math/number.lux +++ b/stdlib/source/test/lux/math/number.lux @@ -11,6 +11,7 @@ ["[0]" / ["[1][0]" digit] ["[1][0]" base] + ["[1][0]" signum] ["[1][0]" i64] ["[1][0]" natural] ["[1][0]" integer] @@ -19,6 +20,15 @@ ["[1][0]" fraction] ["[1][0]" complex] ["[1][0]" rational] + ["[0]" /08 + ["[1]/[0]" natural] + ["[1]/[0]" integer]] + ["[0]" /16 + ["[1]/[0]" natural] + ["[1]/[0]" integer]] + ["[0]" /32 + ["[1]/[0]" natural] + ["[1]/[0]" integer]] ["[1][0]" big ["[1]/[0]" natural] ["[1]/[0]" integer] @@ -30,6 +40,8 @@ (all _.and /digit.test /base.test + /signum.test + /i64.test /natural.test /integer.test @@ -39,6 +51,15 @@ /complex.test /rational.test + /08/natural.test + /08/integer.test + + /16/natural.test + /16/integer.test + + /32/natural.test + /32/integer.test + /big/natural.test /big/integer.test /big/fraction.test diff --git a/stdlib/source/test/lux/math/number/integer/08.lux b/stdlib/source/test/lux/math/number/08/integer.lux similarity index 100% rename from stdlib/source/test/lux/math/number/integer/08.lux rename to stdlib/source/test/lux/math/number/08/integer.lux diff --git a/stdlib/source/test/lux/math/number/natural/08.lux b/stdlib/source/test/lux/math/number/08/natural.lux similarity index 100% rename from stdlib/source/test/lux/math/number/natural/08.lux rename to stdlib/source/test/lux/math/number/08/natural.lux diff --git a/stdlib/source/test/lux/math/number/integer/16.lux b/stdlib/source/test/lux/math/number/16/integer.lux similarity index 100% rename from stdlib/source/test/lux/math/number/integer/16.lux rename to stdlib/source/test/lux/math/number/16/integer.lux diff --git a/stdlib/source/test/lux/math/number/natural/16.lux b/stdlib/source/test/lux/math/number/16/natural.lux similarity index 100% rename from stdlib/source/test/lux/math/number/natural/16.lux rename to stdlib/source/test/lux/math/number/16/natural.lux diff --git a/stdlib/source/test/lux/math/number/integer/32.lux b/stdlib/source/test/lux/math/number/32/integer.lux similarity index 100% rename from stdlib/source/test/lux/math/number/integer/32.lux rename to stdlib/source/test/lux/math/number/32/integer.lux diff --git a/stdlib/source/test/lux/math/number/natural/32.lux b/stdlib/source/test/lux/math/number/32/natural.lux similarity index 100% rename from stdlib/source/test/lux/math/number/natural/32.lux rename to stdlib/source/test/lux/math/number/32/natural.lux diff --git a/stdlib/source/test/lux/math/number/integer.lux b/stdlib/source/test/lux/math/number/integer.lux index a40c42b071..be4a1d9233 100644 --- a/stdlib/source/test/lux/math/number/integer.lux +++ b/stdlib/source/test/lux/math/number/integer.lux @@ -39,10 +39,7 @@ [// ["n" natural] ["d" decimal] - ["[0]" i64]]]] - ["[0]" /08] - ["[0]" /16] - ["[0]" /32]) + ["[0]" i64]]]]) (the signature Test @@ -282,8 +279,4 @@ ..predicate ..signature - - /08.test - /16.test - /32.test ))) diff --git a/stdlib/source/test/lux/math/number/natural.lux b/stdlib/source/test/lux/math/number/natural.lux index 77222dfc38..121a560e26 100644 --- a/stdlib/source/test/lux/math/number/natural.lux +++ b/stdlib/source/test/lux/math/number/natural.lux @@ -38,11 +38,7 @@ [\\library ["[0]" / (.only) [// - ["d" decimal]]]] - ["[0]" / - ["[0]" /08] - ["[0]" /16] - ["[0]" /32]]) + ["d" decimal]]]]) (the signature Test @@ -237,8 +233,4 @@ ..predicate ..signature - - /08.test - /16.test - /32.test ))) diff --git a/stdlib/source/test/lux/math/number/signum.lux b/stdlib/source/test/lux/math/number/signum.lux new file mode 100644 index 0000000000..1f9d60c4ab --- /dev/null +++ b/stdlib/source/test/lux/math/number/signum.lux @@ -0,0 +1,60 @@ +... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +(.using + [library + [lux (.except) + [abstract + [monad (.only do)]] + [data + ["[0]" bit] + ["[0]" text] + [collection + ["[0]" list (.use "[1]#[0]" functor)] + ["[0]" set]]] + [macro + ["[0]" expansion] + ["[0]" template]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["[0]" natural]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(the random + (Random /.Signum) + (random.either (random#pure /.positive) + (random#pure /.negative))) + +(expansion.let [,each (these /.positive /.negative)] + (the .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [it ..random]) + (_.for [/.Signum + ,each]) + (`` (all _.and + (,, (template.with [,slot ,hash] + [(_.coverage [,slot] + (let [each (list ,each) + each_unique (|> each + (list#each (its ,slot)) + (set.of_list ,hash))] + (natural.= (list.size each) + (set.size each_unique))))] + + [/.#character text.hash] + [/.#value bit.hash] + )) + (_.coverage [/.Value /.x] + (and (bit.= (its /.#value /.negative) + (/.x (its /.#value /.positive) + (its /.#value /.negative))) + (bit.= (its /.#value /.positive) + (/.x (its /.#value it) + (its /.#value it))))) + ))))) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 41b05aefc0..0243ff0915 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -37,10 +37,10 @@ ["i" integer] ["d" decimal] ["[0]" i64] - [natural - ["n[0]" /08]] - [integer - ["[0]" /32]]]] + ["n[0]" /08 + ["[1]" natural]] + ["[0]" /32 + ["[1]" integer]]]] [macro ["[0]" template]] [test diff --git a/stdlib/source/test/lux/target/jvm/bytecode/jump.lux b/stdlib/source/test/lux/target/jvm/bytecode/jump.lux index d44e3bf61f..e4b3deaaef 100644 --- a/stdlib/source/test/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/test/lux/target/jvm/bytecode/jump.lux @@ -16,8 +16,8 @@ [number ["n" natural] ["i" integer] - [integer - ["[0]" /32]]]] + ["[0]" /32 + ["[1]" integer]]]] [meta ["[0]" static]] [test diff --git a/stdlib/source/test/lux/target/jvm/index.lux b/stdlib/source/test/lux/target/jvm/index.lux index 7d2f0d7c66..2d28643676 100644 --- a/stdlib/source/test/lux/target/jvm/index.lux +++ b/stdlib/source/test/lux/target/jvm/index.lux @@ -15,8 +15,8 @@ ["[0]" random] [number ["n" natural] - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [meta ["[0]" static]] [test diff --git a/stdlib/source/test/lux/target/jvm/magic.lux b/stdlib/source/test/lux/target/jvm/magic.lux index 27c1c23e36..f8e1180938 100644 --- a/stdlib/source/test/lux/target/jvm/magic.lux +++ b/stdlib/source/test/lux/target/jvm/magic.lux @@ -13,8 +13,8 @@ ["[0]" random (.only Random)] [number (.only hex) ["n" natural] - [natural - ["[0]" /32]]]] + ["[0]" /32 + ["[1]" natural]]]] [test ["_" property (.only Test)]]]] [\\library diff --git a/stdlib/source/test/lux/target/jvm/version.lux b/stdlib/source/test/lux/target/jvm/version.lux index 36232b9589..d11ae4e459 100644 --- a/stdlib/source/test/lux/target/jvm/version.lux +++ b/stdlib/source/test/lux/target/jvm/version.lux @@ -16,8 +16,8 @@ ["[0]" random (.only Random)] [number ["n" natural] - [natural - ["[0]" /16]]]] + ["[0]" /16 + ["[1]" natural]]]] [test ["_" property (.only Test)]]]] [\\library