aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2018-07-28 14:55:30 -0400
committerEduardo Julian2018-07-28 14:55:30 -0400
commit15e71e57b688f5079fe606b2fee5e3efd2a5d5a7 (patch)
treeb59e411ebc82a4fb4fdfe66efcc2817fc83c6188 /stdlib
parentdff8878c13610ae8d1207aaabefbecc88cd3911f (diff)
Added "+" sign to positive Int.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux90
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis/structure.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux12
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux28
-rw-r--r--stdlib/source/lux/compiler/default/syntax.lux4
-rw-r--r--stdlib/source/lux/control/comonad.lux2
-rw-r--r--stdlib/source/lux/control/contract.lux6
-rw-r--r--stdlib/source/lux/control/pipe.lux60
-rw-r--r--stdlib/source/lux/data/collection/row.lux2
-rw-r--r--stdlib/source/lux/data/collection/sequence.lux2
-rw-r--r--stdlib/source/lux/data/collection/tree/rose.lux6
-rw-r--r--stdlib/source/lux/data/color.lux120
-rw-r--r--stdlib/source/lux/data/error.lux8
-rw-r--r--stdlib/source/lux/data/format/json.lux2
-rw-r--r--stdlib/source/lux/data/maybe.lux4
-rw-r--r--stdlib/source/lux/data/number.lux256
-rw-r--r--stdlib/source/lux/data/number/complex.lux46
-rw-r--r--stdlib/source/lux/data/text/regex.lux5
-rw-r--r--stdlib/source/lux/host.js.lux6
-rw-r--r--stdlib/source/lux/math.lux50
-rw-r--r--stdlib/source/lux/math/modular.lux10
-rw-r--r--stdlib/source/lux/test.lux26
-rw-r--r--stdlib/source/lux/time/date.lux54
-rw-r--r--stdlib/source/lux/time/duration.lux56
-rw-r--r--stdlib/source/lux/time/instant.lux146
-rw-r--r--stdlib/source/lux/type/unit.lux16
-rw-r--r--stdlib/test/test/lux.lux26
-rw-r--r--stdlib/test/test/lux/compiler/default/syntax.lux2
-rw-r--r--stdlib/test/test/lux/concurrency/frp.lux24
-rw-r--r--stdlib/test/test/lux/control/parser.lux68
-rw-r--r--stdlib/test/test/lux/control/pipe.lux70
-rw-r--r--stdlib/test/test/lux/control/reader.lux28
-rw-r--r--stdlib/test/test/lux/control/writer.lux24
-rw-r--r--stdlib/test/test/lux/data/collection/list.lux8
-rw-r--r--stdlib/test/test/lux/data/color.lux24
-rw-r--r--stdlib/test/test/lux/data/error.lux28
-rw-r--r--stdlib/test/test/lux/data/format/json.lux2
-rw-r--r--stdlib/test/test/lux/data/maybe.lux8
-rw-r--r--stdlib/test/test/lux/data/number.lux26
-rw-r--r--stdlib/test/test/lux/data/number/complex.lux18
-rw-r--r--stdlib/test/test/lux/data/number/i64.lux6
-rw-r--r--stdlib/test/test/lux/data/product.lux10
-rw-r--r--stdlib/test/test/lux/data/sum.lux18
-rw-r--r--stdlib/test/test/lux/data/text/format.lux6
-rw-r--r--stdlib/test/test/lux/host.js.lux8
-rw-r--r--stdlib/test/test/lux/io.lux20
-rw-r--r--stdlib/test/test/lux/macro/code.lux24
-rw-r--r--stdlib/test/test/lux/macro/poly/equivalence.lux2
-rw-r--r--stdlib/test/test/lux/macro/syntax.lux22
-rw-r--r--stdlib/test/test/lux/math.lux14
-rw-r--r--stdlib/test/test/lux/math/modular.lux10
-rw-r--r--stdlib/test/test/lux/time/duration.lux4
-rw-r--r--stdlib/test/test/lux/time/instant.lux2
-rw-r--r--stdlib/test/test/lux/world/file.lux6
55 files changed, 776 insertions, 753 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index a30c03a78..dd5a42064 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -1029,7 +1029,7 @@
(#Cons [(tag$ ["lux" "doc"])
(text$ "## Throws away any code given to it.
## Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor.
- (comment 1 2 3 4)")]
+ (comment +1 +2 +3 +4)")]
#Nil)
(return #Nil))
@@ -1338,7 +1338,7 @@
(macro:' #export (list xs)
(#Cons [(tag$ ["lux" "doc"])
(text$ "## List-construction macro.
- (list 1 2 3)")]
+ (list +1 +2 +3)")]
#Nil)
(return (#Cons (list/fold (function'' [head tail]
(form$ (#Cons (tag$ ["lux" "Cons"])
@@ -1352,7 +1352,7 @@
(#Cons [(tag$ ["lux" "doc"])
(text$ "## List-construction macro, with the last element being a tail-list.
## In other words, this macro prepends elements to another list.
- (list& 1 2 3 (list 4 5 6))")]
+ (list& +1 +2 +3 (list +4 +5 +6))")]
#Nil)
({(#Cons last init)
(return (list (list/fold (function'' [head tail]
@@ -2257,7 +2257,7 @@
(-> Int Int)
(i/+ <diff>))]
- [inc 1]
+ [inc +1]
[dec -1])")])
({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])])
({[(#Some bindings') (#Some data')]
@@ -2364,7 +2364,7 @@
(list [(tag$ ["lux" "doc"])
(text$ "Nat(ural) division.")])
(-> Nat Nat Nat)
- (if ("lux int <" ("lux coerce" Int param) 0)
+ (if ("lux int <" ("lux coerce" Int param) +0)
(if (n/< param subject)
|0
|1)
@@ -2469,11 +2469,11 @@
(list [(tag$ ["lux" "doc"])
(text$ "Rev(olution) division.")])
(-> Rev Rev Rev)
- (if ("lux i64 =" 0 param)
+ (if ("lux i64 =" +0 param)
("lux io error" "Cannot divide Rev by zero!")
(let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 ("lux coerce" Nat param))
[trailing-zeroes denominator] ("lux check" (#Product Nat Nat)
- (if ("lux i64 =" 0 trailing-zeroes)
+ (if ("lux i64 =" +0 trailing-zeroes)
[|1 ("lux i64 logical-right-shift" |1 remaining)]
[trailing-zeroes remaining]))
shift ("lux i64 -" trailing-zeroes |64)
@@ -2560,7 +2560,7 @@
(let' [loop ("lux check" (-> Nat Text Text)
(function' recur [input output]
(if (n/= |0 input)
- (text/compose "+" output)
+ (text/compose "|" output)
(recur (n// |10 input)
(text/compose (|> input (n/% |10) digit-to-text)
output)))))]
@@ -2570,27 +2570,27 @@
(def:''' (int/abs value)
#Nil
(-> Int Int)
- (if (i/< 0 value)
+ (if (i/< +0 value)
(i/* -1 value)
value))
(def:''' (int/encode value)
#Nil
(-> Int Text)
- (if (i/= 0 value)
+ (if (i/= +0 value)
"0"
- (let' [sign (if (i/> 0 value)
+ (let' [sign (if (i/> +0 value)
""
"-")]
(("lux check" (-> Int Text Text)
(function' recur [input output]
- (if (i/= 0 input)
+ (if (i/= +0 input)
(text/compose sign output)
- (recur (i// 10 input)
- (text/compose (|> input (i/% 10) ("lux coerce" Nat) digit-to-text)
+ (recur (i// +10 input)
+ (text/compose (|> input (i/% +10) ("lux coerce" Nat) digit-to-text)
output)))))
- (|> value (i// 10) int/abs)
- (|> value (i/% 10) int/abs ("lux coerce" Nat) digit-to-text)))))
+ (|> value (i// +10) int/abs)
+ (|> value (i/% +10) int/abs ("lux coerce" Nat) digit-to-text)))))
(def:''' (frac/encode x)
#Nil
@@ -2836,7 +2836,7 @@
(macro:' #export (: tokens)
(list [(tag$ ["lux" "doc"])
(text$ "## The type-annotation macro.
- (: (List Int) (list 1 2 3))")])
+ (: (List Int) (list +1 +2 +3))")])
({(#Cons type (#Cons value #Nil))
(return (list (` ("lux check" (type (~ type)) (~ value)))))
@@ -2847,7 +2847,7 @@
(macro:' #export (:coerce tokens)
(list [(tag$ ["lux" "doc"])
(text$ "## The type-coercion macro.
- (:coerce Dinosaur (list 1 2 3))")])
+ (:coerce Dinosaur (list +1 +2 +3))")])
({(#Cons type (#Cons value #Nil))
(return (list (` ("lux coerce" (type (~ type)) (~ value)))))
@@ -3117,7 +3117,7 @@
(list [(tag$ ["lux" "doc"])
(text$ "## The pattern-matching macro.
## Allows the usage of macros within the patterns to provide custom syntax.
- (case (: (List Int) (list 1 2 3))
+ (case (: (List Int) (list +1 +2 +3))
(#Cons x (#Cons y (#Cons z #Nil)))
(#Some ($_ i/* x y z))
@@ -3136,7 +3136,7 @@
(list [(tag$ ["lux" "doc"])
(text$ "## Macro-expanding patterns.
## It's a special macro meant to be used with 'case'.
- (case (: (List Int) (list 1 2 3))
+ (case (: (List Int) (list +1 +2 +3))
(^ (list x y z))
(#Some ($_ i/* x y z))
@@ -3353,7 +3353,7 @@
(def: branching-exponent
Int
- 5)")])
+ +5)")])
(let [[export? tokens'] (export^ tokens)
parts (: (Maybe [Code (List Code) (Maybe Code) Code (List [Code Code])])
(case tokens'
@@ -3610,9 +3610,9 @@
(macro: (default tokens state)
{#.doc "## Allows you to provide a default value that will be used
## if a (Maybe x) value turns out to be #.None.
- (default 20 (#.Some 10)) => 10
+ (default +20 (#.Some +10)) => +10
- (default 20 #.None) => 20"}
+ (default +20 #.None) => +20"}
(case tokens
(^ (list else maybe))
(let [g!temp (: Code [dummy-cursor (#Identifier ["" ""])])
@@ -4872,7 +4872,7 @@
(:: Codec<Text,Int> encode)
## Also allows using that value as a function.
- (:: Codec<Text,Int> encode 123)"}
+ (:: Codec<Text,Int> encode +123)"}
(case tokens
(^ (list struct [_ (#Identifier member)]))
(return (list (` (let [(^open ".") (~ struct)] (~ (identifier$ member))))))
@@ -5199,7 +5199,7 @@
(def: (repeat n x)
(All [a] (-> Int a (List a)))
- (if (i/> 0 n)
+ (if (i/> +0 n)
(#Cons x (repeat (i/+ -1 n) x))
#Nil))
@@ -5289,9 +5289,9 @@
## For Example:
(doc \"Allows arbitrary looping, using the \\\"recur\\\" form to re-start the loop.
Can be used in monadic code to create monadic loops.\"
- (loop [count 0
+ (loop [count +0
x init]
- (if (< 10 count)
+ (if (< +10 count)
(recur (inc count) (f x))
x)))"}
(return (list (` [(~ cursor-code)
@@ -5354,17 +5354,17 @@
(macro: #export (loop tokens)
{#.doc (doc "Allows arbitrary looping, using the \"recur\" form to re-start the loop."
"Can be used in monadic code to create monadic loops."
- (loop [count 0
+ (loop [count +0
x init]
- (if (< 10 count)
+ (if (< +10 count)
(recur (inc count) (f x))
x))
"Loops can also be given custom names."
(loop my-loop
- [count 0
+ [count +0
x init]
- (if (< 10 count)
+ (if (< +10 count)
(my-loop (inc count) (f x))
x)))}
(let [?params (case tokens
@@ -5497,14 +5497,14 @@
[(bit #1) "#1" [_ (#.Bit #1)]]
[(bit #0) "#0" [_ (#.Bit #0)]]
- [(int 123) "123" [_ (#.Int 123)]]
- [(frac 123.0) "123.0" [_ (#.Frac 123.0)]]
+ [(int +123) "+123" [_ (#.Int +123)]]
+ [(frac +123.0) "+123.0" [_ (#.Frac +123.0)]]
[(text "\n") "\"\\n\"" [_ (#.Text "\n")]]
[(tag ["yolo" "lol"]) "#yolo.lol" [_ (#.Tag ["yolo" "lol"])]]
[(identifier ["yolo" "lol"]) "yolo.lol" [_ (#.Identifier ["yolo" "lol"])]]
- [(form (list (bit #1) (int 123))) "(#1 123)" (^ [_ (#.Form (list [_ (#.Bit #1)] [_ (#.Int 123)]))])]
- [(tuple (list (bit #1) (int 123))) "[#1 123]" (^ [_ (#.Tuple (list [_ (#.Bit #1)] [_ (#.Int 123)]))])]
- [(record (list [(bit #1) (int 123)])) "{#1 123}" (^ [_ (#.Record (list [[_ (#.Bit #1)] [_ (#.Int 123)]]))])]
+ [(form (list (bit #1) (int +123))) "(#1 +123)" (^ [_ (#.Form (list [_ (#.Bit #1)] [_ (#.Int +123)]))])]
+ [(tuple (list (bit #1) (int +123))) "[#1 +123]" (^ [_ (#.Tuple (list [_ (#.Bit #1)] [_ (#.Int +123)]))])]
+ [(record (list [(bit #1) (int +123)])) "{#1 +123}" (^ [_ (#.Record (list [[_ (#.Bit #1)] [_ (#.Int +123)]]))])]
[(local-tag "lol") "#lol" [_ (#.Tag ["" "lol"])]]
[(local-identifier "lol") "lol" [_ (#.Identifier ["" "lol"])]]
)]
@@ -5716,7 +5716,7 @@
(not (<even> n)))]
[Nat n/even? n/odd? n/% n/= |0 |2]
- [Int i/even? i/odd? i/% i/= 0 2])
+ [Int i/even? i/odd? i/% i/= +0 +2])
(def: (get-scope-type-vars state)
(Meta (List Nat))
@@ -5765,11 +5765,11 @@
(def: #export (is? reference sample)
{#.doc (doc "Tests whether the 2 values are identical (not just \"equal\")."
"This one should succeed:"
- (let [value 5]
+ (let [value +5]
(is? value value))
"This one should fail:"
- (is? 5 (i/+ 2 3)))}
+ (is? +5 (i/+ +2 +3)))}
(All [a] (-> a a Bit))
("lux is" reference sample))
@@ -5807,7 +5807,7 @@
(macro: #export (:assume tokens)
{#.doc (doc "Coerces the given expression to the type of whatever is expected."
- (: Dinosaur (:assume (list 1 2 3))))}
+ (: Dinosaur (:assume (list +1 +2 +3))))}
(case tokens
(^ (list expr))
(do Monad<Meta>
@@ -5833,7 +5833,7 @@
(macro: #export (:of tokens)
{#.doc (doc "Generates the type corresponding to a given definition or variable."
- (let [my-num (: Int 123)]
+ (let [my-num (: Int +123)]
(:of my-num))
"=="
Int)}
@@ -6152,8 +6152,8 @@
(def: #export (i/mod param subject)
(All [m] (-> Int Int Int))
(let [raw (i/% param subject)]
- (if (i/< 0 raw)
- (let [shift (if (i/< 0 param) i/- i/+)]
+ (if (i/< +0 raw)
+ (let [shift (if (i/< +0 param) i/- i/+)]
(|> raw (shift param)))
raw)))
@@ -6177,11 +6177,11 @@
(def: #export (frac-to-rev input)
(-> Frac Rev)
- (let [abs (if (f/< 0.0 input)
+ (let [abs (if (f/< +0.0 input)
(f/* -1.0 input)
input)]
(|> abs
- (f/% 1.0)
+ (f/% +1.0)
(f/* rev-denominator)
frac-to-int
("lux i64 left-shift" |11))))
diff --git a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux
index 26a91dff6..29203290a 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux
@@ -181,7 +181,7 @@
## the tuple represents the expectations of the user.
## If the type is for a 3-tuple, but a 5-tuple is provided, it
## is assumed that the user intended the following layout:
- ## [0, 1, [2, 3, 4]]
+ ## [+0, +1, [+2, +3, +4]]
## but that, for whatever reason, it was written in a flat
## way.
[tailT tailC]
diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux
index 10a893f09..b1dce6688 100644
--- a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux
+++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux
@@ -91,17 +91,17 @@
(def: (bit::left-shift [subjectO paramO])
Binary
- (_.arithmetic-shift/2 (_.remainder/2 (_.int 64) paramO)
+ (_.arithmetic-shift/2 (_.remainder/2 (_.int +64) paramO)
subjectO))
(def: (bit::arithmetic-right-shift [subjectO paramO])
Binary
- (_.arithmetic-shift/2 (|> paramO (_.remainder/2 (_.int 64)) (_.*/2 (_.int -1)))
+ (_.arithmetic-shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1)))
subjectO))
(def: (bit::logical-right-shift [subjectO paramO])
Binary
- (runtime.bit//logical-right-shift (_.remainder/2 (_.int 64) paramO) subjectO))
+ (runtime.bit//logical-right-shift (_.remainder/2 (_.int +64) paramO) subjectO))
(def: bundle::bit
Bundle
@@ -209,7 +209,7 @@
(bundle.install "%" (binary int::%))
(bundle.install "=" (binary int::=))
(bundle.install "<" (binary int::<))
- (bundle.install "to-frac" (unary (|>> (_.//2 (_.float 1.0)))))
+ (bundle.install "to-frac" (unary (|>> (_.//2 (_.float +1.0)))))
(bundle.install "char" (unary int::char)))))
(def: bundle::frac
@@ -302,7 +302,7 @@
(def: (atom::read atom)
Unary
- (_.vector-ref/2 atom (_.int 0)))
+ (_.vector-ref/2 atom (_.int +0)))
(def: (atom::compare-and-swap [atomO oldO newO])
Trinary
@@ -332,7 +332,7 @@
## [[Processes]]
(def: (process::parallelism-level [])
Nullary
- (_.int 1))
+ (_.int +1))
(def: bundle::process
Bundle
diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux
index 437c92520..bf65a7606 100644
--- a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux
+++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux
@@ -77,7 +77,7 @@
(_.apply/2 (_.global "apply") (_.global "values") @curried)]))
bodyO))
(_.if (|> @num-args (_.>/2 arityO))
- (let [arity-args (runtime.slice (_.int 0) arityO @curried)
+ (let [arity-args (runtime.slice (_.int +0) arityO @curried)
output-func-args (runtime.slice arityO
(|> @num-args (_.-/2 arityO))
@curried)]
diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux
index a2c9e31da..d72312693 100644
--- a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux
+++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux
@@ -114,14 +114,14 @@
(runtime: (slice offset length list)
(<| (_.if (_.null?/1 list)
list)
- (_.if (|> offset (_.>/2 (_.int 0)))
- (slice (|> offset (_.-/2 (_.int 1)))
+ (_.if (|> offset (_.>/2 (_.int +0)))
+ (slice (|> offset (_.-/2 (_.int +1)))
length
(_.cdr/1 list)))
- (_.if (|> length (_.>/2 (_.int 0)))
+ (_.if (|> length (_.>/2 (_.int +0)))
(_.cons/2 (_.car/1 list)
(slice offset
- (|> length (_.-/2 (_.int 1)))
+ (|> length (_.-/2 (_.int +1)))
(_.cdr/1 list))))
_.nil))
@@ -157,7 +157,7 @@
(def: minimum-index-length
(-> Expression Computation)
- (|>> (_.+/2 (_.int 1))))
+ (|>> (_.+/2 (_.int +1))))
(def: product-element
(-> Expression Expression Computation)
@@ -165,7 +165,7 @@
(def: (product-tail product)
(-> Expression Computation)
- (_.vector-ref/2 product (|> (_.length/1 product) (_.-/2 (_.int 1)))))
+ (_.vector-ref/2 product (|> (_.length/1 product) (_.-/2 (_.int +1)))))
(def: (updated-index min-length product)
(-> Expression Expression Computation)
@@ -202,7 +202,7 @@
(_.begin
(list (_.define @slice [(list) #.None]
(_.make-vector/1 (|> @product_length (_.-/2 index))))
- (_.vector-copy!/5 @slice (_.int 0) product index @product_length)
+ (_.vector-copy!/5 @slice (_.int +0) product index @product_length)
@slice)))))))
(runtime: (sum//get sum last? wanted-tag)
@@ -235,11 +235,11 @@
@@sum//get)))
(runtime: (bit//logical-right-shift shift input)
- (_.if (_.=/2 (_.int 0) shift)
+ (_.if (_.=/2 (_.int +0) shift)
input
(|> input
(_.arithmetic-shift/2 (_.*/2 (_.int -1) shift))
- (_.bit-and/2 (_.int (hex "7FFFFFFFFFFFFFFF"))))))
+ (_.bit-and/2 (_.int (hex "+7FFFFFFFFFFFFFFF"))))))
(def: runtime//bit
Computation
@@ -286,10 +286,10 @@
(runtime: (atom//compare-and-swap atom old new)
(with-vars [@temp]
- (_.let (list [@temp (_.vector-ref/2 atom (_.int 0))])
+ (_.let (list [@temp (_.vector-ref/2 atom (_.int +0))])
(_.if (_.eq?/2 old @temp)
(_.begin
- (list (_.vector-set!/3 atom (_.int 0) new)
+ (list (_.vector-set!/3 atom (_.int +0) new)
(_.bool #1)))
(_.bool #0)))))
@@ -300,7 +300,7 @@
(runtime: (box//write value box)
(_.begin
(list
- (_.vector-set!/3 box (_.int 0) value)
+ (_.vector-set!/3 box (_.int +0) value)
..unit)))
(def: runtime//box
@@ -309,7 +309,7 @@
(runtime: (io//current-time _)
(|> (_.apply/* (_.global "current-second") (list))
- (_.*/2 (_.int 1_000))
+ (_.*/2 (_.int +1_000))
_.exact/1))
(def: runtime//io
@@ -334,7 +334,7 @@
(_.set! process//incoming (_.cons/2 process process//incoming)))]
(_.begin
(list
- (_.if (_.=/2 (_.int 0) milli-seconds)
+ (_.if (_.=/2 (_.int +0) milli-seconds)
(process//future procedure)
(with-vars [@start @process @now @ignored]
(_.let (list [@start (io//current-time ..unit)])
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux
index b5e9acb51..f88cedc9b 100644
--- a/stdlib/source/lux/compiler/default/syntax.lux
+++ b/stdlib/source/lux/compiler/default/syntax.lux
@@ -317,9 +317,9 @@
_ (l.this? "/")
denominator frac-ratio-fragment
_ (p.assert "Denominator cannot be 0."
- (not (f/= 0.0 denominator)))]
+ (not (f/= +0.0 denominator)))]
(wrap (|> numerator
- (f/* (if signed? -1.0 1.0))
+ (f/* (if signed? -1.0 +1.0))
(f// denominator)))))]
(wrap [(update@ #.column (n/+ (text.size chunk)) where)
[where (#.Frac value)]])))
diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux
index ef262762f..7efe24942 100644
--- a/stdlib/source/lux/control/comonad.lux
+++ b/stdlib/source/lux/control/comonad.lux
@@ -32,7 +32,7 @@
{#.doc (doc "A co-monadic parallel to the \"do\" macro."
(let [square (function (_ n) (i/* n n))]
(be CoMonad<Stream>
- [inputs (iterate inc 2)]
+ [inputs (iterate inc +2)]
(square (head inputs)))))}
(case tokens
(#.Cons comonad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil)))
diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux
index 72aefd174..065829f44 100644
--- a/stdlib/source/lux/control/contract.lux
+++ b/stdlib/source/lux/control/contract.lux
@@ -19,8 +19,8 @@
{#.doc (doc "Pre-conditions."
"Given a test and an expression to run, only runs the expression if the test passes."
"Otherwise, an error is raised."
- (pre (i/= 4 (i/+ 2 2))
- (foo 123 456 789)))}
+ (pre (i/= +4 (i/+ +2 +2))
+ (foo +123 +456 +789)))}
(wrap (list (` (exec (assert! (~ (code.text (format "Pre-condition failed: " (%code test))))
(~ test))
(~ expr))))))
@@ -31,7 +31,7 @@
"If the predicate returns #1, returns the value of the expression."
"Otherwise, an error is raised."
(post i/even?
- (i/+ 2 2)))}
+ (i/+ +2 +2)))}
(with-gensyms [g!output]
(wrap (list (` (let [(~ g!output) (~ expr)]
(exec (assert! (~ (code.text (format "Post-condition failed: " (%code test))))
diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux
index 716304479..a9a97b0c9 100644
--- a/stdlib/source/lux/control/pipe.lux
+++ b/stdlib/source/lux/control/pipe.lux
@@ -18,10 +18,10 @@
(syntax: #export (new> {tokens (p.at-least |2 s.any)})
{#.doc (doc "Ignores the piped argument, and begins a new pipe."
- (|> 20
- (i/* 3)
- (i/+ 4)
- (new> 0 inc)))}
+ (|> +20
+ (i/* +3)
+ (i/+ +4)
+ (new> +0 inc)))}
(case (list.reverse tokens)
(^ (list& _ r-body))
(wrap (list (` (|> (~+ (list.reverse r-body))))))
@@ -31,7 +31,7 @@
(syntax: #export (let> binding body prev)
{#.doc (doc "Gives a name to the piped-argument, within the given expression."
- (|> 5
+ (|> +5
(let> X (i/+ X X))))}
(wrap (list (` (let [(~ binding) (~ prev)]
(~ body))))))
@@ -48,9 +48,9 @@
{branches (p.some (p.and body^ body^))})
{#.doc (doc "Branching for pipes."
"Both the tests and the bodies are piped-code, and must be given inside a tuple."
- (|> 5
- (cond> [i/even?] [(i/* 2)]
- [i/odd?] [(i/* 3)]
+ (|> +5
+ (cond> [i/even?] [(i/* +2)]
+ [i/odd?] [(i/* +3)]
[(new> -1)])))}
(with-gensyms [g!temp]
(wrap (list (` (with-expansions
@@ -71,8 +71,8 @@
prev)
{#.doc (doc "Loops for pipes."
"Both the testing and calculating steps are pipes and must be given inside tuples."
- (|> 1
- (loop> [(i/< 10)]
+ (|> +1
+ (loop> [(i/< +10)]
[inc])))}
(with-gensyms [g!temp]
(wrap (list (` (loop [(~ g!temp) (~ prev)]
@@ -85,10 +85,10 @@
prev)
{#.doc (doc "Monadic pipes."
"Each steps in the monadic computation is a pipe and must be given inside a tuple."
- (|> 5
+ (|> +5
(do> Monad<Identity>
- [(i/* 3)]
- [(i/+ 4)]
+ [(i/* +3)]
+ [(i/+ +4)]
[inc])))}
(with-gensyms [g!temp]
(case (list.reverse steps)
@@ -108,9 +108,9 @@
prev)
{#.doc (doc "Non-updating pipes."
"Will generate piped computations, but their results will not be used in the larger scope."
- (|> 5
+ (|> +5
(exec> [.nat %n log!])
- (i/* 10)))}
+ (i/* +10)))}
(with-gensyms [g!temp]
(wrap (list (` (let [(~ g!temp) (~ prev)]
(exec (|> (~ g!temp) (~+ body))
@@ -120,11 +120,11 @@
prev)
{#.doc (doc "Parallel branching for pipes."
"Allows to run multiple pipelines for a value and gives you a tuple of the outputs."
- (|> 5
- (tuple> [(i/* 10)]
- [dec (i// 2)]
+ (|> +5
+ (tuple> [(i/* +10)]
+ [dec (i// +2)]
[Int/encode]))
- "Will become: [50 2 \"5\"]")}
+ "Will become: [+50 +2 \"+5\"]")}
(with-gensyms [g!temp]
(wrap (list (` (let [(~ g!temp) (~ prev)]
[(~+ (list/map (function (_ body) (` (|> (~ g!temp) (~+ body))))
@@ -134,17 +134,17 @@
prev)
{#.doc (doc "Pattern-matching for pipes."
"The bodies of each branch are NOT pipes; just regular values."
- (|> 5
- (case> 0 "zero"
- 1 "one"
- 2 "two"
- 3 "three"
- 4 "four"
- 5 "five"
- 6 "six"
- 7 "seven"
- 8 "eight"
- 9 "nine"
+ (|> +5
+ (case> +0 "zero"
+ +1 "one"
+ +2 "two"
+ +3 "three"
+ +4 "four"
+ +5 "five"
+ +6 "six"
+ +7 "seven"
+ +8 "eight"
+ +9 "nine"
_ "???")))}
(wrap (list (` (case (~ prev)
(~+ (list/join (list/map (function (_ [pattern body]) (list pattern body))
diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux
index ddedad6c5..c9e2c6786 100644
--- a/stdlib/source/lux/data/collection/row.lux
+++ b/stdlib/source/lux/data/collection/row.lux
@@ -343,7 +343,7 @@
## [Syntax]
(syntax: #export (row {elems (p.some s.any)})
{#.doc (doc "Row literals."
- (row 10 20 30 40))}
+ (row +10 +20 +30 +40))}
(wrap (list (` (from-list (list (~+ elems)))))))
## [Structures]
diff --git a/stdlib/source/lux/data/collection/sequence.lux b/stdlib/source/lux/data/collection/sequence.lux
index 95d60b555..ed06547c2 100644
--- a/stdlib/source/lux/data/collection/sequence.lux
+++ b/stdlib/source/lux/data/collection/sequence.lux
@@ -138,7 +138,7 @@
{branches (p.some s.any)})
{#.doc (doc "Allows destructuring of sequences in pattern-matching expressions."
"Caveat emptor: Only use it for destructuring, and not for testing values within the sequences."
- (let [(^sequence& x y z _tail) (some-sequence-func 1 2 3)]
+ (let [(^sequence& x y z _tail) (some-sequence-func +1 +2 +3)]
(func x y z)))}
(with-gensyms [g!sequence]
(let [body+ (` (let [(~+ (list/join (list/map (function (_ pattern)
diff --git a/stdlib/source/lux/data/collection/tree/rose.lux b/stdlib/source/lux/data/collection/tree/rose.lux
index 62b65422a..fc25f414f 100644
--- a/stdlib/source/lux/data/collection/tree/rose.lux
+++ b/stdlib/source/lux/data/collection/tree/rose.lux
@@ -49,9 +49,9 @@
(syntax: #export (tree {root tree^})
{#.doc (doc "Tree literals."
- (tree Int [10 {20 {}
- 30 {}
- 40 {}}]))}
+ (tree Int [+10 {+20 {}
+ +30 {}
+ +40 {}}]))}
(wrap (list (` (~ (loop [[value children] root]
(` {#value (~ value)
#children (list (~+ (list/map recur children)))})))))))
diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux
index c708e8775..2eb8bd35f 100644
--- a/stdlib/source/lux/data/color.lux
+++ b/stdlib/source/lux/data/color.lux
@@ -53,62 +53,62 @@
blue (scale-down blue)
max ($_ f/max red green blue)
min ($_ f/min red green blue)
- luminance (|> (f/+ max min) (f// 2.0))]
+ luminance (|> (f/+ max min) (f// +2.0))]
(if (f/= max min)
## Achromatic
- [0.0 0.0 luminance]
+ [+0.0 +0.0 luminance]
## Chromatic
(let [diff (|> max (f/- min))
saturation (|> diff
- (f// (if (f/> 0.5 luminance)
- (|> 2.0 (f/- max) (f/- min))
+ (f// (if (f/> +0.5 luminance)
+ (|> +2.0 (f/- max) (f/- min))
(|> max (f/+ min)))))
hue' (cond (f/= red max)
(|> green (f/- blue) (f// diff)
- (f/+ (if (f/< blue green) 6.0 0.0)))
+ (f/+ (if (f/< blue green) +6.0 +0.0)))
(f/= green max)
(|> blue (f/- red) (f// diff)
- (f/+ 2.0))
+ (f/+ +2.0))
## (f/= blue max)
(|> red (f/- green) (f// diff)
- (f/+ 4.0)))]
- [(|> hue' (f// 6.0))
+ (f/+ +4.0)))]
+ [(|> hue' (f// +6.0))
saturation
luminance]))))
(def: (hue-to-rgb p q t)
(-> Frac Frac Frac Frac)
- (let [t (cond (f/< 0.0 t) (f/+ 1.0 t)
- (f/> 1.0 t) (f/- 1.0 t)
+ (let [t (cond (f/< +0.0 t) (f/+ +1.0 t)
+ (f/> +1.0 t) (f/- +1.0 t)
## else
t)
- f2/3 (f// 3.0 2.0)]
- (cond (f/< (f// 6.0 1.0) t)
- (|> q (f/- p) (f/* 6.0) (f/* t) (f/+ p))
+ f2/3 (f// +3.0 +2.0)]
+ (cond (f/< (f// +6.0 +1.0) t)
+ (|> q (f/- p) (f/* +6.0) (f/* t) (f/+ p))
- (f/< (f// 2.0 1.0) t)
+ (f/< (f// +2.0 +1.0) t)
q
(f/< f2/3 t)
- (|> q (f/- p) (f/* (|> f2/3 (f/- t))) (f/* 6.0) (f/+ p))
+ (|> q (f/- p) (f/* (|> f2/3 (f/- t))) (f/* +6.0) (f/+ p))
## else
p)))
(def: #export (from-hsl [hue saturation luminance])
(-> [Frac Frac Frac] Color)
- (if (f/= 0.0 saturation)
+ (if (f/= +0.0 saturation)
## Achromatic
(let [intensity (scale-up luminance)]
(color [intensity intensity intensity]))
## Chromatic
- (let [q (if (f/< 0.5 luminance)
- (|> saturation (f/+ 1.0) (f/* luminance))
+ (let [q (if (f/< +0.5 luminance)
+ (|> saturation (f/+ +1.0) (f/* luminance))
(|> luminance (f/+ saturation) (f/- (f/* saturation luminance))))
- p (|> luminance (f/* 2.0) (f/- q))
- third (|> 1.0 (f// 3.0))]
+ p (|> luminance (f/* +2.0) (f/- q))
+ third (|> +1.0 (f// +3.0))]
(color [(scale-up (|> hue (f/+ third) (hue-to-rgb p q)))
(scale-up (|> hue (hue-to-rgb p q)))
(scale-up (|> hue (f/- third) (hue-to-rgb p q)))]))))
@@ -123,38 +123,38 @@
min ($_ f/min red green blue)
brightness max
diff (|> max (f/- min))
- saturation (if (f/= 0.0 max)
- 0.0
+ saturation (if (f/= +0.0 max)
+ +0.0
(|> diff (f// max)))]
(if (f/= max min)
## Achromatic
- [0.0 saturation brightness]
+ [+0.0 saturation brightness]
## Chromatic
(let [hue (cond (f/= red max)
(|> green (f/- blue) (f// diff)
- (f/+ (if (f/< blue green) 6.0 0.0)))
+ (f/+ (if (f/< blue green) +6.0 +0.0)))
(f/= green max)
(|> blue (f/- red) (f// diff)
- (f/+ 2.0))
+ (f/+ +2.0))
## (f/= blue max)
(|> red (f/- green) (f// diff)
- (f/+ 4.0)))]
- [(|> hue (f// 6.0))
+ (f/+ +4.0)))]
+ [(|> hue (f// +6.0))
saturation
brightness]))))
(def: #export (from-hsb [hue saturation brightness])
(-> [Frac Frac Frac] Color)
- (let [hue (|> hue (f/* 6.0))
+ (let [hue (|> hue (f/* +6.0))
i (math.floor hue)
f (|> hue (f/- i))
- p (|> 1.0 (f/- saturation) (f/* brightness))
- q (|> 1.0 (f/- (f/* f saturation)) (f/* brightness))
- t (|> 1.0 (f/- (|> 1.0 (f/- f) (f/* saturation))) (f/* brightness))
+ p (|> +1.0 (f/- saturation) (f/* brightness))
+ q (|> +1.0 (f/- (f/* f saturation)) (f/* brightness))
+ t (|> +1.0 (f/- (|> +1.0 (f/- f) (f/* saturation))) (f/* brightness))
v brightness
- mod (|> i (f/% 6.0) frac-to-int .nat)
+ mod (|> i (f/% +6.0) frac-to-int .nat)
red (case mod |0 v |1 q |2 p |3 p |4 t |5 v _ (undefined))
green (case mod |0 t |1 v |2 v |3 q |4 p |5 p _ (undefined))
blue (case mod |0 p |1 p |2 t |3 v |4 v |5 q _ (undefined))]
@@ -168,34 +168,34 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- key (|> 1.0 (f/- ($_ f/max red green blue)))
- f (if (f/< 1.0 key)
- (|> 1.0 (f// (|> 1.0 (f/- key))))
- 0.0)
- cyan (|> 1.0 (f/- red) (f/- key) (f/* f))
- magenta (|> 1.0 (f/- green) (f/- key) (f/* f))
- yellow (|> 1.0 (f/- blue) (f/- key) (f/* f))]
+ key (|> +1.0 (f/- ($_ f/max red green blue)))
+ f (if (f/< +1.0 key)
+ (|> +1.0 (f// (|> +1.0 (f/- key))))
+ +0.0)
+ cyan (|> +1.0 (f/- red) (f/- key) (f/* f))
+ magenta (|> +1.0 (f/- green) (f/- key) (f/* f))
+ yellow (|> +1.0 (f/- blue) (f/- key) (f/* f))]
[cyan magenta yellow key]))
(def: #export (from-cmyk [cyan magenta yellow key])
(-> [Frac Frac Frac Frac] Color)
- (if (f/= 1.0 key)
+ (if (f/= +1.0 key)
(color [|0 |0 |0])
- (let [red (|> (|> 1.0 (f/- cyan))
- (f/* (|> 1.0 (f/- key))))
- green (|> (|> 1.0 (f/- magenta))
- (f/* (|> 1.0 (f/- key))))
- blue (|> (|> 1.0 (f/- yellow))
- (f/* (|> 1.0 (f/- key))))]
+ (let [red (|> (|> +1.0 (f/- cyan))
+ (f/* (|> +1.0 (f/- key))))
+ green (|> (|> +1.0 (f/- magenta))
+ (f/* (|> +1.0 (f/- key))))
+ blue (|> (|> +1.0 (f/- yellow))
+ (f/* (|> +1.0 (f/- key))))]
(color [(scale-up red) (scale-up green) (scale-up blue)]))))
(def: (normalize ratio)
(-> Frac Frac)
- (cond (f/> 1.0 ratio)
- (f/% 1.0 ratio)
+ (cond (f/> +1.0 ratio)
+ (f/% +1.0 ratio)
- (f/< 0.0 ratio)
- (|> 1.0 (f/+ (f/% 1.0 ratio)))
+ (f/< +0.0 ratio)
+ (|> +1.0 (f/+ (f/% +1.0 ratio)))
## else
ratio))
@@ -203,7 +203,7 @@
(def: #export (interpolate ratio end start)
(-> Frac Color Color Color)
(let [dS (normalize ratio)
- dE (|> 1.0 (f/- dS))
+ dE (|> +1.0 (f/- dS))
interpolate' (: (-> Nat Nat Nat)
(function (_ end start)
(|> (|> start .int int-to-frac (f/* dS))
@@ -242,8 +242,8 @@
(let [[hue saturation luminance] (to-hsl color)]
(from-hsl [hue
(|> saturation
- (f/* (|> 1.0 (<op> (normalize ratio))))
- (f/min 1.0))
+ (f/* (|> +1.0 (<op> (normalize ratio))))
+ (f/min +1.0))
luminance])))]
[saturate f/+]
@@ -253,7 +253,7 @@
(def: #export (gray-scale color)
(-> Color Color)
(let [[_ _ luminance] (to-hsl color)]
- (from-hsl [0.0 0.0 luminance])))
+ (from-hsl [+0.0 +0.0 luminance])))
(do-template [<name> <1> <2>]
[(def: #export (<name> color)
@@ -263,9 +263,9 @@
(from-hsl [(|> hue (f/+ <1>) normalize) saturation luminance])
(from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance])]))]
- [triad (|> 1.0 (f// 3.0)) (|> 2.0 (f// 3.0))]
- [clash (|> 1.0 (f// 4.0)) (|> 3.0 (f// 4.0))]
- [split-complement (|> 1.0 (f// 5.0)) (|> 3.0 (f// 5.0))]
+ [triad (|> +1.0 (f// +3.0)) (|> +2.0 (f// +3.0))]
+ [clash (|> +1.0 (f// +4.0)) (|> +3.0 (f// +4.0))]
+ [split-complement (|> +1.0 (f// +5.0)) (|> +3.0 (f// +5.0))]
)
(do-template [<name> <1> <2> <3>]
@@ -277,8 +277,8 @@
(from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance])
(from-hsl [(|> hue (f/+ <3>) normalize) saturation luminance])]))]
- [square (|> 1.0 (f// 4.0)) (|> 2.0 (f// 4.0)) (|> 3.0 (f// 4.0))]
- [tetradic (|> 2.0 (f// 12.0)) (|> 6.0 (f// 12.0)) (|> 8.0 (f// 12.0))]
+ [square (|> +1.0 (f// +4.0)) (|> +2.0 (f// +4.0)) (|> +3.0 (f// +4.0))]
+ [tetradic (|> +2.0 (f// +12.0)) (|> +6.0 (f// +12.0)) (|> +8.0 (f// +12.0))]
)
(def: #export (analogous results slice color)
@@ -298,7 +298,7 @@
(if (n/= |0 results)
(list)
(let [[hue saturation brightness] (to-hsb color)
- slice (|> 1.0 (f// (|> results .int int-to-frac)))]
+ slice (|> +1.0 (f// (|> results .int int-to-frac)))]
(|> (list.n/range |0 (dec results))
(list/map (|>> .int int-to-frac
(f/* slice)
diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux
index 8054736e9..17d88a5a0 100644
--- a/stdlib/source/lux/data/error.lux
+++ b/stdlib/source/lux/data/error.lux
@@ -86,10 +86,10 @@
(macro: #export (default tokens compiler)
{#.doc (doc "Allows you to provide a default value that will be used"
"if a (Error x) value turns out to be #Error."
- (is? 10
- (default 20 (#Success 10)))
- (is? 20
- (default 20 (#Error "KABOOM!"))))}
+ (is? +10
+ (default +20 (#Success +10)))
+ (is? +20
+ (default +20 (#Error "KABOOM!"))))}
(case tokens
(^ (list else error))
(#Success [compiler (list (` (case (~ error)
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 02c05f5dd..549631f2a 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -55,7 +55,7 @@
(syntax: #export (json token)
{#.doc (doc "A simple way to produce JSON literals."
(json #1)
- (json 123.456)
+ (json +123.456)
(json "Some text")
(json #null)
(json ["this" "is" "an" "array"])
diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux
index d6b44e02d..57ff95727 100644
--- a/stdlib/source/lux/data/maybe.lux
+++ b/stdlib/source/lux/data/maybe.lux
@@ -84,9 +84,9 @@
(macro: #export (default tokens state)
{#.doc "## Allows you to provide a default value that will be used
## if a (Maybe x) value turns out to be #.None.
- (default 20 (#.Some 10)) => 10
+ (default +20 (#.Some +10)) => +10
- (default 20 #.None) => 20"}
+ (default +20 #.None) => +20"}
(case tokens
(^ (list else maybe))
(let [g!temp (: Code [dummy-cursor (#.Identifier ["" ""])])
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 9934af3de..573e422d6 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -10,7 +10,7 @@
interval
[codec (#+ Codec)]]
[data
- ["e" error]
+ ["." error (#+ Error)]
["." maybe]
["." text]]]
[/
@@ -74,8 +74,8 @@
<1>))
)]
- [ Int Order<Int> i/+ i/- i/* i// i/% i/= i/< 0 1 -1]
- [Frac Order<Frac> f/+ f/- f/* f// f/% f/= f/< 0.0 1.0 -1.0]
+ [ Int Order<Int> i/+ i/- i/* i// i/% i/= i/< +0 +1 -1]
+ [Frac Order<Frac> f/+ f/- f/* f// f/% f/= f/< +0.0 +1.0 -1.0]
)
(structure: #export _ (Number Rev)
@@ -108,7 +108,7 @@
(def: bottom <bottom>))]
[ Nat Enum<Nat> (:coerce Nat -1) |0]
- [ Int Enum<Int> 9_223_372_036_854_775_807 -9_223_372_036_854_775_808]
+ [ Int Enum<Int> +9_223_372_036_854_775_807 -9_223_372_036_854_775_808]
[Frac Enum<Frac> ("lux frac max") ("lux frac min")]
[ Rev Enum<Rev> (:coerce Rev -1) (:coerce Rev |0)]
)
@@ -122,12 +122,12 @@
[ Mul@Monoid<Nat> Nat |1 n/*]
[ Max@Monoid<Nat> Nat (:: Interval<Nat> bottom) n/max]
[ Min@Monoid<Nat> Nat (:: Interval<Nat> top) n/min]
- [ Add@Monoid<Int> Int 0 i/+]
- [ Mul@Monoid<Int> Int 1 i/*]
+ [ Add@Monoid<Int> Int +0 i/+]
+ [ Mul@Monoid<Int> Int +1 i/*]
[ Max@Monoid<Int> Int (:: Interval<Int> bottom) i/max]
[ Min@Monoid<Int> Int (:: Interval<Int> top) i/min]
- [Add@Monoid<Frac> Frac 0.0 f/+]
- [Mul@Monoid<Frac> Frac 1.0 f/*]
+ [Add@Monoid<Frac> Frac +0.0 f/+]
+ [Mul@Monoid<Frac> Frac +1.0 f/*]
[Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f/max]
[Min@Monoid<Frac> Frac (:: Interval<Frac> top) f/min]
[ Add@Monoid<Rev> Rev (:: Interval<Rev> bottom) r/+]
@@ -140,10 +140,10 @@
[(def: #export <name>
{#.doc <doc>}
Frac
- (f// 0.0 <numerator>))]
+ (f// +0.0 <numerator>))]
- [not-a-number 0.0 "Not a number."]
- [positive-infinity 1.0 "Positive infinity."]
+ [not-a-number +0.0 "Not a number."]
+ [positive-infinity +1.0 "Positive infinity."]
[negative-infinity -1.0 "Negative infinity."]
)
@@ -166,10 +166,10 @@
(def: (decode input)
(case (<decoder> [input])
(#.Some value)
- (#e.Success value)
+ (#error.Success value)
#.None
- (#e.Error <error>))))]
+ (#error.Error <error>))))]
[Frac "lux frac encode" "lux frac decode" "Could not decode Frac"]
)
@@ -314,16 +314,16 @@
(let [digit (maybe.assume (get-char repr idx))]
(case (<to-value> digit)
#.None
- (#e.Error ("lux text concat" <error> repr))
+ (#error.Error ("lux text concat" <error> repr))
(#.Some digit-value)
(recur (inc idx)
(|> output (n/* <base>) (n/+ digit-value)))))
- (#e.Success output)))
+ (#error.Success output)))
_
- (#e.Error ("lux text concat" <error> repr)))
- (#e.Error ("lux text concat" <error> repr))))))]
+ (#error.Error ("lux text concat" <error> repr)))
+ (#error.Error ("lux text concat" <error> repr))))))]
[Binary@Codec<Text,Nat> |2 binary-character binary-value "Invalid binary syntax for Nat: "]
[Octal@Codec<Text,Nat> |8 octal-character octal-value "Invalid octal syntax for Nat: "]
@@ -331,51 +331,69 @@
[Hex@Codec<Text,Nat> |16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "]
)
+(def: (int/sign!! value)
+ (-> Int Text)
+ (if (i/< +0 value)
+ "-"
+ "+"))
+
+(def: (int/sign?? representation)
+ (-> Text (Maybe Int))
+ (case (get-char representation |0)
+ (^ (#.Some "-"))
+ (#.Some -1)
+
+ (^ (#.Some "+"))
+ (#.Some +1)
+
+ _
+ #.None))
+
+(def: (int-decode-loop input-size repr sign <base> <to-value> <error>)
+ (-> Nat Text Int Int (-> Text (Maybe Nat)) Text (Error Int))
+ (loop [idx |1
+ output +0]
+ (if (n/< input-size idx)
+ (let [digit (maybe.assume (get-char repr idx))]
+ (case (<to-value> digit)
+ #.None
+ (#error.Error <error>)
+
+ (#.Some digit-value)
+ (recur (inc idx)
+ (|> output (i/* <base>) (i/+ (.int digit-value))))))
+ (#error.Success (i/* sign output)))))
+
(do-template [<struct> <base> <to-character> <to-value> <error>]
[(structure: #export <struct> (Codec Text Int)
(def: (encode value)
- (if (i/= 0 value)
- "0"
- (let [sign (if (i/< 0 value)
- "-"
- "")]
- (loop [input (|> value (i// <base>) (:: Number<Int> abs))
- output (|> value (i/% <base>) (:: Number<Int> abs) .nat
- <to-character>
- maybe.assume)]
- (if (i/= 0 input)
- ("lux text concat" sign output)
- (let [digit (maybe.assume (<to-character> (.nat (i/% <base> input))))]
- (recur (i// <base> input)
- ("lux text concat" digit output))))))))
+ (if (i/= +0 value)
+ "+0"
+ (loop [input (|> value (i// <base>) (:: Number<Int> abs))
+ output (|> value (i/% <base>) (:: Number<Int> abs) .nat
+ <to-character>
+ maybe.assume)]
+ (if (i/= +0 input)
+ ("lux text concat" (int/sign!! value) output)
+ (let [digit (maybe.assume (<to-character> (.nat (i/% <base> input))))]
+ (recur (i// <base> input)
+ ("lux text concat" digit output)))))))
(def: (decode repr)
(let [input-size ("lux text size" repr)]
- (if (n/>= |1 input-size)
- (let [sign (case (get-char repr |0)
- (^ (#.Some "-"))
- -1
-
- _
- 1)]
- (loop [idx (if (i/= -1 sign) |1 |0)
- output 0]
- (if (n/< input-size idx)
- (let [digit (maybe.assume (get-char repr idx))]
- (case (<to-value> digit)
- #.None
- (#e.Error <error>)
-
- (#.Some digit-value)
- (recur (inc idx)
- (|> output (i/* <base>) (i/+ (:coerce Int digit-value))))))
- (#e.Success (i/* sign output)))))
- (#e.Error <error>)))))]
-
- [Binary@Codec<Text,Int> 2 binary-character binary-value "Invalid binary syntax for Int: "]
- [Octal@Codec<Text,Int> 8 octal-character octal-value "Invalid octal syntax for Int: "]
- [_ 10 decimal-character decimal-value "Invalid syntax for Int: "]
- [Hex@Codec<Text,Int> 16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Int: "]
+ (if (n/> |1 input-size)
+ (case (int/sign?? repr)
+ (#.Some sign)
+ (int-decode-loop input-size repr sign <base> <to-value> <error>)
+
+ #.None
+ (#error.Error <error>))
+ (#error.Error <error>)))))]
+
+ [Binary@Codec<Text,Int> +2 binary-character binary-value "Invalid binary syntax for Int: "]
+ [Octal@Codec<Text,Int> +8 octal-character octal-value "Invalid octal syntax for Int: "]
+ [_ +10 decimal-character decimal-value "Invalid syntax for Int: "]
+ [Hex@Codec<Text,Int> +16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Int: "]
)
(def: (de-prefix input)
@@ -403,12 +421,12 @@
(case ("lux text char" repr |0)
(^multi (^ (#.Some (char ".")))
[(:: <nat> decode ("lux text concat" "|" (de-prefix repr)))
- (#e.Success output)])
- (#e.Success (:coerce Rev output))
+ (#error.Success output)])
+ (#error.Success (:coerce Rev output))
_
- (#e.Error ("lux text concat" <error> repr)))
- (#e.Error ("lux text concat" <error> repr))))))]
+ (#error.Error ("lux text concat" <error> repr)))
+ (#error.Error ("lux text concat" <error> repr))))))]
[Binary@Codec<Text,Rev> Binary@Codec<Text,Nat> |1 "Invalid binary syntax: "]
[Octal@Codec<Text,Rev> Octal@Codec<Text,Nat> |3 "Invalid octal syntax: "]
@@ -420,17 +438,17 @@
(def: (encode value)
(let [whole (frac-to-int value)
whole-part (:: <int> encode whole)
- decimal (:: Number<Frac> abs (f/% 1.0 value))
- decimal-part (if (f/= 0.0 decimal)
+ decimal (:: Number<Frac> abs (f/% +1.0 value))
+ decimal-part (if (f/= +0.0 decimal)
".0"
(loop [dec-left decimal
output ""]
- (if (f/= 0.0 dec-left)
+ (if (f/= +0.0 dec-left)
("lux text concat" "." output)
(let [shifted (f/* <base> dec-left)
digit (|> shifted (f/% <base>) frac-to-int .nat
(get-char <char-set>) maybe.assume)]
- (recur (f/% 1.0 shifted)
+ (recur (f/% +1.0 shifted)
("lux text concat" output digit))))))]
("lux text concat" whole-part decimal-part)))
@@ -441,34 +459,34 @@
decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr)))]
(case [(:: <int> decode whole-part)
(:: <int> decode decimal-part)]
- (^multi [(#e.Success whole) (#e.Success decimal)]
- (i/>= 0 decimal))
- (let [sign (if (i/< 0 whole)
+ (^multi [(#error.Success whole) (#error.Success decimal)]
+ (i/>= +0 decimal))
+ (let [sign (if (i/< +0 whole)
-1.0
- 1.0)
+ +1.0)
div-power (loop [muls-left ("lux text size" decimal-part)
- output 1.0]
+ output +1.0]
(if (n/= |0 muls-left)
output
(recur (dec muls-left)
(f/* <base> output))))
adjusted-decimal (|> decimal int-to-frac (f// div-power))
dec-rev (case (:: Hex@Codec<Text,Rev> decode ("lux text concat" "." decimal-part))
- (#e.Success dec-rev)
+ (#error.Success dec-rev)
dec-rev
- (#e.Error error)
+ (#error.Error error)
(error! error))]
- (#e.Success (f/+ (int-to-frac whole)
- (f/* sign adjusted-decimal))))
+ (#error.Success (f/+ (int-to-frac whole)
+ (f/* sign adjusted-decimal))))
_
- (#e.Error ("lux text concat" <error> repr))))
+ (#error.Error ("lux text concat" <error> repr))))
_
- (#e.Error ("lux text concat" <error> repr)))))]
+ (#error.Error ("lux text concat" <error> repr)))))]
- [Binary@Codec<Text,Frac> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "]
+ [Binary@Codec<Text,Frac> Binary@Codec<Text,Int> +2.0 "01" "Invalid binary syntax: "]
)
(def: (segment-digits chunk-size digits)
@@ -627,7 +645,7 @@
-1.0
_
- 1.0)]
+ +1.0)]
(case ("lux text index" repr "." |0)
(#.Some split-index)
(let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) |1 |0) split-index))
@@ -637,14 +655,14 @@
("lux text concat" (<to> whole-part))
("lux text concat" (if (f/= -1.0 sign) "-" "")))]
(case (:: Binary@Codec<Text,Frac> decode as-binary)
- (#e.Error _)
- (#e.Error ("lux text concat" <error> repr))
+ (#error.Error _)
+ (#error.Error ("lux text concat" <error> repr))
output
output))
_
- (#e.Error ("lux text concat" <error> repr))))))]
+ (#error.Error ("lux text concat" <error> repr))))))]
[Octal@Codec<Text,Frac> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary]
[Hex@Codec<Text,Frac> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary]
@@ -661,12 +679,12 @@
description [cursor (#.Text ($_ "lux text concat"
encoding "\n"
underscore))]]
- (#e.Success [state (list (` (doc (~ description)
- (~ example-1)
- (~ example-2))))]))
+ (#error.Success [state (list (` (doc (~ description)
+ (~ example-1)
+ (~ example-2))))]))
_
- (#e.Error "Wrong syntax for \"encoding-doc\".")))
+ (#error.Error "Wrong syntax for \"encoding-doc\".")))
(def: (underscore-prefixed? number)
(-> Text Bit)
@@ -687,36 +705,36 @@
(case tokens
(#.Cons [meta (#.Text repr')] #.Nil)
(if (underscore-prefixed? repr')
- (#e.Error <error>)
+ (#error.Error <error>)
(let [repr (clean-underscores repr')]
(case (:: <nat> decode repr)
- (#e.Success value)
- (#e.Success [state (list [meta (#.Nat value)])])
+ (#error.Success value)
+ (#error.Success [state (list [meta (#.Nat value)])])
- (^multi (#e.Error _)
- [(:: <int> decode repr) (#e.Success value)])
- (#e.Success [state (list [meta (#.Int value)])])
+ (^multi (#error.Error _)
+ [(:: <int> decode repr) (#error.Success value)])
+ (#error.Success [state (list [meta (#.Int value)])])
- (^multi (#e.Error _)
- [(:: <rev> decode repr) (#e.Success value)])
- (#e.Success [state (list [meta (#.Rev value)])])
+ (^multi (#error.Error _)
+ [(:: <rev> decode repr) (#error.Success value)])
+ (#error.Success [state (list [meta (#.Rev value)])])
- (^multi (#e.Error _)
- [(:: <frac> decode repr) (#e.Success value)])
- (#e.Success [state (list [meta (#.Frac value)])])
+ (^multi (#error.Error _)
+ [(:: <frac> decode repr) (#error.Success value)])
+ (#error.Success [state (list [meta (#.Frac value)])])
_
- (#e.Error <error>))))
+ (#error.Error <error>))))
_
- (#e.Error <error>)))]
+ (#error.Error <error>)))]
[bin Binary@Codec<Text,Nat> Binary@Codec<Text,Int> Binary@Codec<Text,Rev> Binary@Codec<Text,Frac>
"Invalid binary syntax."
- (encoding-doc "binary" (bin "11001001") (bin "11_00_10_01"))]
+ (encoding-doc "binary" (bin "+11001001") (bin "+11_00_10_01"))]
[oct Octal@Codec<Text,Nat> Octal@Codec<Text,Int> Octal@Codec<Text,Rev> Octal@Codec<Text,Frac>
"Invalid octal syntax."
- (encoding-doc "octal" (oct "615243") (oct "615_243"))]
+ (encoding-doc "octal" (oct "+615243") (oct "+615_243"))]
[hex Hex@Codec<Text,Nat> Hex@Codec<Text,Int> Hex@Codec<Text,Rev> Hex@Codec<Text,Frac>
"Invalid hexadecimal syntax."
(encoding-doc "hexadecimal" (hex "deadBEEF") (hex "dead_BEEF"))]
@@ -755,7 +773,7 @@
(loop [idx idx
carry |0
output output]
- (if (i/>= 0 (:coerce Int idx))
+ (if (i/>= +0 (:coerce Int idx))
(let [raw (|> (digits-get idx output)
(n/* |5)
(n/+ carry))]
@@ -769,7 +787,7 @@
(loop [times power
output (|> (make-digits [])
(digits-put power |1))]
- (if (i/>= 0 (:coerce Int times))
+ (if (i/>= +0 (:coerce Int times))
(recur (dec times)
(digits-times-5! power output))
output)))
@@ -779,7 +797,7 @@
(loop [idx (dec i64.width)
all-zeroes? #1
output ""]
- (if (i/>= 0 (:coerce Int idx))
+ (if (i/>= +0 (:coerce Int idx))
(let [digit (digits-get idx digits)]
(if (and (n/= |0 digit)
all-zeroes?)
@@ -798,7 +816,7 @@
(loop [idx (dec i64.width)
carry |0
output (make-digits [])]
- (if (i/>= 0 (:coerce Int idx))
+ (if (i/>= +0 (:coerce Int idx))
(let [raw ($_ n/+
carry
(digits-get idx param)
@@ -816,7 +834,7 @@
output (make-digits [])]
(if (n/< length idx)
(let [char (maybe.assume (get-char input idx))]
- (case ("lux text index" "0123456789" char |0)
+ (case ("lux text index" "+0123456789" char |0)
#.None
#.None
@@ -852,7 +870,7 @@
(-> Digits Digits Digits)
(loop [idx (dec i64.width)
output subject]
- (if (i/>= 0 (.int idx))
+ (if (i/>= +0 (.int idx))
(recur (dec idx)
(digits-sub-once! idx (digits-get idx param) output))
output)))
@@ -865,7 +883,7 @@
".0"
(loop [idx last-idx
digits (make-digits [])]
- (if (i/>= 0 (:coerce Int idx))
+ (if (i/>= +0 (:coerce Int idx))
(if (i64.set? idx input)
(let [digits' (digits-add (digits-power (n/- idx last-idx))
digits)]
@@ -901,16 +919,16 @@
(recur (digits-sub! power digits)
(inc idx)
(i64.set (n/- idx (dec i64.width)) output))))
- (#e.Success (:coerce Rev output))))
+ (#error.Success (:coerce Rev output))))
#.None
- (#e.Error ("lux text concat" "Wrong syntax for Rev: " input)))
- (#e.Error ("lux text concat" "Wrong syntax for Rev: " input))))
+ (#error.Error ("lux text concat" "Wrong syntax for Rev: " input)))
+ (#error.Error ("lux text concat" "Wrong syntax for Rev: " input))))
))
(def: (log2 input)
(-> Frac Frac)
- (f// ("lux math log" 2.0)
+ (f// ("lux math log" +2.0)
("lux math log" input)))
(def: double-bias Nat |1023)
@@ -929,8 +947,8 @@
(f/= negative-infinity input)
(hex "|FFF0000000000000")
- (f/= 0.0 input)
- (let [reciprocal (f// input 1.0)]
+ (f/= +0.0 input)
+ (let [reciprocal (f// input +1.0)]
(if (f/= positive-infinity reciprocal)
## Positive zero
(hex "|0000000000000000")
@@ -944,9 +962,9 @@
exponent-mask (|> |1 (i64.left-shift exponent-size) dec)
mantissa (|> input
## Normalize
- (f// ("lux math pow" 2.0 exponent))
+ (f// ("lux math pow" +2.0 exponent))
## Make it int-equivalent
- (f/* ("lux math pow" 2.0 52.0)))
+ (f/* ("lux math pow" +2.0 +52.0)))
sign-bit (if (f/= -1.0 sign) |1 |0)
exponent-bits (|> exponent frac-to-int .nat (n/+ double-bias) (i64.and exponent-mask))
mantissa-bits (|> mantissa frac-to-int .nat)]
@@ -981,16 +999,16 @@
(and (n/= |0 E) (n/= |0 M))
(if (n/= |0 S)
- 0.0
- (f/* -1.0 0.0))
+ +0.0
+ (f/* -1.0 +0.0))
## else
(let [normalized (|> M (i64.set mantissa-size)
.int int-to-frac
- (f// ("lux math pow" 2.0 52.0)))
+ (f// ("lux math pow" +2.0 +52.0)))
power (|> E (n/- double-bias)
.int int-to-frac
- ("lux math pow" 2.0))
+ ("lux math pow" +2.0))
shifted (f/* power
normalized)]
(if (n/= |0 S)
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index 41e074be6..fb0401582 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -27,14 +27,14 @@
"The imaginary part can be omitted if it's 0."
(complex real))}
(wrap (list (` {#..real (~ real)
- #..imaginary (~ (maybe.default (' 0.0)
+ #..imaginary (~ (maybe.default (' +0.0)
?imaginary))}))))
-(def: #export i Complex (complex 0.0 1.0))
+(def: #export i Complex (complex +0.0 +1.0))
-(def: #export one Complex (complex 1.0 0.0))
+(def: #export one Complex (complex +1.0 +0.0))
-(def: #export zero Complex (complex 0.0 0.0))
+(def: #export zero Complex (complex +0.0 +0.0))
(def: #export (not-a-number? complex)
(or (number.not-a-number? (get@ #real complex))
@@ -158,8 +158,8 @@
(def: #export (tan subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- r2 (f/* 2.0 real)
- i2 (f/* 2.0 imaginary)
+ r2 (f/* +2.0 real)
+ i2 (f/* +2.0 imaginary)
d (f/+ (math.cos r2) (math.cosh i2))]
{#real (f// d (math.sin r2))
#imaginary (f// d (math.sinh i2))}))
@@ -167,8 +167,8 @@
(def: #export (tanh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- r2 (f/* 2.0 real)
- i2 (f/* 2.0 imaginary)
+ r2 (f/* +2.0 real)
+ i2 (f/* +2.0 imaginary)
d (f/+ (math.cosh r2) (math.cos i2))]
{#real (f// d (math.sinh r2))
#imaginary (f// d (math.sin i2))}))
@@ -178,15 +178,15 @@
(let [(^slots [#real #imaginary]) subject]
(complex (if (f/< (frac/abs imaginary)
(frac/abs real))
- (if (f/= 0.0 imaginary)
+ (if (f/= +0.0 imaginary)
(frac/abs real)
(let [q (f// imaginary real)]
- (f/* (math.pow 0.5 (f/+ 1.0 (f/* q q)))
+ (f/* (math.pow +0.5 (f/+ +1.0 (f/* q q)))
(frac/abs imaginary))))
- (if (f/= 0.0 real)
+ (if (f/= +0.0 real)
(frac/abs imaginary)
(let [q (f// real imaginary)]
- (f/* (math.pow 0.5 (f/+ 1.0 (f/* q q)))
+ (f/* (math.pow +0.5 (f/+ +1.0 (f/* q q)))
(frac/abs real))))
))))
@@ -234,18 +234,18 @@
(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))]
- (if (f/>= 0.0 real)
+ (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 (f// (f/* +2.0 t)
imaginary)}
- {#real (f// (f/* 2.0 t)
+ {#real (f// (f/* +2.0 t)
(frac/abs imaginary))
- #imaginary (f/* t (copy-sign imaginary 1.0))})))
+ #imaginary (f/* t (copy-sign imaginary +1.0))})))
(def: #export (root2-1z input)
(-> Complex Complex)
- (|> (complex 1.0) (- (* input input)) root2))
+ (|> (complex +1.0) (- (* input input)) root2))
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
@@ -253,12 +253,12 @@
(frac/abs real))
(let [q (f// imaginary real)
scale (f// (|> real (f/* q) (f/+ imaginary))
- 1.0)]
+ +1.0)]
{#real (f/* q scale)
#imaginary (frac/negate scale)})
(let [q (f// real imaginary)
scale (f// (|> imaginary (f/* q) (f/+ real))
- 1.0)]
+ +1.0)]
{#real scale
#imaginary (|> scale frac/negate (f/* q))})))
@@ -283,7 +283,7 @@
(+ i)
(/ (- input i))
log
- (* (/ (complex 2.0) i))))
+ (* (/ (complex +2.0) i))))
(def: #export (argument (^slots [#real #imaginary]))
(-> Complex Frac)
@@ -294,9 +294,9 @@
(if (n/= |0 nth)
(list)
(let [r-nth (|> nth .int int-to-frac)
- nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth 1.0)))
+ nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth +1.0)))
nth-phi (|> input argument (f// r-nth))
- slice (|> math.pi (f/* 2.0) (f// r-nth))]
+ slice (|> math.pi (f/* +2.0) (f// r-nth))]
(|> (list.n/range |0 (dec nth))
(list/map (function (_ nth')
(let [inner (|> nth' .int int-to-frac
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index 3cb65dd14..658d51ae2 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -183,8 +183,7 @@
(def: number^
(l.Lexer Nat)
(|> (l.many l.decimal)
- (p.codec number.Codec<Text,Int>)
- (parser/map .nat)))
+ (p.codec number.Codec<Text,Nat>)))
(def: re-back-reference^
(l.Lexer Code)
@@ -298,7 +297,7 @@
(' #let) (` [(~ g!total) (:: (~! text.Monoid<Text>) (~' compose) (~ g!total) (~ access))]))
steps)])
)))
- [0
+ [+0
(: (List Code) (list))
(: (List (List Code)) (list))]
parts)]]
diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux
index d074b1ff1..0302064b3 100644
--- a/stdlib/source/lux/host.js.lux
+++ b/stdlib/source/lux/host.js.lux
@@ -30,7 +30,7 @@
## [Syntax]
(syntax: #export (set! field-name field-value object)
{#.doc (doc "A way to set fields from objects."
- (set! "foo" 1234 some-object))}
+ (set! "foo" +1234 some-object))}
(wrap (list (` ("js set-field" (~ object) (~ field-name) (~ field-value))))))
(syntax: #export (delete! field-name object)
@@ -75,8 +75,8 @@
(syntax: #export (call! {shape (p.or ($_ p.and s.any (s.tuple (p.some s.any)) (p.maybe s.any))
($_ p.and s.any s.text (s.tuple (p.some s.any)) (p.maybe s.any)))})
{#.doc (doc "A way to call JavaScript functions and methods."
- (call! (ref "Math.ceil") [123.45])
- (call! (ref "Math") "ceil" [123.45]))}
+ (call! (ref "Math.ceil") [+123.45])
+ (call! (ref "Math") "ceil" [+123.45]))}
(case shape
(#.Left [function args ?type])
(wrap (list (` (:coerce (~ (default (' ..Object) ?type))
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index 124320ce9..63eedfc9a 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -19,9 +19,9 @@
Frac
<value>)]
- [e 2.7182818284590452354 "The base of the natural logarithm."]
- [pi 3.14159265358979323846 "The ratio of a circle's circumference to its diameter."]
- [tau 6.28318530717958647692 "The ratio of a circle's circumference to its radius."]
+ [e +2.7182818284590452354 "The base of the natural logarithm."]
+ [pi +3.14159265358979323846 "The ratio of a circle's circumference to its diameter."]
+ [tau +6.28318530717958647692 "The ratio of a circle's circumference to its radius."]
)
(do-template [<name> <method>]
@@ -48,8 +48,8 @@
(-> Frac Frac)
(let [floored (floor input)
diff (f/- floored input)]
- (cond (f/> 0.5 diff)
- (f/+ 1.0 floored)
+ (cond (f/> +0.5 diff)
+ (f/+ +1.0 floored)
(f/< -0.5 diff)
(f/+ -1.0 floored)
@@ -63,22 +63,22 @@
(def: #export (atan2 param subject)
(-> Frac Frac Frac)
- (cond (f/> 0.0 param)
+ (cond (f/> +0.0 param)
(atan (f// param subject))
- (f/< 0.0 param)
- (if (f/>= 0.0 subject)
+ (f/< +0.0 param)
+ (if (f/>= +0.0 subject)
(|> subject (f// param) atan (f/+ pi))
(|> subject (f// param) atan (f/- pi)))
- ## (f/= 0.0 param)
- (cond (f/> 0.0 subject)
- (|> pi (f// 2.0))
+ ## (f/= +0.0 param)
+ (cond (f/> +0.0 subject)
+ (|> pi (f// +2.0))
- (f/< 0.0 subject)
+ (f/< +0.0 subject)
(|> pi (f// -2.0))
- ## (f/= 0.0 subject)
+ ## (f/= +0.0 subject)
number.not-a-number)))
(def: #export (log' base input)
@@ -96,8 +96,8 @@
(def: #export (hypotenuse catA catB)
(-> Frac Frac Frac)
- (pow 0.5 (f/+ (pow 2.0 catA)
- (pow 2.0 catB))))
+ (pow +0.5 (f/+ (pow +2.0 catA)
+ (pow +2.0 catB))))
(do-template [<type> <mod> <gcd> <lcm> <zero> <*> </> <->]
[(def: #export (<gcd> a b)
@@ -119,7 +119,7 @@
))]
[Nat n/mod n/gcd n/lcm |0 n/* n// n/-]
- [Int i/mod i/gcd i/lcm 0 i/* i// i/-]
+ [Int i/mod i/gcd i/lcm +0 i/* i// i/-]
)
## Hyperbolic functions
@@ -127,11 +127,11 @@
(do-template [<name> <comp> <inverse>]
[(def: #export (<name> x)
(-> Frac Frac)
- (|> (exp x) (<comp> (exp (f/* -1.0 x))) (f// 2.0)))
+ (|> (exp x) (<comp> (exp (f/* -1.0 x))) (f// +2.0)))
(def: #export (<inverse> x)
(-> Frac Frac)
- (|> 2.0 (f// (|> (exp x) (<comp> (exp (f/* -1.0 x)))))))]
+ (|> +2.0 (f// (|> (exp x) (<comp> (exp (f/* -1.0 x)))))))]
[sinh f/- csch]
[cosh f/+ sech]
@@ -154,7 +154,7 @@
(do-template [<name> <comp>]
[(def: #export (<name> x)
(-> Frac Frac)
- (|> x (pow 2.0) (<comp> 1.0) (pow 0.5) (f/+ x) log))]
+ (|> x (pow +2.0) (<comp> +1.0) (pow +0.5) (f/+ x) log))]
[asinh f/+]
[acosh f/-]
@@ -165,17 +165,17 @@
(-> Frac Frac)
(let [x+ (|> <base> (f/+ <diff>))
x- (|> <base> (f/- <diff>))]
- (|> x+ (f// x-) log (f// 2.0))))]
+ (|> x+ (f// x-) log (f// +2.0))))]
- [atanh 1.0 x]
- [acoth x 1.0]
+ [atanh +1.0 x]
+ [acoth x +1.0]
)
(do-template [<name> <op>]
[(def: #export (<name> x)
(-> Frac Frac)
- (let [x^2 (|> x (pow 2.0))]
- (|> 1.0 (<op> x^2) (pow 0.5) (f/+ 1.0) (f// x) log)))]
+ (let [x^2 (|> x (pow +2.0))]
+ (|> +1.0 (<op> x^2) (pow +0.5) (f/+ +1.0) (f// x) log)))]
[asech f/-]
[acsch f/+]
@@ -246,7 +246,7 @@
(syntax: #export (infix {expr infix^})
{#.doc (doc "Infix math syntax."
- (infix [x i/* 10])
+ (infix [x i/* +10])
(infix [[x i/+ y] i/* [x i/- y]])
(infix [sin [x i/+ y]])
(infix [[x n/< y] and [y n/< z]])
diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux
index 092b18944..ef0f36bb2 100644
--- a/stdlib/source/lux/math/modular.lux
+++ b/stdlib/source/lux/math/modular.lux
@@ -26,7 +26,7 @@
(def: #export (from-int value)
(Ex [m] (-> Int (Error (Modulus m))))
- (if (i/= 0 value)
+ (if (i/= +0 value)
(ex.throw zero-cannot-be-a-modulus [])
(#e.Success (:abstraction value))))
@@ -52,7 +52,7 @@
(|> sample
(i/- reference)
(i/% (to-int modulus))
- (i/= 0)))
+ (i/= +0)))
(syntax: #export (modulus {modulus s.int})
(case (from-int modulus)
@@ -144,8 +144,8 @@
(def: (i/gcd+ a b)
(-> Int Int [Int Int Int])
- (if (i/= 0 a)
- [0 1 b]
+ (if (i/= +0 a)
+ [+0 +1 b]
(let [[ak bk gcd] (i/gcd+ (i/% a b) a)]
[(i/- (i/* ak
(i// a b))
@@ -158,7 +158,7 @@
(let [[value modulus] (:representation modular)
_modulus (to-int modulus)
[vk mk gcd] (i/gcd+ value _modulus)
- co-prime? (i/= 1 gcd)]
+ co-prime? (i/= +1 gcd)]
(if co-prime?
(#.Some (mod modulus vk))
#.None)))
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index f9ea42c2e..3230ca27e 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -126,23 +126,23 @@
(context: "Simple macros and constructs"
($_ seq
(test "Can write easy loops for iterative programming."
- (i/= 1000
- (loop [counter 0
- value 1]
- (if (i/< 3 counter)
- (recur (inc counter) (i/* 10 value))
+ (i/= +1000
+ (loop [counter +0
+ value +1]
+ (if (i/< +3 counter)
+ (recur (inc counter) (i/* +10 value))
value))))
(test "Can create lists easily through macros."
- (and (case (list 1 2 3)
- (#.Cons 1 (#.Cons 2 (#.Cons 3 #.Nil)))
+ (and (case (list +1 +2 +3)
+ (#.Cons +1 (#.Cons +2 (#.Cons +3 #.Nil)))
#1
_
#0)
- (case (list& 1 2 3 (list 4 5 6))
- (#.Cons 1 (#.Cons 2 (#.Cons 3 (#.Cons 4 (#.Cons 5 (#.Cons 6 #.Nil))))))
+ (case (list& +1 +2 +3 (list +4 +5 +6))
+ (#.Cons +1 (#.Cons +2 (#.Cons +3 (#.Cons +4 (#.Cons +5 (#.Cons +6 #.Nil))))))
#1
_
@@ -217,8 +217,8 @@
(def: (success-message successes failures)
(-> Nat Nat Text)
(format "Test-suite finished." "\n"
- (%i (.int successes)) " out of " (%i (.int (n/+ failures successes))) " tests passed." "\n"
- (%i (.int failures)) " tests failed." "\n"))
+ (%n successes) " out of " (%n (n/+ failures successes)) " tests passed." "\n"
+ (%n failures) " tests failed." "\n"))
(syntax: #export (run)
{#.doc (doc "Runs all the tests defined on the current module, and in all imported modules."
@@ -249,8 +249,8 @@
(exec (log! ((~! success-message) (~ g!total-successes) (~ g!total-failures)))
((~! promise.future)
((~! io.exit) (if (n/> |0 (~ g!total-failures))
- 1
- 0)))))
+ +1
+ +0)))))
[])))))))))
(def: #export (seq left right)
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index d3306f826..688546698 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -223,7 +223,7 @@
## Based on this: https://stackoverflow.com/a/42936293/6823464
(def: (pad value)
(-> Int Text)
- (if (i/< 10 value)
+ (if (i/< +10 value)
(text/compose "0" (int/encode value))
(int/encode value)))
@@ -237,11 +237,11 @@
(def: lex-year
(l.Lexer Int)
(do p.Monad<Parser>
- [sign? (p.maybe (l.this "-"))
+ [sign (p.or (l.this "-") (l.this "+"))
raw-year (p.codec number.Codec<Text,Int> (l.many l.decimal))
- #let [signum (case sign?
- #.None 1
- (#.Some _) -1)]]
+ #let [signum (case sign
+ (#.Left _) -1
+ (#.Right _) +1)]]
(wrap (i/* signum raw-year))))
(def: lex-section
@@ -250,9 +250,9 @@
(def: (leap-years year)
(-> Int Int)
- (|> (i// 4 year)
- (i/- (i// 100 year))
- (i/+ (i// 400 year))))
+ (|> (i// +4 year)
+ (i/- (i// +100 year))
+ (i/+ (i// +400 year))))
(def: normal-months
(Row Nat)
@@ -267,13 +267,13 @@
(def: (divisible? factor input)
(-> Int Int Bit)
- (|> input (i/% factor) (i/= 0)))
+ (|> input (i/% factor) (i/= +0)))
(def: (leap-year? year)
(-> Int Bit)
- (and (divisible? 4 year)
- (or (not (divisible? 100 year))
- (divisible? 400 year))))
+ (and (divisible? +4 year)
+ (or (not (divisible? +100 year))
+ (divisible? +400 year))))
## Based on: https://stackoverflow.com/a/3309340/6823464
(def: lex-date
@@ -283,8 +283,8 @@
_ (l.this "-")
utc-month lex-section
_ (p.assert "Invalid month."
- (and (i/>= 1 utc-month)
- (i/<= 12 utc-month)))
+ (and (i/>= +1 utc-month)
+ (i/<= +12 utc-month)))
#let [months (if (leap-year? utc-year)
leap-year-months
normal-months)
@@ -294,22 +294,22 @@
_ (l.this "-")
utc-day lex-section
_ (p.assert "Invalid day."
- (and (i/>= 1 utc-day)
+ (and (i/>= +1 utc-day)
(i/<= (.int month-days) utc-day)))]
(wrap {#year utc-year
#month (case utc-month
- 1 #January
- 2 #February
- 3 #March
- 4 #April
- 5 #May
- 6 #June
- 7 #July
- 8 #August
- 9 #September
- 10 #October
- 11 #November
- 12 #December
+ +1 #January
+ +2 #February
+ +3 #March
+ +4 #April
+ +5 #May
+ +6 #June
+ +7 #July
+ +8 #August
+ +9 #September
+ +10 #October
+ +11 #November
+ +12 #December
_ (undefined))
#day (.nat utc-day)})))
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 0588d7ba2..1abac1cc0 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -63,21 +63,21 @@
(do-template [<name> <op>]
[(def: #export (<name> duration)
(-> Duration Bit)
- (<op> 0 (:representation duration)))]
+ (<op> +0 (:representation duration)))]
[positive? i/>]
[negative? i/<]
[neutral? i/=])
)
-(def: #export empty Duration (from-millis 0))
-(def: #export milli Duration (from-millis 1))
-(def: #export second Duration (scale 1_000 milli))
-(def: #export minute Duration (scale 60 second))
-(def: #export hour Duration (scale 60 minute))
-(def: #export day Duration (scale 24 hour))
-(def: #export week Duration (scale 7 day))
-(def: #export normal-year Duration (scale 365 day))
+(def: #export empty Duration (from-millis +0))
+(def: #export milli Duration (from-millis +1))
+(def: #export second Duration (scale +1_000 milli))
+(def: #export minute Duration (scale +60 second))
+(def: #export hour Duration (scale +60 minute))
+(def: #export day Duration (scale +24 hour))
+(def: #export week Duration (scale +7 day))
+(def: #export normal-year Duration (scale +365 day))
(def: #export leap-year Duration (merge day normal-year))
(structure: #export _ (Monoid Duration)
@@ -87,7 +87,7 @@
(def: (encode duration)
(-> Duration Text)
(if (:: Equivalence<Duration> = empty duration)
- "0ms"
+ "+0ms"
(let [signed? (negative? duration)
[days time-left] [(query day duration) (frame day duration)]
days (if signed?
@@ -102,38 +102,44 @@
millis (to-millis time-left)]
($_ text/compose
(if signed? "-" "")
- (if (i/= 0 days) "" (text/compose (int/encode days) "D"))
- (if (i/= 0 hours) "" (text/compose (int/encode hours) "h"))
- (if (i/= 0 minutes) "" (text/compose (int/encode minutes) "m"))
- (if (i/= 0 seconds) "" (text/compose (int/encode seconds) "s"))
- (if (i/= 0 millis) "" (text/compose (int/encode millis) "ms"))
+ (if (i/= +0 days) "" (text/compose (int/encode days) "D"))
+ (if (i/= +0 hours) "" (text/compose (int/encode hours) "h"))
+ (if (i/= +0 minutes) "" (text/compose (int/encode minutes) "m"))
+ (if (i/= +0 seconds) "" (text/compose (int/encode seconds) "s"))
+ (if (i/= +0 millis) "" (text/compose (int/encode millis) "ms"))
))))
(def: (lex-section suffix)
(-> Text (l.Lexer Int))
(|> (p.codec number.Codec<Text,Int> (l.many l.decimal))
(p.before (p.and (l.this suffix) (p.not l.alpha)))
- (p.default 0)))
+ (p.default +0)))
(def: lex-duration
(l.Lexer Duration)
(do p.Monad<Parser>
- [signed? (l.this? "-")
- #let [sign (function (_ raw) (if signed? (i/* -1 raw) raw))]
+ [signed? (p.or (l.this? "-") (l.this? "+"))
+ #let [sign (function (_ raw)
+ (case signed?
+ (#.Left _)
+ (i/* -1 raw)
+
+ (#.Right _)
+ raw))]
utc-day (lex-section "D")
utc-hour (lex-section "h")
utc-minute (lex-section "m")
_ (p.assert "Invalid minute."
- (and (i/>= 0 utc-minute)
- (i/<= 59 utc-minute)))
+ (and (i/>= +0 utc-minute)
+ (i/<= +59 utc-minute)))
utc-second (lex-section "s")
_ (p.assert "Invalid second."
- (and (i/>= 0 utc-second)
- (i/<= 59 utc-second)))
+ (and (i/>= +0 utc-second)
+ (i/<= +59 utc-second)))
utc-millis (lex-section "ms")
_ (p.assert "Invalid milli-seconds."
- (and (i/>= 0 utc-millis)
- (i/<= 999 utc-millis)))]
+ (and (i/>= +0 utc-millis)
+ (i/<= +999 utc-millis)))]
(wrap (|> empty
(merge (scale (sign utc-day) day))
(merge (scale (sign utc-hour) hour))
@@ -146,7 +152,7 @@
(l.run input lex-duration))
(structure: #export _
- {#.doc "For example: 15D21h14m51s827ms"}
+ {#.doc "For example: +15D21h14m51s827ms"}
(Codec Text Duration)
(def: encode encode)
(def: decode decode))
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 427f4883e..2119608e9 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -77,20 +77,20 @@
(def: #export epoch
{#.doc "The instant corresponding to 1970-01-01T00:00:00Z"}
Instant
- (from-millis 0))
+ (from-millis +0))
## Codec::encode
(def: (divisible? factor input)
(-> Int Int Bit)
- (|> input (i/% factor) (i/= 0)))
+ (|> input (i/% factor) (i/= +0)))
(def: (leap-year? year)
(-> Int Bit)
- (and (divisible? 4 year)
- (or (not (divisible? 100 year))
- (divisible? 400 year))))
+ (and (divisible? +4 year)
+ (or (not (divisible? +100 year))
+ (divisible? +400 year))))
-(def: epoch-year Int 1970)
+(def: epoch-year Int +1970)
(def: (find-year now)
(-> Instant [Int duration.Duration])
@@ -99,7 +99,7 @@
(let [year (if (leap-year? reference)
duration.leap-year
duration.normal-year)]
- (if (i/= 0 (duration.query year time-left))
+ (if (i/= +0 (duration.query year time-left))
[reference time-left]
(if (duration/>= duration.empty time-left)
(recur (inc reference) (duration.merge (duration.scale -1 year) time-left))
@@ -122,14 +122,14 @@
(if (duration/>= duration.empty time)
(row/fold (function (_ month-days [current-month time-left])
(let [month-duration (duration.scale (.int month-days) duration.day)]
- (if (i/= 0 (duration.query month-duration time-left))
+ (if (i/= +0 (duration.query month-duration time-left))
[current-month time-left]
[(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)])))
[|0 time]
months)
(row/fold (function (_ month-days [current-month time-left])
(let [month-duration (duration.scale (.int month-days) duration.day)]
- (if (i/= 0 (duration.query month-duration time-left))
+ (if (i/= +0 (duration.query month-duration time-left))
[current-month time-left]
[(dec current-month) (duration.merge month-duration time-left)])))
[|11 time]
@@ -137,7 +137,7 @@
(def: (pad value)
(-> Int Text)
- (if (i/< 10 value)
+ (if (i/< +10 value)
(text/compose "0" (int/encode value))
(int/encode value)))
@@ -149,48 +149,48 @@
(def: (encode-millis millis)
(-> Int Text)
- (cond (i/= 0 millis) ""
- (i/< 10 millis) ($_ text/compose ".00" (int/encode millis))
- (i/< 100 millis) ($_ text/compose ".0" (int/encode millis))
- ## (i/< 1_000 millis)
+ (cond (i/= +0 millis) ""
+ (i/< +10 millis) ($_ text/compose ".00" (int/encode millis))
+ (i/< +100 millis) ($_ text/compose ".0" (int/encode millis))
+ ## (i/< +1_000 millis)
($_ text/compose "." (int/encode millis))))
(def: seconds-per-day Int (duration.query duration.second duration.day))
-(def: days-up-to-epoch Int 719468)
+(def: days-up-to-epoch Int +719468)
(def: (extract-date instant)
(-> Instant [[Int Int Int] duration.Duration])
(let [offset (relative instant)
seconds (duration.query duration.second offset)
z (|> seconds (i// seconds-per-day) (i/+ days-up-to-epoch))
- era (i// 146097
- (if (i/>= 0 z)
+ era (i// +146097
+ (if (i/>= +0 z)
z
- (i/- 146096 z)))
- days-of-era (|> z (i/- (i/* 146097 era)))
+ (i/- +146096 z)))
+ days-of-era (|> z (i/- (i/* +146097 era)))
years-of-era (|> days-of-era
- (i/- (i// 1460 days-of-era))
- (i/+ (i// 36524 days-of-era))
- (i/- (i// 146096 days-of-era))
- (i// 365))
- year (|> years-of-era (i/+ (i/* 400 era)))
+ (i/- (i// +1460 days-of-era))
+ (i/+ (i// +36524 days-of-era))
+ (i/- (i// +146096 days-of-era))
+ (i// +365))
+ year (|> years-of-era (i/+ (i/* +400 era)))
days-of-year (|> days-of-era
- (i/- (|> (i/* 365 years-of-era)
- (i/+ (i// 4 years-of-era))
- (i/- (i// 100 years-of-era)))))
+ (i/- (|> (i/* +365 years-of-era)
+ (i/+ (i// +4 years-of-era))
+ (i/- (i// +100 years-of-era)))))
day-time (duration.frame duration.day offset)
days-of-year (if (duration/>= duration.empty day-time)
days-of-year
(dec days-of-year))
- mp (|> days-of-year (i/* 5) (i/+ 2) (i// 153))
+ mp (|> days-of-year (i/* +5) (i/+ +2) (i// +153))
day (|> days-of-year
- (i/- (|> mp (i/* 153) (i/+ 2) (i// 5)))
- (i/+ 1))
+ (i/- (|> mp (i/* +153) (i/+ +2) (i// +5)))
+ (i/+ +1))
month (|> mp
- (i/+ (if (i/< 10 mp)
- 3
+ (i/+ (if (i/< +10 mp)
+ +3
-9)))
- year (if (i/<= 2 month)
+ year (if (i/<= +2 month)
(inc year)
year)]
[[year month day]
@@ -218,11 +218,11 @@
(def: lex-year
(l.Lexer Int)
(do p.Monad<Parser>
- [sign? (p.maybe (l.this "-"))
+ [sign (p.or (l.this "-") (l.this "+"))
raw-year (p.codec number.Codec<Text,Int> (l.many l.decimal))
- #let [signum (case sign?
- #.None 1
- (#.Some _) -1)]]
+ #let [signum (case sign
+ (#.Left _) -1
+ (#.Right _) +1)]]
(wrap (i/* signum raw-year))))
(def: lex-section
@@ -234,13 +234,13 @@
(p.either (|> (l.at-most |3 l.decimal)
(p.codec number.Codec<Text,Int>)
(p.after (l.this ".")))
- (:: p.Monad<Parser> wrap 0)))
+ (:: p.Monad<Parser> wrap +0)))
(def: (leap-years year)
(-> Int Int)
- (|> (i// 4 year)
- (i/- (i// 100 year))
- (i/+ (i// 400 year))))
+ (|> (i// +4 year)
+ (i/- (i// +100 year))
+ (i/+ (i// +400 year))))
## Based on: https://stackoverflow.com/a/3309340/6823464
(def: lex-instant
@@ -250,8 +250,8 @@
_ (l.this "-")
utc-month lex-section
_ (p.assert "Invalid month."
- (and (i/>= 1 utc-month)
- (i/<= 12 utc-month)))
+ (and (i/>= +1 utc-month)
+ (i/<= +12 utc-month)))
#let [months (if (leap-year? utc-year)
leap-year-months
normal-months)
@@ -261,29 +261,29 @@
_ (l.this "-")
utc-day lex-section
_ (p.assert "Invalid day."
- (and (i/>= 1 utc-day)
+ (and (i/>= +1 utc-day)
(i/<= (.int month-days) utc-day)))
_ (l.this "T")
utc-hour lex-section
_ (p.assert "Invalid hour."
- (and (i/>= 0 utc-hour)
- (i/<= 23 utc-hour)))
+ (and (i/>= +0 utc-hour)
+ (i/<= +23 utc-hour)))
_ (l.this ":")
utc-minute lex-section
_ (p.assert "Invalid minute."
- (and (i/>= 0 utc-minute)
- (i/<= 59 utc-minute)))
+ (and (i/>= +0 utc-minute)
+ (i/<= +59 utc-minute)))
_ (l.this ":")
utc-second lex-section
_ (p.assert "Invalid second."
- (and (i/>= 0 utc-second)
- (i/<= 59 utc-second)))
+ (and (i/>= +0 utc-second)
+ (i/<= +59 utc-second)))
utc-millis lex-millis
_ (l.this "Z")
#let [years-since-epoch (i/- epoch-year utc-year)
previous-leap-days (i/- (leap-years epoch-year)
(leap-years (dec utc-year)))
- year-days-so-far (|> (i/* 365 years-since-epoch)
+ year-days-so-far (|> (i/* +365 years-since-epoch)
(i/+ previous-leap-days))
month-days-so-far (|> months
row.to-list
@@ -320,18 +320,18 @@
(let [[[year month day] _] (extract-date instant)]
{#date.year year
#date.month (case (dec month)
- 0 #date.January
- 1 #date.February
- 2 #date.March
- 3 #date.April
- 4 #date.May
- 5 #date.June
- 6 #date.July
- 7 #date.August
- 8 #date.September
- 9 #date.October
- 10 #date.November
- 11 #date.December
+ +0 #date.January
+ +1 #date.February
+ +2 #date.March
+ +3 #date.April
+ +4 #date.May
+ +5 #date.June
+ +6 #date.July
+ +7 #date.August
+ +8 #date.September
+ +9 #date.October
+ +10 #date.November
+ +11 #date.December
_ (undefined))
#date.day (.nat day)}))
@@ -350,16 +350,16 @@
(dec days)
days)
## 1970/01/01 was a Thursday
- y1970m0d0 4]
+ y1970m0d0 +4]
(case (|> y1970m0d0
- (i/+ days) (i/% 7)
+ (i/+ days) (i/% +7)
## This is done to turn negative days into positive days.
- (i/+ 7) (i/% 7))
- 0 #date.Sunday
- 1 #date.Monday
- 2 #date.Tuesday
- 3 #date.Wednesday
- 4 #date.Thursday
- 5 #date.Friday
- 6 #date.Saturday
+ (i/+ +7) (i/% +7))
+ +0 #date.Sunday
+ +1 #date.Monday
+ +2 #date.Tuesday
+ +3 #date.Wednesday
+ +4 #date.Thursday
+ +5 #date.Friday
+ +6 #date.Saturday
_ (undefined))))
diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux
index df714a996..96584a989 100644
--- a/stdlib/source/lux/type/unit.lux
+++ b/stdlib/source/lux/type/unit.lux
@@ -85,10 +85,10 @@
(s.tuple (do p.Monad<Parser>
[numerator s.int
_ (p.assert (format "Numerator must be positive: " (%i numerator))
- (i/> 0 numerator))
+ (i/> +0 numerator))
denominator s.int
_ (p.assert (format "Denominator must be positive: " (%i denominator))
- (i/> 0 denominator))]
+ (i/> +0 denominator))]
(wrap [(.nat numerator) (.nat denominator)]))))
(syntax: #export (scale:
@@ -150,13 +150,13 @@
(i// (.int denominator))
in)))
-(scale: #export Kilo [1 1_000])
-(scale: #export Mega [1 1_000_000])
-(scale: #export Giga [1 1_000_000_000])
+(scale: #export Kilo [+1 +1_000])
+(scale: #export Mega [+1 +1_000_000])
+(scale: #export Giga [+1 +1_000_000_000])
-(scale: #export Milli [ 1_000 1])
-(scale: #export Micro [ 1_000_000 1])
-(scale: #export Nano [1_000_000_000 1])
+(scale: #export Milli [ +1_000 +1])
+(scale: #export Micro [ +1_000_000 +1])
+(scale: #export Nano [+1_000_000_000 +1])
(unit: #export Gram)
(unit: #export Meter)
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index df0bb8278..f52b7764e 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -126,8 +126,8 @@
))))]
["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> |0 |1 |1_000_000 (n/% |1_000) id]
- ["Int" r.int i/= i/+ i/- i/* i// i/% i/> 0 1 1_000_000 (i/% 1_000) id]
- ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1_000_000.0 id math.floor]
+ ["Int" r.int i/= i/+ i/- i/* i// i/% i/> +0 +1 +1_000_000 (i/% +1_000) id]
+ ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> +0.0 +1.0 +1_000_000.0 id math.floor]
["Rev" r.rev r/= r/+ r/- r/* r// r/% r/> .0 (.rev -1) (.rev -1) id id]
)
@@ -145,9 +145,9 @@
(test ""
(|> value -> <- (= value))))))]
- ["Int->Nat" r.int .nat .int i/= (i/% 1_000_000)]
+ ["Int->Nat" r.int .nat .int i/= (i/% +1_000_000)]
["Nat->Int" r.nat .int .nat n/= (n/% |1_000_000)]
- ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% 1_000_000)]
+ ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% +1_000_000)]
["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor]
["Rev->Frac" frac-rev rev-to-frac frac-to-rev r/= id]
)
@@ -155,23 +155,23 @@
(context: "Simple macros and constructs"
($_ seq
(test "Can write easy loops for iterative programming."
- (i/= 1000
- (loop [counter 0
- value 1]
- (if (i/< 3 counter)
- (recur (inc counter) (i/* 10 value))
+ (i/= +1000
+ (loop [counter +0
+ value +1]
+ (if (i/< +3 counter)
+ (recur (inc counter) (i/* +10 value))
value))))
(test "Can create lists easily through macros."
- (and (case (list 1 2 3)
- (#.Cons 1 (#.Cons 2 (#.Cons 3 #.Nil)))
+ (and (case (list +1 +2 +3)
+ (#.Cons +1 (#.Cons +2 (#.Cons +3 #.Nil)))
#1
_
#0)
- (case (list& 1 2 3 (list 4 5 6))
- (#.Cons 1 (#.Cons 2 (#.Cons 3 (#.Cons 4 (#.Cons 5 (#.Cons 6 #.Nil))))))
+ (case (list& +1 +2 +3 (list +4 +5 +6))
+ (#.Cons +1 (#.Cons +2 (#.Cons +3 (#.Cons +4 (#.Cons +5 (#.Cons +6 #.Nil))))))
#1
_
diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux
index 76cc98717..5bd7c09d8 100644
--- a/stdlib/test/test/lux/compiler/default/syntax.lux
+++ b/stdlib/test/test/lux/compiler/default/syntax.lux
@@ -119,7 +119,7 @@
[numerator (|> r.nat (:: @ map (|>> (n/% |100) .int int-to-frac)))
denominator (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1) .int int-to-frac)))
signed? r.bit
- #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 1.0)))]]
+ #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 +1.0)))]]
(test "Can parse frac ratio syntax."
(case (&.read "" (dict.new text.Hash<Text>)
[default-cursor |0
diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux
index 668882485..7ba1a80e9 100644
--- a/stdlib/test/test/lux/concurrency/frp.lux
+++ b/stdlib/test/test/lux/concurrency/frp.lux
@@ -35,7 +35,7 @@
(let [(^open "list/.") (list.Equivalence<List> number.Equivalence<Int>)]
($_ seq
(wrap (do promise.Monad<Promise>
- [#let [values (list 0 1 2 3 4 5)]
+ [#let [values (list +0 +1 +2 +3 +4 +5)]
output (promise.future
(do io.Monad<IO>
[#let [input (: (Channel Int) (frp.channel []))]
@@ -54,12 +54,12 @@
[#let [input (: (Channel Int) (frp.channel []))
elems (frp.filter i/even? input)]
output (read! elems)
- _ (write! (list 0 1 2 3 4 5) input)]
+ _ (write! (list +0 +1 +2 +3 +4 +5) input)]
(wrap output)))
_ (promise.wait |100)
output (promise.future (atom.read output))]
(assert "Can filter a channel's elements."
- (list/= (list 0 2 4)
+ (list/= (list +0 +2 +4)
(list.reverse output)))))
(wrap (do promise.Monad<Promise>
@@ -69,13 +69,13 @@
right (: (Channel Int) (frp.channel []))]
merged (frp.merge (list left right))
output (read! merged)
- _ (write! (list 0 1 2 3 4 5) left)
- _ (write! (list 0 -1 -2 -3 -4 -5) right)]
+ _ (write! (list +0 +1 +2 +3 +4 +5) left)
+ _ (write! (list +0 -1 -2 -3 -4 -5) right)]
(wrap output)))
_ (promise.wait |100)
output (promise.future (atom.read output))]
(assert "Can merge channels."
- (list/= (list 0 1 2 3 4 5 0 -1 -2 -3 -4 -5)
+ (list/= (list +0 +1 +2 +3 +4 +5 +0 -1 -2 -3 -4 -5)
(list.reverse output)))))
(wrap (do promise.Monad<Promise>
@@ -84,12 +84,12 @@
[#let [inputs (: (Channel Int) (frp.channel []))
mapped (:: frp.Functor<Channel> map inc inputs)]
output (read! mapped)
- _ (write! (list 0 1 2 3 4 5) inputs)]
+ _ (write! (list +0 +1 +2 +3 +4 +5) inputs)]
(wrap output)))
_ (promise.wait |100)
output (promise.future (atom.read output))]
(assert "Functor goes over every element in a channel."
- (list/= (list 1 2 3 4 5 6)
+ (list/= (list +1 +2 +3 +4 +5 +6)
(list.reverse output)))))
(wrap (do promise.Monad<Promise>
@@ -100,23 +100,23 @@
output (read! (let [(^open ".") frp.Apply<Channel>]
(apply >f< >a<)))
_ (write! (list inc) >f<)
- _ (write! (list 12345) >a<)]
+ _ (write! (list +12345) >a<)]
(wrap output)))
_ (promise.wait |100)
output (promise.future (atom.read output))]
(assert "Apply works over all channel values."
- (list/= (list 12346)
+ (list/= (list +12346)
(list.reverse output)))))
(wrap (do promise.Monad<Promise>
[output (promise.future
(read! (do frp.Monad<Channel>
[f (frp.from-promise (promise.delay |100 inc))
- a (frp.from-promise (promise.delay |200 12345))]
+ a (frp.from-promise (promise.delay |200 +12345))]
(frp.from-promise (promise.delay |300 (f a))))))
_ (promise.wait |700)
output (promise.future (atom.read output))]
(assert "Valid monad."
- (list/= (list 12346)
+ (list/= (list +12346)
(list.reverse output)))))
)))
diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux
index c4f42a7b7..19ed2000d 100644
--- a/stdlib/test/test/lux/control/parser.lux
+++ b/stdlib/test/test/lux/control/parser.lux
@@ -59,9 +59,9 @@
(context: "Assertions"
(test "Can make assertions while parsing."
(and (match []
- (&.run (list (code.bit #1) (code.int 123))
+ (&.run (list (code.bit #1) (code.int +123))
(&.assert "yolo" #1)))
- (fails? (&.run (list (code.bit #1) (code.int 123))
+ (fails? (&.run (list (code.bit #1) (code.int +123))
(&.assert "yolo" #0))))))
(context: "Combinators [Part 1]"
@@ -96,22 +96,22 @@
(let [positive (: (s.Syntax Int)
(do &.Monad<Parser>
[value s.int
- _ (&.assert "" (i/> 0 value))]
+ _ (&.assert "" (i/> +0 value))]
(wrap value)))]
- (and (match 123
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (match +123
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.either positive s.int)))
(match -123
- (&.run (list (code.int -123) (code.int 456) (code.int 789))
+ (&.run (list (code.int -123) (code.int +456) (code.int +789))
(&.either positive s.int)))
- (fails? (&.run (list (code.bit #1) (code.int 456) (code.int 789))
+ (fails? (&.run (list (code.bit #1) (code.int +456) (code.int +789))
(&.either positive s.int))))))
(test "Can create the opposite/negation of any parser."
- (and (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.not s.int)))
(match []
- (&.run (list (code.bit #1) (code.int 456) (code.int 789))
+ (&.run (list (code.bit #1) (code.int +456) (code.int +789))
(&.not s.int)))))
))
@@ -122,53 +122,53 @@
(&.fail "Well, it really SHOULD fail..."))))
(test "Can apply a parser N times."
- (and (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.exactly |3 s.int)))
- (match (list 123 456)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (match (list +123 +456)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.exactly |2 s.int)))
- (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.exactly |4 s.int)))))
(test "Can apply a parser at-least N times."
- (and (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-least |3 s.int)))
- (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-least |2 s.int)))
- (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-least |4 s.int)))))
(test "Can apply a parser at-most N times."
- (and (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-most |3 s.int)))
- (match (list 123 456)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (match (list +123 +456)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-most |2 s.int)))
- (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.at-most |4 s.int)))))
(test "Can apply a parser between N and M times."
- (and (match (list 123 456 789)
- (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (and (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.between |3 |10 s.int)))
- (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789))
+ (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789))
(&.between |4 |10 s.int)))))
(test "Can parse while taking separators into account."
- (and (match (list 123 456 789)
- (&.run (list (code.int 123) (code.text "YOLO") (code.int 456) (code.text "YOLO") (code.int 789))
+ (and (match (list +123 +456 +789)
+ (&.run (list (code.int +123) (code.text "YOLO") (code.int +456) (code.text "YOLO") (code.int +789))
(&.sep-by (s.this (' "YOLO")) s.int)))
- (match (list 123 456)
- (&.run (list (code.int 123) (code.text "YOLO") (code.int 456) (code.int 789))
+ (match (list +123 +456)
+ (&.run (list (code.int +123) (code.text "YOLO") (code.int +456) (code.int +789))
(&.sep-by (s.this (' "YOLO")) s.int)))))
(test "Can obtain the whole of the remaining input."
(|> &.remaining
- (&.run (list (code.int 123) (code.int 456) (code.int 789)))
- (match (list [_ (#.Int 123)] [_ (#.Int 456)] [_ (#.Int 789)]))))
+ (&.run (list (code.int +123) (code.int +456) (code.int +789)))
+ (match (list [_ (#.Int +123)] [_ (#.Int +456)] [_ (#.Int +789)]))))
))
diff --git a/stdlib/test/test/lux/control/pipe.lux b/stdlib/test/test/lux/control/pipe.lux
index 2cc09fbf8..e5ceaeb19 100644
--- a/stdlib/test/test/lux/control/pipe.lux
+++ b/stdlib/test/test/lux/control/pipe.lux
@@ -14,59 +14,59 @@
(context: "Pipes"
($_ seq
(test "Can dismiss previous pipeline results and begin a new line."
- (|> 20
- (i/* 3)
- (i/+ 4)
- (new> 0 inc)
- (i/= 1)))
+ (|> +20
+ (i/* +3)
+ (i/+ +4)
+ (new> +0 inc)
+ (i/= +1)))
(test "Can give names to piped values within a pipeline's scope."
- (|> 5
+ (|> +5
(let> X [(i/+ X X)])
- (i/= 10)))
+ (i/= +10)))
(test "Can do branching in pipelines."
- (and (|> 5
- (cond> [i/even?] [(i/* 2)]
- [i/odd?] [(i/* 3)]
+ (and (|> +5
+ (cond> [i/even?] [(i/* +2)]
+ [i/odd?] [(i/* +3)]
[(new> -1)])
- (i/= 15))
- (|> 4
- (cond> [i/even?] [(i/* 2)]
- [i/odd?] [(i/* 3)]
+ (i/= +15))
+ (|> +4
+ (cond> [i/even?] [(i/* +2)]
+ [i/odd?] [(i/* +3)]
[])
- (i/= 8))
- (|> 5
- (cond> [i/even?] [(i/* 2)]
+ (i/= +8))
+ (|> +5
+ (cond> [i/even?] [(i/* +2)]
[(new> -1)])
(i/= -1))))
(test "Can loop within pipelines."
- (|> 1
- (loop> [(i/< 10)]
+ (|> +1
+ (loop> [(i/< +10)]
[inc])
- (i/= 10)))
+ (i/= +10)))
(test "Can use monads within pipelines."
- (|> 5
+ (|> +5
(do> Monad<Identity>
- [(i/* 3)]
- [(i/+ 4)]
+ [(i/* +3)]
+ [(i/+ +4)]
[inc])
- (i/= 20)))
+ (i/= +20)))
(test "Can pattern-match against piped values."
- (|> 5
- (case> 0 "zero"
- 1 "one"
- 2 "two"
- 3 "three"
- 4 "four"
- 5 "five"
- 6 "six"
- 7 "seven"
- 8 "eight"
- 9 "nine"
+ (|> +5
+ (case> +0 "zero"
+ +1 "one"
+ +2 "two"
+ +3 "three"
+ +4 "four"
+ +5 "five"
+ +6 "six"
+ +7 "seven"
+ +8 "eight"
+ +9 "nine"
_ "???")
(text/= "five")))
))
diff --git a/stdlib/test/test/lux/control/reader.lux b/stdlib/test/test/lux/control/reader.lux
index 135cce4ee..57f487426 100644
--- a/stdlib/test/test/lux/control/reader.lux
+++ b/stdlib/test/test/lux/control/reader.lux
@@ -11,27 +11,27 @@
(let [(^open "&/.") &.Apply<Reader>
(^open "&/.") &.Monad<Reader>]
($_ seq
- (test "" (i/= 123 (&.run 123 &.ask)))
- (test "" (i/= 246 (&.run 123 (&.local (i/* 2) &.ask))))
- (test "" (i/= 134 (&.run 123 (&/map inc (i/+ 10)))))
- (test "" (i/= 10 (&.run 123 (&/wrap 10))))
- (test "" (i/= 30 (&.run 123 (&/apply (&/wrap (i/+ 10)) (&/wrap 20)))))
- (test "" (i/= 30 (&.run 123 (do &.Monad<Reader>
- [f (wrap i/+)
- x (wrap 10)
- y (wrap 20)]
- (wrap (f x y)))))))))
+ (test "" (i/= +123 (&.run +123 &.ask)))
+ (test "" (i/= +246 (&.run +123 (&.local (i/* +2) &.ask))))
+ (test "" (i/= +134 (&.run +123 (&/map inc (i/+ +10)))))
+ (test "" (i/= +10 (&.run +123 (&/wrap +10))))
+ (test "" (i/= +30 (&.run +123 (&/apply (&/wrap (i/+ +10)) (&/wrap +20)))))
+ (test "" (i/= +30 (&.run +123 (do &.Monad<Reader>
+ [f (wrap i/+)
+ x (wrap +10)
+ y (wrap +20)]
+ (wrap (f x y)))))))))
(context: "Monad transformer"
(let [(^open "io/.") io.Monad<IO>]
(test "Can add reader functionality to any monad."
(|> (: (&.Reader Text (io.IO Int))
(do (&.ReaderT io.Monad<IO>)
- [a (&.lift (io/wrap 123))
- b (wrap 456)]
+ [a (&.lift (io/wrap +123))
+ b (wrap +456)]
(wrap (i/+ a b))))
(&.run "")
io.run
- (case> 579 #1
- _ #0)))
+ (case> +579 #1
+ _ #0)))
))
diff --git a/stdlib/test/test/lux/control/writer.lux b/stdlib/test/test/lux/control/writer.lux
index 6b31046ea..de8bdc599 100644
--- a/stdlib/test/test/lux/control/writer.lux
+++ b/stdlib/test/test/lux/control/writer.lux
@@ -15,18 +15,18 @@
(^open "&/.") (&.Apply<Writer> text.Monoid<Text>)]
($_ seq
(test "Functor respects Writer."
- (i/= 11 (product.right (&/map inc ["" 10]))))
+ (i/= +11 (product.right (&/map inc ["" +10]))))
(test "Apply respects Writer."
- (and (i/= 20 (product.right (&/wrap 20)))
- (i/= 30 (product.right (&/apply (&/wrap (i/+ 10)) (&/wrap 20))))))
+ (and (i/= +20 (product.right (&/wrap +20)))
+ (i/= +30 (product.right (&/apply (&/wrap (i/+ +10)) (&/wrap +20))))))
(test "Monad respects Writer."
- (i/= 30 (product.right (do (&.Monad<Writer> text.Monoid<Text>)
- [f (wrap i/+)
- a (wrap 10)
- b (wrap 20)]
- (wrap (f a b))))))
+ (i/= +30 (product.right (do (&.Monad<Writer> text.Monoid<Text>)
+ [f (wrap i/+)
+ a (wrap +10)
+ b (wrap +20)]
+ (wrap (f a b))))))
(test "Can log any value."
(text/= "YOLO" (product.left (&.log "YOLO"))))
@@ -37,9 +37,9 @@
(^open "io/.") io.Monad<IO>]
(test "Can add writer functionality to any monad."
(|> (io.run (do (&.WriterT text.Monoid<Text> io.Monad<IO>)
- [a (lift (io/wrap 123))
- b (wrap 456)]
+ [a (lift (io/wrap +123))
+ b (wrap +456)]
(wrap (i/+ a b))))
- (case> ["" 579] #1
- _ #0)))
+ (case> ["" +579] #1
+ _ #0)))
))
diff --git a/stdlib/test/test/lux/data/collection/list.lux b/stdlib/test/test/lux/data/collection/list.lux
index 9a8b4a4cd..dbe92f70a 100644
--- a/stdlib/test/test/lux/data/collection/list.lux
+++ b/stdlib/test/test/lux/data/collection/list.lux
@@ -232,8 +232,8 @@
(^open "io/.") io.Monad<IO>]
(test "Can add list functionality to any monad."
(|> (io.run (do (&.ListT io.Monad<IO>)
- [a (lift (io/wrap 123))
- b (wrap 456)]
+ [a (lift (io/wrap +123))
+ b (wrap +456)]
(wrap (i/+ a b))))
- (case> (^ (list 579)) #1
- _ #0)))))
+ (case> (^ (list +579)) #1
+ _ #0)))))
diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux
index d8e93aa5e..7d584ab4b 100644
--- a/stdlib/test/test/lux/data/color.lux
+++ b/stdlib/test/test/lux/data/color.lux
@@ -18,18 +18,18 @@
(-> Nat Frac)
(|>> .int int-to-frac))
-(def: square (-> Frac Frac) (math.pow 2.0))
+(def: square (-> Frac Frac) (math.pow +2.0))
(def: (distance from to)
(-> @.Color @.Color Frac)
(let [[fr fg fb] (@.unpack from)
[tr tg tb] (@.unpack to)]
- (math.pow 0.5 ($_ f/+
- (|> (scale tr) (f/- (scale fr)) square)
- (|> (scale tg) (f/- (scale fg)) square)
- (|> (scale tb) (f/- (scale fb)) square)))))
+ (math.pow +0.5 ($_ f/+
+ (|> (scale tr) (f/- (scale fr)) square)
+ (|> (scale tg) (f/- (scale fg)) square)
+ (|> (scale tb) (f/- (scale fb)) square)))))
-(def: error-margin Frac 1.8)
+(def: error-margin Frac +1.8)
(def: black @.Color (@.color [|0 |0 |0]))
(def: white @.Color (@.color [|255 |255 |255]))
@@ -49,14 +49,14 @@
(do @
[any color
colorful (|> color
- (r.filter (function (_ color) (|> (distance color black) (f/>= 100.0))))
- (r.filter (function (_ color) (|> (distance color white) (f/>= 100.0)))))
+ (r.filter (function (_ color) (|> (distance color black) (f/>= +100.0))))
+ (r.filter (function (_ color) (|> (distance color white) (f/>= +100.0)))))
mediocre (|> color
(r.filter (|>> saturation
((function (_ saturation)
- (and (f/>= 0.25 saturation)
- (f/<= 0.75 saturation)))))))
- ratio (|> r.frac (r.filter (f/>= 0.5)))]
+ (and (f/>= +0.25 saturation)
+ (f/<= +0.75 saturation)))))))
+ ratio (|> r.frac (r.filter (f/>= +0.5)))]
($_ seq
(test "Has equivalence."
(:: @.Equivalence<Color> = any any))
@@ -90,7 +90,7 @@
(saturation (@.de-saturate ratio mediocre))))
(test "Can gray-scale color."
(let [gray'ed (@.gray-scale mediocre)]
- (and (f/= 0.0
+ (and (f/= +0.0
(saturation gray'ed))
(|> (luminance gray'ed)
(f/- (luminance mediocre))
diff --git a/stdlib/test/test/lux/data/error.lux b/stdlib/test/test/lux/data/error.lux
index bea6146aa..30a12855d 100644
--- a/stdlib/test/test/lux/data/error.lux
+++ b/stdlib/test/test/lux/data/error.lux
@@ -13,9 +13,9 @@
(^open "&/.") &.Monad<Error>]
($_ seq
(test "Functor correctly handles both cases."
- (and (|> (: (&.Error Int) (#&.Success 10))
+ (and (|> (: (&.Error Int) (#&.Success +10))
(&/map inc)
- (case> (#&.Success 11) #1 _ #0))
+ (case> (#&.Success +11) #1 _ #0))
(|> (: (&.Error Int) (#&.Error "YOLO"))
(&/map inc)
@@ -23,24 +23,24 @@
))
(test "Apply correctly handles both cases."
- (and (|> (&/wrap 20)
- (case> (#&.Success 20) #1 _ #0))
- (|> (&/apply (&/wrap inc) (&/wrap 10))
- (case> (#&.Success 11) #1 _ #0))
+ (and (|> (&/wrap +20)
+ (case> (#&.Success +20) #1 _ #0))
+ (|> (&/apply (&/wrap inc) (&/wrap +10))
+ (case> (#&.Success +11) #1 _ #0))
(|> (&/apply (&/wrap inc) (#&.Error "YOLO"))
(case> (#&.Error "YOLO") #1 _ #0))))
(test "Monad correctly handles both cases."
(and (|> (do &.Monad<Error>
[f (wrap i/+)
- a (wrap 10)
- b (wrap 20)]
+ a (wrap +10)
+ b (wrap +20)]
(wrap (f a b)))
- (case> (#&.Success 30) #1 _ #0))
+ (case> (#&.Success +30) #1 _ #0))
(|> (do &.Monad<Error>
[f (wrap i/+)
a (#&.Error "YOLO")
- b (wrap 20)]
+ b (wrap +20)]
(wrap (f a b)))
(case> (#&.Error "YOLO") #1 _ #0))
))
@@ -51,8 +51,8 @@
(^open "io/.") io.Monad<IO>]
(test "Can add error functionality to any monad."
(|> (io.run (do (&.ErrorT io.Monad<IO>)
- [a (lift (io/wrap 123))
- b (wrap 456)]
+ [a (lift (io/wrap +123))
+ b (wrap +456)]
(wrap (i/+ a b))))
- (case> (#&.Success 579) #1
- _ #0)))))
+ (case> (#&.Success +579) #1
+ _ #0)))))
diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux
index 5333cfb0e..a898a2c97 100644
--- a/stdlib/test/test/lux/data/format/json.lux
+++ b/stdlib/test/test/lux/data/format/json.lux
@@ -48,7 +48,7 @@
($_ r.or
(:: @ wrap [])
r.bit
- (|> r.frac (:: @ map (f/* 1_000_000.0)))
+ (|> r.frac (:: @ map (f/* +1_000_000.0)))
(r.unicode size)
(r.row size gen-json)
(r.dictionary text.Hash<Text> size (r.unicode size) gen-json)
diff --git a/stdlib/test/test/lux/data/maybe.lux b/stdlib/test/test/lux/data/maybe.lux
index 95ee39d91..4f135b68a 100644
--- a/stdlib/test/test/lux/data/maybe.lux
+++ b/stdlib/test/test/lux/data/maybe.lux
@@ -49,8 +49,8 @@
(let [lift (&.lift io.Monad<IO>)]
(test "Can add maybe functionality to any monad."
(|> (io.run (do (&.MaybeT io.Monad<IO>)
- [a (lift (io/wrap 123))
- b (wrap 456)]
+ [a (lift (io/wrap +123))
+ b (wrap +456)]
(wrap (i/+ a b))))
- (case> (#.Some 579) #1
- _ #0)))))
+ (case> (#.Some +579) #1
+ _ #0)))))
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux
index 8e9a867da..c8e436d1d 100644
--- a/stdlib/test/test/lux/data/number.lux
+++ b/stdlib/test/test/lux/data/number.lux
@@ -87,7 +87,7 @@
["Int" r.int Number<Int> Order<Int> Interval<Int> (function (_ _) #1)]
## Both min and max values will be positive (thus, greater than zero)
["Rev" r.rev Number<Rev> Order<Rev> Interval<Rev> (function (_ _) #1)]
- ["Frac" r.frac Number<Frac> Order<Frac> Interval<Frac> (f/> 0.0)]
+ ["Frac" r.frac Number<Frac> Order<Frac> Interval<Frac> (f/> +0.0)]
)
(do-template [category rand-gen <Number> <Order> <Monoid> <cap> <test>]
@@ -107,18 +107,18 @@
["Nat/Mul" r.nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n/% |1000) (function (_ _) #1)]
["Nat/Min" r.nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n/% |1000) (function (_ _) #1)]
["Nat/Max" r.nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n/% |1000) (function (_ _) #1)]
- ["Int/Add" r.int Number<Int> Order<Int> Add@Monoid<Int> (i/% 1000) (function (_ _) #1)]
- ["Int/Mul" r.int Number<Int> Order<Int> Mul@Monoid<Int> (i/% 1000) (function (_ _) #1)]
- ["Int/Min" r.int Number<Int> Order<Int> Min@Monoid<Int> (i/% 1000) (function (_ _) #1)]
- ["Int/Max" r.int Number<Int> Order<Int> Max@Monoid<Int> (i/% 1000) (function (_ _) #1)]
+ ["Int/Add" r.int Number<Int> Order<Int> Add@Monoid<Int> (i/% +1000) (function (_ _) #1)]
+ ["Int/Mul" r.int Number<Int> Order<Int> Mul@Monoid<Int> (i/% +1000) (function (_ _) #1)]
+ ["Int/Min" r.int Number<Int> Order<Int> Min@Monoid<Int> (i/% +1000) (function (_ _) #1)]
+ ["Int/Max" r.int Number<Int> Order<Int> Max@Monoid<Int> (i/% +1000) (function (_ _) #1)]
["Rev/Add" r.rev Number<Rev> Order<Rev> Add@Monoid<Rev> (r/% .125) (function (_ _) #1)]
["Rev/Mul" r.rev Number<Rev> Order<Rev> Mul@Monoid<Rev> (r/% .125) (function (_ _) #1)]
["Rev/Min" r.rev Number<Rev> Order<Rev> Min@Monoid<Rev> (r/% .125) (function (_ _) #1)]
["Rev/Max" r.rev Number<Rev> Order<Rev> Max@Monoid<Rev> (r/% .125) (function (_ _) #1)]
- ["Frac/Add" r.frac Number<Frac> Order<Frac> Add@Monoid<Frac> (f/% 1000.0) (f/> 0.0)]
- ["Frac/Mul" r.frac Number<Frac> Order<Frac> Mul@Monoid<Frac> (f/% 1000.0) (f/> 0.0)]
- ["Frac/Min" r.frac Number<Frac> Order<Frac> Min@Monoid<Frac> (f/% 1000.0) (f/> 0.0)]
- ["Frac/Max" r.frac Number<Frac> Order<Frac> Max@Monoid<Frac> (f/% 1000.0) (f/> 0.0)]
+ ["Frac/Add" r.frac Number<Frac> Order<Frac> Add@Monoid<Frac> (f/% +1000.0) (f/> +0.0)]
+ ["Frac/Mul" r.frac Number<Frac> Order<Frac> Mul@Monoid<Frac> (f/% +1000.0) (f/> +0.0)]
+ ["Frac/Min" r.frac Number<Frac> Order<Frac> Min@Monoid<Frac> (f/% +1000.0) (f/> +0.0)]
+ ["Frac/Max" r.frac Number<Frac> Order<Frac> Max@Monoid<Frac> (f/% +1000.0) (f/> +0.0)]
)
(do-template [<category> <rand-gen> <Equivalence> <Codec>]
@@ -170,14 +170,14 @@
($_ seq
(test "Binary."
(and (n/= (bin "|11001001") (bin "|11_00_10_01"))
- (i/= (bin "11001001") (bin "11_00_10_01"))
+ (i/= (bin "+11001001") (bin "+11_00_10_01"))
(r/= (bin ".11001001") (bin ".11_00_10_01"))
- (f/= (bin "1100.1001") (bin "11_00.10_01"))))
+ (f/= (bin "+1100.1001") (bin "+11_00.10_01"))))
(test "Octal."
(and (n/= (oct "|615243") (oct "|615_243"))
- (i/= (oct "615243") (oct "615_243"))
+ (i/= (oct "+615243") (oct "+615_243"))
(r/= (oct ".615243") (oct ".615_243"))
- (f/= (oct "6152.43") (oct "615_2.43"))))
+ (f/= (oct "+6152.43") (oct "+615_2.43"))))
(test "Hexadecimal."
(and (n/= (hex "|deadBEEF") (hex "|dead_BEEF"))
(i/= (hex "deadBEEF") (hex "dead_BEEF"))
diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux
index 0d66cf1af..994e1cafb 100644
--- a/stdlib/test/test/lux/data/number/complex.lux
+++ b/stdlib/test/test/lux/data/number/complex.lux
@@ -12,7 +12,7 @@
["r" random]]]
lux/test)
-(def: margin-of-error Frac 1.0e-9)
+(def: margin-of-error Frac +1.0e-9)
(def: (within? margin standard value)
(-> Frac &.Complex &.Complex Bit)
@@ -27,7 +27,7 @@
(r.Random Frac)
(do r.Monad<Random>
[factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1))))
- measure (|> r.frac (r.filter (f/> 0.0)))]
+ measure (|> r.frac (r.filter (f/> +0.0)))]
(wrap (f/* (|> factor .int int-to-frac)
measure))))
@@ -116,7 +116,7 @@
floored (|> quotient
(update@ #&.real math.floor)
(update@ #&.imaginary math.floor))]
- (within? 0.000000000001
+ (within? +0.000000000001
x
(|> quotient (&.* y) (&.+ rem)))))
))))
@@ -141,9 +141,9 @@
(test "Absolute value of signum is always root2(2), 1 or 0."
(let [signum-abs (|> x &.signum &.abs (get@ #&.real))]
- (or (f/= 0.0 signum-abs)
- (f/= 1.0 signum-abs)
- (f/= (math.pow 0.5 2.0) signum-abs))))
+ (or (f/= +0.0 signum-abs)
+ (f/= +1.0 signum-abs)
+ (f/= (math.pow +0.5 +2.0) signum-abs))))
(test "Negation is its own inverse."
(let [there (&.negate x)
@@ -165,8 +165,8 @@
(<| (seed |17274883666004960943)
## (times |100)
(do @
- [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% 1.0))
- (update@ #&.imaginary (f/% 1.0)))))]
+ [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% +1.0))
+ (update@ #&.imaginary (f/% +1.0)))))]
($_ seq
(test "Arc-sine is the inverse of sine."
(trigonometric-symmetry &.sin &.asin angle))
@@ -183,7 +183,7 @@
[x gen-complex]
($_ seq
(test "Root 2 is inverse of power 2."
- (|> x (&.pow' 2.0) (&.pow' 0.5) (within? margin-of-error x)))
+ (|> x (&.pow' +2.0) (&.pow' +0.5) (within? margin-of-error x)))
(test "Logarithm is inverse of exponentiation."
(|> x &.log &.exp (within? margin-of-error x)))
diff --git a/stdlib/test/test/lux/data/number/i64.lux b/stdlib/test/test/lux/data/number/i64.lux
index 2868b91a6..96a174eaa 100644
--- a/stdlib/test/test/lux/data/number/i64.lux
+++ b/stdlib/test/test/lux/data/number/i64.lux
@@ -69,7 +69,7 @@
(n/= pattern))))
(test "Shift right respect the sign of ints."
(let [value (.int pattern)]
- (if (i/< 0 value)
- (i/< 0 (&.arithmetic-right-shift idx value))
- (i/>= 0 (&.arithmetic-right-shift idx value)))))
+ (if (i/< +0 value)
+ (i/< +0 (&.arithmetic-right-shift idx value))
+ (i/>= +0 (&.arithmetic-right-shift idx value)))))
))))
diff --git a/stdlib/test/test/lux/data/product.lux b/stdlib/test/test/lux/data/product.lux
index 440ccf62c..86db80d0e 100644
--- a/stdlib/test/test/lux/data/product.lux
+++ b/stdlib/test/test/lux/data/product.lux
@@ -7,11 +7,11 @@
(context: "Products"
($_ seq
(test "Can access the sides of a pair."
- (and (i/= 1 (@.left [1 2]))
- (i/= 2 (@.right [1 2]))))
+ (and (i/= +1 (@.left [+1 +2]))
+ (i/= +2 (@.right [+1 +2]))))
(test "Can swap the sides of a pair."
- (let [[_left _right] (@.swap [1 2])]
- (and (i/= 2 _left)
- (i/= 1 _right))))
+ (let [[_left _right] (@.swap [+1 +2])]
+ (and (i/= +2 _left)
+ (i/= +1 _right))))
))
diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux
index 23dfd6078..4023c1cc3 100644
--- a/stdlib/test/test/lux/data/sum.lux
+++ b/stdlib/test/test/lux/data/sum.lux
@@ -18,20 +18,20 @@
(test "Can discriminate eithers based on their cases."
(let [[_lefts _rights] (partition (: (List (| Text Text))
- (list (|0 "0") (|1 "1") (|0 "2"))))]
+ (list (|0 "+0") (|1 "+1") (|0 "+2"))))]
(and (List/= _lefts
(lefts (: (List (| Text Text))
- (list (|0 "0") (|1 "1") (|0 "2")))))
+ (list (|0 "+0") (|1 "+1") (|0 "+2")))))
(List/= _rights
(rights (: (List (| Text Text))
- (list (|0 "0") (|1 "1") (|0 "2"))))))))
+ (list (|0 "+0") (|1 "+1") (|0 "+2"))))))))
(test "Can apply a function to an Either value depending on the case."
- (and (i/= 10 (either (function (_ _) 10)
- (function (_ _) 20)
- (: (| Text Text) (|0 ""))))
- (i/= 20 (either (function (_ _) 10)
- (function (_ _) 20)
- (: (| Text Text) (|1 ""))))))
+ (and (i/= +10 (either (function (_ _) +10)
+ (function (_ _) +20)
+ (: (| Text Text) (|0 ""))))
+ (i/= +20 (either (function (_ _) +10)
+ (function (_ _) +20)
+ (: (| Text Text) (|1 ""))))))
)))
diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux
index b66ee9f8e..adf4cdf7b 100644
--- a/stdlib/test/test/lux/data/text/format.lux
+++ b/stdlib/test/test/lux/data/text/format.lux
@@ -13,9 +13,9 @@
(test "Can format common values simply."
(and (&/= "#1" (%b #1))
(&/= "|123" (%n |123))
- (&/= "123" (%i 123))
- (&/= "123.456" (%f 123.456))
+ (&/= "+123" (%i +123))
+ (&/= "+123.456" (%f +123.456))
(&/= ".5" (%r .5))
(&/= "\"YOLO\"" (%t "YOLO"))
- (&/= "User-id: 123 -- Active: #1" (format "User-id: " (%i 123) " -- Active: " (%b #1)))))
+ (&/= "User-id: +123 -- Active: #1" (format "User-id: " (%i +123) " -- Active: " (%b #1)))))
)))
diff --git a/stdlib/test/test/lux/host.js.lux b/stdlib/test/test/lux/host.js.lux
index cba72d0ae..faf9f6b5f 100644
--- a/stdlib/test/test/lux/host.js.lux
+++ b/stdlib/test/test/lux/host.js.lux
@@ -21,8 +21,8 @@
(is? "BAR")))
(test "Can call JavaScript functions"
- (and (is? 124.0
- (&.call! (&.ref "Math.ceil" &.Function) [123.45] Frac))
- (is? 124.0
- (&.call! (&.ref "Math") "ceil" [123.45] Frac))))
+ (and (is? +124.0
+ (&.call! (&.ref "Math.ceil" &.Function) [+123.45] Frac))
+ (is? +124.0
+ (&.call! (&.ref "Math") "ceil" [+123.45] Frac))))
))
diff --git a/stdlib/test/test/lux/io.lux b/stdlib/test/test/lux/io.lux
index 1cef1097d..66cd4a730 100644
--- a/stdlib/test/test/lux/io.lux
+++ b/stdlib/test/test/lux/io.lux
@@ -12,13 +12,13 @@
(context: "I/O"
($_ seq
(test "" (text/= "YOLO" (&.run (&.io "YOLO"))))
- (test "" (i/= 11 (&.run (:: &.Functor<IO> map inc (&.io 10)))))
- (test "" (i/= 10 (&.run (:: &.Monad<IO> wrap 10))))
- (test "" (i/= 30 (&.run (let [(^open "&/.") &.Apply<IO>
- (^open "&/.") &.Monad<IO>]
- (&/apply (&/wrap (i/+ 10)) (&/wrap 20))))))
- (test "" (i/= 30 (&.run (do &.Monad<IO>
- [f (wrap i/+)
- x (wrap 10)
- y (wrap 20)]
- (wrap (f x y))))))))
+ (test "" (i/= +11 (&.run (:: &.Functor<IO> map inc (&.io +10)))))
+ (test "" (i/= +10 (&.run (:: &.Monad<IO> wrap +10))))
+ (test "" (i/= +30 (&.run (let [(^open "&/.") &.Apply<IO>
+ (^open "&/.") &.Monad<IO>]
+ (&/apply (&/wrap (i/+ +10)) (&/wrap +20))))))
+ (test "" (i/= +30 (&.run (do &.Monad<IO>
+ [f (wrap i/+)
+ x (wrap +10)
+ y (wrap +20)]
+ (wrap (f x y))))))))
diff --git a/stdlib/test/test/lux/macro/code.lux b/stdlib/test/test/lux/macro/code.lux
index d4739c894..1e0d4a606 100644
--- a/stdlib/test/test/lux/macro/code.lux
+++ b/stdlib/test/test/lux/macro/code.lux
@@ -18,17 +18,17 @@
(and (text/= <text> (&.to-text <expr>))
(:: &.Equivalence<Code> = <expr> <expr>)))]
- [(&.bit #1) "#1"]
- [(&.bit #0) "#0"]
- [(&.int 123) "123"]
- [(&.frac 123.0) "123.0"]
- [(&.text "\n") "\"\\n\""]
- [(&.tag ["yolo" "lol"]) "#yolo.lol"]
- [(&.identifier ["yolo" "lol"]) "yolo.lol"]
- [(&.form (list (&.bit #1) (&.int 123))) "(#1 123)"]
- [(&.tuple (list (&.bit #1) (&.int 123))) "[#1 123]"]
- [(&.record (list [(&.bit #1) (&.int 123)])) "{#1 123}"]
- [(&.local-tag "lol") "#lol"]
- [(&.local-identifier "lol") "lol"]
+ [(&.bit #1) "#1"]
+ [(&.bit #0) "#0"]
+ [(&.int +123) "+123"]
+ [(&.frac +123.0) "+123.0"]
+ [(&.text "\n") "\"\\n\""]
+ [(&.tag ["yolo" "lol"]) "#yolo.lol"]
+ [(&.identifier ["yolo" "lol"]) "yolo.lol"]
+ [(&.form (list (&.bit #1) (&.int +123))) "(#1 +123)"]
+ [(&.tuple (list (&.bit #1) (&.int +123))) "[#1 +123]"]
+ [(&.record (list [(&.bit #1) (&.int +123)])) "{#1 +123}"]
+ [(&.local-tag "lol") "#lol"]
+ [(&.local-identifier "lol") "lol"]
)]
($_ seq <tests>)))
diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux
index 061b5714d..5d7cfee64 100644
--- a/stdlib/test/test/lux/macro/poly/equivalence.lux
+++ b/stdlib/test/test/lux/macro/poly/equivalence.lux
@@ -49,7 +49,7 @@
(r.Random Record)
(do r.Monad<Random>
[size (:: @ map (n/% |2) r.nat)
- #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]]
+ #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% +1_000_000))))]]
($_ r.and
r.bit
gen-int
diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux
index 4f6a29a05..63d592251 100644
--- a/stdlib/test/test/lux/macro/syntax.lux
+++ b/stdlib/test/test/lux/macro/syntax.lux
@@ -74,9 +74,9 @@
["Can parse Bit syntax." #1 code.bit bit.Equivalence<Bit> s.bit]
["Can parse Nat syntax." |123 code.nat number.Equivalence<Nat> s.nat]
- ["Can parse Int syntax." 123 code.int number.Equivalence<Int> s.int]
+ ["Can parse Int syntax." +123 code.int number.Equivalence<Int> s.int]
["Can parse Rev syntax." .123 code.rev number.Equivalence<Rev> s.rev]
- ["Can parse Frac syntax." 123.0 code.frac number.Equivalence<Frac> s.frac]
+ ["Can parse Frac syntax." +123.0 code.frac number.Equivalence<Frac> s.frac]
["Can parse Text syntax." "\n" code.text text.Equivalence<Text> s.text]
["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.Equivalence<Name> s.identifier]
["Can parse Tag syntax." ["yolo" "lol"] code.tag name.Equivalence<Name> s.tag]
@@ -103,21 +103,21 @@
(with-expansions
[<group-tests> (do-template [<type> <parser> <ctor>]
[(test (format "Can parse " <type> " syntax.")
- (and (match [#1 123]
- (p.run (list (<ctor> (list (code.bit #1) (code.int 123))))
+ (and (match [#1 +123]
+ (p.run (list (<ctor> (list (code.bit #1) (code.int +123))))
(<parser> (p.and s.bit s.int))))
(match #1
(p.run (list (<ctor> (list (code.bit #1))))
(<parser> s.bit)))
- (fails? (p.run (list (<ctor> (list (code.bit #1) (code.int 123))))
+ (fails? (p.run (list (<ctor> (list (code.bit #1) (code.int +123))))
(<parser> s.bit)))
(match (#.Left #1)
(p.run (list (<ctor> (list (code.bit #1))))
(<parser> (p.or s.bit s.int))))
- (match (#.Right 123)
- (p.run (list (<ctor> (list (code.int 123))))
+ (match (#.Right +123)
+ (p.run (list (<ctor> (list (code.int +123))))
(<parser> (p.or s.bit s.int))))
- (fails? (p.run (list (<ctor> (list (code.frac 123.0))))
+ (fails? (p.run (list (<ctor> (list (code.frac +123.0))))
(<parser> (p.or s.bit s.int))))))]
["form" s.form code.form]
@@ -126,8 +126,8 @@
<group-tests>
(test "Can parse record syntax."
- (match [#1 123]
- (p.run (list (code.record (list [(code.bit #1) (code.int 123)])))
+ (match [#1 +123]
+ (p.run (list (code.record (list [(code.bit #1) (code.int +123)])))
(s.record (p.and s.bit s.int)))))
)))
@@ -135,7 +135,7 @@
($_ seq
(test "Can parse any Code."
(match [_ (#.Bit #1)]
- (p.run (list (code.bit #1) (code.int 123))
+ (p.run (list (code.bit #1) (code.int +123))
s.any)))
(test "Can check whether the end has been reached."
diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux
index eb086243f..83ed1f8b0 100644
--- a/stdlib/test/test/lux/math.lux
+++ b/stdlib/test/test/lux/math.lux
@@ -14,7 +14,7 @@
(f/< margin-of-error
(frac/abs (f/- standard value))))
-(def: margin Frac 0.0000001)
+(def: margin Frac +0.0000001)
(def: (trigonometric-symmetry forward backward angle)
(-> (-> Frac Frac) (-> Frac Frac) Frac Bit)
@@ -39,32 +39,32 @@
(context: "Rounding"
(<| (times |100)
(do @
- [sample (|> r.frac (:: @ map (f/* 1000.0)))]
+ [sample (|> r.frac (:: @ map (f/* +1000.0)))]
($_ seq
(test "The ceiling will be an integer value, and will be >= the original."
(let [ceil'd (&.ceil sample)]
(and (|> ceil'd frac-to-int int-to-frac (f/= ceil'd))
(f/>= sample ceil'd)
- (f/<= 1.0 (f/- sample ceil'd)))))
+ (f/<= +1.0 (f/- sample ceil'd)))))
(test "The floor will be an integer value, and will be <= the original."
(let [floor'd (&.floor sample)]
(and (|> floor'd frac-to-int int-to-frac (f/= floor'd))
(f/<= sample floor'd)
- (f/<= 1.0 (f/- floor'd sample)))))
+ (f/<= +1.0 (f/- floor'd sample)))))
(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"
(<| (times |100)
(do @
- [sample (|> r.frac (:: @ map (f/* 10.0)))]
+ [sample (|> r.frac (:: @ map (f/* +10.0)))]
(test "Logarithm is the inverse of exponential."
- (|> sample &.exp &.log (within? 1.0e-15 sample))))))
+ (|> sample &.exp &.log (within? +1.0e-15 sample))))))
(context: "Greatest-Common-Divisor and Least-Common-Multiple"
(<| (times |100)
diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux
index 4d4ae3d8d..43f7d178e 100644
--- a/stdlib/test/test/lux/math/modular.lux
+++ b/stdlib/test/test/lux/math/modular.lux
@@ -14,18 +14,18 @@
[type ("type/." Equivalence<Type>)]]
lux/test)
-(def: %3 (/.modulus 3))
+(def: %3 (/.modulus +3))
(`` (type: Mod3 (~~ (:of %3))))
(def: modulusR
(r.Random Int)
(|> r.int
- (:: r.Monad<Random> map (i/% 1000))
- (r.filter (|>> (i/= 0) not))))
+ (:: r.Monad<Random> map (i/% +1000))
+ (r.filter (|>> (i/= +0) not))))
(def: valueR
(r.Random Int)
- (|> r.int (:: r.Monad<Random> map (i/% 1000))))
+ (|> r.int (:: r.Monad<Random> map (i/% +1000))))
(def: (modR modulus)
(All [m] (-> (/.Modulus m) (r.Random [Int (/.Mod m)])))
@@ -109,7 +109,7 @@
(#.Some subject^-1)
(|> subject
(/.m/* subject^-1)
- (/.m/= (/.mod normalM 1)))
+ (/.m/= (/.mod normalM +1)))
#.None
#1))
diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux
index 01ca9c98e..0f8c9f553 100644
--- a/stdlib/test/test/lux/time/duration.lux
+++ b/stdlib/test/test/lux/time/duration.lux
@@ -47,13 +47,13 @@
(do @
[sample (|> duration (:: @ map (@.frame @.day)))
frame duration
- factor (|> r.int (:: @ map (|>> (i/% 10) (i/max 1))))
+ factor (|> r.int (:: @ map (|>> (i/% +10) (i/max +1))))
#let [(^open "@/.") @.Order<Duration>]]
($_ seq
(test "Can scale a duration."
(|> sample (@.scale factor) (@.query sample) (i/= factor)))
(test "Scaling a duration by one does not change it."
- (|> sample (@.scale 1) (@/= sample)))
+ (|> sample (@.scale +1) (@/= sample)))
(test "Merging with the empty duration changes nothing."
(|> sample (@.merge @.empty) (@/= sample)))
(test "Merging a duration with it's opposite yields an empty duration."
diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux
index 59c01019e..db4898e20 100644
--- a/stdlib/test/test/lux/time/instant.lux
+++ b/stdlib/test/test/lux/time/instant.lux
@@ -18,7 +18,7 @@
[//
["_." duration]])
-(def: boundary Int 99_999_999_999_999)
+(def: boundary Int +99_999_999_999_999)
(def: #export instant
(r.Random @.Instant)
diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux
index cadc242e6..857b6afb5 100644
--- a/stdlib/test/test/lux/world/file.lux
+++ b/stdlib/test/test/lux/world/file.lux
@@ -23,7 +23,7 @@
["_." binary]])
(def: truncate-millis
- (|>> (i// 1_000) (i/* 1_000)))
+ (|>> (i// +1_000) (i/* +1_000)))
(context: "File system."
(do @
@@ -158,8 +158,8 @@
(assert "Can change the time of last modification."
(error.default #0 result))))
(wrap (do promise.Monad<Promise>
- [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "0")
- file1 (format "temp_file_" (%n (n/+ |9 code)) "1")]
+ [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "+0")
+ file1 (format "temp_file_" (%n (n/+ |9 code)) "+1")]
result (promise.future
(do (:: @.JVM@System &monad)
[_ (:: @.JVM@System write dataL file0)