aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/math/number
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/math/number.lux2
-rw-r--r--stdlib/source/library/lux/math/number/complex.lux70
-rw-r--r--stdlib/source/library/lux/math/number/frac.lux62
-rw-r--r--stdlib/source/library/lux/math/number/i16.lux10
-rw-r--r--stdlib/source/library/lux/math/number/i32.lux10
-rw-r--r--stdlib/source/library/lux/math/number/i64.lux48
-rw-r--r--stdlib/source/library/lux/math/number/i8.lux10
-rw-r--r--stdlib/source/library/lux/math/number/int.lux56
-rw-r--r--stdlib/source/library/lux/math/number/nat.lux48
-rw-r--r--stdlib/source/library/lux/math/number/ratio.lux36
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux46
11 files changed, 199 insertions, 199 deletions
diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux
index 288afd703..d1e8144ab 100644
--- a/stdlib/source/library/lux/math/number.lux
+++ b/stdlib/source/library/lux/math/number.lux
@@ -46,7 +46,7 @@
(text.replace_all ..separator ""))
(template [<macro> <nat> <int> <rev> <frac> <error> <doc>]
- [(macro: #export (<macro> tokens state)
+ [(macro: .public (<macro> tokens state)
{#.doc <doc>}
(case tokens
(#.Item [meta (#.Text repr')] #.End)
diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux
index de73592f0..63df9b5ae 100644
--- a/stdlib/source/library/lux/math/number/complex.lux
+++ b/stdlib/source/library/lux/math/number/complex.lux
@@ -23,12 +23,12 @@
["f" frac]
["." int]]]]])
-(type: #export Complex
+(type: .public Complex
{#.doc (doc "A complex number.")}
{#real Frac
#imaginary Frac})
-(syntax: #export (complex real {?imaginary (<>.maybe <code>.any)})
+(syntax: .public (complex real {?imaginary (<>.maybe <code>.any)})
{#.doc (doc "Complex literals."
(complex real imaginary)
"The imaginary part can be omitted if it's +0.0."
@@ -36,23 +36,23 @@
(in (list (` {#..real (~ real)
#..imaginary (~ (maybe.else (' +0.0) ?imaginary))}))))
-(def: #export i
+(def: .public i
(..complex +0.0 +1.0))
-(def: #export +one
+(def: .public +one
(..complex +1.0 +0.0))
-(def: #export -one
+(def: .public -one
(..complex -1.0 +0.0))
-(def: #export zero
+(def: .public zero
(..complex +0.0 +0.0))
-(def: #export (not_a_number? complex)
+(def: .public (not_a_number? complex)
(or (f.not_a_number? (get@ #real complex))
(f.not_a_number? (get@ #imaginary complex))))
-(def: #export (= param input)
+(def: .public (= param input)
(-> Complex Complex Bit)
(and (f.= (get@ #real param)
(get@ #real input))
@@ -60,7 +60,7 @@
(get@ #imaginary input))))
(template [<name> <op>]
- [(def: #export (<name> param input)
+ [(def: .public (<name> param input)
(-> Complex Complex Complex)
{#real (<op> (get@ #real param)
(get@ #real input))
@@ -71,13 +71,13 @@
[- f.-]
)
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Complex)
(def: = ..=))
(template [<name> <transform>]
- [(def: #export <name>
+ [(def: .public <name>
(-> Complex Complex)
(|>> (update@ #real <transform>)
(update@ #imaginary <transform>)))]
@@ -86,18 +86,18 @@
[signum f.signum]
)
-(def: #export conjugate
+(def: .public conjugate
(-> Complex Complex)
(update@ #imaginary f.opposite))
-(def: #export (*' param input)
+(def: .public (*' param input)
(-> Frac Complex Complex)
{#real (f.* param
(get@ #real input))
#imaginary (f.* param
(get@ #imaginary input))})
-(def: #export (* param input)
+(def: .public (* param input)
(-> Complex Complex Complex)
{#real (f.- (f.* (get@ #imaginary param)
(get@ #imaginary input))
@@ -108,7 +108,7 @@
(f.* (get@ #imaginary param)
(get@ #real input)))})
-(def: #export (/ param input)
+(def: .public (/ param input)
(-> Complex Complex Complex)
(let [(^slots [#real #imaginary]) param]
(if (f.< (f.abs imaginary)
@@ -122,13 +122,13 @@
{#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom))
#imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))}))))
-(def: #export (/' param subject)
+(def: .public (/' param subject)
(-> Frac Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (f./ param real)
#imaginary (f./ param imaginary)}))
-(def: #export (% param input)
+(def: .public (% param input)
(-> Complex Complex Complex)
(let [scaled (/ param input)
quotient (|> scaled
@@ -137,7 +137,7 @@
(- (* quotient param)
input)))
-(def: #export (cos subject)
+(def: .public (cos subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (f.* (math.cosh imaginary)
@@ -145,7 +145,7 @@
#imaginary (f.opposite (f.* (math.sinh imaginary)
(math.sin real)))}))
-(def: #export (cosh subject)
+(def: .public (cosh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (f.* (math.cos imaginary)
@@ -153,7 +153,7 @@
#imaginary (f.* (math.sin imaginary)
(math.sinh real))}))
-(def: #export (sin subject)
+(def: .public (sin subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (f.* (math.cosh imaginary)
@@ -161,7 +161,7 @@
#imaginary (f.* (math.sinh imaginary)
(math.cos real))}))
-(def: #export (sinh subject)
+(def: .public (sinh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (f.* (math.cos imaginary)
@@ -169,7 +169,7 @@
#imaginary (f.* (math.sin imaginary)
(math.cosh real))}))
-(def: #export (tan subject)
+(def: .public (tan subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r2 (f.* +2.0 real)
@@ -178,7 +178,7 @@
{#real (f./ d (math.sin r2))
#imaginary (f./ d (math.sinh i2))}))
-(def: #export (tanh subject)
+(def: .public (tanh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r2 (f.* +2.0 real)
@@ -187,7 +187,7 @@
{#real (f./ d (math.sinh r2))
#imaginary (f./ d (math.sin i2))}))
-(def: #export (abs subject)
+(def: .public (abs subject)
(-> Complex Frac)
(let [(^slots [#real #imaginary]) subject]
(if (f.< (f.abs imaginary)
@@ -203,21 +203,21 @@
(f.* (math.pow +0.5 (f.+ +1.0 (f.* q q)))
(f.abs real)))))))
-(def: #export (exp subject)
+(def: .public (exp subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r_exp (math.exp real)]
{#real (f.* r_exp (math.cos imaginary))
#imaginary (f.* r_exp (math.sin imaginary))}))
-(def: #export (log subject)
+(def: .public (log subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
{#real (|> subject ..abs math.log)
#imaginary (math.atan/2 real imaginary)}))
(template [<name> <type> <op>]
- [(def: #export (<name> param input)
+ [(def: .public (<name> param input)
(-> <type> Complex Complex)
(|> input log (<op> param) exp))]
@@ -229,7 +229,7 @@
(-> Frac Frac Frac)
(f.* (f.signum sign) magnitude))
-(def: #export (root/2 input)
+(def: .public (root/2 input)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) input
t (|> input ..abs (f.+ (f.abs real)) (f./ +2.0) (math.pow +0.5))]
@@ -245,7 +245,7 @@
(-> Complex Complex)
(|> (complex +1.0) (- (* input input)) ..root/2))
-(def: #export (reciprocal (^slots [#real #imaginary]))
+(def: .public (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
(if (f.< (f.abs imaginary)
(f.abs real))
@@ -260,14 +260,14 @@
{#real scale
#imaginary (|> scale f.opposite (f.* q))})))
-(def: #export (acos input)
+(def: .public (acos input)
(-> Complex Complex)
(|> input
(..+ (|> input ..root/2-1z (..* ..i)))
..log
(..* (..opposite ..i))))
-(def: #export (asin input)
+(def: .public (asin input)
(-> Complex Complex)
(|> input
..root/2-1z
@@ -275,7 +275,7 @@
..log
(..* (..opposite ..i))))
-(def: #export (atan input)
+(def: .public (atan input)
(-> Complex Complex)
(|> input
(..+ ..i)
@@ -283,11 +283,11 @@
..log
(..* (../ (..complex +2.0) ..i))))
-(def: #export (argument (^slots [#real #imaginary]))
+(def: .public (argument (^slots [#real #imaginary]))
(-> Complex Frac)
(math.atan/2 real imaginary))
-(def: #export (roots nth input)
+(def: .public (roots nth input)
(-> Nat Complex (List Complex))
(if (n.= 0 nth)
(list)
@@ -307,7 +307,7 @@
{#real real
#imaginary imaginary})))))))
-(def: #export (approximately? margin_of_error standard value)
+(def: .public (approximately? margin_of_error standard value)
(-> Frac Complex Complex Bit)
(and (f.approximately? margin_of_error
(get@ #..real standard)
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index c602db1c5..729d9b5b7 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -22,35 +22,35 @@
["#." rev]
["/#" //]])
-(def: #export (= reference sample)
+(def: .public (= reference sample)
{#.doc "Frac(tion) equivalence."}
(-> Frac Frac Bit)
("lux f64 =" reference sample))
-(def: #export (< reference sample)
+(def: .public (< reference sample)
{#.doc "Frac(tion) less-than."}
(-> Frac Frac Bit)
("lux f64 <" reference sample))
-(def: #export (<= reference sample)
+(def: .public (<= reference sample)
{#.doc "Frac(tion) less-than or equal."}
(-> Frac Frac Bit)
(or ("lux f64 <" reference sample)
("lux f64 =" reference sample)))
-(def: #export (> reference sample)
+(def: .public (> reference sample)
{#.doc "Frac(tion) greater-than."}
(-> Frac Frac Bit)
("lux f64 <" sample reference))
-(def: #export (>= reference sample)
+(def: .public (>= reference sample)
{#.doc "Frac(tion) greater-than or equal."}
(-> Frac Frac Bit)
(or ("lux f64 <" sample reference)
("lux f64 =" sample reference)))
(template [<comparison> <name>]
- [(def: #export <name>
+ [(def: .public <name>
(Predicate Frac)
(<comparison> +0.0))]
@@ -60,7 +60,7 @@
)
(template [<name> <op> <doc>]
- [(def: #export (<name> param subject)
+ [(def: .public (<name> param subject)
{#.doc <doc>}
(-> Frac Frac Frac)
(<op> param subject))]
@@ -72,22 +72,22 @@
[% "lux f64 %" "Frac(tion) remainder."]
)
-(def: #export (/% param subject)
+(def: .public (/% param subject)
(-> Frac Frac [Frac Frac])
[(../ param subject)
(..% param subject)])
-(def: #export opposite
+(def: .public opposite
(-> Frac Frac)
(..* -1.0))
-(def: #export (abs x)
+(def: .public (abs x)
(-> Frac Frac)
(if (..< +0.0 x)
(..* -1.0 x)
x))
-(def: #export (signum x)
+(def: .public (signum x)
(-> Frac Frac)
(cond (..= +0.0 x) +0.0
(..< +0.0 x) -1.0
@@ -98,7 +98,7 @@
(def: max_exponent (//int.frac +1023))
(template [<name> <test> <doc>]
- [(def: #export (<name> left right)
+ [(def: .public (<name> left right)
{#.doc <doc>}
(-> Frac Frac Frac)
(if (<test> right left)
@@ -109,11 +109,11 @@
[max ..> "Frac(tion) minimum."]
)
-(def: #export nat
+(def: .public nat
(-> Frac Nat)
(|>> "lux f64 i64" .nat))
-(def: #export int
+(def: .public int
(-> Frac Int)
(|>> "lux f64 i64"))
@@ -125,7 +125,7 @@
("lux i64 right-shift" ..exponent_size)
"lux i64 f64"))
-(def: #export rev
+(def: .public rev
(-> Frac Rev)
(|>> ..abs
(..% +1.0)
@@ -133,23 +133,23 @@
"lux f64 i64"
("lux i64 left-shift" ..exponent_size)))
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Frac)
(def: = ..=))
-(implementation: #export order
+(implementation: .public order
(Order Frac)
(def: &equivalence ..equivalence)
(def: < ..<))
-(def: #export smallest
+(def: .public smallest
Frac
(///.pow (//int.frac (//int.- (.int ..mantissa_size) ..min_exponent))
+2.0))
-(def: #export biggest
+(def: .public biggest
Frac
(let [f2^-52 (///.pow (//nat.frac (//nat.- ..mantissa_size 0)) +2.0)
f2^+1023 (///.pow ..max_exponent +2.0)]
@@ -158,7 +158,7 @@
(..* f2^+1023))))
(template [<name> <compose> <identity>]
- [(implementation: #export <name>
+ [(implementation: .public <name>
(Monoid Frac)
(def: identity <identity>)
@@ -171,7 +171,7 @@
)
(template [<name> <numerator> <doc>]
- [(def: #export <name>
+ [(def: .public <name>
{#.doc <doc>}
Frac
(../ +0.0 <numerator>))]
@@ -180,23 +180,23 @@
[positive_infinity +1.0 "Positive infinity."]
)
-(def: #export negative_infinity
+(def: .public negative_infinity
{#.doc "Negative infinity."}
Frac
(..* -1.0 ..positive_infinity))
-(def: #export (not_a_number? number)
+(def: .public (not_a_number? number)
{#.doc "Tests whether a frac is actually not-a-number."}
(-> Frac Bit)
(not (..= number number)))
-(def: #export (number? value)
+(def: .public (number? value)
(-> Frac Bit)
(not (or (..not_a_number? value)
(..= ..positive_infinity value)
(..= ..negative_infinity value))))
-(implementation: #export decimal
+(implementation: .public decimal
(Codec Text Frac)
(def: (encode x)
@@ -247,7 +247,7 @@
(def: smallest_exponent
(..log/2 ..smallest))
-(def: #export (bits input)
+(def: .public (bits input)
(-> Frac I64)
(.i64 (cond (..not_a_number? input)
..not_a_number_bits
@@ -310,7 +310,7 @@
[sign 1 ..sign_offset]
)
-(def: #export (of_bits input)
+(def: .public (of_bits input)
(-> I64 Frac)
(case [(: Nat (..exponent input))
(: Nat (..mantissa input))
@@ -374,7 +374,7 @@
(#try.Success [representation +0])))
(template [<struct> <nat> <int> <error>]
- [(implementation: #export <struct>
+ [(implementation: .public <struct>
(Codec Text Frac)
(def: (encode value)
@@ -427,20 +427,20 @@
[hex //nat.hex //int.hex "Invalid hexadecimal syntax: "]
)
-(implementation: #export hash
+(implementation: .public hash
(Hash Frac)
(def: &equivalence ..equivalence)
(def: hash ..bits))
-(def: #export (approximately? margin_of_error standard value)
+(def: .public (approximately? margin_of_error standard value)
(-> Frac Frac Frac Bit)
(|> value
(..- standard)
..abs
(..< margin_of_error)))
-(def: #export (mod divisor dividend)
+(def: .public (mod divisor dividend)
(All [m] (-> Frac Frac Frac))
(let [remainder (..% divisor dividend)]
(if (or (and (..< +0.0 divisor)
diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux
index 569e228fd..0f273497c 100644
--- a/stdlib/source/library/lux/math/number/i16.lux
+++ b/stdlib/source/library/lux/math/number/i16.lux
@@ -12,7 +12,7 @@
(def: sub
(maybe.assume (i64.sub 16)))
-(def: #export I16
+(def: .public I16
{#.doc (doc "A 16-bit integer.")}
(:by_example [size]
(Sub size)
@@ -20,7 +20,7 @@
(I64 size)))
-(def: #export equivalence (Equivalence I16) (\ ..sub &equivalence))
-(def: #export width Nat (\ ..sub width))
-(def: #export i16 (-> I64 I16) (\ ..sub narrow))
-(def: #export i64 (-> I16 I64) (\ ..sub widen))
+(def: .public equivalence (Equivalence I16) (\ ..sub &equivalence))
+(def: .public width Nat (\ ..sub width))
+(def: .public i16 (-> I64 I16) (\ ..sub narrow))
+(def: .public i64 (-> I16 I64) (\ ..sub widen))
diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux
index 33374d19a..61fe87f40 100644
--- a/stdlib/source/library/lux/math/number/i32.lux
+++ b/stdlib/source/library/lux/math/number/i32.lux
@@ -12,7 +12,7 @@
(def: sub
(maybe.assume (i64.sub 32)))
-(def: #export I32
+(def: .public I32
{#.doc (doc "A 32-bit integer.")}
(:by_example [size]
(Sub size)
@@ -20,7 +20,7 @@
(I64 size)))
-(def: #export equivalence (Equivalence I32) (\ ..sub &equivalence))
-(def: #export width Nat (\ ..sub width))
-(def: #export i32 (-> I64 I32) (\ ..sub narrow))
-(def: #export i64 (-> I32 I64) (\ ..sub widen))
+(def: .public equivalence (Equivalence I32) (\ ..sub &equivalence))
+(def: .public width Nat (\ ..sub width))
+(def: .public i32 (-> I64 I32) (\ ..sub narrow))
+(def: .public i64 (-> I32 I64) (\ ..sub widen))
diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux
index 02dc98748..c6b8a69d8 100644
--- a/stdlib/source/library/lux/math/number/i64.lux
+++ b/stdlib/source/library/lux/math/number/i64.lux
@@ -10,19 +10,19 @@
[//
["n" nat]])
-(def: #export bits_per_byte
+(def: .public bits_per_byte
8)
-(def: #export bytes_per_i64
+(def: .public bytes_per_i64
8)
-(def: #export width
+(def: .public width
Nat
(n.* ..bits_per_byte
..bytes_per_i64))
(template [<parameter_type> <name> <op> <doc>]
- [(def: #export (<name> parameter subject)
+ [(def: .public (<name> parameter subject)
{#.doc <doc>}
(All [s] (-> <parameter_type> (I64 s) (I64 s)))
(<op> parameter subject))]
@@ -36,34 +36,34 @@
)
## https://en.wikipedia.org/wiki/Mask_(computing)
-(type: #export Mask
+(type: .public Mask
{#.doc (doc "A pattern of bits that can be imposed on I64 values.")}
I64)
-(def: #export (bit position)
+(def: .public (bit position)
{#.doc (doc "A mask with only a specific bit set.")}
(-> Nat Mask)
(|> 1 .i64 (..left_shifted (n.% ..width position))))
-(def: #export sign
+(def: .public sign
{#.doc (doc "A mask for the sign bit of ints.")}
Mask
(..bit (dec ..width)))
-(def: #export not
+(def: .public not
{#.doc "Bitwise negation."}
(All [s] (-> (I64 s) (I64 s)))
(..xor (.i64 (dec 0))))
-(def: #export false
+(def: .public false
Mask
(.i64 0))
-(def: #export true
+(def: .public true
Mask
(..not ..false))
-(def: #export (mask amount_of_bits)
+(def: .public (mask amount_of_bits)
{#.doc (doc "Mask a block of bits of the specified size.")}
(-> Nat Mask)
(case amount_of_bits
@@ -76,7 +76,7 @@
(-> Nat Nat Nat)
(|> value (right_shifted shift) (n.+ value)))
-(def: #export (count subject)
+(def: .public (count subject)
{#.doc "Count the number of 1s in a bit-map."}
(-> (I64 Any) Nat)
(let [count' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64)
@@ -89,13 +89,13 @@
(add_shift 32)
(..and 127))))
-(def: #export (clear index input)
+(def: .public (clear index input)
{#.doc "Clear bit at the given index."}
(All [s] (-> Nat (I64 s) (I64 s)))
(|> index ..bit ..not (..and input)))
(template [<name> <op> <doc>]
- [(def: #export (<name> index input)
+ [(def: .public (<name> index input)
{#.doc <doc>}
(All [s] (-> Nat (I64 s) (I64 s)))
(|> index ..bit (<op> input)))]
@@ -104,16 +104,16 @@
[flip ..xor "Flip bit at given index."]
)
-(def: #export (set? index input)
+(def: .public (set? index input)
(-> Nat (I64 Any) Bit)
(|> input (:as I64) (..and (..bit index)) (n.= 0) .not))
-(def: #export (clear? index input)
+(def: .public (clear? index input)
(-> Nat (I64 Any) Bit)
(.not (..set? index input)))
(template [<name> <forward> <backward>]
- [(def: #export (<name> distance input)
+ [(def: .public (<name> distance input)
(All [s] (-> Nat (I64 s) (I64 s)))
(..or (<forward> distance input)
(<backward> (n.- (n.% ..width distance) ..width) input)))]
@@ -122,18 +122,18 @@
[right_rotated ..right_shifted ..left_shifted]
)
-(def: #export (region offset size)
+(def: .public (region offset size)
{#.doc (doc "A mask for a block of bits of the given size, starting at the given offset.")}
(-> Nat Nat Mask)
(..left_rotated offset (..mask size)))
-(implementation: #export equivalence
+(implementation: .public equivalence
(All [a] (Equivalence (I64 a)))
(def: (= reference sample)
("lux i64 =" reference sample)))
-(implementation: #export hash
+(implementation: .public hash
(All [a] (Hash (I64 a)))
(def: &equivalence ..equivalence)
@@ -141,7 +141,7 @@
(def: hash .nat))
(template [<monoid> <identity> <compose>]
- [(implementation: #export <monoid>
+ [(implementation: .public <monoid>
(All [a] (Monoid (I64 a)))
(def: identity <identity>)
@@ -151,7 +151,7 @@
[conjunction ..true ..and]
)
-(def: #export reversed
+(def: .public reversed
(All [a] (-> (I64 a) (I64 a)))
(let [swapper (: (-> Nat (All [a] (-> (I64 a) (I64 a))))
(function (_ power)
@@ -188,7 +188,7 @@
swap/02
swap/01)))
-(interface: #export (Sub size)
+(interface: .public (Sub size)
{#.doc (doc "A sub-space of I64 with a reduce amount of bits.")}
(: (Equivalence (I64 size))
@@ -200,7 +200,7 @@
(: (-> (I64 size) I64)
widen))
-(def: #export (sub width)
+(def: .public (sub width)
{#.doc (doc "Given a width in the interval (0,64), yields an implementation for integers of that width.")}
(Ex [size] (-> Nat (Maybe (Sub size))))
(if (.and (n.> 0 width)
diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux
index 1f02b508b..1c3bccea6 100644
--- a/stdlib/source/library/lux/math/number/i8.lux
+++ b/stdlib/source/library/lux/math/number/i8.lux
@@ -12,7 +12,7 @@
(def: sub
(maybe.assume (i64.sub 8)))
-(def: #export I8
+(def: .public I8
{#.doc (doc "An 8-bit integer.")}
(:by_example [size]
(Sub size)
@@ -20,7 +20,7 @@
(I64 size)))
-(def: #export equivalence (Equivalence I8) (\ ..sub &equivalence))
-(def: #export width Nat (\ ..sub width))
-(def: #export i8 (-> I64 I8) (\ ..sub narrow))
-(def: #export i64 (-> I8 I64) (\ ..sub widen))
+(def: .public equivalence (Equivalence I8) (\ ..sub &equivalence))
+(def: .public width Nat (\ ..sub width))
+(def: .public i8 (-> I64 I8) (\ ..sub narrow))
+(def: .public i64 (-> I8 I64) (\ ..sub widen))
diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux
index 610ad296e..dbef9c89c 100644
--- a/stdlib/source/library/lux/math/number/int.lux
+++ b/stdlib/source/library/lux/math/number/int.lux
@@ -19,29 +19,29 @@
["#." nat]
["#." i64]])
-(def: #export (= reference sample)
+(def: .public (= reference sample)
{#.doc "Int(eger) equivalence."}
(-> Int Int Bit)
("lux i64 =" reference sample))
-(def: #export (< reference sample)
+(def: .public (< reference sample)
{#.doc "Int(eger) less-than."}
(-> Int Int Bit)
("lux i64 <" reference sample))
-(def: #export (<= reference sample)
+(def: .public (<= reference sample)
{#.doc "Int(eger) less-than or equal."}
(-> Int Int Bit)
(if ("lux i64 <" reference sample)
#1
("lux i64 =" reference sample)))
-(def: #export (> reference sample)
+(def: .public (> reference sample)
{#.doc "Int(eger) greater-than."}
(-> Int Int Bit)
("lux i64 <" sample reference))
-(def: #export (>= reference sample)
+(def: .public (>= reference sample)
{#.doc "Int(eger) greater-than or equal."}
(-> Int Int Bit)
(if ("lux i64 <" sample reference)
@@ -49,7 +49,7 @@
("lux i64 =" reference sample)))
(template [<comparison> <name>]
- [(def: #export <name>
+ [(def: .public <name>
(Predicate Int)
(<comparison> +0))]
@@ -59,7 +59,7 @@
)
(template [<name> <test> <doc>]
- [(def: #export (<name> left right)
+ [(def: .public (<name> left right)
{#.doc <doc>}
(-> Int Int Int)
(if (<test> right left)
@@ -71,7 +71,7 @@
)
(template [<name> <op> <doc>]
- [(def: #export (<name> param subject)
+ [(def: .public (<name> param subject)
{#.doc <doc>}
(-> Int Int Int)
(<op> param subject))]
@@ -83,25 +83,25 @@
[% "lux i64 %" "Int(eger) remainder."]
)
-(def: #export (/% param subject)
+(def: .public (/% param subject)
{#.doc "Int(eger) [division remainder]."}
(-> Int Int [Int Int])
[(../ param subject)
(..% param subject)])
-(def: #export (opposite value)
+(def: .public (opposite value)
{#.doc (doc "A value of equal magnitude and opposite sign.")}
(-> Int Int)
(..- value +0))
-(def: #export (abs x)
+(def: .public (abs x)
{#.doc (doc "A value of equal magnitude and positive sign.")}
(-> Int Int)
(if (..< +0 x)
(..* -1 x)
x))
-(def: #export (signum x)
+(def: .public (signum x)
{#.doc (doc "A value (either -1, 0 or +0) which represents the sign.")}
(-> Int Int)
(cond (..= +0 x) +0
@@ -110,7 +110,7 @@
+1))
## https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/
-(def: #export (mod divisor dividend)
+(def: .public (mod divisor dividend)
{#.doc (doc "Integer modulo."
"Note: The modulo and the remainder are not the same.")}
(All [m] (-> Int Int Int))
@@ -122,28 +122,28 @@
(..+ divisor remainder)
remainder)))
-(def: #export even?
+(def: .public even?
(-> Int Bit)
(|>> (..% +2) ("lux i64 =" +0)))
-(def: #export odd?
+(def: .public odd?
(-> Int Bit)
(|>> ..even? not))
## https://en.wikipedia.org/wiki/Greatest_common_divisor
-(def: #export (gcd a b)
+(def: .public (gcd a b)
{#.doc "Greatest Common Divisor."}
(-> Int Int Int)
(case b
+0 a
_ (gcd b (..% b a))))
-(def: #export (co_prime? a b)
+(def: .public (co_prime? a b)
(-> Int Int Bit)
(..= +1 (..gcd a b)))
## https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
-(def: #export (extended_gcd a b)
+(def: .public (extended_gcd a b)
{#.doc "Extended euclidean algorithm."}
(-> Int Int [[Int Int] Int])
(loop [x +1 x1 +0
@@ -157,7 +157,7 @@
b1 (- (* q b1) a1))))))
## https://en.wikipedia.org/wiki/Least_common_multiple
-(def: #export (lcm a b)
+(def: .public (lcm a b)
{#.doc "Least Common Multiple."}
(-> Int Int Int)
(case [a b]
@@ -167,22 +167,22 @@
_
(|> a (/ (gcd a b)) (* b))))
-(def: #export frac
+(def: .public frac
(-> Int Frac)
(|>> "lux i64 f64"))
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Int)
(def: = ..=))
-(implementation: #export order
+(implementation: .public order
(Order Int)
(def: &equivalence ..equivalence)
(def: < ..<))
-(implementation: #export enum
+(implementation: .public enum
(Enum Int)
(def: &order ..order)
@@ -190,7 +190,7 @@
(def: pred dec))
## TODO: Find out why the numeric literals fail during JS compilation.
-(implementation: #export interval
+(implementation: .public interval
(Interval Int)
(def: &enum ..enum)
@@ -204,7 +204,7 @@
(//i64.left_shifted 63 +1)))
(template [<name> <compose> <identity>]
- [(implementation: #export <name>
+ [(implementation: .public <name>
(Monoid Int)
(def: identity <identity>)
@@ -220,7 +220,7 @@
(def: +sign "+")
(template [<struct> <codec> <error>]
- [(implementation: #export <struct>
+ [(implementation: .public <struct>
(Codec Text Int)
(def: (encode value)
@@ -254,13 +254,13 @@
[hex //nat.hex "Invalid hexadecimal syntax for Int: "]
)
-(implementation: #export hash
+(implementation: .public hash
(Hash Int)
(def: &equivalence ..equivalence)
(def: hash .nat))
-(def: #export (right_shifted parameter subject)
+(def: .public (right_shifted parameter subject)
{#.doc "Signed/arithmetic bitwise right-shift."}
(-> Nat Int Int)
(//i64.or (//i64.and //i64.sign subject)
diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux
index 7599e221f..63c2302c4 100644
--- a/stdlib/source/library/lux/math/number/nat.lux
+++ b/stdlib/source/library/lux/math/number/nat.lux
@@ -16,7 +16,7 @@
["." maybe]]]])
(template [<extension> <output> <name> <documentation>]
- [(def: #export (<name> parameter subject)
+ [(def: .public (<name> parameter subject)
{#.doc <documentation>}
(-> Nat Nat <output>)
(<extension> parameter subject))]
@@ -35,7 +35,7 @@
(let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))]
(|>> ("lux i64 and" mask))))
-(def: #export (< reference sample)
+(def: .public (< reference sample)
{#.doc "Nat(ural) less-than."}
(-> Nat Nat Bit)
(let [referenceH (..high reference)
@@ -48,19 +48,19 @@
(..low sample))
#0))))
-(def: #export (<= reference sample)
+(def: .public (<= reference sample)
{#.doc "Nat(ural) less-than or equal."}
(-> Nat Nat Bit)
(if (..< reference sample)
#1
("lux i64 =" reference sample)))
-(def: #export (> reference sample)
+(def: .public (> reference sample)
{#.doc "Nat(ural) greater-than."}
(-> Nat Nat Bit)
(..< sample reference))
-(def: #export (>= reference sample)
+(def: .public (>= reference sample)
{#.doc "Nat(ural) greater-than or equal."}
(-> Nat Nat Bit)
(if (..< sample reference)
@@ -68,7 +68,7 @@
("lux i64 =" reference sample)))
(template [<name> <test> <doc>]
- [(def: #export (<name> left right)
+ [(def: .public (<name> left right)
{#.doc <doc>}
(-> Nat Nat Nat)
(if (<test> right left)
@@ -79,7 +79,7 @@
[max ..> "Nat(ural) maximum."]
)
-(def: #export (* parameter subject)
+(def: .public (* parameter subject)
{#.doc "Nat(ural) multiplication."}
(-> Nat Nat Nat)
(:as Nat
@@ -87,7 +87,7 @@
(:as Int parameter)
(:as Int subject))))
-(def: #export (/ parameter subject)
+(def: .public (/ parameter subject)
{#.doc "Nat(ural) division."}
(-> Nat Nat Nat)
(if ("lux i64 <" +0 (:as Int parameter))
@@ -106,7 +106,7 @@
quotient
("lux i64 +" 1 quotient)))))
-(def: #export (/% parameter subject)
+(def: .public (/% parameter subject)
{#.doc "Nat(ural) [division remainder]."}
(-> Nat Nat [Nat Nat])
(let [quotient (../ parameter subject)
@@ -115,7 +115,7 @@
(:as Int quotient))]
[quotient ("lux i64 -" flat subject)]))
-(def: #export (% parameter subject)
+(def: .public (% parameter subject)
{#.doc "Nat(ural) remainder."}
(-> Nat Nat Nat)
(let [flat ("lux i64 *"
@@ -123,18 +123,18 @@
(:as Int (../ parameter subject)))]
("lux i64 -" flat subject)))
-(def: #export (gcd a b)
+(def: .public (gcd a b)
{#.doc "Greatest Common Divisor."}
(-> Nat Nat Nat)
(case b
0 a
_ (gcd b (..% b a))))
-(def: #export (co_prime? a b)
+(def: .public (co_prime? a b)
(-> Nat Nat Bit)
(..= 1 (..gcd a b)))
-(def: #export (lcm a b)
+(def: .public (lcm a b)
{#.doc "Least Common Multiple."}
(-> Nat Nat Nat)
(case [a b]
@@ -144,37 +144,37 @@
_
(|> a (../ (..gcd a b)) (..* b))))
-(def: #export even?
+(def: .public even?
(-> Nat Bit)
(|>> (..% 2) ("lux i64 =" 0)))
-(def: #export odd?
+(def: .public odd?
(-> Nat Bit)
(|>> ..even? not))
-(def: #export frac
+(def: .public frac
(-> Nat Frac)
(|>> .int "lux i64 f64"))
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Nat)
(def: = ..=))
-(implementation: #export order
+(implementation: .public order
(Order Nat)
(def: &equivalence ..equivalence)
(def: < ..<))
-(implementation: #export enum
+(implementation: .public enum
(Enum Nat)
(def: &order ..order)
(def: succ inc)
(def: pred dec))
-(implementation: #export interval
+(implementation: .public interval
(Interval Nat)
(def: &enum ..enum)
@@ -182,7 +182,7 @@
(def: bottom 0))
(template [<name> <compose> <identity>]
- [(implementation: #export <name>
+ [(implementation: .public <name>
(Monoid Nat)
(def: identity <identity>)
@@ -300,7 +300,7 @@
_ #.None))
(template [<shift> <struct> <to_character> <to_value> <error>]
- [(implementation: #export <struct>
+ [(implementation: .public <struct>
(Codec Text Nat)
(def: encode
@@ -341,7 +341,7 @@
[4 hex hexadecimal_character hexadecimal_value "Invalid hexadecimal syntax for Nat: "]
)
-(implementation: #export decimal
+(implementation: .public decimal
(Codec Text Nat)
(def: (encode value)
@@ -373,7 +373,7 @@
(#try.Success output)))
<failure>)))))
-(implementation: #export hash
+(implementation: .public hash
(Hash Nat)
(def: &equivalence ..equivalence)
diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux
index a53f87dd9..a9a494208 100644
--- a/stdlib/source/library/lux/math/number/ratio.lux
+++ b/stdlib/source/library/lux/math/number/ratio.lux
@@ -23,12 +23,12 @@
[//
["n" nat ("#\." decimal)]])
-(type: #export Ratio
+(type: .public Ratio
{#.doc (doc "An unsigned ratio of numbers.")}
{#numerator Nat
#denominator Nat})
-(def: #export (nat value)
+(def: .public (nat value)
(-> Ratio (Maybe Nat))
(case (get@ #denominator value)
1 (#.Some (get@ #numerator value))
@@ -40,7 +40,7 @@
{#numerator (n./ common numerator)
#denominator (n./ common denominator)}))
-(syntax: #export (ratio numerator {?denominator (<>.maybe <code>.any)})
+(syntax: .public (ratio numerator {?denominator (<>.maybe <code>.any)})
{#.doc (doc "Rational literals."
(ratio numerator denominator)
"The denominator can be omitted if it is 1."
@@ -48,14 +48,14 @@
(in (list (` ((~! ..normal) {#..numerator (~ numerator)
#..denominator (~ (maybe.else (' 1) ?denominator))})))))
-(def: #export (= parameter subject)
+(def: .public (= parameter subject)
(-> Ratio Ratio Bit)
(and (n.= (get@ #numerator parameter)
(get@ #numerator subject))
(n.= (get@ #denominator parameter)
(get@ #denominator subject))))
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Ratio)
(def: = ..=))
@@ -67,72 +67,72 @@
(n.* (get@ #denominator parameter)
(get@ #numerator subject))])
-(def: #export (< parameter subject)
+(def: .public (< parameter subject)
(-> Ratio Ratio Bit)
(let [[parameter' subject'] (..equalized parameter subject)]
(n.< parameter' subject')))
-(def: #export (<= parameter subject)
+(def: .public (<= parameter subject)
(-> Ratio Ratio Bit)
(or (< parameter subject)
(= parameter subject)))
-(def: #export (> parameter subject)
+(def: .public (> parameter subject)
(-> Ratio Ratio Bit)
(..< subject parameter))
-(def: #export (>= parameter subject)
+(def: .public (>= parameter subject)
(-> Ratio Ratio Bit)
(or (> parameter subject)
(= parameter subject)))
-(implementation: #export order
+(implementation: .public order
(Order Ratio)
(def: &equivalence ..equivalence)
(def: < ..<))
-(def: #export (+ parameter subject)
+(def: .public (+ parameter subject)
(-> Ratio Ratio Ratio)
(let [[parameter' subject'] (..equalized parameter subject)]
(normal [(n.+ parameter' subject')
(n.* (get@ #denominator parameter)
(get@ #denominator subject))])))
-(def: #export (- parameter subject)
+(def: .public (- parameter subject)
(-> Ratio Ratio Ratio)
(let [[parameter' subject'] (..equalized parameter subject)]
(normal [(n.- parameter' subject')
(n.* (get@ #denominator parameter)
(get@ #denominator subject))])))
-(def: #export (* parameter subject)
+(def: .public (* parameter subject)
(-> Ratio Ratio Ratio)
(normal [(n.* (get@ #numerator parameter)
(get@ #numerator subject))
(n.* (get@ #denominator parameter)
(get@ #denominator subject))]))
-(def: #export (/ parameter subject)
+(def: .public (/ parameter subject)
(-> Ratio Ratio Ratio)
(let [[parameter' subject'] (..equalized parameter subject)]
(normal [subject' parameter'])))
-(def: #export (% parameter subject)
+(def: .public (% parameter subject)
(-> Ratio Ratio Ratio)
(let [[parameter' subject'] (..equalized parameter subject)
quot (n./ parameter' subject')]
(..- (update@ #numerator (n.* quot) parameter)
subject)))
-(def: #export (reciprocal (^slots [#numerator #denominator]))
+(def: .public (reciprocal (^slots [#numerator #denominator]))
(-> Ratio Ratio)
{#numerator denominator
#denominator numerator})
(def: separator ":")
-(implementation: #export codec
+(implementation: .public codec
(Codec Text Ratio)
(def: (encode (^slots [#numerator #denominator]))
@@ -151,7 +151,7 @@
(#.Left (text\compose "Invalid syntax for ratio: " input)))))
(template [<identity> <compose> <name>]
- [(implementation: #export <name>
+ [(implementation: .public <name>
(Monoid Ratio)
(def: identity (..ratio <identity>))
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 66abd7e12..dadb71641 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -21,7 +21,7 @@
["#." int]])
(template [<power> <name>]
- [(def: #export <name>
+ [(def: .public <name>
Rev
(.rev (//i64.left_shifted (//nat.- <power> //i64.width) 1)))]
@@ -39,29 +39,29 @@
[12 /4096]
)
-(def: #export (= reference sample)
+(def: .public (= reference sample)
{#.doc "Rev(olution) equivalence."}
(-> Rev Rev Bit)
("lux i64 =" reference sample))
-(def: #export (< reference sample)
+(def: .public (< reference sample)
{#.doc "Rev(olution) less-than."}
(-> Rev Rev Bit)
(//nat.< (.nat reference) (.nat sample)))
-(def: #export (<= reference sample)
+(def: .public (<= reference sample)
{#.doc "Rev(olution) less-than or equal."}
(-> Rev Rev Bit)
(if (//nat.< (.nat reference) (.nat sample))
true
("lux i64 =" reference sample)))
-(def: #export (> reference sample)
+(def: .public (> reference sample)
{#.doc "Rev(olution) greater-than."}
(-> Rev Rev Bit)
(..< sample reference))
-(def: #export (>= reference sample)
+(def: .public (>= reference sample)
{#.doc "Rev(olution) greater-than or equal."}
(-> Rev Rev Bit)
(if (..< sample reference)
@@ -69,7 +69,7 @@
("lux i64 =" reference sample)))
(template [<name> <test> <doc>]
- [(def: #export (<name> left right)
+ [(def: .public (<name> left right)
{#.doc <doc>}
(-> Rev Rev Rev)
(if (<test> right left)
@@ -81,7 +81,7 @@
)
(template [<name> <op> <doc>]
- [(def: #export (<name> param subject)
+ [(def: .public (<name> param subject)
{#.doc <doc>}
(-> Rev Rev Rev)
(<op> param subject))]
@@ -99,7 +99,7 @@
(let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))]
(|>> ("lux i64 and" mask))))
-(def: #export (* param subject)
+(def: .public (* param subject)
{#.doc "Rev(olution) multiplication."}
(-> Rev Rev Rev)
(let [subjectH (..high subject)
@@ -131,14 +131,14 @@
(//nat./ numerator ..odd_one))
(with_expansions [<least_significant_bit> 1]
- (def: #export (reciprocal numerator)
+ (def: .public (reciprocal numerator)
{#.doc "Rev(olution) reciprocal of a Nat(ural)."}
(-> Nat Rev)
(.rev (case (: Nat ("lux i64 and" <least_significant_bit> numerator))
0 (..even_reciprocal numerator)
_ (..odd_reciprocal numerator))))
- (def: #export (/ param subject)
+ (def: .public (/ param subject)
{#.doc "Rev(olution) division."}
(-> Rev Rev Rev)
(if ("lux i64 =" +0 param)
@@ -149,7 +149,7 @@
(.rev (//nat.* reciprocal (.nat subject)))))))
(template [<operator> <name> <output> <output_type> <documentation>]
- [(def: #export (<name> param subject)
+ [(def: .public (<name> param subject)
{#.doc <documentation>}
(-> Rev Rev <output_type>)
(<output> (<operator> (.nat param) (.nat subject))))]
@@ -159,7 +159,7 @@
)
(template [<operator> <name>]
- [(def: #export (<name> scale subject)
+ [(def: .public (<name> scale subject)
(-> Nat Rev Rev)
(.rev (<operator> (.nat scale) (.nat subject))))]
@@ -167,7 +167,7 @@
[//nat./ down]
)
-(def: #export (/% param subject)
+(def: .public (/% param subject)
(-> Rev Rev [Rev Rev])
[(../ param subject)
(..% param subject)])
@@ -180,35 +180,35 @@
(def: frac_denominator
(..mantissa -1))
-(def: #export frac
+(def: .public frac
(-> Rev Frac)
(|>> ..mantissa ("lux f64 /" ..frac_denominator)))
-(implementation: #export equivalence
+(implementation: .public equivalence
(Equivalence Rev)
(def: = ..=))
-(implementation: #export hash
+(implementation: .public hash
(Hash Rev)
(def: &equivalence ..equivalence)
(def: hash .nat))
-(implementation: #export order
+(implementation: .public order
(Order Rev)
(def: &equivalence ..equivalence)
(def: < ..<))
-(implementation: #export enum
+(implementation: .public enum
(Enum Rev)
(def: &order ..order)
(def: succ inc)
(def: pred dec))
-(implementation: #export interval
+(implementation: .public interval
(Interval Rev)
(def: &enum ..enum)
@@ -216,7 +216,7 @@
(def: bottom (.rev 0)))
(template [<name> <compose> <identity>]
- [(implementation: #export <name>
+ [(implementation: .public <name>
(Monoid Rev)
(def: identity (\ interval <identity>))
@@ -233,7 +233,7 @@
(template [<struct> <codec> <char_bit_size> <error>]
[(with_expansions [<error_output> (as_is (#try.Failure ("lux text concat" <error> repr)))]
- (implementation: #export <struct>
+ (implementation: .public <struct>
(Codec Text Rev)
(def: (encode value)
@@ -408,7 +408,7 @@
(digits\-!' idx (..digit idx param) output))
output)))
-(implementation: #export decimal
+(implementation: .public decimal
(Codec Text Rev)
(def: (encode input)