Skip to content

Commit

Permalink
Number alias in all the math/number modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Oct 4, 2023
1 parent 9858723 commit 606f6ad
Show file tree
Hide file tree
Showing 16 changed files with 330 additions and 56 deletions.
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/complex.lux
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
[#real Decimal
#imaginary Decimal]))

(the .public Number
..Complex)

(the .public complex
(syntax.macro (_ [real <code>.any
?imaginary (<>.maybe <code>.any)])
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/decimal.lux
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
[//
[arithmetic (.only Arithmetic)]]])

(the .public Number
.Decimal)

(the with_template' (.in_module# .prelude .with_template))
(the template#macro (.in_module# .prelude .template#macro))

Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/fraction.lux
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
[#numerator Natural
#denominator Natural]))

(the .public Number
..Fraction)

(the .public not_a_natural
Error
(location.with (location.here)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/i16.lux
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
try.trusted
(static.literal type.code))))))

(the .public Number
..I16)

(the .public equivalence (Equivalence I16) (of ..sub sub_equivalence))

(alias [=]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/i32.lux
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
try.trusted
(static.literal type.code))))))

(the .public Number
..I32)

(the .public equivalence (Equivalence I32) (of ..sub sub_equivalence))

(alias [=]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/i64.lux
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
[//
["n" natural]])

(the .public Number
.I64)

(the with_template' (.in_module# .prelude .with_template))

(the .public bits_per_byte
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/i8.lux
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
try.trusted
(static.literal type.code))))))

(the .public Number
..I8)

(the .public equivalence (Equivalence I8) (of ..sub sub_equivalence))

(alias [=]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/integer.lux
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
[//
[arithmetic (.only Arithmetic)]]])

(the .public Number
.Integer)

(the with_template' (.in_module# .prelude .with_template))

(with_template' [<name> <op>]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/natural.lux
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
[///
[arithmetic (.only Arithmetic)]])

(the .public Number
.Natural)

(the with_template' (.in_module# .prelude .with_template))

(with_template' [<extension> <output> <name>]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/rational.lux
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
[#numerator Integer
#denominator Integer]))

(the .public Number
..Rational)

(the .public not_an_integer
Error
(location.with (location.here)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/math/number/revolution.lux
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
[//
[arithmetic (.only Arithmetic)]]])

(the .public Number
.Revolution)

(the with_template' (.in_module# .prelude .with_template))

(the .public /1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[library
[lux (.except Declaration)
[abstract
[equivalence (.only Equivalence)]]
[equivalence (.only Equivalence)]
[hash (.only Hash)]]
[data
["[0]" text (.only)
["%" \\injection]]]
Expand All @@ -25,7 +26,8 @@
Text

(the .public reflection
(-> (Reflection Any) Text)
(-> (Reflection Any)
Text)
(|>> nominal.representation))

(the .public equivalence
Expand All @@ -39,6 +41,16 @@
(alias [=]
..equivalence)

(the .public hash
(for_any (_ category)
(Hash (Reflection category)))
(implementation
(the equivalence
..equivalence)
(the hash
(|>> nominal.representation
(of text.hash hash)))))

(template.with [<category> <name> <reflection>]
[(the .public <name>
(Reflection <category>)
Expand All @@ -56,19 +68,23 @@
)

(the .public class
(-> External (Reflection Class))
(-> External
(Reflection Class))
(|>> nominal.abstraction))

(the .public (declaration name)
(-> External (Reflection Declaration))
(-> External
(Reflection Declaration))
(nominal.transmutation (..class name)))

(the .public as_class
(-> (Reflection Declaration) (Reflection Class))
(-> (Reflection Declaration)
(Reflection Class))
(|>> nominal.transmutation))

(the .public (array element)
(-> (Reflection Value) (Reflection Array))
(-> (Reflection Value)
(Reflection Array))
(let [element' (nominal.representation element)
elementR (`` (if (text.starts_with? //descriptor.array_prefix element')
element'
Expand Down Expand Up @@ -107,10 +123,12 @@
)

(the .public (lower reflection)
(-> (Reflection Parameter) (Reflection Parameter))
(-> (Reflection Parameter)
(Reflection Parameter))
..wildcard)

(the .public upper
(-> (Reflection Parameter) (Reflection Parameter))
(-> (Reflection Parameter)
(Reflection Parameter))
(|>> nominal.transmutation))
)
85 changes: 43 additions & 42 deletions stdlib/source/test/lux/meta/compiler/target/jvm.lux
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
[type
["[1][0]" box]
["[1][0]" category]
["[1][0]" descriptor]]])
["[1][0]" descriptor]
["[1][0]" reflection]]])

(the method_modifier
(all /modifier#composite
Expand Down Expand Up @@ -891,51 +892,50 @@
(-> (Bytecode Any) (Random a) (-> a (Bytecode Any))
[(Bytecode Any) (Bytecode Any) (Bytecode Any)]
(-> a Any Bit)
Test))
(Random Bit)))
(function (_ constructor random literal [*store *load *wrap] test)
(do [! random.monad]
[size (of ! each (|>> (n.% 1024) (n.max 1)) random.natural)
value random]
(all _.and
(<| (_.lifted "length")
(length size constructor))
(<| (_.lifted "write and read")
(write_and_read size constructor value literal [*store *load *wrap] test))))))]
value random
length! (length size constructor)
write_and_read! (write_and_read size constructor value literal [*store *load *wrap] test)]
(in (and length!
write_and_read!)))))]
(all _.and
(_.context "boolean"
(array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap]
(function (_ expected) (|>> (as Bit) (bit.= (as Bit expected))))))
(_.context "byte"
(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))))))))
(_.context "short"
(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))))))))
(_.context "int"
(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)))))))
(_.context "long"
(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)))))))
(_.context "float"
(array (/.newarray /instruction.t_float) ..valid_float $Float::literal [/.fastore /.faload $Float::wrap]
(function (_ expected)
(|>> (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# (as java/lang/Float expected)))))))
(_.context "double"
(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)))))))
(_.context "char"
(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)))))))
(_.context "object"
(array (/.anewarray ..$String) $String::random $String::literal [/.aastore /.aaload /.nop]
(function (_ expected) (|>> (as Text) (text.= (as Text expected))))))
(_.coverage' [/.bastore /.baload]
(array (/.newarray /instruction.t_boolean) $Boolean::random $Boolean::literal [/.bastore /.baload $Boolean::wrap]
(function (_ expected) (|>> (as Bit) (bit.= (as 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))))))))
(_.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))))))))
(_.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)))))))
(_.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)))))))
(_.coverage' [/.fastore /.faload]
(array (/.newarray /instruction.t_float) ..valid_float $Float::literal [/.fastore /.faload $Float::wrap]
(function (_ expected)
(|>> (as java/lang/Float) .jvm_object_cast# (.jvm_float_=# (.jvm_object_cast# (as java/lang/Float expected)))))))
(_.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)))))))
(_.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)))))))
(_.coverage' [/.aastore /.aaload]
(array (/.anewarray ..$String) $String::random $String::literal [/.aastore /.aaload /.nop]
(function (_ expected) (|>> (as Text) (text.= (as Text expected))))))
(<| (_.context "multi")
(do [! random.monad]
[.let [size (is (Random Natural)
Expand Down Expand Up @@ -1612,4 +1612,5 @@
/box.test
/category.test
/descriptor.test
/reflection.test
)))

0 comments on commit 606f6ad

Please sign in to comment.