diff options
Diffstat (limited to 'stdlib/source/library/lux/math')
-rw-r--r-- | stdlib/source/library/lux/math/number/i16.lux | 30 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/i32.lux | 34 | ||||
-rw-r--r-- | stdlib/source/library/lux/math/number/i8.lux | 30 |
3 files changed, 40 insertions, 54 deletions
diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 53c71f68f..04ee87a9e 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -4,29 +4,25 @@ [abstract [equivalence (.only Equivalence)]] [control - ["[0]" maybe]] + ["?" parser] + ["[0]" maybe] + ["[0]" try]] [meta - [type (.only by_example)]]]] + ["[0]" static] + ["[0]" type (.only) + ["?[1]" \\parser]]]]] [// - ["[0]" i64 (.only Sub)]]) + ["[0]" i64]]) (def sub (maybe.trusted (i64.sub 16))) -(def .public I16 - Type - ... TODO: Switch to the cleaner approach ASAP. - (when (type_of ..sub) - {.#Apply :size: :sub:} - (type_literal (I64 :size:)) - - _ - (undefined)) - ... (by_example [size] - ... (is (Sub size) - ... ..sub) - ... (I64 size)) - ) +(`` (type .public I16 + (I64 (,, (|> (type_of ..sub) + (?type.result (?type.applied (?.after (?type.exactly i64.Sub) + ?type.any))) + try.trusted + (static.literal type.code)))))) (def .public equivalence (Equivalence I16) (at ..sub sub_equivalence)) (def .public width Nat (at ..sub bits)) diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index af4d6d592..e2bce4938 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -4,31 +4,25 @@ [abstract [equivalence (.only Equivalence)]] [control - ["[0]" maybe]] + ["?" parser] + ["[0]" maybe] + ["[0]" try]] [meta - [type (.only by_example)]]]] + ["[0]" static] + ["[0]" type (.only) + ["?[1]" \\parser]]]]] [// - ["[0]" i64 (.only Sub)]]) + ["[0]" i64]]) (def sub - ... TODO: Stop needing this coercion. - (as (Sub (I64 (Nominal "#I32"))) - (maybe.trusted (i64.sub 32)))) + (maybe.trusted (i64.sub 32))) -(def .public I32 - Type - ... TODO: Switch to the cleaner approach ASAP. - (when (type_of ..sub) - {.#Apply :size: :sub:} - (type_literal (I64 :size:)) - - _ - (undefined)) - ... (by_example [size] - ... (is (Sub size) - ... ..sub) - ... (I64 size)) - ) +(`` (type .public I32 + (I64 (,, (|> (type_of ..sub) + (?type.result (?type.applied (?.after (?type.exactly i64.Sub) + ?type.any))) + try.trusted + (static.literal type.code)))))) (def .public equivalence (Equivalence I32) (at ..sub sub_equivalence)) (def .public width Nat (at ..sub bits)) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index d4ac05aaf..5a36246c6 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -4,29 +4,25 @@ [abstract [equivalence (.only Equivalence)]] [control - ["[0]" maybe]] + ["?" parser] + ["[0]" maybe] + ["[0]" try]] [meta - [type (.only by_example)]]]] + ["[0]" static] + ["[0]" type (.only) + ["?[1]" \\parser]]]]] [// - ["[0]" i64 (.only Sub)]]) + ["[0]" i64]]) (def sub (maybe.trusted (i64.sub 8))) -(def .public I8 - Type - ... TODO: Switch to the cleaner approach ASAP. - (when (type_of ..sub) - {.#Apply :size: :sub:} - (type_literal (I64 :size:)) - - _ - (undefined)) - ... (by_example [size] - ... (is (Sub size) - ... ..sub) - ... (I64 size)) - ) +(`` (type .public I8 + (I64 (,, (|> (type_of ..sub) + (?type.result (?type.applied (?.after (?type.exactly i64.Sub) + ?type.any))) + try.trusted + (static.literal type.code)))))) (def .public equivalence (Equivalence I8) (at ..sub sub_equivalence)) (def .public width Nat (at ..sub bits)) |