aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/abstract/number.lux14
-rw-r--r--stdlib/source/lux/data/number/complex.lux71
-rw-r--r--stdlib/source/lux/data/number/frac.lux94
-rw-r--r--stdlib/source/lux/data/number/int.lux63
-rw-r--r--stdlib/source/lux/data/number/nat.lux32
-rw-r--r--stdlib/source/lux/data/number/ratio.lux76
-rw-r--r--stdlib/source/lux/data/number/rev.lux5
-rw-r--r--stdlib/source/lux/time/duration.lux4
-rw-r--r--stdlib/source/lux/type/unit.lux9
-rw-r--r--stdlib/source/test/lux/abstract/number.lux46
-rw-r--r--stdlib/source/test/lux/data/color.lux4
-rw-r--r--stdlib/source/test/lux/data/number/complex.lux13
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux2
-rw-r--r--stdlib/source/test/lux/data/number/int.lux2
-rw-r--r--stdlib/source/test/lux/data/number/nat.lux2
-rw-r--r--stdlib/source/test/lux/data/number/ratio.lux2
-rw-r--r--stdlib/source/test/lux/data/number/rev.lux1
-rw-r--r--stdlib/source/test/lux/macro/poly/equivalence.lux41
-rw-r--r--stdlib/source/test/lux/math.lux6
-rw-r--r--stdlib/source/test/lux/world/file.lux2
20 files changed, 203 insertions, 286 deletions
diff --git a/stdlib/source/lux/abstract/number.lux b/stdlib/source/lux/abstract/number.lux
deleted file mode 100644
index b3a314ba5..000000000
--- a/stdlib/source/lux/abstract/number.lux
+++ /dev/null
@@ -1,14 +0,0 @@
-(.module:
- lux)
-
-(`` (signature: #export (Number n)
- {#.doc "Everything that should be expected of a number type."}
-
- (~~ (template [<name>]
- [(: (-> n n n) <name>)]
- [+] [-] [*] [/] [%]))
-
- (~~ (template [<name>]
- [(: (-> n n) <name>)]
- [negate] [signum] [abs]))
- ))
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index 064a3a847..8b9be426f 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -3,8 +3,7 @@
["." math]
[abstract
[equivalence (#+ Equivalence)]
- number
- codec
+ [codec (#+ Codec)]
["M" monad (#+ Monad do)]]
[control
["p" parser
@@ -12,7 +11,7 @@
[data
["." maybe]
[number
- ["." frac ("#;." number)]]
+ ["." frac]]
["." text ("#;." monoid)]
[collection
["." list ("#;." functor)]]]
@@ -65,19 +64,19 @@
(structure: #export equivalence (Equivalence Complex)
(def: = ..=))
-(def: #export negate
- (-> Complex Complex)
- (|>> (update@ #real frac;negate)
- (update@ #imaginary frac;negate)))
+(template [<name> <transform>]
+ [(def: #export <name>
+ (-> Complex Complex)
+ (|>> (update@ #real <transform>)
+ (update@ #imaginary <transform>)))]
-(def: #export signum
- (-> Complex Complex)
- (|>> (update@ #real frac;signum)
- (update@ #imaginary frac;signum)))
+ [negate frac.negate]
+ [signum frac.signum]
+ )
(def: #export conjugate
(-> Complex Complex)
- (update@ #imaginary frac;negate))
+ (update@ #imaginary frac.negate))
(def: #export (*' param input)
(-> Frac Complex Complex)
@@ -100,8 +99,8 @@
(def: #export (/ param input)
(-> Complex Complex Complex)
(let [(^slots [#real #imaginary]) param]
- (if (f/< (frac;abs imaginary)
- (frac;abs real))
+ (if (f/< (frac.abs imaginary)
+ (frac.abs real))
(let [quot (f// imaginary real)
denom (|> real (f/* quot) (f/+ imaginary))]
{#real (|> (get@ #real input) (f/* quot) (f/+ (get@ #imaginary input)) (f// denom))
@@ -131,7 +130,7 @@
(let [(^slots [#real #imaginary]) subject]
{#real (f/* (math.cosh imaginary)
(math.cos real))
- #imaginary (frac;negate (f/* (math.sinh imaginary)
+ #imaginary (frac.negate (f/* (math.sinh imaginary)
(math.sin real)))}))
(def: #export (cosh subject)
@@ -179,36 +178,20 @@
(def: #export (abs subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- (complex (if (f/< (frac;abs imaginary)
- (frac;abs real))
+ (complex (if (f/< (frac.abs imaginary)
+ (frac.abs real))
(if (f/= +0.0 imaginary)
- (frac;abs real)
+ (frac.abs real)
(let [q (f// imaginary real)]
(f/* (math.pow +0.5 (f/+ +1.0 (f/* q q)))
- (frac;abs imaginary))))
+ (frac.abs imaginary))))
(if (f/= +0.0 real)
- (frac;abs imaginary)
+ (frac.abs imaginary)
(let [q (f// real imaginary)]
(f/* (math.pow +0.5 (f/+ +1.0 (f/* q q)))
- (frac;abs real))))
+ (frac.abs real))))
))))
-(structure: #export number (Number Complex)
- (def: + ..+)
- (def: - ..-)
- (def: * ..*)
- (def: / ../)
- (def: % ..%)
- (def: (negate x)
- (|> x
- (update@ #real frac;negate)
- (update@ #imaginary frac;negate)))
- (def: abs ..abs)
- (def: (signum x)
- (|> x
- (update@ #real frac;signum)
- (update@ #imaginary frac;signum))))
-
(def: #export (exp subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
@@ -233,17 +216,17 @@
(def: (copy-sign sign magnitude)
(-> Frac Frac Frac)
- (f/* (frac;signum sign) magnitude))
+ (f/* (frac.signum sign) magnitude))
(def: #export (root2 (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
- (let [t (|> input ..abs (get@ #real) (f/+ (frac;abs real)) (f// +2.0) (math.pow +0.5))]
+ (let [t (|> input ..abs (get@ #real) (f/+ (frac.abs real)) (f// +2.0) (math.pow +0.5))]
(if (f/>= +0.0 real)
{#real t
#imaginary (f// (f/* +2.0 t)
imaginary)}
{#real (f// (f/* +2.0 t)
- (frac;abs imaginary))
+ (frac.abs imaginary))
#imaginary (f/* t (copy-sign imaginary +1.0))})))
(def: #export (root2-1z input)
@@ -252,18 +235,18 @@
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
- (if (f/< (frac;abs imaginary)
- (frac;abs real))
+ (if (f/< (frac.abs imaginary)
+ (frac.abs real))
(let [q (f// imaginary real)
scale (f// (|> real (f/* q) (f/+ imaginary))
+1.0)]
{#real (f/* q scale)
- #imaginary (frac;negate scale)})
+ #imaginary (frac.negate scale)})
(let [q (f// real imaginary)
scale (f// (|> imaginary (f/* q) (f/+ real))
+1.0)]
{#real scale
- #imaginary (|> scale frac;negate (f/* q))})))
+ #imaginary (|> scale frac.negate (f/* q))})))
(def: #export (acos input)
(-> Complex Complex)
diff --git a/stdlib/source/lux/data/number/frac.lux b/stdlib/source/lux/data/number/frac.lux
index 6fb8f3831..ce7fb08bf 100644
--- a/stdlib/source/lux/data/number/frac.lux
+++ b/stdlib/source/lux/data/number/frac.lux
@@ -2,11 +2,10 @@
[lux #*
[abstract
[hash (#+ Hash)]
- [number (#+ Number)]
[monoid (#+ Monoid)]
[equivalence (#+ Equivalence)]
- ["." order (#+ Order)]
- [codec (#+ Codec)]]
+ [codec (#+ Codec)]
+ ["." order (#+ Order)]]
[control
["." try (#+ Try)]]
[data
@@ -25,31 +24,39 @@
(def: &equivalence ..equivalence)
(def: < f/<))
-(structure: #export number (Number Frac)
- (def: + f/+)
- (def: - f/-)
- (def: * f/*)
- (def: / f//)
- (def: % f/%)
- (def: negate (f/* -1.0))
- (def: (abs x)
- (if (f/< +0.0 x)
- (f/* -1.0 x)
- x))
- (def: (signum x)
- (cond (f/= +0.0 x) +0.0
- (f/< +0.0 x) -1.0
- ## else
- +1.0))
- )
+(def: #export + (-> Frac Frac Frac) f/+)
+
+(def: #export - (-> Frac Frac Frac) f/-)
+
+(def: #export * (-> Frac Frac Frac) f/*)
+
+(def: #export / (-> Frac Frac Frac) f//)
+
+(def: #export % (-> Frac Frac Frac) f/%)
+
+(def: #export negate (-> Frac Frac) (f/* -1.0))
+
+(def: #export (abs x)
+ (-> Frac Frac)
+ (if (f/< +0.0 x)
+ (..* -1.0 x)
+ x))
+
+(def: #export (signum x)
+ (-> Frac Frac)
+ (cond (f/= +0.0 x) +0.0
+ (f/< +0.0 x) -1.0
+ ## else
+ +1.0))
+
(template [<name> <compose> <identity>]
[(structure: #export <name> (Monoid Frac)
(def: identity <identity>)
(def: compose <compose>))]
- [addition f/+ +0.0]
- [multiplication f/* +1.0]
+ [addition ..+ +0.0]
+ [multiplication ..* +1.0]
[maximum f/max ("lux f64 min")]
[minimum f/min ("lux f64 max")]
)
@@ -58,7 +65,7 @@
[(def: #export <name>
{#.doc <doc>}
Frac
- (f// +0.0 <numerator>))]
+ (../ +0.0 <numerator>))]
[not-a-number +0.0 "Not a number."]
[positive-infinity +1.0 "Positive infinity."]
@@ -95,16 +102,16 @@
(def: (encode value)
(let [whole (frac-to-int value)
whole-part (:: <int> encode whole)
- decimal (:: ..number abs (f/% +1.0 value))
+ decimal (|> value (..% +1.0) ..abs)
decimal-part (if (f/= +0.0 decimal)
".0"
(loop [dec-left decimal
output ""]
(if (f/= +0.0 dec-left)
("lux text concat" "." output)
- (let [shifted (f/* <base> dec-left)
- digit-idx (|> shifted (f/% <base>) frac-to-int .nat)]
- (recur (f/% +1.0 shifted)
+ (let [shifted (..* <base> dec-left)
+ digit-idx (|> shifted (..% <base>) frac-to-int .nat)]
+ (recur (..% +1.0 shifted)
("lux text concat" output ("lux text clip" digit-idx (inc digit-idx) <char-set>)))))))]
("lux text concat" whole-part decimal-part)))
@@ -125,16 +132,16 @@
(if (n/= 0 muls-left)
output
(recur (dec muls-left)
- (f/* <base> output))))
- adjusted-decimal (|> decimal int-to-frac (f// div-power))
+ (..* <base> output))))
+ adjusted-decimal (|> decimal int-to-frac (../ div-power))
dec-rev (case (:: //rev.hex decode ("lux text concat" "." decimal-part))
(#try.Success dec-rev)
dec-rev
(#try.Failure error)
(error! error))]
- (#try.Success (f/+ (int-to-frac whole)
- (f/* sign adjusted-decimal))))
+ (#try.Success (..+ (int-to-frac whole)
+ (..* sign adjusted-decimal))))
_
(#try.Failure ("lux text concat" <error> repr))))
@@ -282,7 +289,7 @@
(template [<struct> <error> <from> <to>]
[(structure: #export <struct> (Codec Text Frac)
(def: (encode value)
- (let [sign (:: ..number signum value)
+ (let [sign (..signum value)
raw-bin (:: ..binary encode value)
dot-idx (maybe.assume ("lux text index" 0 "." raw-bin))
whole-part ("lux text clip" (if (f/= -1.0 sign) 1 0) dot-idx raw-bin)
@@ -324,7 +331,7 @@
(def: (log2 input)
(-> Frac Frac)
- (f// (math.log +2.0)
+ (../ (math.log +2.0)
(math.log input)))
(def: double-bias Nat 1023)
@@ -355,7 +362,7 @@
..negative-infinity-bits
(f/= +0.0 input)
- (let [reciprocal (f// input +1.0)]
+ (let [reciprocal (../ input +1.0)]
(if (f/= positive-infinity reciprocal)
## Positive zero
..positive-zero-bits
@@ -363,16 +370,17 @@
..negative-zero-bits))
## else
- (let [sign (:: ..number signum input)
- input (:: ..number abs input)
+ (let [input (..abs input)
exponent (math.floor (log2 input))
exponent-mask (|> 1 (//i64.left-shift exponent-size) dec)
mantissa (|> input
## Normalize
- (f// (math.pow exponent +2.0))
+ (../ (math.pow exponent +2.0))
## Make it int-equivalent
- (f/* (math.pow +52.0 +2.0)))
- sign-bit (if (f/= -1.0 sign) 1 0)
+ (..* (math.pow +52.0 +2.0)))
+ sign-bit (if (f/= -1.0 (..signum input))
+ 1
+ 0)
exponent-bits (|> exponent frac-to-int .nat (n/+ double-bias) (//i64.and exponent-mask))
mantissa-bits (|> mantissa frac-to-int .nat)]
($_ //i64.or
@@ -407,20 +415,20 @@
(and (n/= 0 E) (n/= 0 M))
(if (n/= 0 S)
+0.0
- (f/* -1.0 +0.0))
+ (..* -1.0 +0.0))
## else
(let [normalized (|> M (//i64.set mantissa-size)
.int int-to-frac
- (f// (math.pow +52.0 +2.0)))
+ (../ (math.pow +52.0 +2.0)))
power (math.pow (|> E (n/- double-bias)
.int int-to-frac)
+2.0)
- shifted (f/* power
+ shifted (..* power
normalized)]
(if (n/= 0 S)
shifted
- (f/* -1.0 shifted))))))
+ (..* -1.0 shifted))))))
(structure: #export hash (Hash Frac)
(def: &equivalence ..equivalence)
diff --git a/stdlib/source/lux/data/number/int.lux b/stdlib/source/lux/data/number/int.lux
index c924ba9fe..9e1299ae2 100644
--- a/stdlib/source/lux/data/number/int.lux
+++ b/stdlib/source/lux/data/number/int.lux
@@ -2,18 +2,17 @@
[lux #*
[abstract
[hash (#+ Hash)]
- [number (#+ Number)]
[enum (#+ Enum)]
[interval (#+ Interval)]
[monoid (#+ Monoid)]
[equivalence (#+ Equivalence)]
- ["." order (#+ Order)]
- [codec (#+ Codec)]]
+ [codec (#+ Codec)]
+ ["." order (#+ Order)]]
[control
["." try (#+ Try)]]
[data
- ["." maybe]
- [text (#+ Char)]]]
+ [text (#+ Char)]
+ ["." maybe]]]
[//
["." nat]])
@@ -34,23 +33,31 @@
(def: top +9,223,372,036,854,775,807)
(def: bottom -9,223,372,036,854,775,808))
-(structure: #export number (Number Int)
- (def: + i/+)
- (def: - i/-)
- (def: * i/*)
- (def: / i//)
- (def: % i/%)
- (def: negate (i/* -1))
- (def: (abs x)
- (if (i/< +0 x)
- (i/* -1 x)
- x))
- (def: (signum x)
- (cond (i/= +0 x) +0
- (i/< +0 x) -1
- ## else
- +1))
- )
+(def: #export + (-> Int Int Int) i/+)
+
+(def: #export - (-> Int Int Int) i/-)
+
+(def: #export * (-> Int Int Int) i/*)
+
+(def: #export / (-> Int Int Int) i//)
+
+(def: #export % (-> Int Int Int) i/%)
+
+(def: #export negate (-> Int Int) (i/* -1))
+
+(def: #export (abs x)
+ (-> Int Int)
+ (if (i/< +0 x)
+ (i/* -1 x)
+ x))
+
+(def: #export (signum x)
+ (-> Int Int)
+ (cond (i/= +0 x) +0
+ (i/< +0 x) -1
+ ## else
+ +1))
+
(template [<name> <compose> <identity>]
[(structure: #export <name> (Monoid Int)
@@ -63,13 +70,13 @@
[minimum i/min (:: ..interval top)]
)
-(def: (int;sign!! value)
+(def: (sign!! value)
(-> Int Text)
(if (i/< +0 value)
"-"
"+"))
-(def: (int;sign?? representation)
+(def: (sign?? representation)
(-> Text (Maybe Int))
(case ("lux text char" 0 representation)
(^ (char "-"))
@@ -100,12 +107,12 @@
(def: (encode value)
(if (i/= +0 value)
"+0"
- (loop [input (|> value (i// <base>) (:: ..number abs))
- output (|> value (i/% <base>) (:: ..number abs) .nat
+ (loop [input (|> value (i// <base>) ..abs)
+ output (|> value (i/% <base>) ..abs .nat
<to-character>
maybe.assume)]
(if (i/= +0 input)
- ("lux text concat" (int;sign!! value) output)
+ ("lux text concat" (sign!! value) output)
(let [digit (maybe.assume (<to-character> (.nat (i/% <base> input))))]
(recur (i// <base> input)
("lux text concat" digit output)))))))
@@ -113,7 +120,7 @@
(def: (decode repr)
(let [input-size ("lux text size" repr)]
(if (n/> 1 input-size)
- (case (int;sign?? repr)
+ (case (sign?? repr)
(#.Some sign)
(int-decode-loop input-size repr sign <base> <to-value> <error>)
diff --git a/stdlib/source/lux/data/number/nat.lux b/stdlib/source/lux/data/number/nat.lux
index 0a5b94f0a..a7c804f65 100644
--- a/stdlib/source/lux/data/number/nat.lux
+++ b/stdlib/source/lux/data/number/nat.lux
@@ -2,7 +2,6 @@
[lux #*
[abstract
[hash (#+ Hash)]
- [number (#+ Number)]
[enum (#+ Enum)]
[interval (#+ Interval)]
[monoid (#+ Monoid)]
@@ -33,26 +32,23 @@
(def: top (.nat -1))
(def: bottom 0))
-(structure: #export number (Number Nat)
- (def: + n/+)
- (def: - n/-)
- (def: * n/*)
- (def: / n//)
- (def: % n/%)
- (def: (negate value) (n/- value 0))
- (def: abs function.identity)
- (def: (signum x)
- (case x
- 0 0
- _ 1)))
+(def: #export + (-> Nat Nat Nat) n/+)
+
+(def: #export - (-> Nat Nat Nat) n/-)
+
+(def: #export * (-> Nat Nat Nat) n/*)
+
+(def: #export / (-> Nat Nat Nat) n//)
+
+(def: #export % (-> Nat Nat Nat) n/%)
(template [<name> <compose> <identity>]
[(structure: #export <name> (Monoid Nat)
(def: identity <identity>)
(def: compose <compose>))]
- [addition n/+ 0]
- [multiplication n/* 1]
+ [addition ..+ 0]
+ [multiplication ..* 1]
[minimum n/min (:: ..interval top)]
[maximum n/max (:: ..interval bottom)]
)
@@ -174,9 +170,9 @@
(def: (encode value)
(loop [input value
output ""]
- (let [digit (maybe.assume (<to-character> (n/% <base> input)))
+ (let [digit (maybe.assume (<to-character> (..% <base> input)))
output' ("lux text concat" digit output)]
- (case (n// <base> input)
+ (case (../ <base> input)
0
output'
@@ -195,7 +191,7 @@
(#.Some digit-value)
(recur (inc idx)
- (|> output (n/* <base>) (n/+ digit-value))))
+ (|> output (..* <base>) (..+ digit-value))))
(#try.Success output)))
(#try.Failure ("lux text concat" <error> repr))))))]
diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux
index 5709b5724..09d81d20d 100644
--- a/stdlib/source/lux/data/number/ratio.lux
+++ b/stdlib/source/lux/data/number/ratio.lux
@@ -1,10 +1,10 @@
-(.module: {#.doc "Rational numbers."}
+(.module:
+ {#.doc "Rational numbers."}
[lux #*
[abstract
[equivalence (#+ Equivalence)]
[order (#+ Order)]
[monoid (#+ Monoid)]
- [number (#+ Number)]
[codec (#+ Codec)]
[monad (#+ do)]]
[control
@@ -55,51 +55,45 @@
(n/< parameter' subject')))
)
-(def: (- parameter subject)
+(def: #export (+ parameter subject)
+ (-> Ratio Ratio Ratio)
(let [[parameter' subject'] (..equalize parameter subject)]
- (normalize [(n/- parameter' subject')
+ (normalize [(n/+ parameter' subject')
(n/* (get@ #denominator parameter)
(get@ #denominator subject))])))
-(structure: #export number
- (Number Ratio)
-
- (def: (+ parameter subject)
- (let [[parameter' subject'] (..equalize parameter subject)]
- (normalize [(n/+ parameter' subject')
- (n/* (get@ #denominator parameter)
- (get@ #denominator subject))])))
-
- (def: - ..-)
-
- (def: (* parameter subject)
- (normalize [(n/* (get@ #numerator parameter)
- (get@ #numerator subject))
+(def: #export (- parameter subject)
+ (-> Ratio Ratio Ratio)
+ (let [[parameter' subject'] (..equalize parameter subject)]
+ (normalize [(n/- parameter' subject')
(n/* (get@ #denominator parameter)
- (get@ #denominator subject))]))
+ (get@ #denominator subject))])))
- (def: (/ parameter subject)
- (let [[parameter' subject'] (..equalize parameter subject)]
- (normalize [subject' parameter'])))
+(def: #export (* parameter subject)
+ (-> Ratio Ratio Ratio)
+ (normalize [(n/* (get@ #numerator parameter)
+ (get@ #numerator subject))
+ (n/* (get@ #denominator parameter)
+ (get@ #denominator subject))]))
- (def: (% parameter subject)
- (let [[parameter' subject'] (..equalize parameter subject)
- quot (n// parameter' subject')]
- (..- (update@ #numerator (n/* quot) parameter)
- subject)))
+(def: #export (/ parameter subject)
+ (-> Ratio Ratio Ratio)
+ (let [[parameter' subject'] (..equalize parameter subject)]
+ (normalize [subject' parameter'])))
- (def: (negate (^slots [#numerator #denominator]))
- {#numerator denominator
- #denominator numerator})
-
- (def: abs function.identity)
-
- (def: (signum x)
- {#numerator 1
- #denominator 1})
- )
+(def: #export (% parameter subject)
+ (-> Ratio Ratio Ratio)
+ (let [[parameter' subject'] (..equalize parameter subject)
+ quot (n// parameter' subject')]
+ (..- (update@ #numerator (n/* quot) parameter)
+ subject)))
+
+(def: #export (reciprocal (^slots [#numerator #denominator]))
+ (-> Ratio Ratio)
+ {#numerator denominator
+ #denominator numerator})
-(def: separator Text ":")
+(def: separator ":")
(structure: #export codec (Codec Text Ratio)
(def: (encode (^slots [#numerator #denominator]))
@@ -131,9 +125,9 @@
(Monoid Ratio)
(def: identity (..ratio <identity>))
- (def: compose (:: ..number <compose>))
+ (def: compose <compose>)
)]
- [0 + addition]
- [1 * multiplication]
+ [0 ..+ addition]
+ [1 ..* multiplication]
)
diff --git a/stdlib/source/lux/data/number/rev.lux b/stdlib/source/lux/data/number/rev.lux
index f57137c88..0633d5c0b 100644
--- a/stdlib/source/lux/data/number/rev.lux
+++ b/stdlib/source/lux/data/number/rev.lux
@@ -2,13 +2,12 @@
[lux #*
[abstract
[hash (#+ Hash)]
- [number (#+ Number)]
[enum (#+ Enum)]
[interval (#+ Interval)]
[monoid (#+ Monoid)]
[equivalence (#+ Equivalence)]
- ["." order (#+ Order)]
- [codec (#+ Codec)]]
+ [codec (#+ Codec)]
+ ["." order (#+ Order)]]
[control
["." function]
["." try (#+ Try)]]
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 8a5611d16..a82ae6bed 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -13,7 +13,7 @@
[data
[number
["." nat ("#@." decimal)]
- ["." int ("#@." decimal number)]]
+ ["." int]]
["." text ("#@." monoid)]]
[type
abstract]])
@@ -106,7 +106,7 @@
(let [signed? (negative? duration)
[days time-left] [(query day duration) (frame day duration)]
days (if signed?
- (int@abs days)
+ (int.abs days)
days)
time-left (if signed?
(..inverse time-left)
diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux
index dd8b467bf..dbf356488 100644
--- a/stdlib/source/lux/type/unit.lux
+++ b/stdlib/source/lux/type/unit.lux
@@ -11,7 +11,7 @@
["s" code (#+ Parser)]]]
[data
[number
- ["r" ratio (#+ Ratio)]]
+ ["." ratio (#+ Ratio)]]
[text
["%" format (#+ format)]]]
["." macro
@@ -95,7 +95,7 @@
(syntax: #export (scale:
{export csr.export}
{name s.local-identifier}
- {(^slots [#r.numerator #r.denominator]) ratio^}
+ {(^slots [#ratio.numerator #ratio.denominator]) ratio^}
{annotations (p.default cs.empty-annotations csr.annotations)})
(let [g!scale (code.local-identifier name)]
(wrap (list (` (type: (~+ (csw.export export)) ((~ g!scale) (~' u))
@@ -144,9 +144,8 @@
(def: #export (re-scale from to quantity)
(All [si so u] (-> (Scale si) (Scale so) (Qty (si u)) (Qty (so u))))
- (let [[numerator denominator] (:: r.number /
- (:: from ratio)
- (:: to ratio))]
+ (let [[numerator denominator] (ratio./ (:: from ratio)
+ (:: to ratio))]
(|> quantity
out
(i/* (.int numerator))
diff --git a/stdlib/source/test/lux/abstract/number.lux b/stdlib/source/test/lux/abstract/number.lux
deleted file mode 100644
index e04ad3124..000000000
--- a/stdlib/source/test/lux/abstract/number.lux
+++ /dev/null
@@ -1,46 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract/monad (#+ do)]
- [data
- [text
- ["%" format (#+ format)]]]
- [math
- ["r" random (#+ Random)]]]
- {1
- ["." / (#+ Number)
- [//
- ["." order (#+ Order)]]]})
-
-(def: #export (spec (^@ order (^open "/@.")) (^open "/@.") gen-sample)
- (All [a] (-> (Order a) (Number a) (Random a) Test))
- (do r.monad
- [#let [non-zero (r.filter (function (_ sample)
- (|> sample (/@+ sample) (/@= sample) not))
- gen-sample)]
- parameter non-zero
- subject non-zero]
- (<| (_.context (%.name (name-of /.Number)))
- ($_ _.and
- (_.test "Addition and subtraction are inverse functions."
- (|> subject (/@+ parameter) (/@- parameter) (/@= subject)))
- (_.test "Multiplication and division are inverse functions."
- (|> subject (/@* parameter) (/@/ parameter) (/@= subject)))
- (_.test "Modulus fills all the information division misses."
- (let [modulus (/@% parameter subject)
- multiple (/@- modulus subject)
- factor (/@/ parameter multiple)]
- (|> parameter (/@* factor) (/@+ modulus) (/@= subject))))
- (_.test "Negation flips the sign of a number and mimics subtraction."
- (let [unsigned? (/@= (/@signum parameter)
- (/@signum (/@negate parameter)))]
- (or unsigned?
- (/@= (/@+ (/@negate parameter) subject)
- (/@- parameter subject)))))
- (_.test "The absolute value is always positive."
- (let [unsigned? (/@= parameter
- (/@negate parameter))]
- (if unsigned?
- (/@= subject (/@abs subject))
- (order.>= order subject (/@abs subject)))))
- ))))
diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux
index 86abba0a3..ee3bdffb1 100644
--- a/stdlib/source/test/lux/data/color.lux
+++ b/stdlib/source/test/lux/data/color.lux
@@ -9,7 +9,7 @@
[data
["%" text/format (#+ format)]
[number
- ["." frac ("#@." number)]]]
+ ["." frac]]]
["." math
["r" random (#+ Random)]]]
{1
@@ -100,6 +100,6 @@
(saturation gray'ed))
(|> (luminance gray'ed)
(f/- (luminance mediocre))
- frac@abs
+ frac.abs
(f/<= error-margin)))))
))))
diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux
index 6d7689582..52e43a77e 100644
--- a/stdlib/source/test/lux/data/number/complex.lux
+++ b/stdlib/source/test/lux/data/number/complex.lux
@@ -8,11 +8,10 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." codec]]}]
[data
[number
- ["." frac ("#@." number)]]
+ ["." frac]]
[collection
["." list ("#@." functor)]]]
["." math
@@ -24,9 +23,9 @@
(def: (within? margin standard value)
(-> Frac Complex Complex Bit)
- (let [real-dist (frac@abs (f/- (get@ #/.real standard)
+ (let [real-dist (frac.abs (f/- (get@ #/.real standard)
(get@ #/.real value)))
- imgn-dist (frac@abs (f/- (get@ #/.imaginary standard)
+ imgn-dist (frac.abs (f/- (get@ #/.imaginary standard)
(get@ #/.imaginary value)))]
(and (f/< margin real-dist)
(f/< margin imgn-dist))))
@@ -70,8 +69,8 @@
(_.test "Absolute value of complex >= absolute value of any of the parts."
(let [r+i (/.complex real imaginary)
abs (get@ #/.real (/.abs r+i))]
- (and (f/>= (frac@abs real) abs)
- (f/>= (frac@abs imaginary) abs))))
+ (and (f/>= (frac.abs real) abs)
+ (f/>= (frac.abs imaginary) abs))))
(_.test "The absolute value of a complex number involving a NaN on either dimension, results in a NaN value."
(and (frac.not-a-number? (get@ #/.real (/.abs (/.complex frac.not-a-number imaginary))))
(frac.not-a-number? (get@ #/.real (/.abs (/.complex real frac.not-a-number))))))
@@ -130,7 +129,7 @@
(let [cx (/.conjugate x)]
(and (f/= (get@ #/.real x)
(get@ #/.real cx))
- (f/= (frac@negate (get@ #/.imaginary x))
+ (f/= (frac.negate (get@ #/.imaginary x))
(get@ #/.imaginary cx)))))
(_.test "The reciprocal functions is its own inverse."
(|> x /.reciprocal /.reciprocal (within? margin-of-error x)))
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
index 9edc0f921..736f82457 100644
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ b/stdlib/source/test/lux/data/number/frac.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." monoid]
["$." codec]]}]
[math
@@ -24,7 +23,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence gen-frac)
($order.spec /.order gen-frac)
- ($number.spec /.order /.number gen-frac)
(~~ (template [<monoid>]
[(<| (_.context (%.name (name-of <monoid>)))
($monoid.spec /.equivalence <monoid> gen-frac))]
diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux
index 4fa93051b..7d11f0a03 100644
--- a/stdlib/source/test/lux/data/number/int.lux
+++ b/stdlib/source/test/lux/data/number/int.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
@@ -25,7 +24,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence r.int)
($order.spec /.order r.int)
- ($number.spec /.order /.number (:: r.monad map (i/% +1,000,000) r.int))
($enum.spec /.enum r.int)
($interval.spec /.interval r.int)
(~~ (template [<monoid>]
diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux
index dda227223..9a7f5907c 100644
--- a/stdlib/source/test/lux/data/number/nat.lux
+++ b/stdlib/source/test/lux/data/number/nat.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
@@ -25,7 +24,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence r.nat)
($order.spec /.order r.nat)
- ($number.spec /.order /.number (:: r.monad map (n/% 1,000,000) r.nat))
($enum.spec /.enum r.nat)
($interval.spec /.interval r.nat)
(~~ (template [<monoid>]
diff --git a/stdlib/source/test/lux/data/number/ratio.lux b/stdlib/source/test/lux/data/number/ratio.lux
index 160a4fa53..f2162681d 100644
--- a/stdlib/source/test/lux/data/number/ratio.lux
+++ b/stdlib/source/test/lux/data/number/ratio.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." monoid]
["$." codec]]}]
[math
@@ -33,7 +32,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence ..ratio)
($order.spec /.order ..ratio)
- ($number.spec /.order /.number ..ratio)
(~~ (template [<monoid>]
[(<| (_.context (%.name (name-of <monoid>)))
($monoid.spec /.equivalence <monoid> ..ratio))]
diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux
index 37df07567..1a0bc4571 100644
--- a/stdlib/source/test/lux/data/number/rev.lux
+++ b/stdlib/source/test/lux/data/number/rev.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux
index ef46b9063..c6dcd4687 100644
--- a/stdlib/source/test/lux/macro/poly/equivalence.lux
+++ b/stdlib/source/test/lux/macro/poly/equivalence.lux
@@ -1,16 +1,17 @@
(.module:
[lux #*
["%" data/text/format (#+ format)]
- ["r" math/random (#+ Random)]
["_" test (#+ Test)]
- [abstract/monad (#+ do)]
+ [math
+ ["." random (#+ Random)]]
[abstract
+ [monad (#+ do)]
[equivalence (#+ Equivalence)]]
[data
["." bit]
["." maybe]
[number
- ["." int ("#@." number)]]
+ ["." int]]
["." text]
[collection
["." list]]]
@@ -40,25 +41,25 @@
#recursive Recursive})
(def: gen-recursive
- (r.Random Recursive)
- (r.rec (function (_ gen-recursive)
- (r.or r.frac
- (r.and r.frac gen-recursive)))))
+ (Random Recursive)
+ (random.rec (function (_ gen-recursive)
+ (random.or random.frac
+ (random.and random.frac gen-recursive)))))
(def: gen-record
- (r.Random Record)
- (do r.monad
- [size (:: @ map (n/% 2) r.nat)
- #let [gen-int (|> r.int (:: @ map (|>> int@abs (i/% +1,000,000))))]]
- ($_ r.and
- r.bit
+ (Random Record)
+ (do random.monad
+ [size (:: @ map (n/% 2) random.nat)
+ #let [gen-int (|> random.int (:: @ map (|>> int.abs (i/% +1,000,000))))]]
+ ($_ random.and
+ random.bit
gen-int
- r.frac
- (r.unicode size)
- (r.maybe gen-int)
- (r.list size gen-int)
- ($_ r.or r.bit gen-int r.frac)
- ($_ r.and gen-int r.frac (r.unicode size))
+ random.frac
+ (random.unicode size)
+ (random.maybe gen-int)
+ (random.list size gen-int)
+ ($_ random.or random.bit gen-int random.frac)
+ ($_ random.and gen-int random.frac (random.unicode size))
gen-recursive)))
(derived: equivalence (/.equivalence Record))
@@ -66,7 +67,7 @@
(def: #export test
Test
(<| (_.context (%.name (name-of /._)))
- (do r.monad
+ (do random.monad
[sample gen-record
#let [(^open "/@.") ..equivalence]]
(_.test "Every instance equals itself."
diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux
index 88dc6d420..46b5171ee 100644
--- a/stdlib/source/test/lux/math.lux
+++ b/stdlib/source/test/lux/math.lux
@@ -7,7 +7,7 @@
[data
["." bit ("#@." equivalence)]
[number
- ["." frac ("#@." number)]]]]
+ ["." frac]]]]
{1
["." /]}
["." / #_
@@ -20,7 +20,7 @@
(def: (within? margin-of-error standard value)
(-> Frac Frac Frac Bit)
(f/< margin-of-error
- (frac@abs (f/- standard value))))
+ (frac.abs (f/- standard value))))
(def: margin Frac +0.0000001)
@@ -61,7 +61,7 @@
(_.test "The round will be an integer value, and will be < or > or = the original."
(let [round'd (/.round sample)]
(and (|> round'd frac-to-int int-to-frac (f/= round'd))
- (f/<= +1.0 (frac@abs (f/- sample round'd))))))
+ (f/<= +1.0 (frac.abs (f/- sample round'd))))))
)))
(<| (_.context "Exponentials and logarithms")
(do r.monad
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 808a09e0e..2659183af 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -71,7 +71,7 @@
[file-size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
dataL (_binary.binary file-size)
dataR (_binary.binary file-size)
- new-modified (|> r.int (:: @ map (|>> (:: int.number abs)
+ new-modified (|> r.int (:: @ map (|>> int.abs
truncate-millis
duration.from-millis
instant.absolute)))]