aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux196
-rw-r--r--stdlib/source/lux/concurrency/actor.lux10
-rw-r--r--stdlib/source/lux/concurrency/frp.lux2
-rw-r--r--stdlib/source/lux/concurrency/space.lux2
-rw-r--r--stdlib/source/lux/concurrency/stm.lux2
-rw-r--r--stdlib/source/lux/control/comonad.lux6
-rw-r--r--stdlib/source/lux/control/concatenative.lux96
-rw-r--r--stdlib/source/lux/control/contract.lux6
-rw-r--r--stdlib/source/lux/control/monad.lux4
-rw-r--r--stdlib/source/lux/control/parser.lux10
-rw-r--r--stdlib/source/lux/control/pipe.lux28
-rw-r--r--stdlib/source/lux/data/bit.lux4
-rw-r--r--stdlib/source/lux/data/coll/array.lux52
-rw-r--r--stdlib/source/lux/data/coll/dict.lux62
-rw-r--r--stdlib/source/lux/data/coll/list.lux44
-rw-r--r--stdlib/source/lux/data/coll/ordered/dict.lux6
-rw-r--r--stdlib/source/lux/data/coll/priority-queue.lux8
-rw-r--r--stdlib/source/lux/data/coll/queue.lux2
-rw-r--r--stdlib/source/lux/data/coll/sequence.lux68
-rw-r--r--stdlib/source/lux/data/coll/set.lux4
-rw-r--r--stdlib/source/lux/data/coll/stream.lux6
-rw-r--r--stdlib/source/lux/data/color.lux220
-rw-r--r--stdlib/source/lux/data/format/css.lux2
-rw-r--r--stdlib/source/lux/data/format/json.lux4
-rw-r--r--stdlib/source/lux/data/format/xml.lux2
-rw-r--r--stdlib/source/lux/data/ident.lux2
-rw-r--r--stdlib/source/lux/data/number.lux336
-rw-r--r--stdlib/source/lux/data/number/complex.lux180
-rw-r--r--stdlib/source/lux/data/number/ratio.lux48
-rw-r--r--stdlib/source/lux/data/text.lux6
-rw-r--r--stdlib/source/lux/data/text/lexer.lux26
-rw-r--r--stdlib/source/lux/data/text/regex.lux8
-rw-r--r--stdlib/source/lux/lang/syntax.lux64
-rw-r--r--stdlib/source/lux/lang/type.lux12
-rw-r--r--stdlib/source/lux/lang/type/check.lux20
-rw-r--r--stdlib/source/lux/macro.lux4
-rw-r--r--stdlib/source/lux/macro/poly.lux46
-rw-r--r--stdlib/source/lux/macro/poly/eq.lux2
-rw-r--r--stdlib/source/lux/macro/poly/functor.lux12
-rw-r--r--stdlib/source/lux/macro/poly/json.lux8
-rw-r--r--stdlib/source/lux/macro/syntax.lux12
-rw-r--r--stdlib/source/lux/math.lux24
-rw-r--r--stdlib/source/lux/math/logic/continuous.lux12
-rw-r--r--stdlib/source/lux/math/logic/fuzzy.lux26
-rw-r--r--stdlib/source/lux/math/random.lux104
-rw-r--r--stdlib/source/lux/test.lux24
-rw-r--r--stdlib/source/lux/time/date.lux50
-rw-r--r--stdlib/source/lux/time/duration.lux48
-rw-r--r--stdlib/source/lux/time/instant.lux128
-rw-r--r--stdlib/source/lux/type/implicit.lux14
-rw-r--r--stdlib/source/lux/type/object.lux14
-rw-r--r--stdlib/source/lux/type/unit.lux44
-rw-r--r--stdlib/source/lux/world/blob.jvm.lux72
-rw-r--r--stdlib/source/lux/world/file.lux2
-rw-r--r--stdlib/test/test/lux.lux42
-rw-r--r--stdlib/test/test/lux/cli.lux2
-rw-r--r--stdlib/test/test/lux/concurrency/actor.lux8
-rw-r--r--stdlib/test/test/lux/concurrency/atom.lux10
-rw-r--r--stdlib/test/test/lux/concurrency/frp.lux12
-rw-r--r--stdlib/test/test/lux/concurrency/space.lux2
-rw-r--r--stdlib/test/test/lux/concurrency/stm.lux18
-rw-r--r--stdlib/test/test/lux/control/cont.lux22
-rw-r--r--stdlib/test/test/lux/control/exception.lux2
-rw-r--r--stdlib/test/test/lux/control/interval.lux12
-rw-r--r--stdlib/test/test/lux/control/parser.lux21
-rw-r--r--stdlib/test/test/lux/control/pipe.lux42
-rw-r--r--stdlib/test/test/lux/control/reader.lux18
-rw-r--r--stdlib/test/test/lux/control/state.lux48
-rw-r--r--stdlib/test/test/lux/control/writer.lux12
-rw-r--r--stdlib/test/test/lux/data/bit.lux34
-rw-r--r--stdlib/test/test/lux/data/coll/array.lux38
-rw-r--r--stdlib/test/test/lux/data/coll/dict.lux36
-rw-r--r--stdlib/test/test/lux/data/coll/list.lux94
-rw-r--r--stdlib/test/test/lux/data/coll/ordered/dict.lux16
-rw-r--r--stdlib/test/test/lux/data/coll/ordered/set.lux12
-rw-r--r--stdlib/test/test/lux/data/coll/priority-queue.lux12
-rw-r--r--stdlib/test/test/lux/data/coll/queue.lux12
-rw-r--r--stdlib/test/test/lux/data/coll/sequence.lux28
-rw-r--r--stdlib/test/test/lux/data/coll/set.lux6
-rw-r--r--stdlib/test/test/lux/data/coll/stack.lux8
-rw-r--r--stdlib/test/test/lux/data/coll/stream.lux70
-rw-r--r--stdlib/test/test/lux/data/coll/tree/rose.lux8
-rw-r--r--stdlib/test/test/lux/data/coll/tree/zipper.lux4
-rw-r--r--stdlib/test/test/lux/data/color.lux38
-rw-r--r--stdlib/test/test/lux/data/error.lux14
-rw-r--r--stdlib/test/test/lux/data/format/json.lux17
-rw-r--r--stdlib/test/test/lux/data/format/xml.lux6
-rw-r--r--stdlib/test/test/lux/data/ident.lux8
-rw-r--r--stdlib/test/test/lux/data/lazy.lux20
-rw-r--r--stdlib/test/test/lux/data/maybe.lux2
-rw-r--r--stdlib/test/test/lux/data/number.lux40
-rw-r--r--stdlib/test/test/lux/data/number/complex.lux65
-rw-r--r--stdlib/test/test/lux/data/number/ratio.lux8
-rw-r--r--stdlib/test/test/lux/data/product.lux8
-rw-r--r--stdlib/test/test/lux/data/sum.lux4
-rw-r--r--stdlib/test/test/lux/data/text.lux22
-rw-r--r--stdlib/test/test/lux/data/text/lexer.lux2
-rw-r--r--stdlib/test/test/lux/host.jvm.lux12
-rw-r--r--stdlib/test/test/lux/io.lux12
-rw-r--r--stdlib/test/test/lux/lang/syntax.lux37
-rw-r--r--stdlib/test/test/lux/lang/type.lux12
-rw-r--r--stdlib/test/test/lux/lang/type/check.lux12
-rw-r--r--stdlib/test/test/lux/macro/poly/eq.lux6
-rw-r--r--stdlib/test/test/lux/macro/poly/functor.lux2
-rw-r--r--stdlib/test/test/lux/math.lux91
-rw-r--r--stdlib/test/test/lux/math/logic/continuous.lux14
-rw-r--r--stdlib/test/test/lux/math/logic/fuzzy.lux68
-rw-r--r--stdlib/test/test/lux/math/random.lux24
-rw-r--r--stdlib/test/test/lux/time/duration.lux6
-rw-r--r--stdlib/test/test/lux/time/instant.lux7
-rw-r--r--stdlib/test/test/lux/type/implicit.lux12
-rw-r--r--stdlib/test/test/lux/type/object.lux6
-rw-r--r--stdlib/test/test/lux/world/blob.lux48
-rw-r--r--stdlib/test/test/lux/world/file.lux42
-rw-r--r--stdlib/test/test/lux/world/net/tcp.lux10
-rw-r--r--stdlib/test/test/lux/world/net/udp.lux12
116 files changed, 1756 insertions, 1774 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 5521e2d0d..e5da4a105 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -2199,10 +2199,10 @@
(do-template [<name> <diff>]
[(def: #export <name>
(-> Int Int)
- (i.+ <diff>))]
+ (i/+ <diff>))]
- [i.inc 1]
- [i.dec -1])")])
+ [i/inc 1]
+ [i/dec -1])")])
("lux case" tokens
{(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])])
("lux case" [(monad/map Monad<Maybe> get-name bindings)
@@ -2256,16 +2256,16 @@
true
(<eq-proc> subject test)))]
- [ Nat "lux nat =" "lux nat <" n.= n.< n.<= n.> n.>=
+ [ Nat "lux nat =" "lux nat <" n/= n/< n/<= n/> n/>=
"Nat(ural) equality." "Nat(ural) less-than." "Nat(ural) less-than-equal." "Nat(ural) greater-than." "Nat(ural) greater-than-equal."]
- [ Int "lux int =" "lux int <" i.= i.< i.<= i.> i.>=
+ [ Int "lux int =" "lux int <" i/= i/< i/<= i/> i/>=
"Int(eger) equality." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."]
- [ Deg "lux deg =" "lux deg <" d.= d.< d.<= d.> d.>=
+ [ Deg "lux deg =" "lux deg <" d/= d/< d/<= d/> d/>=
"Deg(ree) equality." "Deg(ree) less-than." "Deg(ree) less-than-equal." "Deg(ree) greater-than." "Deg(ree) greater-than-equal."]
- [Frac "lux frac =" "lux frac <" f.= f.< f.<= f.> f.>=
+ [Frac "lux frac =" "lux frac <" f/= f/< f/<= f/> f/>=
"Frac(tion) equality." "Frac(tion) less-than." "Frac(tion) less-than-equal." "Frac(tion) greater-than." "Frac(tion) greater-than-equal."]
)
@@ -2275,29 +2275,29 @@
(-> <type> <type> <type>)
(<op> subject param))]
- [ Nat n.+ "lux nat +" "Nat(ural) addition."]
- [ Nat n.- "lux nat -" "Nat(ural) substraction."]
- [ Nat n.* "lux nat *" "Nat(ural) multiplication."]
- [ Nat n./ "lux nat /" "Nat(ural) division."]
- [ Nat n.% "lux nat %" "Nat(ural) remainder."]
+ [ Nat n/+ "lux nat +" "Nat(ural) addition."]
+ [ Nat n/- "lux nat -" "Nat(ural) substraction."]
+ [ Nat n/* "lux nat *" "Nat(ural) multiplication."]
+ [ Nat n// "lux nat /" "Nat(ural) division."]
+ [ Nat n/% "lux nat %" "Nat(ural) remainder."]
- [ Int i.+ "lux int +" "Int(eger) addition."]
- [ Int i.- "lux int -" "Int(eger) substraction."]
- [ Int i.* "lux int *" "Int(eger) multiplication."]
- [ Int i./ "lux int /" "Int(eger) division."]
- [ Int i.% "lux int %" "Int(eger) remainder."]
-
- [ Deg d.+ "lux deg +" "Deg(ree) addition."]
- [ Deg d.- "lux deg -" "Deg(ree) substraction."]
- [ Deg d.* "lux deg *" "Deg(ree) multiplication."]
- [ Deg d./ "lux deg /" "Deg(ree) division."]
- [ Deg d.% "lux deg %" "Deg(ree) remainder."]
+ [ Int i/+ "lux int +" "Int(eger) addition."]
+ [ Int i/- "lux int -" "Int(eger) substraction."]
+ [ Int i/* "lux int *" "Int(eger) multiplication."]
+ [ Int i// "lux int /" "Int(eger) division."]
+ [ Int i/% "lux int %" "Int(eger) remainder."]
+
+ [ Deg d/+ "lux deg +" "Deg(ree) addition."]
+ [ Deg d/- "lux deg -" "Deg(ree) substraction."]
+ [ Deg d/* "lux deg *" "Deg(ree) multiplication."]
+ [ Deg d// "lux deg /" "Deg(ree) division."]
+ [ Deg d/% "lux deg %" "Deg(ree) remainder."]
- [Frac f.+ "lux frac +" "Frac(tion) addition."]
- [Frac f.- "lux frac -" "Frac(tion) substraction."]
- [Frac f.* "lux frac *" "Frac(tion) multiplication."]
- [Frac f./ "lux frac /" "Frac(tion) division."]
- [Frac f.% "lux frac %" "Frac(tion) remainder."]
+ [Frac f/+ "lux frac +" "Frac(tion) addition."]
+ [Frac f/- "lux frac -" "Frac(tion) substraction."]
+ [Frac f/* "lux frac *" "Frac(tion) multiplication."]
+ [Frac f// "lux frac /" "Frac(tion) division."]
+ [Frac f/% "lux frac %" "Frac(tion) remainder."]
)
(do-template [<type> <name> <op> <doc>]
@@ -2306,8 +2306,8 @@
(-> Nat <type> <type>)
(<op> subject param))]
- [ Deg d.scale "lux deg scale" "Deg(ree) scale."]
- [ Deg d.reciprocal "lux deg reciprocal" "Deg(ree) reciprocal."]
+ [ Deg d/scale "lux deg scale" "Deg(ree) scale."]
+ [ Deg d/reciprocal "lux deg reciprocal" "Deg(ree) reciprocal."]
)
(do-template [<name> <type> <test> <doc>]
@@ -2318,17 +2318,17 @@
left
right))]
- [n.min Nat n.< "Nat(ural) minimum."]
- [n.max Nat n.> "Nat(ural) maximum."]
+ [n/min Nat n/< "Nat(ural) minimum."]
+ [n/max Nat n/> "Nat(ural) maximum."]
- [i.min Int i.< "Int(eger) minimum."]
- [i.max Int i.> "Int(eger) maximum."]
+ [i/min Int i/< "Int(eger) minimum."]
+ [i/max Int i/> "Int(eger) maximum."]
- [d.min Deg d.< "Deg(ree) minimum."]
- [d.max Deg d.> "Deg(ree) maximum."]
+ [d/min Deg d/< "Deg(ree) minimum."]
+ [d/max Deg d/> "Deg(ree) maximum."]
- [f.min Frac f.< "Frac minimum."]
- [f.max Frac f.> "Frac minimum."]
+ [f/min Frac f/< "Frac minimum."]
+ [f/max Frac f/> "Frac minimum."]
)
(def:''' (bool/encode x)
@@ -2356,37 +2356,37 @@
_
(let' [loop ("lux check" (-> Nat Text Text)
(function' recur [input output]
- (if (n.= +0 input)
+ (if (n/= +0 input)
(text/compose "+" output)
- (recur (n./ +10 input)
- (text/compose (|> input (n.% +10) digit-to-text)
+ (recur (n// +10 input)
+ (text/compose (|> input (n/% +10) digit-to-text)
output)))))]
(loop value ""))}))
(def:''' (int/abs value)
#Nil
(-> Int Int)
- (if (i.< 0 value)
- (i.* -1 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
@@ -2396,7 +2396,7 @@
(def:''' (multiple? div n)
#Nil
(-> Nat Nat Bool)
- (|> n (n.% div) (n.= +0)))
+ (|> n (n/% div) (n/= +0)))
(def:''' #export (not x)
(list [(tag$ ["lux" "doc"])
@@ -2724,7 +2724,7 @@
#scope-type-vars scope-type-vars}
(#Right {#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed (n.+ +1 seed) #expected expected
+ #seed (n/+ +1 seed) #expected expected
#cursor cursor
#scope-type-vars scope-type-vars}
(symbol$ ["" ($_ text/compose "__gensym__" prefix (nat/encode seed))]))}))
@@ -2906,7 +2906,7 @@
## Allows the usage of macros within the patterns to provide custom syntax.
(case (: (List Int) (list 1 2 3))
(#Cons x (#Cons y (#Cons z #Nil)))
- (#Some ($_ i.* x y z))
+ (#Some ($_ i/* x y z))
_
#None)")])
@@ -2925,7 +2925,7 @@
## It's a special macro meant to be used with 'case'.
(case (: (List Int) (list 1 2 3))
(^ (list x y z))
- (#Some ($_ i.* x y z))
+ (#Some ($_ i/* x y z))
_
#None)")])
@@ -3392,7 +3392,7 @@
(def: (last-index-of' part part-size since text)
(-> Text Nat Nat Text (Maybe Nat))
- (case ("lux text index" text part (n.+ part-size since))
+ (case ("lux text index" text part (n/+ part-size since))
#;None
(#;Some since)
@@ -3453,7 +3453,7 @@
(clip2 +0 idx input))
(text/split splitter
(default (error! "UNDEFINED")
- (clip1 (n.+ +1 idx) input))))))
+ (clip1 (n/+ +1 idx) input))))))
(def: (nth idx xs)
(All [a]
@@ -3463,9 +3463,9 @@
#None
(#Cons x xs')
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(#Some x)
- (nth (n.- +1 idx) xs')
+ (nth (n/- +1 idx) xs')
)))
(def: (beta-reduce env type)
@@ -4074,8 +4074,8 @@
ups
(#;Some found)
- (if (n.= ups found)
- (count-ups (n.+ +1 ups) input)
+ (if (n/= ups found)
+ (count-ups (n/+ +1 ups) input)
ups)))
(def: (list/drop amount a+)
@@ -4085,7 +4085,7 @@
a+
[_ (#;Cons _ a+')]
- (list/drop (n.- +1 amount) a+')))
+ (list/drop (n/- +1 amount) a+')))
(def: (clean-module relative-root module)
(-> Text Text (Meta Text))
@@ -4095,10 +4095,10 @@
ups
(let [parts (text/split "/" relative-root)]
- (if (n.< (list/size parts) (n.- +1 ups))
+ (if (n/< (list/size parts) (n/- +1 ups))
(let [prefix (|> parts
list/reverse
- (list/drop (n.- +1 ups))
+ (list/drop (n/- +1 ups))
list/reverse
(interpose "/")
text/join)
@@ -4298,7 +4298,7 @@
#;Nil
(#;Cons [var bound] bindings')
- (if (n.= idx var)
+ (if (n/= idx var)
bound
(find-type-var idx bindings'))))
@@ -4470,11 +4470,11 @@
(macro: #export (cond tokens)
{#;doc "## Branching structures with multiple test conditions.
- (cond (n.even? num) \"even\"
- (n.odd? num) \"odd\"
+ (cond (n/even? num) \"even\"
+ (n/odd? num) \"odd\"
## else-branch
\"???\")"}
- (if (n.= +0 (n.% +2 (list/size tokens)))
+ (if (n/= +0 (n/% +2 (list/size tokens)))
(fail "cond requires an even number of arguments.")
(case (list/reverse tokens)
(^ (list& else branches'))
@@ -4492,7 +4492,7 @@
(All [a] (-> Nat (List a) (List [Nat a])))
(case xs
(#Cons x xs')
- (#Cons [idx x] (enumerate' (n.+ +1 idx) xs'))
+ (#Cons [idx x] (enumerate' (n/+ +1 idx) xs'))
#Nil
#Nil))
@@ -4524,7 +4524,7 @@
(#Some members)
(let [pattern (record$ (map (: (-> [Ident [Nat Type]] [Code Code])
(function [[[r-prefix r-name] [r-idx r-type]]]
- [(tag$ [r-prefix r-name]) (if (n.= idx r-idx)
+ [(tag$ [r-prefix r-name]) (if (n/= idx r-idx)
g!output
g!_)]))
(zip2 tags (enumerate members))))]
@@ -4847,7 +4847,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat Code] [Code Code])
(function [[r-slot-name r-idx r-var]]
- [(tag$ r-slot-name) (if (n.= idx r-idx)
+ [(tag$ r-slot-name) (if (n/= idx r-idx)
value
r-var)]))
pattern'))]
@@ -4899,7 +4899,7 @@
(macro: #export (update@ tokens)
{#;doc "## Modifies the value of a record at a given tag, based on some function.
- (update@ #age i.inc person)
+ (update@ #age i/inc person)
## Can also work with multiple levels of nesting:
(update@ [#foo #bar #baz] func my-record)
@@ -4933,7 +4933,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat Code] [Code Code])
(function [[r-slot-name r-idx r-var]]
- [(tag$ r-slot-name) (if (n.= idx r-idx)
+ [(tag$ r-slot-name) (if (n/= idx r-idx)
(` ((~ fun) (~ r-var)))
r-var)]))
pattern'))]
@@ -5013,7 +5013,7 @@
(do Monad<Maybe>
[bindings' (monad/map Monad<Maybe> get-name bindings)
data' (monad/map Monad<Maybe> tuple->list data)]
- (if (every? (n.= (list/size bindings')) (map list/size data'))
+ (if (every? (n/= (list/size bindings')) (map list/size data'))
(let [apply (: (-> RepEnv (List Code))
(function [env] (map (apply-template env) templates)))]
(|> data'
@@ -5055,12 +5055,12 @@
(^template [<tag>]
[[_ _ column] (<tag> parts)]
- (list/fold n.min column (map find-baseline-column parts)))
+ (list/fold n/min column (map find-baseline-column parts)))
([#Form]
[#Tuple])
[[_ _ column] (#Record pairs)]
- (list/fold n.min column
+ (list/fold n/min column
(list/compose (map (. find-baseline-column first) pairs)
(map (. find-baseline-column second) pairs)))
))
@@ -5098,10 +5098,10 @@
(-> <type> <type>)
(<op> <one> value))]
- [i.inc i.+ 1 Int "[Int] Increment function."]
- [i.dec i.- 1 Int "[Int] Decrement function."]
- [n.inc n.+ +1 Nat "[Nat] Increment function."]
- [n.dec n.- +1 Nat "[Nat] Decrement function."]
+ [i/inc i/+ 1 Int "[Int] Increment function."]
+ [i/dec i/- 1 Int "[Int] Decrement function."]
+ [n/inc n/+ +1 Nat "[Nat] Increment function."]
+ [n/dec n/- +1 Nat "[Nat] Decrement function."]
)
(def: tag/encode
@@ -5121,16 +5121,16 @@
(def: (repeat n x)
(All [a] (-> Int a (List a)))
- (if (i.> 0 n)
- (#;Cons x (repeat (i.+ -1 n) x))
+ (if (i/> 0 n)
+ (#;Cons x (repeat (i/+ -1 n) x))
#;Nil))
(def: (cursor-padding baseline [_ old-line old-column] [_ new-line new-column])
(-> Nat Cursor Cursor Text)
- (if (n.= old-line new-line)
- (text/join (repeat (nat-to-int (n.- old-column new-column)) " "))
- (let [extra-lines (text/join (repeat (nat-to-int (n.- old-line new-line)) "\n"))
- space-padding (text/join (repeat (nat-to-int (n.- baseline new-column)) " "))]
+ (if (n/= old-line new-line)
+ (text/join (repeat (nat-to-int (n/- old-column new-column)) " "))
+ (let [extra-lines (text/join (repeat (nat-to-int (n/- old-line new-line)) "\n"))
+ space-padding (text/join (repeat (nat-to-int (n/- baseline new-column)) " "))]
(text/compose extra-lines space-padding))))
(def: (text/size x)
@@ -5139,11 +5139,11 @@
(def: (update-cursor [file line column] code-text)
(-> Cursor Text Cursor)
- [file line (n.+ column (text/size code-text))])
+ [file line (n/+ column (text/size code-text))])
(def: (delim-update-cursor [file line column])
(-> Cursor Cursor)
- [file line (n.inc column)])
+ [file line (n/inc column)])
(def: rejoin-all-pairs
(-> (List [Code Code]) (List Code))
@@ -5214,7 +5214,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (i.inc count) (f x))
+ (recur (i/inc count) (f x))
x)))"}
(return (list (` [(~ cursor-code)
(#;Text (~ (|> tokens
@@ -5286,7 +5286,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (i.inc count) (f x))
+ (recur (i/inc count) (f x))
x)))}
(case tokens
(^ (list [_ (#Tuple bindings)] body))
@@ -5645,8 +5645,8 @@
(-> <type> Bool)
(not (<even> n)))]
- [Nat n.even? n.odd? n.% n.= +0 +2]
- [Int i.even? i.odd? i.% i.= 0 2])
+ [Nat n/even? n/odd? n/% n/= +0 +2]
+ [Int i/even? i/odd? i/% i/= 0 2])
(def: (get-scope-type-vars state)
(Meta (List Nat))
@@ -5665,9 +5665,9 @@
#;None
(#;Cons x xs')
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(#;Some x)
- (list-at (n.dec idx) xs'))))
+ (list-at (n/dec idx) xs'))))
(macro: #export ($ tokens)
{#;doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index."
@@ -5699,14 +5699,14 @@
(is value value))
"This one should fail:"
- (is 5 (i.+ 2 3)))}
+ (is 5 (i/+ 2 3)))}
(All [a] (-> a a Bool))
("lux is" reference sample))
(macro: #export (^@ tokens)
{#;doc (doc "Allows you to simultaneously bind and de-structure a value."
(def: (hash (^@ set [Hash<a> _]))
- (list/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc))
+ (list/fold (function [elem acc] (n/+ (:: Hash<a> hash elem) acc))
+0
(to-list set))))}
(case tokens
@@ -5722,7 +5722,7 @@
(macro: #export (^|> tokens)
{#;doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable."
(case input
- (^|> value [n.inc (n.% +10) (n.max +1)])
+ (^|> value [n/inc (n/% +10) (n/max +1)])
(foo value)))}
(case tokens
(^ (list& [_meta (#;Form (list [_ (#;Symbol ["" name])] [_ (#;Tuple steps)]))] body branches))
@@ -5860,7 +5860,7 @@
{#;doc (doc "Define macros in the style of do-template and ^template."
"For simple macros that do not need any fancy features."
(template: (square x)
- (i.* x x)))}
+ (i/* x x)))}
(do Monad<Meta>
[?export-level|tokens (parse-export-level tokens)
#let [[?export-level tokens] ?export-level|tokens]
@@ -5896,7 +5896,7 @@
(macro: #export (char tokens compiler)
(case tokens
(^multi (^ (list [_ (#Text input)]))
- (n.= +1 ("lux text size" input)))
+ (n/= +1 ("lux text size" input)))
(|> ("lux text char" input +0)
(default (undefined))
nat$ list
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux
index dbe11b3a0..18bdaa61d 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -300,7 +300,7 @@
(message: #export Counter
(count! [increment Nat] state self Nat)
- (let [state' (n.+ increment state)]
+ (let [state' (n/+ increment state)]
(T;return [state' state'])))
(message: #export (Stack a)
@@ -322,12 +322,12 @@
g!actor-refs (: (List Code)
(if (list;empty? actor-vars)
(list)
- (|> actor-vars list;size n.dec
- (list;n.range +0) (list/map (|>. code;nat (~) ($) (`))))))
+ (|> actor-vars list;size n/dec
+ (list;n/range +0) (list/map (|>. code;nat (~) ($) (`))))))
ref-replacements (|> (if (list;empty? actor-vars)
(list)
- (|> actor-vars list;size n.dec
- (list;n.range +0) (list/map (|>. code;nat (~) ($) (`)))))
+ (|> actor-vars list;size n/dec
+ (list;n/range +0) (list/map (|>. code;nat (~) ($) (`)))))
(: (List Code))
(list;zip2 g!all-vars)
(: (List [Code Code])))
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux
index ce5069b45..ba438fcf4 100644
--- a/stdlib/source/lux/concurrency/frp.lux
+++ b/stdlib/source/lux/concurrency/frp.lux
@@ -235,7 +235,7 @@
(let [(^open) &;Monad<Promise>]
(folds (function [input window]
(let [window' (L/compose window (list input))]
- (wrap (if (n.<= max (list;size window'))
+ (wrap (if (n/<= max (list;size window'))
window'
(tail window')))))
(list)
diff --git a/stdlib/source/lux/concurrency/space.lux b/stdlib/source/lux/concurrency/space.lux
index 8fe9fa583..87a1d3c22 100644
--- a/stdlib/source/lux/concurrency/space.lux
+++ b/stdlib/source/lux/concurrency/space.lux
@@ -128,7 +128,7 @@
#;Pong #;Ping)
space
self)]
- (wrap (n.inc hits)))))}
+ (wrap (n/inc hits)))))}
(with-gensyms [g!_]
(do @
[actor-name (A;resolve-actor actor-name)
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index e29edc9a2..b845c3538 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -148,7 +148,7 @@
base
(#;Right key-num)
- (n.max key-num base)))
+ (n/max key-num base)))
+0
(dict;keys observers)))]
[value (dict;put label (observer label) observers)]))
diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux
index 15625b8f1..dd395ff64 100644
--- a/stdlib/source/lux/control/comonad.lux
+++ b/stdlib/source/lux/control/comonad.lux
@@ -27,13 +27,13 @@
(macro: #export (be tokens state)
{#;doc (doc "A co-monadic parallel to the \"do\" macro."
- (let [square (function [n] (i.* n n))]
+ (let [square (function [n] (i/* n n))]
(be CoMonad<Stream>
- [inputs (iterate i.inc 2)]
+ [inputs (iterate i/inc 2)]
(square (head inputs)))))}
(case tokens
(#;Cons comonad (#;Cons [_ (#;Tuple bindings)] (#;Cons body #;Nil)))
- (if (|> bindings list;size (n.% +2) (n.= +0))
+ (if (|> bindings list;size (n/% +2) (n/= +0))
(let [g!map (: Code [_cursor (#;Symbol ["" " map "])])
g!split (: Code [_cursor (#;Symbol ["" " split "])])
body' (list/fold (: (-> [Code Code] Code Code)
diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux
index b0ed0f585..ef66ffac8 100644
--- a/stdlib/source/lux/control/concatenative.lux
+++ b/stdlib/source/lux/control/concatenative.lux
@@ -1,8 +1,8 @@
(;module: [lux #- if loop when
- n.+ n.- n.* n./ n.% n.= n.< n.<= n.> n.>=
- i.+ i.- i.* i./ i.% i.= i.< i.<= i.> i.>=
- d.+ d.- d.* d./ d.% d.= d.< d.<= d.> d.>=
- f.+ f.- f.* f./ f.% f.= f.< f.<= f.> f.>=]
+ n/+ n/- n/* n// n/% n/= n/< n/<= n/> n/>=
+ i/+ i/- i/* i// i/% i/= i/< i/<= i/> i/>=
+ d/+ d/- d/* d// d/% d/= d/< d/<= d/> d/>=
+ f/+ f/- f/* f// f/% f/= f/< f/<= f/> f/>=]
(lux (control ["p" parser "p/" Monad<Parser>]
[monad])
(data [text]
@@ -121,7 +121,7 @@
(~ type)
(|>. (~@ (L/map prepare commands))))))))
-(syntax: #export (apply [arity (|> s;nat (p;filter (;n.> +0)))])
+(syntax: #export (apply [arity (|> s;nat (p;filter (;n/> +0)))])
(with-gensyms [g!func g!stack g!output]
(monad;do @
[g!inputs (|> (macro;gensym "input") (list;repeat arity) (monad;seq @))]
@@ -198,49 +198,49 @@
(function [[[stack subject] param]]
[stack (<func> param subject)]))]
- [Nat Nat n.+ ;n.+]
- [Nat Nat n.- ;n.-]
- [Nat Nat n.* ;n.*]
- [Nat Nat n./ ;n./]
- [Nat Nat n.% ;n.%]
- [Nat Bool n.= ;n.=]
- [Nat Bool n.< ;n.<]
- [Nat Bool n.<= ;n.<=]
- [Nat Bool n.> ;n.>]
- [Nat Bool n.>= ;n.>=]
-
- [Int Int i.+ ;i.+]
- [Int Int i.- ;i.-]
- [Int Int i.* ;i.*]
- [Int Int i./ ;i./]
- [Int Int i.% ;i.%]
- [Int Bool i.= ;i.=]
- [Int Bool i.< ;i.<]
- [Int Bool i.<= ;i.<=]
- [Int Bool i.> ;i.>]
- [Int Bool i.>= ;i.>=]
-
- [Deg Deg d.+ ;d.+]
- [Deg Deg d.- ;d.-]
- [Deg Deg d.* ;d.*]
- [Deg Deg d./ ;d./]
- [Deg Deg d.% ;d.%]
- [Deg Bool d.= ;d.=]
- [Deg Bool d.< ;d.<]
- [Deg Bool d.<= ;d.<=]
- [Deg Bool d.> ;d.>]
- [Deg Bool d.>= ;d.>=]
-
- [Frac Frac f.+ ;f.+]
- [Frac Frac f.- ;f.-]
- [Frac Frac f.* ;f.*]
- [Frac Frac f./ ;f./]
- [Frac Frac f.% ;f.%]
- [Frac Bool f.= ;f.=]
- [Frac Bool f.< ;f.<]
- [Frac Bool f.<= ;f.<=]
- [Frac Bool f.> ;f.>]
- [Frac Bool f.>= ;f.>=]
+ [Nat Nat n/+ ;n/+]
+ [Nat Nat n/- ;n/-]
+ [Nat Nat n/* ;n/*]
+ [Nat Nat n// ;n//]
+ [Nat Nat n/% ;n/%]
+ [Nat Bool n/= ;n/=]
+ [Nat Bool n/< ;n/<]
+ [Nat Bool n/<= ;n/<=]
+ [Nat Bool n/> ;n/>]
+ [Nat Bool n/>= ;n/>=]
+
+ [Int Int i/+ ;i/+]
+ [Int Int i/- ;i/-]
+ [Int Int i/* ;i/*]
+ [Int Int i// ;i//]
+ [Int Int i/% ;i/%]
+ [Int Bool i/= ;i/=]
+ [Int Bool i/< ;i/<]
+ [Int Bool i/<= ;i/<=]
+ [Int Bool i/> ;i/>]
+ [Int Bool i/>= ;i/>=]
+
+ [Deg Deg d/+ ;d/+]
+ [Deg Deg d/- ;d/-]
+ [Deg Deg d/* ;d/*]
+ [Deg Deg d// ;d//]
+ [Deg Deg d/% ;d/%]
+ [Deg Bool d/= ;d/=]
+ [Deg Bool d/< ;d/<]
+ [Deg Bool d/<= ;d/<=]
+ [Deg Bool d/> ;d/>]
+ [Deg Bool d/>= ;d/>=]
+
+ [Frac Frac f/+ ;f/+]
+ [Frac Frac f/- ;f/-]
+ [Frac Frac f/* ;f/*]
+ [Frac Frac f// ;f//]
+ [Frac Frac f/% ;f/%]
+ [Frac Bool f/= ;f/=]
+ [Frac Bool f/< ;f/<]
+ [Frac Bool f/<= ;f/<=]
+ [Frac Bool f/> ;f/>]
+ [Frac Bool f/>= ;f/>=]
)
(def: #export if
diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux
index cc3267715..3b072caa8 100644
--- a/stdlib/source/lux/control/contract.lux
+++ b/stdlib/source/lux/control/contract.lux
@@ -16,7 +16,7 @@
{#;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))
+ (pre (i/= 4 (i/+ 2 2))
(foo 123 456 789)))}
(wrap (list (` (exec (assert! (~ (code;text (format "Pre-condition failed: " (%code test))))
(~ test))
@@ -27,8 +27,8 @@
"Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate."
"If the predicate returns true, returns the value of the expression."
"Otherwise, an error is raised."
- (post i.even?
- (i.+ 2 2)))}
+ (post i/even?
+ (i/+ 2 2)))}
(do @
[g!output (macro;gensym "")]
(wrap (list (` (let [(~ g!output) (~ expr)]
diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux
index fb900d3e7..e4495cc92 100644
--- a/stdlib/source/lux/control/monad.lux
+++ b/stdlib/source/lux/control/monad.lux
@@ -23,7 +23,7 @@
counter
(#;Cons _ xs')
- (recur (n.inc counter) xs'))))
+ (recur (n/inc counter) xs'))))
(def: (reverse xs)
(All [a]
@@ -60,7 +60,7 @@
(wrap (f3 z))))}
(case tokens
(#;Cons monad (#;Cons [_ (#;Tuple bindings)] (#;Cons body #;Nil)))
- (if (|> bindings list/size (n.% +2) (n.= +0))
+ (if (|> bindings list/size (n/% +2) (n/= +0))
(let [g!map (: Code [_cursor (#;Symbol ["" " map "])])
g!join (: Code [_cursor (#;Symbol ["" " join "])])
g!apply (: Code [_cursor (#;Symbol ["" " apply "])])
diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux
index 1b91a0248..095104f09 100644
--- a/stdlib/source/lux/control/parser.lux
+++ b/stdlib/source/lux/control/parser.lux
@@ -136,10 +136,10 @@
(def: #export (exactly n p)
{#;doc "Parse exactly N times."}
(All [s a] (-> Nat (Parser s a) (Parser s (List a))))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(do Monad<Parser>
[x p
- xs (exactly (n.dec n) p)]
+ xs (exactly (n/dec n) p)]
(wrap (#;Cons x xs)))
(:: Monad<Parser> wrap (list))))
@@ -154,7 +154,7 @@
(def: #export (at-most n p)
{#;doc "Parse at most N times."}
(All [s a] (-> Nat (Parser s a) (Parser s (List a))))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(function [input]
(case (p input)
(#e;Error msg)
@@ -163,7 +163,7 @@
(#e;Success [input' x])
(run input'
(do Monad<Parser>
- [xs (at-most (n.dec n) p)]
+ [xs (at-most (n/dec n) p)]
(wrap (#;Cons x xs))))
))
(:: Monad<Parser> wrap (list))))
@@ -173,7 +173,7 @@
(All [s a] (-> Nat Nat (Parser s a) (Parser s (List a))))
(do Monad<Parser>
[min-xs (exactly from p)
- max-xs (at-most (n.- from to) p)]
+ max-xs (at-most (n/- from to) p)]
(wrap (:: list;Monad<List> join (list min-xs max-xs)))))
(def: #export (sep-by sep p)
diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux
index 6eb8e8156..9903986f7 100644
--- a/stdlib/source/lux/control/pipe.lux
+++ b/stdlib/source/lux/control/pipe.lux
@@ -16,9 +16,9 @@
(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 i.inc)))}
+ (i/* 3)
+ (i/+ 4)
+ (new> 0 i/inc)))}
(case (list;reverse tokens)
(^ (list& _ r-body))
(wrap (list (` (|> (~@ (list;reverse r-body))))))
@@ -29,7 +29,7 @@
(syntax: #export (let> binding body prev)
{#;doc (doc "Gives a name to the piped-argument, within the given expression."
(|> 5
- (let> X (i.+ X X))))}
+ (let> X (i/+ X X))))}
(wrap (list (` (let [(~ binding) (~ prev)]
(~ body))))))
@@ -40,8 +40,8 @@
"Both the tests and the bodies are piped-code, and must be given inside a tuple."
"If a last else-pipe is not given, the piped-argument will be used instead."
(|> 5
- (cond> [i.even?] [(i.* 2)]
- [i.odd?] [(i.* 3)]
+ (cond> [i/even?] [(i/* 2)]
+ [i/odd?] [(i/* 3)]
[(new> -1)])))}
(with-gensyms [g!temp]
(wrap (list (` (with-expansions
@@ -61,8 +61,8 @@
{#;doc (doc "Loops for pipes."
"Both the testing and calculating steps are pipes and must be given inside tuples."
(|> 1
- (loop> [(i.< 10)]
- [i.inc])))}
+ (loop> [(i/< 10)]
+ [i/inc])))}
(with-gensyms [g!temp]
(wrap (list (` (loop [(~ g!temp) (~ prev)]
(if (|> (~ g!temp) (~@ test))
@@ -74,9 +74,9 @@
"Each steps in the monadic computation is a pipe and must be given inside a tuple."
(|> 5
(do> Monad<Identity>
- [(i.* 3)]
- [(i.+ 4)]
- [i.inc])))}
+ [(i/* 3)]
+ [(i/+ 4)]
+ [i/inc])))}
(with-gensyms [g!temp]
(case (list;reverse steps)
(^ (list& last-step prev-steps))
@@ -96,7 +96,7 @@
"Will generate piped computations, but their results will not be used in the larger scope."
(|> 5
(exec> [int-to-nat %n log!])
- (i.* 10)))}
+ (i/* 10)))}
(do @
[g!temp (macro;gensym "")]
(wrap (list (` (let [(~ g!temp) (~ prev)]
@@ -107,8 +107,8 @@
{#;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)]
- [i.dec (i./ 2)]
+ (tuple> [(i/* 10)]
+ [i/dec (i// 2)]
[Int/encode]))
"Will become: [50 2 \"5\"]")}
(do @
diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux
index ee4dc4449..b0b31d2dd 100644
--- a/stdlib/source/lux/data/bit.lux
+++ b/stdlib/source/lux/data/bit.lux
@@ -46,13 +46,13 @@
(def: #export (set? idx input)
(-> Nat Nat Bool)
- (|> input (;;and (shift-left idx +1)) (n.= +0) ;not))
+ (|> input (;;and (shift-left idx +1)) (n/= +0) ;not))
(do-template [<name> <main> <comp>]
[(def: #export (<name> distance input)
(-> Nat Nat Nat)
(;;or (<main> distance input)
- (<comp> (n.- (n.% width distance)
+ (<comp> (n/- (n/% width distance)
width)
input)))]
diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux
index c697e5681..1eeb1342c 100644
--- a/stdlib/source/lux/data/coll/array.lux
+++ b/stdlib/source/lux/data/coll/array.lux
@@ -34,17 +34,17 @@
(def: #export (copy length src-start src-array dest-start dest-array)
(All [a] (-> Nat Nat (Array a) Nat (Array a)
(Array a)))
- (if (n.= +0 length)
+ (if (n/= +0 length)
dest-array
(list/fold (function [offset target]
- (case (read (n.+ offset src-start) src-array)
+ (case (read (n/+ offset src-start) src-array)
#;None
target
(#;Some value)
- (write (n.+ offset dest-start) value target)))
+ (write (n/+ offset dest-start) value target)))
dest-array
- (list;n.range +0 (n.dec length)))))
+ (list;n/range +0 (n/dec length)))))
(def: #export (occupied array)
{#;doc "Finds out how many cells in an array are occupied."}
@@ -55,14 +55,14 @@
count
(#;Some _)
- (n.inc count)))
+ (n/inc count)))
+0
(list;indices (size array))))
(def: #export (vacant array)
{#;doc "Finds out how many cells in an array are vacant."}
(All [a] (-> (Array a) Nat))
- (n.- (occupied array) (size array)))
+ (n/- (occupied array) (size array)))
(def: #export (filter p xs)
(All [a]
@@ -97,15 +97,15 @@
(-> (-> a Bool) (Array a) (Maybe a)))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur (n.inc idx))
+ (recur (n/inc idx))
(#;Some x)
(if (p x)
(#;Some x)
- (recur (n.inc idx))))
+ (recur (n/inc idx))))
#;None))))
(def: #export (find+ p xs)
@@ -114,15 +114,15 @@
(-> (-> Nat a Bool) (Array a) (Maybe [Nat a])))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur (n.inc idx))
+ (recur (n/inc idx))
(#;Some x)
(if (p idx x)
(#;Some [idx x])
- (recur (n.inc idx))))
+ (recur (n/inc idx))))
#;None))))
(def: #export (clone xs)
@@ -141,19 +141,19 @@
(def: #export (from-list xs)
(All [a] (-> (List a) (Array a)))
(product;right (list/fold (function [x [idx arr]]
- [(n.inc idx) (write idx x arr)])
+ [(n/inc idx) (write idx x arr)])
[+0 (new (list;size xs))]
xs)))
-(def: underflow Nat (n.dec +0))
+(def: underflow Nat (n/dec +0))
(def: #export (to-list array)
(All [a] (-> (Array a) (List a)))
- (loop [idx (n.dec (size array))
+ (loop [idx (n/dec (size array))
output #;Nil]
- (if (n.= underflow idx)
+ (if (n/= underflow idx)
output
- (recur (n.dec idx)
+ (recur (n/dec idx)
(case (read idx array)
(#;Some head)
(#;Cons head output)
@@ -166,7 +166,7 @@
(def: (= xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (and (n.= sxy sxs)
+ (and (n/= sxy sxs)
(list/fold (function [idx prev]
(and prev
(case [(read idx xs) (read idx ys)]
@@ -179,7 +179,7 @@
_
false)))
true
- (list;n.range +0 (n.dec sxs)))))
+ (list;n/range +0 (n/dec sxs)))))
))
(struct: #export Monoid<Array> (All [a]
@@ -189,14 +189,14 @@
(def: (compose xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (|> (new (n.+ sxy sxs))
+ (|> (new (n/+ sxy sxs))
(copy sxs +0 xs +0)
(copy sxy +0 ys sxs)))))
(struct: #export _ (Functor Array)
(def: (map f ma)
(let [arr-size (size ma)]
- (if (n.= +0 arr-size)
+ (if (n/= +0 arr-size)
(new arr-size)
(list/fold (: (-> Nat (Array ($ +1)) (Array ($ +1)))
(function [idx mb]
@@ -207,7 +207,7 @@
(#;Some x)
(write idx (f x) mb))))
(new arr-size)
- (list;n.range +0 (n.dec arr-size)))
+ (list;n/range +0 (n/dec arr-size)))
## (list/fold (function [idx mb]
## (case (read idx ma)
## #;None
@@ -216,7 +216,7 @@
## (#;Some x)
## (write idx (f x) mb)))
## (new arr-size)
- ## (list;n.range +0 (n.dec arr-size)))
+ ## (list;n/range +0 (n/dec arr-size)))
))))
(struct: #export _ (Fold Array)
@@ -224,11 +224,11 @@
(let [arr-size (size xs)]
(loop [so-far init
idx +0]
- (if (n.< arr-size idx)
+ (if (n/< arr-size idx)
(case (read idx xs)
#;None
- (recur so-far (n.inc idx))
+ (recur so-far (n/inc idx))
(#;Some value)
- (recur (f value so-far) (n.inc idx)))
+ (recur (f value so-far) (n/inc idx)))
so-far)))))
diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux
index cee6a83fc..0273dc852 100644
--- a/stdlib/source/lux/data/coll/dict.lux
+++ b/stdlib/source/lux/data/coll/dict.lux
@@ -97,13 +97,13 @@
## which is 1/4 of the branching factor (or a left-shift 2).
(def: demotion-threshold
Nat
- (bit;shift-left (n.- +2 branching-exponent) +1))
+ (bit;shift-left (n/- +2 branching-exponent) +1))
## The threshold on which #Base nodes are promoted to #Hierarchy nodes,
## which is 1/2 of the branching factor (or a left-shift 1).
(def: promotion-threshold
Nat
- (bit;shift-left (n.- +1 branching-exponent) +1))
+ (bit;shift-left (n/- +1 branching-exponent) +1))
## The size of hierarchy-nodes, which is 2^(branching-exponent).
(def: hierarchy-nodes-size
@@ -120,12 +120,12 @@
(def: (insert! idx value old-array)
(All [a] (-> Index a (Array a) (Array a)))
(let [old-size (array;size old-array)]
- (|> ## (array;new (n.inc old-size))
+ (|> ## (array;new (n/inc old-size))
(: (Array ($ +0))
- (array;new (n.inc old-size)))
+ (array;new (n/inc old-size)))
(array;copy idx +0 old-array +0)
(array;write idx value)
- (array;copy (n.- idx old-size) idx old-array (n.inc idx)))))
+ (array;copy (n/- idx old-size) idx old-array (n/inc idx)))))
## Creates a copy of an array with an index set to a particular value.
(def: (update! idx value array)
@@ -140,23 +140,23 @@
## Shrinks a copy of the array by removing the space at index.
(def: (remove! idx array)
(All [a] (-> Index (Array a) (Array a)))
- (let [new-size (n.dec (array;size array))]
+ (let [new-size (n/dec (array;size array))]
(|> (array;new new-size)
(array;copy idx +0 array +0)
- (array;copy (n.- idx new-size) (n.inc idx) array idx))))
+ (array;copy (n/- idx new-size) (n/inc idx) array idx))))
## Given a top-limit for indices, produces all indices in [0, R).
(def: indices-for
(-> Nat (List Index))
- (|>. n.dec (list;n.range +0)))
+ (|>. n/dec (list;n/range +0)))
## Increases the level-shift by the branching-exponent, to explore
## levels further down the tree.
(def: level-up
(-> Level Level)
- (n.+ branching-exponent))
+ (n/+ branching-exponent))
-(def: hierarchy-mask BitMap (n.dec hierarchy-nodes-size))
+(def: hierarchy-mask BitMap (n/dec hierarchy-nodes-size))
## Gets the branching-factor sized section of the hash corresponding
## to a particular level, and uses that as an index into the array.
@@ -177,12 +177,12 @@
(def: (bit-position-is-set? bit bitmap)
(-> BitPosition BitMap Bool)
- (not (n.= clean-bitmap (bit;and bit bitmap))))
+ (not (n/= clean-bitmap (bit;and bit bitmap))))
## Figures out whether a bitmap only contains a single bit-position.
(def: only-bit-position?
(-> BitPosition BitMap Bool)
- n.=)
+ n/=)
(def: (set-bit-position bit bitmap)
(-> BitPosition BitMap BitMap)
@@ -203,7 +203,7 @@
## associated with it.
(def: bit-position-mask
(-> BitPosition BitMap)
- n.dec)
+ n/dec)
## The index on the base array, based on it's bit-position.
(def: (base-index bit-position bitmap)
@@ -227,16 +227,16 @@
(let [[bitmap base] node]
(case (array;read idx h-array)
#;None [insertion-idx node]
- (#;Some sub-node) (if (n.= except-idx idx)
+ (#;Some sub-node) (if (n/= except-idx idx)
[insertion-idx node]
- [(n.inc insertion-idx)
+ [(n/inc insertion-idx)
[(set-bit-position (->bit-position idx) bitmap)
(array;write insertion-idx (#;Left sub-node) base)]])
)))
[+0 [clean-bitmap
- ## (array;new (n.dec h-size))
+ ## (array;new (n/dec h-size))
(: (Base ($ +0) ($ +1))
- (array;new (n.dec h-size)))
+ (array;new (n/dec h-size)))
]]
(list;indices (array;size h-array)))))
@@ -253,7 +253,7 @@
(product;right (list/fold (function [hierarchy-idx (^@ default [base-idx h-array])]
(if (bit-position-is-set? (->bit-position hierarchy-idx)
bitmap)
- [(n.inc base-idx)
+ [(n/inc base-idx)
(case (array;read base-idx base)
(#;Some (#;Left sub-node))
(array;write hierarchy-idx sub-node h-array)
@@ -297,14 +297,14 @@
## [_size sub-node]
## _
- ## [(n.inc _size) empty])
+ ## [(n/inc _size) empty])
[_size' sub-node] (: [Nat (Node ($ +0) ($ +1))]
(case (array;read idx hierarchy)
(#;Some sub-node)
[_size sub-node]
_
- [(n.inc _size) empty]))
+ [(n/inc _size) empty]))
]
(#Hierarchy _size'
(update! idx (put' (level-up level) hash key val Hash<k> sub-node)
@@ -334,7 +334,7 @@
## Otherwise, I compare the hashes of the keys.
(#Base bitmap (update! idx
(#;Left (let [hash' (:: Hash<k> hash key')]
- (if (n.= hash hash')
+ (if (n/= hash hash')
## If the hashes are
## the same, a new
## #Collisions node
@@ -357,10 +357,10 @@
## However, if the BitPosition has not been used yet, I check
## whether this #Base node is ready for a promotion.
(let [base-count (bitmap-size bitmap)]
- (if (n.>= promotion-threshold base-count)
+ (if (n/>= promotion-threshold base-count)
## If so, I promote it to a #Hierarchy node, and add the new
## KV-pair as a singleton node to it.
- (#Hierarchy (n.inc base-count)
+ (#Hierarchy (n/inc base-count)
(|> (promote-base put' Hash<k> level bitmap base)
(array;write (level-index level hash)
(put' (level-up level) hash key val Hash<k> empty))))
@@ -371,7 +371,7 @@
## For #Collisions nodes, I compare the hashes.
(#Collisions _hash _colls)
- (if (n.= hash _hash)
+ (if (n/= hash _hash)
## If they're equal, that means the new KV contributes to the
## collisions.
(case (collision-index Hash<k> key _colls)
@@ -415,11 +415,11 @@
## But if the sub-removal yielded an empty sub-node...
(if (empty?' sub-node')
## Check if it's due time for a demotion.
- (if (n.<= demotion-threshold h-size)
+ (if (n/<= demotion-threshold h-size)
## If so, perform it.
(#Base (demote-hierarchy idx [h-size h-array]))
## Otherwise, just clear the space.
- (#Hierarchy (n.dec h-size) (vacant! idx h-array)))
+ (#Hierarchy (n/dec h-size) (vacant! idx h-array)))
## But if the sub-removal yielded a non-empty node, then
## just update the hiearchy branch.
(#Hierarchy h-size (update! idx sub-node' h-array)))))))
@@ -477,7 +477,7 @@
## But if so, then check the size of the collisions list.
(#;Some idx)
- (if (n.= +1 (array;size _colls))
+ (if (n/= +1 (array;size _colls))
## If there's only one left, then removing it leaves us with
## an empty node.
empty
@@ -522,10 +522,10 @@
(All [k v] (-> (Node k v) Nat))
(case node
(#Hierarchy _size hierarchy)
- (array/fold n.+ +0 (array/map size' hierarchy))
+ (array/fold n/+ +0 (array/map size' hierarchy))
(#Base _ base)
- (array/fold n.+ +0 (array/map (function [sub-node']
+ (array/fold n/+ +0 (array/map (function [sub-node']
(case sub-node'
(#;Left sub-node) (size' sub-node)
(#;Right _) +1))
@@ -614,7 +614,7 @@
(def: #export empty?
(All [k v] (-> (Dict k v) Bool))
- (|>. size (n.= +0)))
+ (|>. size (n/= +0)))
(def: #export (entries dict)
(All [k v] (-> (Dict k v) (List [k v])))
@@ -685,7 +685,7 @@
## [Structures]
(struct: #export (Eq<Dict> Eq<v>) (All [k v] (-> (Eq v) (Eq (Dict k v))))
(def: (= test subject)
- (and (n.= (size test)
+ (and (n/= (size test)
(size subject))
(list;every? (function [k]
(case [(get k test) (get k subject)]
diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux
index d7bbe0161..d00428478 100644
--- a/stdlib/source/lux/data/coll/list.lux
+++ b/stdlib/source/lux/data/coll/list.lux
@@ -67,7 +67,7 @@
[(def: #export (<name> n xs)
(All [a]
(-> Nat (List a) (List a)))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(case xs
#;Nil
#;Nil
@@ -76,8 +76,8 @@
<then>)
<else>))]
- [take (#;Cons [x (take (n.dec n) xs')]) #;Nil]
- [drop (drop (n.dec n) xs') xs]
+ [take (#;Cons [x (take (n/dec n) xs')]) #;Nil]
+ [drop (drop (n/dec n) xs') xs]
)
(do-template [<name> <then> <else>]
@@ -100,13 +100,13 @@
(def: #export (split n xs)
(All [a]
(-> Nat (List a) [(List a) (List a)]))
- (if (n.> +0 n)
+ (if (n/> +0 n)
(case xs
#;Nil
[#;Nil #;Nil]
(#;Cons [x xs'])
- (let [[tail rest] (split (n.dec n) xs')]
+ (let [[tail rest] (split (n/dec n) xs')]
[(#;Cons [x tail]) rest]))
[#;Nil xs]))
@@ -144,8 +144,8 @@
{#;doc "A list of the value x, repeated n times."}
(All [a]
(-> Nat a (List a)))
- (if (n.> +0 n)
- (#;Cons [x (repeat (n.dec n) x)])
+ (if (n/> +0 n)
+ (#;Cons [x (repeat (n/dec n) x)])
#;Nil))
(def: (iterate' f x)
@@ -198,7 +198,7 @@
(def: #export (size list)
(All [a] (-> (List a) Nat))
- (fold (function [_ acc] (n.+ +1 acc)) +0 list))
+ (fold (function [_ acc] (n/+ +1 acc)) +0 list))
(do-template [<name> <init> <op>]
[(def: #export (<name> p xs)
@@ -230,9 +230,9 @@
#;None
(#;Cons [x xs'])
- (if (n.= +0 i)
+ (if (n/= +0 i)
(#;Some x)
- (nth (n.dec i) xs'))))
+ (nth (n/dec i) xs'))))
## [Structures]
(struct: #export (Eq<List> Eq<a>)
@@ -311,8 +311,8 @@
(list& from (<name> (<inc> from) to))
(list)))]
- [i.range Int i.<= i.inc]
- [n.range Nat n.<= n.inc]
+ [i/range Int i/<= i/inc]
+ [n/range Nat n/<= n/inc]
)
(def: #export (empty? xs)
@@ -355,16 +355,16 @@
((zip +3) xs ys zs))}
(case tokens
(^ (list [_ (#;Nat num-lists)]))
- (if (n.> +0 num-lists)
+ (if (n/> +0 num-lists)
(let [(^open) Functor<List>
- indices (n.range +0 (n.dec num-lists))
+ indices (n/range +0 (n/dec num-lists))
type-vars (: (List Code) (map (. symbol$ Nat/encode) indices))
zip-type (` (All [(~@ type-vars)]
(-> (~@ (map (: (-> Code Code) (function [var] (` (List (~ var)))))
type-vars))
(List [(~@ type-vars)]))))
vars+lists (|> indices
- (map n.inc)
+ (map n/inc)
(map (function [idx]
(let [base (Nat/encode idx)]
[(symbol$ base)
@@ -396,12 +396,12 @@
{#;doc (doc "Create list zippers with the specified number of input lists."
(def: #export zip2-with (zip-with +2))
(def: #export zip3-with (zip-with +3))
- ((zip-with +2) i.+ xs ys))}
+ ((zip-with +2) i/+ xs ys))}
(case tokens
(^ (list [_ (#;Nat num-lists)]))
- (if (n.> +0 num-lists)
+ (if (n/> +0 num-lists)
(let [(^open) Functor<List>
- indices (n.range +0 (n.dec num-lists))
+ indices (n/range +0 (n/dec num-lists))
g!return-type (symbol$ "\treturn-type\t")
g!func (symbol$ "\tfunc\t")
type-vars (: (List Code) (map (. symbol$ Nat/encode) indices))
@@ -411,7 +411,7 @@
type-vars))
(List (~ g!return-type)))))
vars+lists (|> indices
- (map n.inc)
+ (map n/inc)
(map (function [idx]
(let [base (Nat/encode idx)]
[(symbol$ base)
@@ -499,7 +499,7 @@
#;Nil
(#;Cons x xs')
- (#;Cons [idx x] (enumerate' (n.inc idx) xs'))))
+ (#;Cons [idx x] (enumerate' (n/inc idx) xs'))))
(def: #export (enumerate xs)
{#;doc "Pairs every element in the list with it's index, starting at 0."}
@@ -509,6 +509,6 @@
(def: #export (indices size)
{#;doc "Produces all the valid indices for a given size."}
(All [a] (-> Nat (List Nat)))
- (if (n.= +0 size)
+ (if (n/= +0 size)
(list)
- (|> size n.dec (n.range +0))))
+ (|> size n/dec (n/range +0))))
diff --git a/stdlib/source/lux/data/coll/ordered/dict.lux b/stdlib/source/lux/data/coll/ordered/dict.lux
index 24b6b7c3b..ecf661b15 100644
--- a/stdlib/source/lux/data/coll/ordered/dict.lux
+++ b/stdlib/source/lux/data/coll/ordered/dict.lux
@@ -115,11 +115,11 @@
+0
(#;Some node)
- (n.inc (<op> (recur (get@ #left node))
+ (n/inc (<op> (recur (get@ #left node))
(recur (get@ #right node)))))))]
- [size n.+]
- [depth n.max]
+ [size n/+]
+ [depth n/max]
)
(do-template [<name> <other-color> <self-color> <no-change>]
diff --git a/stdlib/source/lux/data/coll/priority-queue.lux b/stdlib/source/lux/data/coll/priority-queue.lux
index 96ad71a6b..5e270518d 100644
--- a/stdlib/source/lux/data/coll/priority-queue.lux
+++ b/stdlib/source/lux/data/coll/priority-queue.lux
@@ -22,7 +22,7 @@
(All [a] (-> (Queue a) (Maybe a)))
(do maybe;Monad<Maybe>
[fingers queue]
- (wrap (maybe;assume (F;search (n.= (F;tag fingers)) fingers)))))
+ (wrap (maybe;assume (F;search (n/= (F;tag fingers)) fingers)))))
(def: #export (size queue)
(All [a] (-> (Queue a) Nat))
@@ -37,7 +37,7 @@
+1
(#F;Branch _ left right)
- (n.+ (recur left) (recur right))))))
+ (n/+ (recur left) (recur right))))))
(def: #export (member? Eq<a> queue member)
(All [a] (-> (Eq a) (Queue a) a Bool))
@@ -63,12 +63,12 @@
node' (loop [node (get@ #F;tree fingers)]
(case node
(#F;Leaf priority reference)
- (if (n.= highest-priority priority)
+ (if (n/= highest-priority priority)
#;None
(#;Some node))
(#F;Branch priority left right)
- (if (n.= highest-priority (F;tag (set@ #F;tree left fingers)))
+ (if (n/= highest-priority (F;tag (set@ #F;tree left fingers)))
(case (recur left)
#;None
(#;Some right)
diff --git a/stdlib/source/lux/data/coll/queue.lux b/stdlib/source/lux/data/coll/queue.lux
index b6e5a7161..dd26ccc32 100644
--- a/stdlib/source/lux/data/coll/queue.lux
+++ b/stdlib/source/lux/data/coll/queue.lux
@@ -30,7 +30,7 @@
(def: #export (size queue)
(All [a] (-> (Queue a) Nat))
(let [(^slots [#front #rear]) queue]
- (n.+ (list;size front)
+ (n/+ (list;size front)
(list;size rear))))
(def: #export empty?
diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux
index f76c824a7..d8c3ddfb9 100644
--- a/stdlib/source/lux/data/coll/sequence.lux
+++ b/stdlib/source/lux/data/coll/sequence.lux
@@ -42,8 +42,8 @@
(-> Level Level)
(<op> branching-exponent))]
- [level-up n.+]
- [level-down n.-]
+ [level-up n/+]
+ [level-down n/-]
)
(def: full-node-size
@@ -52,7 +52,7 @@
(def: branch-idx-mask
Nat
- (n.dec full-node-size))
+ (n/dec full-node-size))
(def: branch-idx
(-> Index Index)
@@ -64,15 +64,15 @@
(def: (tail-off vec-size)
(-> Nat Nat)
- (if (n.< full-node-size vec-size)
+ (if (n/< full-node-size vec-size)
+0
- (|> (n.dec vec-size)
+ (|> (n/dec vec-size)
(bit;shift-right branching-exponent)
(bit;shift-left branching-exponent))))
(def: (new-path level tail)
(All [a] (-> Level (Base a) (Node a)))
- (if (n.= +0 level)
+ (if (n/= +0 level)
(#Base tail)
(|> ## (new-hierarchy [])
(: (Hierarchy ($ +0))
@@ -89,9 +89,9 @@
(def: (push-tail size level tail parent)
(All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a)))
- (let [sub-idx (branch-idx (bit;shift-right level (n.dec size)))
+ (let [sub-idx (branch-idx (bit;shift-right level (n/dec size)))
## If we're currently on a bottom node
- sub-node (if (n.= branching-exponent level)
+ sub-node (if (n/= branching-exponent level)
## Just add the tail to it
(#Base tail)
## Otherwise, check whether there's a vacant spot
@@ -112,9 +112,9 @@
(def: (expand-tail val tail)
(All [a] (-> a (Base a) (Base a)))
(let [tail-size (array;size tail)]
- (|> ## (array;new (n.inc tail-size))
+ (|> ## (array;new (n/inc tail-size))
(: (Base ($ +0))
- (array;new (n.inc tail-size)))
+ (array;new (n/inc tail-size)))
(array;copy tail-size +0 tail +0)
(array;write tail-size val)
)))
@@ -128,7 +128,7 @@
(array;write sub-idx (#Hierarchy (put' (level-down level) idx val sub-node))))
(^multi (#;Some (#Base base))
- (n.= +0 (level-down level)))
+ (n/= +0 (level-down level)))
(|> (array;clone hierarchy)
(array;write sub-idx (|> (array;clone base)
(array;write (branch-idx idx) val)
@@ -139,11 +139,11 @@
(def: (pop-tail size level hierarchy)
(All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a))))
- (let [sub-idx (branch-idx (bit;shift-right level (n.- +2 size)))]
- (cond (n.= +0 sub-idx)
+ (let [sub-idx (branch-idx (bit;shift-right level (n/- +2 size)))]
+ (cond (n/= +0 sub-idx)
#;None
- (n.> branching-exponent level)
+ (n/> branching-exponent level)
(do maybe;Monad<Maybe>
[base|hierarchy (array;read sub-idx hierarchy)
sub (case base|hierarchy
@@ -198,15 +198,15 @@
(All [a] (-> a (Sequence a) (Sequence a)))
## Check if there is room in the tail.
(let [vec-size (get@ #size vec)]
- (if (|> vec-size (n.- (tail-off vec-size)) (n.< full-node-size))
+ (if (|> vec-size (n/- (tail-off vec-size)) (n/< full-node-size))
## If so, append to it.
(|> vec
- (update@ #size n.inc)
+ (update@ #size n/inc)
(update@ #tail (expand-tail val)))
## Otherwise, push tail into the tree
## --------------------------------------------------------
## Will the root experience an overflow with this addition?
- (|> (if (n.> (bit;shift-left (get@ #level vec) +1)
+ (|> (if (n/> (bit;shift-left (get@ #level vec) +1)
(bit;shift-right branching-exponent vec-size))
## If so, a brand-new root must be established, that is
## 1-level taller.
@@ -222,20 +222,20 @@
(update@ #root (push-tail vec-size (get@ #level vec) (get@ #tail vec)))))
## Finally, update the size of the Sequence and grow a new
## tail with the new element as it's sole member.
- (update@ #size n.inc)
+ (update@ #size n/inc)
(set@ #tail (new-tail val)))
)))
(def: (base-for idx vec)
(All [a] (-> Index (Sequence a) (Maybe (Base a))))
(let [vec-size (get@ #size vec)]
- (if (and (n.>= +0 idx)
- (n.< vec-size idx))
- (if (n.>= (tail-off vec-size) idx)
+ (if (and (n/>= +0 idx)
+ (n/< vec-size idx))
+ (if (n/>= (tail-off vec-size) idx)
(#;Some (get@ #tail vec))
(loop [level (get@ #level vec)
hierarchy (get@ #root vec)]
- (case [(n.> branching-exponent level)
+ (case [(n/> branching-exponent level)
(array;read (branch-idx (bit;shift-right level idx)) hierarchy)]
[true (#;Some (#Hierarchy sub))]
(recur (level-down level) sub)
@@ -259,9 +259,9 @@
(def: #export (put idx val vec)
(All [a] (-> Nat a (Sequence a) (Sequence a)))
(let [vec-size (get@ #size vec)]
- (if (and (n.>= +0 idx)
- (n.< vec-size idx))
- (if (n.>= (tail-off vec-size) idx)
+ (if (and (n/>= +0 idx)
+ (n/< vec-size idx))
+ (if (n/>= (tail-off vec-size) idx)
(|> vec
## (update@ #tail (|>. array;clone (array;write (branch-idx idx) val)))
(update@ #tail (: (-> (Base ($ +0)) (Base ($ +0)))
@@ -290,16 +290,16 @@
empty
vec-size
- (if (|> vec-size (n.- (tail-off vec-size)) (n.> +1))
+ (if (|> vec-size (n/- (tail-off vec-size)) (n/> +1))
(let [old-tail (get@ #tail vec)
- new-tail-size (n.dec (array;size old-tail))]
+ new-tail-size (n/dec (array;size old-tail))]
(|> vec
- (update@ #size n.dec)
+ (update@ #size n/dec)
(set@ #tail (|> (array;new new-tail-size)
(array;copy new-tail-size +0 old-tail +0)))))
(maybe;assume
(do maybe;Monad<Maybe>
- [new-tail (base-for (n.- +2 vec-size) vec)
+ [new-tail (base-for (n/- +2 vec-size) vec)
#let [## [level' root'] (let [init-level (get@ #level vec)]
## (loop [level init-level
## root (maybe;default (new-hierarchy [])
@@ -308,7 +308,7 @@
## ## (maybe;default (new-hierarchy [])
## ## (pop-tail vec-size init-level (get@ #root vec))))
## ]
- ## (if (n.> branching-exponent level)
+ ## (if (n/> branching-exponent level)
## (case [(array;read +1 root) (array;read +0 root)]
## [#;None (#;Some (#Hierarchy sub-node))]
## (recur (level-down level) sub-node)
@@ -325,7 +325,7 @@
root (: (Hierarchy ($ +0))
(maybe;default (new-hierarchy [])
(pop-tail vec-size init-level (get@ #root vec))))]
- (if (n.> branching-exponent level)
+ (if (n/> branching-exponent level)
(case [(array;read +1 root) (array;read +0 root)]
[#;None (#;Some (#Hierarchy sub-node))]
(recur (level-down level) sub-node)
@@ -338,7 +338,7 @@
[level root]))))
]]
(wrap (|> vec
- (update@ #size n.dec)
+ (update@ #size n/dec)
(set@ #level level')
(set@ #root root')
(set@ #tail new-tail))))))
@@ -363,7 +363,7 @@
(def: #export empty?
(All [a] (-> (Sequence a) Bool))
- (|>. (get@ #size) (n.= +0)))
+ (|>. (get@ #size) (n/= +0)))
## [Syntax]
(syntax: #export (sequence [elems (p;some s;any)])
@@ -386,7 +386,7 @@
(struct: #export (Eq<Sequence> Eq<a>) (All [a] (-> (Eq a) (Eq (Sequence a))))
(def: (= v1 v2)
- (and (n.= (get@ #size v1) (get@ #size v2))
+ (and (n/= (get@ #size v1) (get@ #size v2))
(let [(^open "Node/") (Eq<Node> Eq<a>)]
(and (Node/= (#Base (get@ #tail v1))
(#Base (get@ #tail v2)))
diff --git a/stdlib/source/lux/data/coll/set.lux b/stdlib/source/lux/data/coll/set.lux
index 328524a06..b8f860353 100644
--- a/stdlib/source/lux/data/coll/set.lux
+++ b/stdlib/source/lux/data/coll/set.lux
@@ -52,7 +52,7 @@
(def: #export (empty? set)
(All [a] (-> (Set a) Bool))
- (n.= +0 (dict;size set)))
+ (n/= +0 (dict;size set)))
(def: #export (sub? super sub)
(All [a] (-> (Set a) (Set a) Bool))
@@ -71,6 +71,6 @@
(def: eq Eq<Set>)
(def: (hash (^@ set [Hash<a> _]))
- (List/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc))
+ (List/fold (function [elem acc] (n/+ (:: Hash<a> hash elem) acc))
+0
(to-list set))))
diff --git a/stdlib/source/lux/data/coll/stream.lux b/stdlib/source/lux/data/coll/stream.lux
index 43ed0087c..0f1297e8f 100644
--- a/stdlib/source/lux/data/coll/stream.lux
+++ b/stdlib/source/lux/data/coll/stream.lux
@@ -58,8 +58,8 @@
(def: #export (nth idx s)
(All [a] (-> Nat (Stream a) a))
(let [[h t] (cont;run s)]
- (if (n.> +0 idx)
- (nth (n.dec idx) t)
+ (if (n/> +0 idx)
+ (nth (n/dec idx) t)
h)))
(do-template [<taker> <dropper> <splitter> <pred-type> <pred-test> <pred-step>]
@@ -89,7 +89,7 @@
[(list) xs])))]
[take-while drop-while split-while (-> a Bool) (pred x) pred]
- [take drop split Nat (n.> +0 pred) (n.dec pred)]
+ [take drop split Nat (n/> +0 pred) (n/dec pred)]
)
(def: #export (unfold step init)
diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux
index 61ee1249a..17546902a 100644
--- a/stdlib/source/lux/data/color.lux
+++ b/stdlib/source/lux/data/color.lux
@@ -6,7 +6,7 @@
(type opaque)))
(def: rgb Nat +256)
-(def: top Nat (n.dec rgb))
+(def: top Nat (n/dec rgb))
(def: nat-to-frac (-> Nat Frac) (|>. nat-to-int int-to-frac))
(def: frac-to-nat (-> Frac Nat) (|>. frac-to-int int-to-nat))
@@ -15,11 +15,11 @@
(def: scale-down
(-> Nat Frac)
- (|>. nat-to-frac (f./ rgb-factor)))
+ (|>. nat-to-frac (f// rgb-factor)))
(def: scale-up
(-> Frac Nat)
- (|>. (f.* rgb-factor) frac-to-nat))
+ (|>. (f/* rgb-factor) frac-to-nat))
(opaque: #export Color {}
{#red Nat
@@ -28,9 +28,9 @@
(def: #export (color [red green blue])
(-> [Nat Nat Nat] Color)
- (@opaque [(n.% rgb red)
- (n.% rgb green)
- (n.% rgb blue)]))
+ (@opaque [(n/% rgb red)
+ (n/% rgb green)
+ (n/% rgb blue)]))
(def: #export unpack
(-> Color [Nat Nat Nat])
@@ -40,9 +40,9 @@
(def: (= reference sample)
(let [[rr rg rb] (@repr reference)
[sr sg sb] (@repr sample)]
- (and (n.= rr sr)
- (n.= rg sg)
- (n.= rb sb)))))
+ (and (n/= rr sr)
+ (n/= rg sg)
+ (n/= rb sb)))))
)
(def: #export (to-hsl color)
@@ -51,67 +51,67 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- max ($_ f.max red green blue)
- min ($_ f.min red green blue)
- luminance (|> (f.+ max min) (f./ 2.0))]
- (if (f.= max min)
+ max ($_ f/max red green blue)
+ min ($_ f/min red green blue)
+ luminance (|> (f/+ max min) (f// 2.0))]
+ (if (f/= max min)
## Achromatic
[0.0 0.0 luminance]
## Chromatic
- (let [diff (|> max (f.- min))
+ (let [diff (|> max (f/- min))
saturation (|> diff
- (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/> 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.= green max)
- (|> blue (f.- red) (f./ diff)
- (f.+ 2.0))
+ (f/= green max)
+ (|> blue (f/- red) (f// diff)
+ (f/+ 2.0))
- ## (f.= blue max)
- (|> red (f.- green) (f./ diff)
- (f.+ 4.0)))]
- [(|> hue' (f./ 6.0))
+ ## (f/= blue max)
+ (|> red (f/- green) (f// diff)
+ (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))
+ (f/< f2/3 t)
+ (|> 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))
- (|> luminance (f.+ saturation) (f.- (f.* saturation luminance))))
- p (|> luminance (f.* 2.0) (f.- q))
- third (|> 1.0 (f./ 3.0))]
- (color [(scale-up (|> hue (f.+ third) (hue-to-rgb p q)))
+ (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))]
+ (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)))]))))
+ (scale-up (|> hue (f/- third) (hue-to-rgb p q)))]))))
(def: #export (to-hsb color)
(-> Color [Frac Frac Frac])
@@ -119,42 +119,42 @@
red (scale-down red)
green (scale-down green)
blue (scale-down blue)
- max ($_ f.max red green blue)
- min ($_ f.min red green blue)
+ max ($_ f/max red green blue)
+ min ($_ f/min red green blue)
brightness max
- diff (|> max (f.- min))
- saturation (if (f.= 0.0 max)
+ diff (|> max (f/- min))
+ saturation (if (f/= 0.0 max)
0.0
- (|> diff (f./ max)))]
- (if (f.= max min)
+ (|> diff (f// max)))]
+ (if (f/= max min)
## Achromatic
[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.= green max)
- (|> blue (f.- red) (f./ diff)
- (f.+ 2.0))
-
- ## (f.= blue max)
- (|> red (f.- green) (f./ diff)
- (f.+ 4.0)))]
- [(|> hue (f./ 6.0))
+ (let [hue (cond (f/= red max)
+ (|> green (f/- blue) (f// diff)
+ (f/+ (if (f/< blue green) 6.0 0.0)))
+
+ (f/= green max)
+ (|> blue (f/- red) (f// diff)
+ (f/+ 2.0))
+
+ ## (f/= blue max)
+ (|> red (f/- green) (f// diff)
+ (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))
+ 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))
v brightness
- mod (|> i (f.% 6.0) frac-to-nat)
+ mod (|> i (f/% 6.0) frac-to-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))))
+ 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 (|> 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,11 +203,11 @@
(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]
- (frac-to-nat (f.+ (f.* dE (nat-to-frac end))
- (f.* dS (nat-to-frac start))))))
+ (frac-to-nat (f/+ (f/* dE (nat-to-frac end))
+ (f/* dS (nat-to-frac start))))))
[redS greenS blueS] (unpack start)
[redE greenE blueE] (unpack end)]
(color [(interpolate' redE redS)
@@ -229,7 +229,7 @@
(def: #export (complement color)
(-> Color Color)
(let [[red green blue] (unpack color)
- adjust (function [value] (|> top (n.- value)))]
+ adjust (function [value] (|> top (n/- value)))]
(;;color [(adjust red)
(adjust green)
(adjust blue)])))
@@ -240,12 +240,12 @@
(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.+]
- [de-saturate f.-]
+ [saturate f/+]
+ [de-saturate f/-]
)
(def: #export (gray-scale color)
@@ -258,12 +258,12 @@
(-> Color [Color Color Color])
(let [[hue saturation luminance] (to-hsl color)]
[color
- (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance])]))]
+ (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>]
@@ -271,36 +271,36 @@
(-> Color [Color Color Color Color])
(let [[hue saturation luminance] (to-hsl color)]
[color
- (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance])
- (from-hsl [(|> hue (f.+ <3>) normalize) saturation luminance])]))]
+ (from-hsl [(|> hue (f/+ <1>) normalize) saturation luminance])
+ (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)
(-> Nat Frac Color (List Color))
- (if (n.= +0 results)
+ (if (n/= +0 results)
(list)
(let [[hue saturation luminance] (to-hsl color)
slice (normalize slice)]
(L/map (function [idx]
- (from-hsl [(|> idx nat-to-frac (f.* slice) (f.+ hue) normalize)
+ (from-hsl [(|> idx nat-to-frac (f/* slice) (f/+ hue) normalize)
saturation
luminance]))
- (list;n.range +0 (n.dec results))))))
+ (list;n/range +0 (n/dec results))))))
(def: #export (monochromatic results color)
(-> Nat Color (List Color))
- (if (n.= +0 results)
+ (if (n/= +0 results)
(list)
(let [[hue saturation brightness] (to-hsb color)
- slice (|> 1.0 (f./ (nat-to-frac results)))]
- (|> (list;n.range +0 (n.dec results))
+ slice (|> 1.0 (f// (nat-to-frac results)))]
+ (|> (list;n/range +0 (n/dec results))
(L/map (|>. nat-to-frac
- (f.* slice)
- (f.+ brightness)
+ (f/* slice)
+ (f/+ brightness)
normalize
[hue saturation]
from-hsb))))))
diff --git a/stdlib/source/lux/data/format/css.lux b/stdlib/source/lux/data/format/css.lux
index 0c4551e0a..2b0a1a03b 100644
--- a/stdlib/source/lux/data/format/css.lux
+++ b/stdlib/source/lux/data/format/css.lux
@@ -51,7 +51,7 @@
(format "rgba(" (|> red nat-to-int %i)
"," (|> green nat-to-int %i)
"," (|> blue nat-to-int %i)
- "," (if (d.= (:: number;Interval<Deg> top) alpha)
+ "," (if (d/= (:: number;Interval<Deg> top) alpha)
"1.0"
(format "0" (%d alpha)))
")")))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 029d8dde7..b007dba42 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -164,7 +164,7 @@
[#String text;Eq<Text>])
[(#Array xs) (#Array ys)]
- (and (n.= (sequence;size xs) (sequence;size ys))
+ (and (n/= (sequence;size xs) (sequence;size ys))
(list/fold (function [idx prev]
(and prev
(maybe;default false
@@ -176,7 +176,7 @@
(list;indices (sequence;size xs))))
[(#Object xs) (#Object ys)]
- (and (n.= (dict;size xs) (dict;size ys))
+ (and (n/= (dict;size xs) (dict;size ys))
(list/fold (function [[xk xv] prev]
(and prev
(case (dict;get xk ys)
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 1e705e513..64b45851d 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -235,7 +235,7 @@
(#Node sample/tag sample/attrs sample/children)]
(and (ident/= reference/tag sample/tag)
(:: (d;Eq<Dict> text;Eq<Text>) = reference/attrs sample/attrs)
- (n.= (list;size reference/children)
+ (n/= (list;size reference/children)
(list;size sample/children))
(|> (list;zip2 reference/children sample/children)
(list;every? (product;uncurry =))))
diff --git a/stdlib/source/lux/data/ident.lux b/stdlib/source/lux/data/ident.lux
index 592f648ba..24fe97221 100644
--- a/stdlib/source/lux/data/ident.lux
+++ b/stdlib/source/lux/data/ident.lux
@@ -49,4 +49,4 @@
(def: (hash [module name])
(let [(^open) text;Hash<Text>]
- (n.+ (hash module) (hash name)))))
+ (n/+ (hash module) (hash name)))))
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 446e1e152..2749d566c 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -17,10 +17,10 @@
[(struct: #export _ (Eq <type>)
(def: = <test>))]
- [ Nat n.=]
- [ Int i.=]
- [ Deg d.=]
- [Frac f.=]
+ [ Nat n/=]
+ [ Int i/=]
+ [ Deg d/=]
+ [Frac f/=]
)
(do-template [<type> <eq> <lt> <lte> <gt> <gte>]
@@ -31,18 +31,18 @@
(def: > <gt>)
(def: >= <gte>))]
- [ Nat Eq<Nat> n.< n.<= n.> n.>=]
- [ Int Eq<Int> i.< i.<= i.> i.>=]
- [Deg Eq<Deg> d.< d.<= d.> d.>=]
- [Frac Eq<Frac> f.< f.<= f.> f.>=]
+ [ Nat Eq<Nat> n/< n/<= n/> n/>=]
+ [ Int Eq<Int> i/< i/<= i/> i/>=]
+ [Deg Eq<Deg> d/< d/<= d/> d/>=]
+ [Frac Eq<Frac> f/< f/<= f/> f/>=]
)
(struct: #export _ (Number Nat)
- (def: + n.+)
- (def: - n.-)
- (def: * n.*)
- (def: / n./)
- (def: % n.%)
+ (def: + n/+)
+ (def: - n/-)
+ (def: * n/*)
+ (def: / n//)
+ (def: % n/%)
(def: negate id)
(def: abs id)
(def: (signum x)
@@ -70,17 +70,17 @@
<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]
)
(struct: #export _ (Number Deg)
- (def: + d.+)
- (def: - d.-)
- (def: * d.*)
- (def: / d./)
- (def: % d.%)
- (def: (negate x) (d.- x ("lux deg max")))
+ (def: + d/+)
+ (def: - d/-)
+ (def: * d/*)
+ (def: / d//)
+ (def: % d/%)
+ (def: (negate x) (d/- x ("lux deg max")))
(def: abs id)
(def: (signum x)
("lux deg max")))
@@ -91,10 +91,10 @@
(def: succ <succ>)
(def: pred <pred>))]
- [Nat Order<Nat> n.inc n.dec]
- [Int Order<Int> i.inc i.dec]
- [Frac Order<Frac> (f.+ ("lux frac smallest")) (f.- ("lux frac smallest"))]
- [Deg Order<Deg> (d.+ ("lux deg min")) (d.- ("lux deg min"))]
+ [Nat Order<Nat> n/inc n/dec]
+ [Int Order<Int> i/inc i/dec]
+ [Frac Order<Frac> (f/+ ("lux frac smallest")) (f/- ("lux frac smallest"))]
+ [Deg Order<Deg> (d/+ ("lux deg min")) (d/- ("lux deg min"))]
)
(do-template [<type> <enum> <top> <bottom>]
@@ -114,22 +114,22 @@
(def: identity <identity>)
(def: compose <compose>))]
- [ Add@Monoid<Nat> Nat +0 n.+]
- [ 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.*]
- [ 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.*]
- [Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f.max]
- [Min@Monoid<Frac> Frac (:: Interval<Frac> top) f.min]
- [ Add@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.+]
- [ Mul@Monoid<Deg> Deg (:: Interval<Deg> top) d.*]
- [ Max@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.max]
- [ Min@Monoid<Deg> Deg (:: Interval<Deg> top) d.min]
+ [ Add@Monoid<Nat> Nat +0 n/+]
+ [ 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/*]
+ [ 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/*]
+ [Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f/max]
+ [Min@Monoid<Frac> Frac (:: Interval<Frac> top) f/min]
+ [ Add@Monoid<Deg> Deg (:: Interval<Deg> bottom) d/+]
+ [ Mul@Monoid<Deg> Deg (:: Interval<Deg> top) d/*]
+ [ Max@Monoid<Deg> Deg (:: Interval<Deg> bottom) d/max]
+ [ Min@Monoid<Deg> Deg (:: Interval<Deg> top) d/min]
)
(do-template [<name> <const> <doc>]
@@ -146,13 +146,13 @@
(def: #export (not-a-number? number)
{#;doc "Tests whether a frac is actually not-a-number."}
(-> Frac Bool)
- (not (f.= number number)))
+ (not (f/= number number)))
(def: #export (frac? value)
(-> Frac Bool)
(not (or (not-a-number? value)
- (f.= positive-infinity value)
- (f.= negative-infinity value))))
+ (f/= positive-infinity value)
+ (f/= negative-infinity value))))
(do-template [<type> <encoder> <decoder> <error>]
[(struct: #export _ (Codec Text <type>)
@@ -173,37 +173,37 @@
## [Values & Syntax]
(def: (get-char full idx)
(-> Text Nat (Maybe Text))
- ("lux text clip" full idx (n.inc idx)))
+ ("lux text clip" full idx (n/inc idx)))
(do-template [<struct> <base> <char-set> <error>]
[(struct: #export <struct> (Codec Text Nat)
(def: (encode value)
(loop [input value
output ""]
- (let [digit (maybe;assume (get-char <char-set> (n.% <base> input)))
+ (let [digit (maybe;assume (get-char <char-set> (n/% <base> input)))
output' ("lux text concat" digit output)
- input' (n./ <base> input)]
- (if (n.= +0 input')
+ input' (n// <base> input)]
+ (if (n/= +0 input')
("lux text concat" "+" output')
(recur input' output')))))
(def: (decode repr)
(let [input-size ("lux text size" repr)]
- (if (n.>= +2 input-size)
+ (if (n/>= +2 input-size)
(case ("lux text char" repr +0)
(^ (#;Some (char "+")))
(let [input ("lux text upper" repr)]
(loop [idx +1
output +0]
- (if (n.< input-size idx)
+ (if (n/< input-size idx)
(let [digit (maybe;assume (get-char input idx))]
(case ("lux text index" <char-set> digit +0)
#;None
(#e;Error ("lux text concat" <error> repr))
(#;Some index)
- (recur (n.inc idx)
- (|> output (n.* <base>) (n.+ index)))))
+ (recur (n/inc idx)
+ (|> output (n/* <base>) (n/+ index)))))
(#e;Success output))))
_
@@ -219,24 +219,24 @@
(do-template [<struct> <base> <char-set> <error>]
[(struct: #export <struct> (Codec Text Int)
(def: (encode value)
- (if (i.= 0 value)
+ (if (i/= 0 value)
"0"
- (let [sign (if (i.< 0 value)
+ (let [sign (if (i/< 0 value)
"-"
"")]
- (loop [input (|> value (i./ <base>) (:: Number<Int> abs))
- output (|> value (i.% <base>) (:: Number<Int> abs) int-to-nat
+ (loop [input (|> value (i// <base>) (:: Number<Int> abs))
+ output (|> value (i/% <base>) (:: Number<Int> abs) int-to-nat
(get-char <char-set>)
maybe;assume)]
- (if (i.= 0 input)
+ (if (i/= 0 input)
("lux text concat" sign output)
- (let [digit (maybe;assume (get-char <char-set> (int-to-nat (i.% <base> input))))]
- (recur (i./ <base> input)
+ (let [digit (maybe;assume (get-char <char-set> (int-to-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)
+ (if (n/>= +1 input-size)
(let [sign (case (get-char repr +0)
(^ (#;Some "-"))
-1
@@ -244,18 +244,18 @@
_
1)
input ("lux text upper" repr)]
- (loop [idx (if (i.= -1 sign) +1 +0)
+ (loop [idx (if (i/= -1 sign) +1 +0)
output 0]
- (if (n.< input-size idx)
+ (if (n/< input-size idx)
(let [digit (maybe;assume (get-char input idx))]
(case ("lux text index" <char-set> digit +0)
#;None
(#e;Error <error>)
(#;Some index)
- (recur (n.inc idx)
- (|> output (i.* <base>) (i.+ (:! Int index))))))
- (#e;Success (i.* sign output)))))
+ (recur (n/inc idx)
+ (|> output (i/* <base>) (i/+ (:! Int index))))))
+ (#e;Success (i/* sign output)))))
(#e;Error <error>)))))]
[Binary@Codec<Text,Int> 2 "01" "Invalid binary syntax for Int: "]
@@ -272,20 +272,20 @@
[(struct: #export <struct> (Codec Text Deg)
(def: (encode value)
(let [raw-output (de-prefix (:: <nat> encode (:! Nat value)))
- max-num-chars (n./ <char-bit-size> +64)
+ max-num-chars (n// <char-bit-size> +64)
raw-size ("lux text size" raw-output)
- zero-padding (loop [zeroes-left (n.- raw-size max-num-chars)
+ zero-padding (loop [zeroes-left (n/- raw-size max-num-chars)
output ""]
- (if (n.= +0 zeroes-left)
+ (if (n/= +0 zeroes-left)
output
- (recur (n.dec zeroes-left)
+ (recur (n/dec zeroes-left)
("lux text concat" "0" output))))
padded-output ("lux text concat" zero-padding raw-output)]
("lux text concat" "." padded-output)))
(def: (decode repr)
(let [repr-size ("lux text size" repr)]
- (if (n.>= +2 repr-size)
+ (if (n/>= +2 repr-size)
(case ("lux text char" repr +0)
(^multi (^ (#;Some (char ".")))
[(:: <nat> decode ("lux text concat" "+" (de-prefix repr)))
@@ -306,17 +306,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 int-to-nat
+ (let [shifted (f/* <base> dec-left)
+ digit (|> shifted (f/% <base>) frac-to-int int-to-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)))
@@ -324,29 +324,29 @@
(case ("lux text index" repr "." +0)
(#;Some split-index)
(let [whole-part (maybe;assume ("lux text clip" repr +0 split-index))
- decimal-part (maybe;assume ("lux text clip" repr (n.inc split-index) ("lux text size" repr)))]
+ decimal-part (maybe;assume ("lux text clip" repr (n/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)
+ (i/>= 0 decimal))
+ (let [sign (if (i/< 0 whole)
-1.0
1.0)
div-power (loop [muls-left ("lux text size" decimal-part)
output 1.0]
- (if (n.= +0 muls-left)
+ (if (n/= +0 muls-left)
output
- (recur (n.dec muls-left)
- (f.* <base> output))))
- adjusted-decimal (|> decimal int-to-frac (f./ div-power))
+ (recur (n/dec muls-left)
+ (f/* <base> output))))
+ adjusted-decimal (|> decimal int-to-frac (f// div-power))
dec-deg (case (:: Hex@Codec<Text,Deg> decode ("lux text concat" "." decimal-part))
(#e;Success dec-deg)
dec-deg
(#e;Error error)
(error! error))]
- (#e;Success (f.+ (int-to-frac whole)
- (f.* sign adjusted-decimal))))
+ (#e;Success (f/+ (int-to-frac whole)
+ (f/* sign adjusted-decimal))))
_
(#e;Error ("lux text concat" <error> repr))))
@@ -365,9 +365,9 @@
_
(let [num-digits ("lux text size" digits)]
- (if (n.<= chunk-size num-digits)
+ (if (n/<= chunk-size num-digits)
(list digits)
- (let [boundary (n.- chunk-size num-digits)
+ (let [boundary (n/- chunk-size num-digits)
chunk (maybe;assume ("lux text clip" digits boundary num-digits))
remaining (maybe;assume ("lux text clip" digits +0 boundary))]
(list& chunk (segment-digits chunk-size remaining)))))))
@@ -461,17 +461,17 @@
(do-template [<from> <from-translator> <to> <to-translator> <base-bits>]
[(def: (<from> on-left? input)
(-> Bool Text Text)
- (let [max-num-chars (n./ <base-bits> +64)
+ (let [max-num-chars (n// <base-bits> +64)
input-size ("lux text size" input)
- zero-padding (let [num-digits-that-need-padding (n.% <base-bits> input-size)]
- (if (n.= +0 num-digits-that-need-padding)
+ zero-padding (let [num-digits-that-need-padding (n/% <base-bits> input-size)]
+ (if (n/= +0 num-digits-that-need-padding)
""
- (loop [zeroes-left (n.- num-digits-that-need-padding
+ (loop [zeroes-left (n/- num-digits-that-need-padding
<base-bits>)
output ""]
- (if (n.= +0 zeroes-left)
+ (if (n/= +0 zeroes-left)
output
- (recur (n.dec zeroes-left)
+ (recur (n/dec zeroes-left)
("lux text concat" "0" output))))))
padded-input (if on-left?
("lux text concat" zero-padding input)
@@ -499,13 +499,13 @@
raw-bin (:: Binary@Codec<Text,Frac> encode value)
dot-idx (maybe;assume ("lux text index" raw-bin "." +0))
whole-part (maybe;assume ("lux text clip" raw-bin
- (if (f.= -1.0 sign) +1 +0)
+ (if (f/= -1.0 sign) +1 +0)
dot-idx))
- decimal-part (maybe;assume ("lux text clip" raw-bin (n.inc dot-idx) ("lux text size" raw-bin)))
+ decimal-part (maybe;assume ("lux text clip" raw-bin (n/inc dot-idx) ("lux text size" raw-bin)))
hex-output (|> (<from> false decimal-part)
("lux text concat" ".")
("lux text concat" (<from> true whole-part))
- ("lux text concat" (if (f.= -1.0 sign) "-" "")))]
+ ("lux text concat" (if (f/= -1.0 sign) "-" "")))]
hex-output))
(def: (decode repr)
@@ -517,12 +517,12 @@
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))
- decimal-part (maybe;assume ("lux text clip" repr (n.inc split-index) ("lux text size" repr)))
+ (let [whole-part (maybe;assume ("lux text clip" repr (if (f/= -1.0 sign) +1 +0) split-index))
+ decimal-part (maybe;assume ("lux text clip" repr (n/inc split-index) ("lux text size" repr)))
as-binary (|> (<to> decimal-part)
("lux text concat" ".")
("lux text concat" (<to> whole-part))
- ("lux text concat" (if (f.= -1.0 sign) "-" "")))]
+ ("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))
@@ -611,13 +611,13 @@
(loop [idx idx
carry +0
output output]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(let [raw (|> (digits-get idx output)
- (n.* +5)
- (n.+ carry))]
- (recur (n.dec idx)
- (n./ +10 raw)
- (digits-put idx (n.% +10 raw) output)))
+ (n/* +5)
+ (n/+ carry))]
+ (recur (n/dec idx)
+ (n// +10 raw)
+ (digits-put idx (n/% +10 raw) output)))
output)))
(def: (digits-power power)
@@ -625,22 +625,22 @@
(loop [times power
output (|> (make-digits [])
(digits-put power +1))]
- (if (i.>= 0 (:! Int times))
- (recur (n.dec times)
+ (if (i/>= 0 (:! Int times))
+ (recur (n/dec times)
(digits-times-5! power output))
output)))
(def: (digits-to-text digits)
(-> Digits Text)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
all-zeroes? true
output ""]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(let [digit (digits-get idx digits)]
- (if (and (n.= +0 digit)
+ (if (and (n/= +0 digit)
all-zeroes?)
- (recur (n.dec idx) true output)
- (recur (n.dec idx)
+ (recur (n/dec idx) true output)
+ (recur (n/dec idx)
false
("lux text concat"
(:: Codec<Text,Int> encode (:! Int digit))
@@ -651,33 +651,33 @@
(def: (digits-add param subject)
(-> Digits Digits Digits)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
carry +0
output (make-digits [])]
- (if (i.>= 0 (:! Int idx))
- (let [raw ($_ n.+
+ (if (i/>= 0 (:! Int idx))
+ (let [raw ($_ n/+
carry
(digits-get idx param)
(digits-get idx subject))]
- (recur (n.dec idx)
- (n./ +10 raw)
- (digits-put idx (n.% +10 raw) output)))
+ (recur (n/dec idx)
+ (n// +10 raw)
+ (digits-put idx (n/% +10 raw) output)))
output)))
(def: (text-to-digits input)
(-> Text (Maybe Digits))
(let [length ("lux text size" input)]
- (if (n.<= bit;width length)
+ (if (n/<= bit;width length)
(loop [idx +0
output (make-digits [])]
- (if (n.< length idx)
+ (if (n/< length idx)
(let [char (maybe;assume (get-char input idx))]
(case ("lux text index" "0123456789" char +0)
#;None
#;None
(#;Some digit)
- (recur (n.inc idx)
+ (recur (n/inc idx)
(digits-put idx digit output))))
(#;Some output)))
#;None)))
@@ -685,49 +685,49 @@
(def: (digits-lt param subject)
(-> Digits Digits Bool)
(loop [idx +0]
- (and (n.< bit;width idx)
+ (and (n/< bit;width idx)
(let [pd (digits-get idx param)
sd (digits-get idx subject)]
- (if (n.= pd sd)
- (recur (n.inc idx))
- (n.< pd sd))))))
+ (if (n/= pd sd)
+ (recur (n/inc idx))
+ (n/< pd sd))))))
(def: (digits-sub-once! idx param subject)
(-> Nat Nat Digits Digits)
(let [sd (digits-get idx subject)]
- (if (n.>= param sd)
- (digits-put idx (n.- param sd) subject)
+ (if (n/>= param sd)
+ (digits-put idx (n/- param sd) subject)
(let [diff (|> sd
- (n.+ +10)
- (n.- param))]
+ (n/+ +10)
+ (n/- param))]
(|> subject
(digits-put idx diff)
- (digits-sub-once! (n.dec idx) +1))))))
+ (digits-sub-once! (n/dec idx) +1))))))
(def: (digits-sub! param subject)
(-> Digits Digits Digits)
- (loop [idx (n.dec bit;width)
+ (loop [idx (n/dec bit;width)
output subject]
- (if (i.>= 0 (nat-to-int idx))
- (recur (n.dec idx)
+ (if (i/>= 0 (nat-to-int idx))
+ (recur (n/dec idx)
(digits-sub-once! idx (digits-get idx param) output))
output)))
(struct: #export _ (Codec Text Deg)
(def: (encode input)
(let [input (:! Nat input)
- last-idx (n.dec bit;width)]
- (if (n.= +0 input)
+ last-idx (n/dec bit;width)]
+ (if (n/= +0 input)
".0"
(loop [idx last-idx
digits (make-digits [])]
- (if (i.>= 0 (:! Int idx))
+ (if (i/>= 0 (:! Int idx))
(if (bit;set? idx input)
- (let [digits' (digits-add (digits-power (n.- idx last-idx))
+ (let [digits' (digits-add (digits-power (n/- idx last-idx))
digits)]
- (recur (n.dec idx)
+ (recur (n/dec idx)
digits'))
- (recur (n.dec idx)
+ (recur (n/dec idx)
digits))
("lux text concat" "." (digits-to-text digits))
)))))
@@ -741,7 +741,7 @@
_
false)]
(if (and dotted?
- (n.<= (n.inc bit;width) length))
+ (n/<= (n/inc bit;width) length))
(case (|> ("lux text clip" input +1 length)
maybe;assume
text-to-digits)
@@ -749,14 +749,14 @@
(loop [digits digits
idx +0
output +0]
- (if (n.< bit;width idx)
+ (if (n/< bit;width idx)
(let [power (digits-power idx)]
(if (digits-lt power digits)
## Skip power
- (recur digits (n.inc idx) output)
+ (recur digits (n/inc idx) output)
(recur (digits-sub! power digits)
- (n.inc idx)
- (bit;set (n.- idx (n.dec bit;width)) output))))
+ (n/inc idx)
+ (bit;set (n/- idx (n/dec bit;width)) output))))
(#e;Success (:! Deg output))))
#;None
@@ -766,7 +766,7 @@
(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)
@@ -779,15 +779,15 @@
(cond (not-a-number? input)
(hex "+7FF7FFFFFFFFFFFF")
- (f.= positive-infinity input)
+ (f/= positive-infinity input)
(hex "+7FF0000000000000")
- (f.= negative-infinity input)
+ (f/= negative-infinity input)
(hex "+FFF0000000000000")
- (f.= 0.0 input)
- (let [reciprocal (f./ input 1.0)]
- (if (f.= positive-infinity reciprocal)
+ (f/= 0.0 input)
+ (let [reciprocal (f// input 1.0)]
+ (if (f/= positive-infinity reciprocal)
## Positive zero
(hex "+0000000000000000")
## Negative zero
@@ -797,14 +797,14 @@
(let [sign (:: Number<Frac> signum input)
input (:: Number<Frac> abs input)
exponent ("lux math floor" (log2 input))
- exponent-mask (|> +1 (bit;shift-left exponent-size) n.dec)
+ exponent-mask (|> +1 (bit;shift-left exponent-size) n/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)))
- sign-bit (if (f.= -1.0 sign) +1 +0)
- exponent-bits (|> exponent frac-to-int int-to-nat (n.+ double-bias) (bit;and exponent-mask))
+ (f/* ("lux math pow" 2.0 52.0)))
+ sign-bit (if (f/= -1.0 sign) +1 +0)
+ exponent-bits (|> exponent frac-to-int int-to-nat (n/+ double-bias) (bit;and exponent-mask))
mantissa-bits (|> mantissa frac-to-int int-to-nat)]
($_ bit;or
(bit;shift-left +63 sign-bit)
@@ -813,14 +813,14 @@
))
(do-template [<getter> <mask> <size> <offset>]
- [(def: <mask> (|> +1 (bit;shift-left <size>) n.dec (bit;shift-left <offset>)))
+ [(def: <mask> (|> +1 (bit;shift-left <size>) n/dec (bit;shift-left <offset>)))
(def: (<getter> input)
(-> Nat Nat)
(|> input (bit;and <mask>) (bit;shift-right <offset>)))]
[mantissa mantissa-mask mantissa-size +0]
[exponent exponent-mask exponent-size mantissa-size]
- [sign sign-mask +1 (n.+ exponent-size mantissa-size)]
+ [sign sign-mask +1 (n/+ exponent-size mantissa-size)]
)
(def: #export (bits-to-frac input)
@@ -828,30 +828,30 @@
(let [S (sign input)
E (exponent input)
M (mantissa input)]
- (cond (n.= (hex "+7FF") E)
- (if (n.= +0 M)
- (if (n.= +0 S)
+ (cond (n/= (hex "+7FF") E)
+ (if (n/= +0 M)
+ (if (n/= +0 S)
positive-infinity
negative-infinity)
not-a-number)
- (and (n.= +0 E) (n.= +0 M))
- (if (n.= +0 S)
+ (and (n/= +0 E) (n/= +0 M))
+ (if (n/= +0 S)
0.0
- (f.* -1.0 0.0))
+ (f/* -1.0 0.0))
## else
(let [normalized (|> M (bit;set mantissa-size)
nat-to-int int-to-frac
- (f./ ("lux math pow" 2.0 52.0)))
- power (|> E (n.- double-bias)
+ (f// ("lux math pow" 2.0 52.0)))
+ power (|> E (n/- double-bias)
nat-to-int int-to-frac
("lux math pow" 2.0))
- shifted (f.* power
+ shifted (f/* power
normalized)]
- (if (n.= +0 S)
+ (if (n/= +0 S)
shifted
- (f.* -1.0 shifted))))))
+ (f/* -1.0 shifted))))))
## [Hash]
(struct: #export _ (Hash Nat)
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index 7fc8af1dd..15fee133f 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -6,7 +6,7 @@
codec
["M" monad #+ do Monad]
["p" parser])
- (data [number "f/" Number<Frac> Codec<Text,Frac>]
+ (data [number "frac/" Number<Frac> "f/" Codec<Text,Frac>]
[text "text/" Monoid<Text>]
text/format
["E" error]
@@ -41,9 +41,9 @@
(def: #export (c.= param input)
(-> Complex Complex Bool)
- (and (f.= (get@ #real param)
+ (and (f/= (get@ #real param)
(get@ #real input))
- (f.= (get@ #imaginary param)
+ (f/= (get@ #imaginary param)
(get@ #imaginary input))))
(do-template [<name> <op>]
@@ -54,8 +54,8 @@
#imaginary (<op> (get@ #imaginary param)
(get@ #imaginary input))})]
- [c.+ f.+]
- [c.- f.-]
+ [c.+ f/+]
+ [c.- f/-]
)
(struct: #export _ (Eq Complex)
@@ -63,55 +63,55 @@
(def: #export c.negate
(-> Complex Complex)
- (|>. (update@ #real f/negate)
- (update@ #imaginary f/negate)))
+ (|>. (update@ #real frac/negate)
+ (update@ #imaginary frac/negate)))
(def: #export c.signum
(-> Complex Complex)
- (|>. (update@ #real f/signum)
- (update@ #imaginary f/signum)))
+ (|>. (update@ #real frac/signum)
+ (update@ #imaginary frac/signum)))
(def: #export conjugate
(-> Complex Complex)
- (update@ #imaginary f/negate))
+ (update@ #imaginary frac/negate))
(def: #export (c.*' param input)
(-> Frac Complex Complex)
- {#real (f.* param
+ {#real (f/* param
(get@ #real input))
- #imaginary (f.* param
+ #imaginary (f/* param
(get@ #imaginary input))})
(def: #export (c.* param input)
(-> Complex Complex Complex)
- {#real (f.- (f.* (get@ #imaginary param)
+ {#real (f/- (f/* (get@ #imaginary param)
(get@ #imaginary input))
- (f.* (get@ #real param)
+ (f/* (get@ #real param)
(get@ #real input)))
- #imaginary (f.+ (f.* (get@ #real param)
+ #imaginary (f/+ (f/* (get@ #real param)
(get@ #imaginary input))
- (f.* (get@ #imaginary param)
+ (f/* (get@ #imaginary param)
(get@ #real input)))})
(def: #export (c./ param input)
(-> Complex Complex Complex)
(let [(^slots [#real #imaginary]) param]
- (if (f.< (f/abs imaginary)
- (f/abs real))
- (let [quot (f./ imaginary real)
- denom (|> real (f.* quot) (f.+ imaginary))]
- {#real (|> (get@ #real input) (f.* quot) (f.+ (get@ #imaginary input)) (f./ denom))
- #imaginary (|> (get@ #imaginary input) (f.* quot) (f.- (get@ #real input)) (f./ denom))})
- (let [quot (f./ real imaginary)
- denom (|> imaginary (f.* quot) (f.+ real))]
- {#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom))
- #imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))}))))
+ (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (let [quot (f// imaginary real)
+ denom (|> real (f/* quot) (f/+ imaginary))]
+ {#real (|> (get@ #real input) (f/* quot) (f/+ (get@ #imaginary input)) (f// denom))
+ #imaginary (|> (get@ #imaginary input) (f/* quot) (f/- (get@ #real input)) (f// denom))})
+ (let [quot (f// real imaginary)
+ denom (|> imaginary (f/* quot) (f/+ real))]
+ {#real (|> (get@ #imaginary input) (f/* quot) (f/+ (get@ #real input)) (f// denom))
+ #imaginary (|> (get@ #imaginary input) (f/- (f/* quot (get@ #real input))) (f// denom))}))))
(def: #export (c./' param subject)
(-> Frac Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f./ param real)
- #imaginary (f./ param imaginary)}))
+ {#real (f// param real)
+ #imaginary (f// param imaginary)}))
(def: #export (c.% param input)
(-> Complex Complex Complex)
@@ -125,68 +125,68 @@
(def: #export (cos subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cosh imaginary)
+ {#real (f/* (math;cosh imaginary)
(math;cos real))
- #imaginary (f.* (math;sinh imaginary)
- (f/negate (math;sin real)))}))
+ #imaginary (f/* (math;sinh imaginary)
+ (frac/negate (math;sin real)))}))
(def: #export (cosh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cos imaginary)
+ {#real (f/* (math;cos imaginary)
(math;cosh real))
- #imaginary (f.* (math;sin imaginary)
+ #imaginary (f/* (math;sin imaginary)
(math;sinh real))}))
(def: #export (sin subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cosh imaginary)
+ {#real (f/* (math;cosh imaginary)
(math;sin real))
- #imaginary (f.* (math;sinh imaginary)
+ #imaginary (f/* (math;sinh imaginary)
(math;cos real))}))
(def: #export (sinh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (f.* (math;cos imaginary)
+ {#real (f/* (math;cos imaginary)
(math;sinh real))
- #imaginary (f.* (math;sin imaginary)
+ #imaginary (f/* (math;sin imaginary)
(math;cosh real))}))
(def: #export (tan subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- 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))}))
+ 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))}))
(def: #export (tanh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- 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))}))
+ 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))}))
(def: #export (c.abs subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- (complex (if (f.< (f/abs imaginary)
- (f/abs real))
- (if (f.= 0.0 imaginary)
- (f/abs real)
- (let [q (f./ imaginary real)]
- (f.* (math;root2 (f.+ 1.0 (f.* q q)))
- (f/abs imaginary))))
- (if (f.= 0.0 real)
- (f/abs imaginary)
- (let [q (f./ real imaginary)]
- (f.* (math;root2 (f.+ 1.0 (f.* q q)))
- (f/abs real))))
+ (complex (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (if (f/= 0.0 imaginary)
+ (frac/abs real)
+ (let [q (f// imaginary real)]
+ (f/* (math;root2 (f/+ 1.0 (f/* q q)))
+ (frac/abs imaginary))))
+ (if (f/= 0.0 real)
+ (frac/abs imaginary)
+ (let [q (f// real imaginary)]
+ (f/* (math;root2 (f/+ 1.0 (f/* q q)))
+ (frac/abs real))))
))))
(struct: #export _ (Number Complex)
@@ -197,20 +197,20 @@
(def: % c.%)
(def: (negate x)
(|> x
- (update@ #real f/negate)
- (update@ #imaginary f/negate)))
+ (update@ #real frac/negate)
+ (update@ #imaginary frac/negate)))
(def: abs c.abs)
(def: (signum x)
(|> x
- (update@ #real f/signum)
- (update@ #imaginary f/signum))))
+ (update@ #real frac/signum)
+ (update@ #imaginary frac/signum))))
(def: #export (exp subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r-exp (math;exp real)]
- {#real (f.* r-exp (math;cos imaginary))
- #imaginary (f.* r-exp (math;sin imaginary))}))
+ {#real (f/* r-exp (math;cos imaginary))
+ #imaginary (f/* r-exp (math;sin imaginary))}))
(def: #export (log subject)
(-> Complex Complex)
@@ -229,18 +229,18 @@
(def: (copy-sign sign magnitude)
(-> Frac Frac Frac)
- (f.* (f/signum sign) magnitude))
+ (f/* (frac/signum sign) magnitude))
(def: #export (root2 (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
- (let [t (|> input c.abs (get@ #real) (f.+ (f/abs real)) (f./ 2.0) math;root2)]
- (if (f.>= 0.0 real)
+ (let [t (|> input c.abs (get@ #real) (f/+ (frac/abs real)) (f// 2.0) math;root2)]
+ (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)
- (f/abs imaginary))
- #imaginary (f.* t (copy-sign imaginary 1.0))})))
+ {#real (f// (f/* 2.0 t)
+ (frac/abs imaginary))
+ #imaginary (f/* t (copy-sign imaginary 1.0))})))
(def: #export (root2-1z input)
(-> Complex Complex)
@@ -248,18 +248,18 @@
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
- (if (f.< (f/abs imaginary)
- (f/abs real))
- (let [q (f./ imaginary real)
- scale (f./ (|> real (f.* q) (f.+ imaginary))
+ (if (f/< (frac/abs imaginary)
+ (frac/abs real))
+ (let [q (f// imaginary real)
+ scale (f// (|> real (f/* q) (f/+ imaginary))
1.0)]
- {#real (f.* q scale)
- #imaginary (f/negate scale)})
- (let [q (f./ real imaginary)
- scale (f./ (|> imaginary (f.* q) (f.+ real))
+ {#real (f/* q scale)
+ #imaginary (frac/negate scale)})
+ (let [q (f// real imaginary)
+ scale (f// (|> imaginary (f/* q) (f/+ real))
1.0)]
{#real scale
- #imaginary (|> scale f/negate (f.* q))})))
+ #imaginary (|> scale frac/negate (f/* q))})))
(def: #export (acos input)
(-> Complex Complex)
@@ -290,20 +290,20 @@
(def: #export (nth-roots nth input)
(-> Nat Complex (List Complex))
- (if (n.= +0 nth)
+ (if (n/= +0 nth)
(list)
(let [r-nth (|> nth nat-to-int int-to-frac)
- nth-root-of-abs (|> input c.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))]
- (|> (list;n.range +0 (n.dec nth))
+ nth-root-of-abs (|> input c.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))]
+ (|> (list;n/range +0 (n/dec nth))
(L/map (function [nth']
(let [inner (|> nth' nat-to-int int-to-frac
- (f.* slice)
- (f.+ nth-phi))
- real (f.* nth-root-of-abs
+ (f/* slice)
+ (f/+ nth-phi))
+ real (f/* nth-root-of-abs
(math;cos inner))
- imaginary (f.* nth-root-of-abs
+ imaginary (f/* nth-root-of-abs
(math;sin inner))]
{#real real
#imaginary imaginary})))))))
diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux
index f3f9a1196..c056e740a 100644
--- a/stdlib/source/lux/data/number/ratio.lux
+++ b/stdlib/source/lux/data/number/ratio.lux
@@ -7,7 +7,7 @@
codec
monad
["p" parser])
- (data [number "n/" Number<Nat> Codec<Text,Nat>]
+ (data [number "n/" Codec<Text,Nat>]
[text "Text/" Monoid<Text>]
text/format
["E" error]
@@ -24,69 +24,69 @@
(def: #hidden (normalize (^slots [#numerator #denominator]))
(-> Ratio Ratio)
(let [common (math;gcd numerator denominator)]
- {#numerator (n./ common numerator)
- #denominator (n./ common denominator)}))
+ {#numerator (n// common numerator)
+ #denominator (n// common denominator)}))
(def: #export (q.* param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.* (get@ #numerator param)
+ (normalize [(n/* (get@ #numerator param)
(get@ #numerator input))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q./ param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.* (get@ #denominator param)
+ (normalize [(n/* (get@ #denominator param)
(get@ #numerator input))
- (n.* (get@ #numerator param)
+ (n/* (get@ #numerator param)
(get@ #denominator input))]))
(def: #export (q.+ param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.+ (n.* (get@ #denominator input)
+ (normalize [(n/+ (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q.- param input)
(-> Ratio Ratio Ratio)
- (normalize [(n.- (n.* (get@ #denominator input)
+ (normalize [(n/- (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #denominator input))]))
(def: #export (q.% param input)
(-> Ratio Ratio Ratio)
- (let [quot (n./ (n.* (get@ #denominator input)
+ (let [quot (n// (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))]
- (q.- (update@ #numerator (n.* quot) param)
+ (q.- (update@ #numerator (n/* quot) param)
input)))
(def: #export (q.= param input)
(-> Ratio Ratio Bool)
- (and (n.= (get@ #numerator param)
+ (and (n/= (get@ #numerator param)
(get@ #numerator input))
- (n.= (get@ #denominator param)
+ (n/= (get@ #denominator param)
(get@ #denominator input))))
(do-template [<name> <op>]
[(def: #export (<name> param input)
(-> Ratio Ratio Bool)
- (and (<op> (n.* (get@ #denominator input)
+ (and (<op> (n/* (get@ #denominator input)
(get@ #numerator param))
- (n.* (get@ #denominator param)
+ (n/* (get@ #denominator param)
(get@ #numerator input)))))]
- [q.< n.<]
- [q.<= n.<=]
- [q.> n.>]
- [q.>= n.>=]
+ [q.< n/<]
+ [q.<= n/<=]
+ [q.> n/>]
+ [q.>= n/>=]
)
(do-template [<name> <comp>]
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index fe57508cc..d4476b5c2 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -58,7 +58,7 @@
(def: (last-index-of'' part part-size since text)
(-> Text Nat Nat Text (Maybe Nat))
- (case ("lux text index" text part (n.+ part-size since))
+ (case ("lux text index" text part (n/+ part-size since))
#;None
(#;Some since)
@@ -96,8 +96,8 @@
(-> Text Text Bool)
(case (last-index-of postfix x)
(#;Some n)
- (n.= (size x)
- (n.+ (size postfix) n))
+ (n/= (size x)
+ (n/+ (size postfix) n))
_
false))
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux
index 5fc638354..354dc29a9 100644
--- a/stdlib/source/lux/data/text/lexer.lux
+++ b/stdlib/source/lux/data/text/lexer.lux
@@ -33,7 +33,7 @@
(#E;Error msg)
(#E;Success [[end-offset _] output])
- (if (n.= end-offset (text;size input))
+ (if (n/= end-offset (text;size input))
(#E;Success output)
(#E;Error (unconsumed-input-error end-offset input)))
))
@@ -44,7 +44,7 @@
(function [[offset tape]]
(case (text;nth offset tape)
(#;Some output)
- (#E;Success [[(n.inc offset) tape] (text;from-code output)])
+ (#E;Success [[(n/inc offset) tape] (text;from-code output)])
_
(#E;Error cannot-lex-error))
@@ -67,8 +67,8 @@
(function [[offset tape]]
(case (text;index-of' reference offset tape)
(#;Some where)
- (if (n.= offset where)
- (#E;Success [[(n.+ (text;size reference) offset) tape] []])
+ (if (n/= offset where)
+ (#E;Success [[(n/+ (text;size reference) offset) tape] []])
(#E;Error ($_ text/compose "Could not match: " (text;encode reference) " @ " (maybe;assume (text;clip' offset tape)))))
_
@@ -79,8 +79,8 @@
(-> Text (Lexer Bool))
(function [(^@ input [offset tape])]
(case (text;index-of' reference offset tape)
- (^multi (#;Some where) (n.= offset where))
- (#E;Success [[(n.+ (text;size reference) offset) tape] true])
+ (^multi (#;Some where) (n/= offset where))
+ (#E;Success [[(n/+ (text;size reference) offset) tape] true])
_
(#E;Success [input false]))))
@@ -89,7 +89,7 @@
{#;doc "Ensure the lexer's input is empty."}
(Lexer Unit)
(function [(^@ input [offset tape])]
- (if (n.= offset (text;size tape))
+ (if (n/= offset (text;size tape))
(#E;Success [input []])
(#E;Error (unconsumed-input-error offset tape)))))
@@ -97,7 +97,7 @@
{#;doc "Ask if the lexer's input is empty."}
(Lexer Bool)
(function [(^@ input [offset tape])]
- (#E;Success [input (n.= offset (text;size tape))])))
+ (#E;Success [input (n/= offset (text;size tape))])))
(def: #export peek
{#;doc "Lex the next character (without consuming it from the input)."}
@@ -124,8 +124,8 @@
[char any
#let [char' (maybe;assume (text;nth +0 char))]
_ (p;assert ($_ text/compose "Character is not within range: " (text;from-code bottom) "-" (text;from-code top))
- (and (n.>= bottom char')
- (n.<= top char')))]
+ (and (n/>= bottom char')
+ (n/<= top char')))]
(wrap char)))
(do-template [<name> <bottom> <top> <desc>]
@@ -166,7 +166,7 @@
(#;Some output)
(let [output (text;from-code output)]
(if (text;contains? output options)
- (#E;Success [[(n.inc offset) tape] output])
+ (#E;Success [[(n/inc offset) tape] output])
(#E;Error ($_ text/compose "Character (" output ") is not one of: " options))))
_
@@ -180,7 +180,7 @@
(#;Some output)
(let [output (text;from-code output)]
(if (;not (text;contains? output options))
- (#E;Success [[(n.inc offset) tape] output])
+ (#E;Success [[(n/inc offset) tape] output])
(#E;Error ($_ text/compose "Character (" output ") is one of: " options))))
_
@@ -193,7 +193,7 @@
(case (text;nth offset tape)
(#;Some output)
(if (p output)
- (#E;Success [[(n.inc offset) tape] (text;from-code output)])
+ (#E;Success [[(n/inc offset) tape] (text;from-code output)])
(#E;Error ($_ text/compose "Character does not satisfy predicate: " (text;from-code output))))
_
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index 07e2a6ea4..d38111d7d 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -289,8 +289,8 @@
[idx (code;symbol ["" _name])]
#;None
- [(i.inc idx) (code;symbol ["" (Int/encode idx)])])
- access (if (n.> +0 num-captures)
+ [(i/inc idx) (code;symbol ["" (Int/encode idx)])])
+ access (if (n/> +0 num-captures)
(` (product;left (~ name!)))
name!)]
[idx!
@@ -348,7 +348,7 @@
(def: (prep-alternative [num-captures alt])
(-> [Nat Code] Code)
- (if (n.> +0 num-captures)
+ (if (n/> +0 num-captures)
alt
(` (unflatten^ (~ alt)))))
@@ -366,7 +366,7 @@
(` |||_^))]]
(if (list;empty? tail)
(wrap head)
- (wrap [(L/fold n.max (product;left head) (L/map product;left tail))
+ (wrap [(L/fold n/max (product;left head) (L/map product;left tail))
(` ($_ (~ g!op) (~ (prep-alternative head)) (~@ (L/map prep-alternative tail))))]))))
(def: (re-scoped^ current-module)
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index ae20fd9b6..a0d65cc89 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -54,14 +54,14 @@
(-> Cursor (l;Lexer [Cursor Text]))
(p;either (do p;Monad<Parser>
[content (l;many (l;one-of white-space))]
- (wrap [(update@ #;column (n.+ (text;size content)) where)
+ (wrap [(update@ #;column (n/+ (text;size content)) where)
content]))
## New-lines must be handled as a separate case to ensure line
## information is handled properly.
(do p;Monad<Parser>
[content (l;many (l;one-of new-line))]
(wrap [(|> where
- (update@ #;line (n.+ (text;size content)))
+ (update@ #;line (n/+ (text;size content)))
(set@ #;column +0))
content]))
))
@@ -75,7 +75,7 @@
comment (l;some (l;none-of new-line))
_ (l;this new-line)]
(wrap [(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))
comment])))
@@ -98,21 +98,21 @@
(do p;Monad<Parser>
[_ (l;this "#(")]
(loop [comment ""
- where (update@ #;column (n.+ +2) where)]
+ where (update@ #;column (n/+ +2) where)]
($_ p;either
## These are normal chunks of commented text.
(do @
[chunk (l;many (l;not comment-bound^))]
(recur (format comment chunk)
(|> where
- (update@ #;column (n.+ (text;size chunk))))))
+ (update@ #;column (n/+ (text;size chunk))))))
## This is a special rule to handle new-lines within
## comments properly.
(do @
[_ (l;this new-line)]
(recur (format comment new-line)
(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))))
## This is the rule for handling nested sub-comments.
## Ultimately, the whole comment is just treated as text
@@ -127,7 +127,7 @@
## Finally, this is the rule for closing the comment.
(do @
[_ (l;this ")#")]
- (wrap [(update@ #;column (n.+ +2) where)
+ (wrap [(update@ #;column (n/+ +2) where)
comment]))
))))
@@ -184,7 +184,7 @@
[code (l;between +1 +4 l;hexadecimal)]
(wrap (case (|> code (format "+") (:: number;Hex@Codec<Text,Nat> decode))
(#;Right value)
- [(n.+ +2 (text;size code)) (text;from-code value)]
+ [(n/+ +2 (text;size code)) (text;from-code value)]
_
(undefined))))
@@ -219,7 +219,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (<tag> value)]]))))]
[bool #;Bool
@@ -247,19 +247,19 @@
(do @
[normal (l;none-of "\\\"\n")]
(wrap [(|> where
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
normal]))
## Must handle escaped
## chars separately.
(do @
[[chars-consumed char] escaped-char^]
(wrap [(|> where
- (update@ #;column (n.+ chars-consumed)))
+ (update@ #;column (n/+ chars-consumed)))
char]))))
_ (l;this "\"")
#let [char (maybe;assume (text;nth +0 char))]]
(wrap [(|> where'
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
[where (#;Nat char)]])))
(def: (normal-nat where)
@@ -272,7 +272,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Nat value)]]))))
(def: #export (nat where)
@@ -298,7 +298,7 @@
(p;fail error)
(#;Right value)
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Frac value)]]))))
(def: frac-ratio-fragment
@@ -323,11 +323,11 @@
_ (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./ denominator)))))]
- (wrap [(update@ #;column (n.+ (text;size chunk)) where)
+ (f/* (if signed? -1.0 1.0))
+ (f// denominator)))))]
+ (wrap [(update@ #;column (n/+ (text;size chunk)) where)
[where (#;Frac value)]])))
(def: #export (frac where)
@@ -350,7 +350,7 @@
## as many spaces as necessary to be column-aligned.
## This helps ensure that the formatting on the text in the
## source-code matches the formatting of the Text value.
- #let [offset-column (n.inc (get@ #;column where))]
+ #let [offset-column (n/inc (get@ #;column where))]
[where' text-read] (: (l;Lexer [Cursor Text])
## I must keep track of how much of the
## text body has been read, how far the
@@ -359,7 +359,7 @@
## processing normal text body.
(loop [text-read ""
where (|> where
- (update@ #;column n.inc))
+ (update@ #;column n/inc))
must-have-offset? false]
(p;either (if must-have-offset?
## If I'm at the start of a
@@ -371,7 +371,7 @@
(do @
[offset (l;many (l;one-of " "))
#let [offset-size (text;size offset)]]
- (if (n.>= offset-column offset-size)
+ (if (n/>= offset-column offset-size)
## Any extra offset
## becomes part of the
## text's body.
@@ -381,7 +381,7 @@
product;right
(format text-read))
(|> where
- (update@ #;column (n.+ offset-size)))
+ (update@ #;column (n/+ offset-size)))
false)
(p;fail (format "Each line of a multi-line text must have an appropriate offset!\n"
"Expected: " (%i (nat-to-int offset-column)) " columns.\n"
@@ -392,7 +392,7 @@
[normal (l;many (l;none-of "\\\"\n"))]
(recur (format text-read normal)
(|> where
- (update@ #;column (n.+ (text;size normal))))
+ (update@ #;column (n/+ (text;size normal))))
false))
## Must handle escaped
## chars separately.
@@ -400,13 +400,13 @@
[[chars-consumed char] escaped-char^]
(recur (format text-read char)
(|> where
- (update@ #;column (n.+ chars-consumed)))
+ (update@ #;column (n/+ chars-consumed)))
false))
## The text ends when it
## reaches the right-delimiter.
(do @
[_ (l;this "\"")]
- (wrap [(update@ #;column n.inc where)
+ (wrap [(update@ #;column n/inc where)
text-read]))))
## If a new-line is
## encountered, it gets
@@ -417,7 +417,7 @@
[_ (l;this new-line)]
(recur (format text-read new-line)
(|> where
- (update@ #;line n.inc)
+ (update@ #;line n/inc)
(set@ #;column +0))
true)))))]
(wrap [where'
@@ -448,7 +448,7 @@
## end-delimiter.
where' (left-padding^ where)
_ (l;this <close>)]
- (wrap [(update@ #;column n.inc where')
+ (wrap [(update@ #;column n/inc where')
(sequence;to-list elems)]))))]
(wrap [where'
[where (<tag> elems)]])))]
@@ -483,7 +483,7 @@
(do @
[where' (left-padding^ where)
_ (l;this "}")]
- (wrap [(update@ #;column n.inc where')
+ (wrap [(update@ #;column n/inc where')
(sequence;to-list elems)]))))]
(wrap [where'
[where (#;Record elems)]])))
@@ -535,7 +535,7 @@
[_ (l;this current-module-mark)
def-name ident-part^]
(wrap [[current-module def-name]
- (n.+ +2 (text;size def-name))]))
+ (n/+ +2 (text;size def-name))]))
## If the identifier is prefixed by the mark, but no module
## part, the module is assumed to be "lux" (otherwise known as
## the 'prelude').
@@ -546,7 +546,7 @@
[_ (l;this identifier-separator)
def-name ident-part^]
(wrap [["lux" def-name]
- (n.inc (text;size def-name))]))
+ (n/inc (text;size def-name))]))
## Not all identifiers must be specified with a module part.
## If that part is not provided, the identifier will be created
## with the empty "" text as the module.
@@ -563,7 +563,7 @@
second-part ident-part^]
(wrap [[(|> aliases (dict;get first-part) (maybe;default first-part))
second-part]
- ($_ n.+
+ ($_ n/+
(text;size first-part)
+1
(text;size second-part))]))
@@ -582,7 +582,7 @@
(-> Text Aliases Cursor (l;Lexer [Cursor Code]))
(do p;Monad<Parser>
[[value length] <lexer>]
- (wrap [(update@ #;column (|>. ($_ n.+ <extra> length)) where)
+ (wrap [(update@ #;column (|>. ($_ n/+ <extra> length)) where)
[where (<tag> value)]])))]
[symbol #;Symbol (ident^ current-module aliases) +0]
diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux
index d4a3d7d1b..217320ab2 100644
--- a/stdlib/source/lux/lang/type.lux
+++ b/stdlib/source/lux/lang/type.lux
@@ -48,7 +48,7 @@
(case [x y]
[(#;Primitive xname xparams) (#;Primitive yname yparams)]
(and (text/= xname yname)
- (n.= (list;size yparams) (list;size xparams))
+ (n/= (list;size yparams) (list;size xparams))
(list/fold (;function [[x y] prev] (and prev (= x y)))
true
(list;zip2 xparams yparams)))
@@ -60,7 +60,7 @@
(^template [<tag>]
[(<tag> xid) (<tag> yid)]
- (n.= yid xid))
+ (n/= yid xid))
([#;Var] [#;Ex] [#;Bound])
(^or [(#;Function xleft xright) (#;Function yleft yright)]
@@ -79,7 +79,7 @@
(^or [(#;UnivQ xenv xbody) (#;UnivQ yenv ybody)]
[(#;ExQ xenv xbody) (#;ExQ yenv ybody)])
- (and (n.= (list;size yenv) (list;size xenv))
+ (and (n/= (list;size yenv) (list;size xenv))
(= xbody ybody)
(list/fold (;function [[x y] prev] (and prev (= x y)))
true
@@ -97,7 +97,7 @@
type type]
(case type
(<tag> env sub-type)
- (recur (n.inc num-args) sub-type)
+ (recur (n/inc num-args) sub-type)
_
[num-args type])))]
@@ -323,7 +323,7 @@
(-> Nat Type Type)
(case size
+0 body
- _ (<tag> (list) (<name> (n.dec size) body))))]
+ _ (<tag> (list) (<name> (n/dec size) body))))]
[univ-q #;UnivQ]
[ex-q #;ExQ]
@@ -351,4 +351,4 @@
(-> Nat Type Type)
(case level
+0 elem-type
- _ (#;Primitive "#Array" (list (array (n.dec level) elem-type)))))
+ _ (#;Primitive "#Array" (list (array (n/dec level) elem-type)))))
diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux
index 086866ddf..9dc1a6565 100644
--- a/stdlib/source/lux/lang/type/check.lux
+++ b/stdlib/source/lux/lang/type/check.lux
@@ -96,7 +96,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
(#;Some var-type)
(var::get id plist'))
))
@@ -109,7 +109,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
(#;Cons [var-id value]
plist')
(#;Cons [var-id var-type]
@@ -124,7 +124,7 @@
(#;Cons [var-id var-type]
plist')
- (if (n.= id var-id)
+ (if (n/= id var-id)
plist'
(#;Cons [var-id var-type]
(var::remove id plist')))
@@ -150,7 +150,7 @@
(Check [Nat Type])
(function [context]
(let [id (get@ #;ex-counter context)]
- (#e;Success [(update@ #;ex-counter n.inc context)
+ (#e;Success [(update@ #;ex-counter n/inc context)
[id (#;Ex id)]]))))
(do-template [<name> <outputT> <fail> <succeed>]
@@ -219,7 +219,7 @@
(function [context]
(let [id (get@ #;var-counter context)]
(#e;Success [(|> context
- (update@ #;var-counter n.inc)
+ (update@ #;var-counter n/inc)
(update@ #;var-bindings (var::put id #;None)))
[id (#;Var id)]]))))
@@ -270,7 +270,7 @@
(#;Some (#;Some type))
(case type
(#;Var post)
- (if (n.= id post)
+ (if (n/= id post)
(#e;Success [context output])
(recur post (set;add post output)))
@@ -344,7 +344,7 @@
then)
(do Monad<Check>
[ring (ring id)
- _ (assert "" (n.> +1 (set;size ring)))
+ _ (assert "" (n/> +1 (set;size ring)))
_ (monad;map @ (update type) (set;to-list ring))]
then)
(do Monad<Check>
@@ -368,7 +368,7 @@
(List Assumption)
Var Var
(Check (List Assumption)))
- (if (n.= idE idA)
+ (if (n/= idE idA)
(check/wrap assumptions)
(do Monad<Check>
[ebound (attempt (peek idE))
@@ -576,7 +576,7 @@
[(#;Primitive e-name e-params) (#;Primitive a-name a-params)]
(if (and (text/= e-name a-name)
- (n.= (list;size e-params)
+ (n/= (list;size e-params)
(list;size a-params)))
(do Monad<Check>
[assumptions (monad;fold Monad<Check>
@@ -603,7 +603,7 @@
(check' eO aO assumptions))
[(#;Ex e!id) (#;Ex a!id)]
- (if (n.= e!id a!id)
+ (if (n/= e!id a!id)
(check/wrap assumptions)
(fail ""))
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index e800efcd5..53fe18c82 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -363,7 +363,7 @@
A prefix can be given (or just be empty text \"\") to better identify the code for debugging purposes."}
(-> Text (Meta Code))
(function [compiler]
- (#e;Success [(update@ #;seed n.inc compiler)
+ (#e;Success [(update@ #;seed n/inc compiler)
(code;symbol ["" ($_ text/compose "__gensym__" prefix (:: number;Codec<Text,Nat> encode (get@ #;seed compiler)))])])))
(def: (get-local-symbol ast)
@@ -650,7 +650,7 @@
(<macro> #omit
(def: (foo bar baz)
(-> Int Int Int)
- (i.+ bar baz))))}
+ (i/+ bar baz))))}
(case tokens
(^ (list [_ (#;Tag ["" "omit"])]
token))
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index bbed25f98..17a5cdc94 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -161,7 +161,7 @@
(do p;Monad<Parser>
[headT any]
(let [members (<flattener> (type;un-name headT))]
- (if (n.> +1 (list;size members))
+ (if (n/> +1 (list;size members))
(local members poly)
(p;fail ($_ text/compose "Not a " (ident/encode (ident-for <tag>)) " type: " (type;to-text headT)))))))]
@@ -174,7 +174,7 @@
(do p;Monad<Parser>
[headT any
#let [[num-arg bodyT] (type;flatten-univ-q (type;un-name headT))]]
- (if (n.= +0 num-arg)
+ (if (n/= +0 num-arg)
(p;fail ($_ text/compose "Non-polymorphic type: " (type;to-text headT)))
(wrap [num-arg bodyT]))))
@@ -189,21 +189,21 @@
[all-varsL env'] (loop [current-arg +0
env' env
all-varsL (: (List Code) (list))]
- (if (n.< num-args current-arg)
- (if (n.= +0 current-arg)
- (let [varL (label (n.inc funcI))]
- (recur (n.inc current-arg)
+ (if (n/< num-args current-arg)
+ (if (n/= +0 current-arg)
+ (let [varL (label (n/inc funcI))]
+ (recur (n/inc current-arg)
(|> env'
(dict;put funcI [headT funcL])
- (dict;put (n.inc funcI) [(#;Bound (n.inc funcI)) varL]))
+ (dict;put (n/inc funcI) [(#;Bound (n/inc funcI)) varL]))
(#;Cons varL all-varsL)))
- (let [partialI (|> current-arg (n.* +2) (n.+ funcI))
- partial-varI (n.inc partialI)
+ (let [partialI (|> current-arg (n/* +2) (n/+ funcI))
+ partial-varI (n/inc partialI)
partial-varL (label partial-varI)
- partialC (` ((~ funcL) (~@ (|> (list;n.range +0 (n.dec num-args))
- (list/map (|>. (n.* +2) n.inc (n.+ funcI) label))
+ partialC (` ((~ funcL) (~@ (|> (list;n/range +0 (n/dec num-args))
+ (list/map (|>. (n/* +2) n/inc (n/+ funcI) label))
list;reverse))))]
- (recur (n.inc current-arg)
+ (recur (n/inc current-arg)
(|> env'
(dict;put partialI [;Void partialC])
(dict;put partial-varI [(#;Bound partial-varI) partial-varL]))
@@ -220,7 +220,7 @@
(do p;Monad<Parser>
[headT any
#let [[inputsT outputT] (type;flatten-function (type;un-name headT))]]
- (if (n.> +0 (list;size inputsT))
+ (if (n/> +0 (list;size inputsT))
(p;seq (local inputsT in-poly)
(local (list outputT) out-poly))
(p;fail ($_ text/compose "Non-function type: " (type;to-text headT))))))
@@ -230,7 +230,7 @@
(do p;Monad<Parser>
[headT any
#let [[funcT paramsT] (type;flatten-application (type;un-name headT))]]
- (if (n.= +0 (list;size paramsT))
+ (if (n/= +0 (list;size paramsT))
(p;fail ($_ text/compose "Non-application type: " (type;to-text headT)))
(local (#;Cons funcT paramsT) poly))))
@@ -247,10 +247,10 @@
(def: (adjusted-idx env idx)
(-> Env Nat Nat)
- (let [env-level (n./ +2 (dict;size env))
- bound-level (n./ +2 idx)
- bound-idx (n.% +2 idx)]
- (|> env-level n.dec (n.- bound-level) (n.* +2) (n.+ bound-idx))))
+ (let [env-level (n// +2 (dict;size env))
+ bound-level (n// +2 idx)
+ bound-idx (n/% +2 idx)]
+ (|> env-level n/dec (n/- bound-level) (n/* +2) (n/+ bound-idx))))
(def: #export bound
(Poly Code)
@@ -276,7 +276,7 @@
headT any]
(case headT
(#;Bound idx)
- (if (n.= id (adjusted-idx env idx))
+ (if (n/= id (adjusted-idx env idx))
(wrap [])
(p;fail ($_ text/compose "Wrong bound type.\n"
"Expected: " (nat/encode id) "\n"
@@ -319,7 +319,7 @@
headT any]
(case (type;un-name headT)
(^multi (#;Apply #;Void (#;Bound funcT-idx))
- (n.= +0 (adjusted-idx env funcT-idx))
+ (n/= +0 (adjusted-idx env funcT-idx))
[(dict;get +0 env) (#;Some [self-type self-call])])
(wrap self-call)
@@ -426,13 +426,13 @@
(#;Bound idx)
(let [idx (adjusted-idx env idx)]
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(|> (dict;get idx env) maybe;assume product;left (to-ast env))
- (` (;$ (~ (code;nat (n.dec idx)))))))
+ (` (;$ (~ (code;nat (n/dec idx)))))))
(#;Apply #;Void (#;Bound idx))
(let [idx (adjusted-idx env idx)]
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(|> (dict;get idx env) maybe;assume product;left (to-ast env))
(undefined)))
diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux
index 099febb24..a82b99814 100644
--- a/stdlib/source/lux/macro/poly/eq.lux
+++ b/stdlib/source/lux/macro/poly/eq.lux
@@ -110,7 +110,7 @@
## Tuples
(do @
[g!eqs (poly;tuple (p;many Eq<?>))
- #let [indices (|> (list;size g!eqs) n.dec (list;n.range +0))
+ #let [indices (|> (list;size g!eqs) n/dec (list;n/range +0))
g!lefts (list/map (|>. nat/encode (text/compose "left") code;local-symbol) indices)
g!rights (list/map (|>. nat/encode (text/compose "right") code;local-symbol) indices)]]
(wrap (` (: (~ (@Eq inputT))
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux
index ba847d35b..2870fc63f 100644
--- a/stdlib/source/lux/macro/poly/functor.lux
+++ b/stdlib/source/lux/macro/poly/functor.lux
@@ -27,9 +27,9 @@
#let [num-vars (list;size varsC)]
#let [@Functor (: (-> Type Code)
(function [unwrappedT]
- (if (n.= +1 num-vars)
+ (if (n/= +1 num-vars)
(` (functor;Functor (~ (poly;to-ast *env* unwrappedT))))
- (let [paramsC (|> num-vars n.dec list;indices (L/map (|>. %n code;local-symbol)))]
+ (let [paramsC (|> num-vars n/dec list;indices (L/map (|>. %n code;local-symbol)))]
(` (All [(~@ paramsC)]
(functor;Functor ((~ (poly;to-ast *env* unwrappedT)) (~@ paramsC)))))))))
Arg<?> (: (-> Code (poly;Poly Code))
@@ -37,7 +37,7 @@
($_ p;either
## Type-var
(do p;Monad<Parser>
- [#let [varI (|> num-vars (n.* +2) n.dec)]
+ [#let [varI (|> num-vars (n/* +2) n/dec)]
_ (poly;var varI)]
(wrap (` ((~ funcC) (~ valueC)))))
## Variants
@@ -59,7 +59,7 @@
(do @
[_ (wrap [])
memberC (Arg<?> slotC)]
- (recur (n.inc idx)
+ (recur (n/inc idx)
(L/compose pairsCC (list [slotC memberC])))))
(wrap pairsCC)))))]
(wrap (` (case (~ valueC)
@@ -71,8 +71,8 @@
#let [outL (code;local-symbol "\u0000outL")]
[inT+ outC] (poly;function (p;many poly;any)
(Arg<?> outL))
- #let [inC+ (|> (list;size inT+) n.dec
- (list;n.range +0)
+ #let [inC+ (|> (list;size inT+) n/dec
+ (list;n/range +0)
(L/map (|>. %n (format "\u0000inC") code;local-symbol)))]]
(wrap (` (function [(~@ inC+)]
(let [(~ outL) ((~ valueC) (~@ inC+))]
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index 6b4d5fed5..02352109a 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -43,7 +43,7 @@
(function [input]
(non-rec (rec-encode non-rec) input)))
-(def: low-mask Nat (|> +1 (bit;shift-left +32) n.dec))
+(def: low-mask Nat (|> +1 (bit;shift-left +32) n/dec))
(def: high-mask Nat (|> low-mask (bit;shift-left +32)))
(struct: #hidden _ (Codec JSON Nat)
@@ -57,7 +57,7 @@
(do p;Monad<Parser>
[high //;number
low //;number])
- (wrap (n.+ (|> high frac-to-int int-to-nat (bit;shift-left +32))
+ (wrap (n/+ (|> high frac-to-int int-to-nat (bit;shift-left +32))
(|> low frac-to-int int-to-nat))))))
(struct: #hidden _ (Codec JSON Int)
@@ -157,8 +157,8 @@
(list;enumerate members))))))))))
(do @
[g!encoders (poly;tuple (p;many Codec<JSON,?>//encode))
- #let [g!members (|> (list;size g!encoders) n.dec
- (list;n.range +0)
+ #let [g!members (|> (list;size g!encoders) n/dec
+ (list;n/range +0)
(list/map (|>. nat/encode code;local-symbol)))]]
(wrap (` (: (~ (@JSON//encode inputT))
(function [[(~@ g!members)]]
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index 6424ff0fc..bc3369f86 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -92,18 +92,6 @@
_
(#E;Error "There are no tokens to parse!"))))
-(do-template [<name> <comp> <error>]
- [(def: #export <name>
- (Syntax Int)
- (do p;Monad<Parser>
- [n int
- _ (p;assert <error> (<comp> 0 n))]
- (wrap n)))]
-
- [pos-int i.> "Expected a positive integer: N > 0"]
- [neg-int i.< "Expected a negative integer: N < 0"]
- )
-
(do-template [<name> <tag> <desc>]
[(def: #export <name>
{#;doc (code;text ($_ text/compose "Parse a local " <desc> " (a " <desc> " that has no module prefix)."))}
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index 700bc9919..4f4270c74 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -58,20 +58,20 @@
)
(def: #export (log' base input)
- (f./ (log base)
+ (f// (log base)
(log input)))
(def: #export (factorial n)
(-> Nat Nat)
(loop [acc +1
n n]
- (if (n.<= +1 n)
+ (if (n/<= +1 n)
acc
- (recur (n.* n acc) (n.dec n)))))
+ (recur (n/* n acc) (n/dec n)))))
(def: #export (hypotenuse catA catB)
(-> Frac Frac Frac)
- (root2 (f.+ (pow 2.0 catA)
+ (root2 (f/+ (pow 2.0 catA)
(pow 2.0 catB))))
(def: #export (gcd a b)
@@ -79,7 +79,7 @@
(-> Nat Nat Nat)
(case b
+0 a
- _ (gcd b (n.% b a))))
+ _ (gcd b (n/% b a))))
(def: #export (lcm x y)
{#;doc "Least Common Multiple."}
@@ -89,7 +89,7 @@
+0
_
- (|> x (n./ (gcd x y)) (n.* y))
+ (|> x (n// (gcd x y)) (n/* y))
))
## [Syntax]
@@ -157,12 +157,12 @@
(syntax: #export (infix [expr infix^])
{#;doc (doc "Infix math syntax."
- (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]])
- (infix [#and x n.< y n.< z])
- (infix [(n.* +3 +9) gcd +450])
+ (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]])
+ (infix [#and x n/< y n/< z])
+ (infix [(n/* +3 +9) gcd +450])
"The rules for infix syntax are simple."
"If you want your binary function to work well with it."
diff --git a/stdlib/source/lux/math/logic/continuous.lux b/stdlib/source/lux/math/logic/continuous.lux
index 0546cb46c..0b385dae2 100644
--- a/stdlib/source/lux/math/logic/continuous.lux
+++ b/stdlib/source/lux/math/logic/continuous.lux
@@ -10,13 +10,13 @@
(-> Deg Deg Deg)
<chooser>)]
- [~and d.min]
- [~or d.max]
+ [~and d/min]
+ [~or d/max]
)
(def: #export (~not input)
(-> Deg Deg)
- (d.- input ~true))
+ (d/- input ~true))
(def: #export (~implies consequent antecedent)
(-> Deg Deg Deg)
@@ -26,9 +26,9 @@
(def: #export (includes~ sub super)
(-> Deg Deg Deg)
(let [-sub (~not sub)
- sum (d.+ -sub super)
- no-overflow? (and (d.>= -sub sum)
- (d.>= super sum))]
+ sum (d/+ -sub super)
+ no-overflow? (and (d/>= -sub sum)
+ (d/>= super sum))]
(if no-overflow?
sum
~true)))
diff --git a/stdlib/source/lux/math/logic/fuzzy.lux b/stdlib/source/lux/math/logic/fuzzy.lux
index 6183293a8..ba8da7d40 100644
--- a/stdlib/source/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/lux/math/logic/fuzzy.lux
@@ -81,8 +81,8 @@
(<ascending> from to)
(<descending> from to)))]
- [d.ascending d.descending d.gradient Deg d.< d.> d.<= d.>= d.- d./ id]
- [f.ascending f.descending f.gradient Frac f.< f.> f.<= f.>= f.- f./ frac-to-deg]
+ [d/ascending d/descending d/gradient Deg d/< d/> d/<= d/>= d/- d// id]
+ [f/ascending f/descending f/gradient Frac f/< f/> f/<= f/>= f/- f// frac-to-deg]
)
(do-template [<triangle> <trapezoid> <type> <ascending> <descending> <lt>]
@@ -106,21 +106,21 @@
_
(undefined)))]
- [d.triangle d.trapezoid Deg d.ascending d.descending d.<]
- [f.triangle f.trapezoid Frac f.ascending f.descending f.<]
+ [d/triangle d/trapezoid Deg d/ascending d/descending d/<]
+ [f/triangle f/trapezoid Frac f/ascending f/descending f/<]
)
(def: #export (gaussian deviation center)
(-> Frac Frac (Fuzzy Frac))
(function [elem]
- (let [scale (|> deviation (math;pow 2.0) (f.* 2.0))
+ (let [scale (|> deviation (math;pow 2.0) (f/* 2.0))
membership (|> elem
- (f.- center)
+ (f/- center)
(math;pow 2.0)
- (f.* -1.0)
- (f./ scale)
+ (f/* -1.0)
+ (f// scale)
math;exp)]
- (if (f.= 1.0 membership)
+ (if (f/= 1.0 membership)
&;~true
(frac-to-deg membership)))))
@@ -128,14 +128,14 @@
(All [a] (-> Deg (Fuzzy a) (Fuzzy a)))
(function [elem]
(let [membership (set elem)]
- (if (d.> treshold membership)
- (|> membership (d.- treshold) (d.* &;~true))
+ (if (d/> treshold membership)
+ (|> membership (d/- treshold) (d/* &;~true))
&;~false))))
(def: #export (to-predicate treshold set)
(All [a] (-> Deg (Fuzzy a) (-> a Bool)))
(function [elem]
- (d.> treshold (set elem))))
+ (d/> treshold (set elem))))
(type: #export (Fuzzy2 a)
(-> a [Deg Deg]))
@@ -145,6 +145,6 @@
(function [elem]
(let [l-deg (lower elem)
u-deg (upper elem)]
- [(d.min l-deg
+ [(d/min l-deg
u-deg)
u-deg])))
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index 90ee2c97b..e8b552b1c 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -69,7 +69,7 @@
(function [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (n.+ (bit;shift-left +32 left)
+ [prng (n/+ (bit;shift-left +32 left)
right)])))
(def: #export int
@@ -77,20 +77,20 @@
(function [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (nat-to-int (n.+ (bit;shift-left +32 left)
+ [prng (nat-to-int (n/+ (bit;shift-left +32 left)
right))])))
(def: #export bool
(Random Bool)
(function [prng]
(let [[prng output] (prng [])]
- [prng (|> output (bit;and +1) (n.= +1))])))
+ [prng (|> output (bit;and +1) (n/= +1))])))
(def: (bits n)
(-> Nat (Random Nat))
(function [prng]
(let [[prng output] (prng [])]
- [prng (bit;shift-right (n.- n +64) output)])))
+ [prng (bit;shift-right (n/- n +64) output)])))
(def: #export frac
(Random Frac)
@@ -98,10 +98,10 @@
[left (bits +26)
right (bits +27)]
(wrap (|> right
- (n.+ (bit;shift-left +27 left))
+ (n/+ (bit;shift-left +27 left))
nat-to-int
int-to-frac
- (f./ (|> +1 (bit;shift-left +53) nat-to-int int-to-frac))))))
+ (f// (|> +1 (bit;shift-left +53) nat-to-int int-to-frac))))))
(def: #export deg
(Random Deg)
@@ -109,11 +109,11 @@
(def: #export (text' char-gen size)
(-> (Random Nat) Nat (Random Text))
- (if (n.= +0 size)
+ (if (n/= +0 size)
(:: Monad<Random> wrap "")
(do Monad<Random>
[x char-gen
- xs (text' char-gen (n.dec size))]
+ xs (text' char-gen (n/dec size))]
(wrap (text/compose (text;from-code x) xs)))))
(type: Char-Range [Nat Nat])
@@ -135,61 +135,61 @@
(def: (within? [from to] char)
(-> Char-Range Nat Bool)
- (and (n.>= from char) (n.<= to char)))
+ (and (n/>= from char) (n/<= to char)))
-(def: unicode-ceiling (n.inc (product;right CJK-Compatibility-Ideographs-Supplement)))
+(def: unicode-ceiling (n/inc (product;right CJK-Compatibility-Ideographs-Supplement)))
(def: #export unicode
(Random Nat)
(|> ;;nat
- (:: Monad<Random> map (n.% unicode-ceiling))
+ (:: Monad<Random> map (n/% unicode-ceiling))
(;;filter (function [raw]
## From "Basic Latin" to "Syriac"
- (or (n.<= (hex "+074F") raw)
+ (or (n/<= (hex "+074F") raw)
(within? Thaana raw)
## From "Devanagari" to "Ethiopic"
- (and (n.>= (hex "+0900") raw)
- (n.<= (hex "+137F") raw))
+ (and (n/>= (hex "+0900") raw)
+ (n/<= (hex "+137F") raw))
## From "Cherokee" to "Mongolian"
- (and (n.>= (hex "+13A0") raw)
- (n.<= (hex "+18AF") raw))
+ (and (n/>= (hex "+13A0") raw)
+ (n/<= (hex "+18AF") raw))
## From "Limbu" to "Tai Le"
- (and (n.>= (hex "+1900") raw)
- (n.<= (hex "+197F") raw))
+ (and (n/>= (hex "+1900") raw)
+ (n/<= (hex "+197F") raw))
(within? Khmer-Symbols raw)
(within? Phonetic-Extensions raw)
## From "Latin Extended Additional" to "Miscellaneous Symbols and Arrows"
- (and (n.>= (hex "+1E00") raw)
- (n.<= (hex "+2BFF") raw))
+ (and (n/>= (hex "+1E00") raw)
+ (n/<= (hex "+2BFF") raw))
## From "CJK Radicals Supplement" to "Kangxi Radicals"
- (and (n.>= (hex "+2E80") raw)
- (n.<= (hex "+2FDF") raw))
+ (and (n/>= (hex "+2E80") raw)
+ (n/<= (hex "+2FDF") raw))
## From "Ideographic Description Characters" to "Bopomofo Extended"
- (and (n.>= (hex "+2FF0") raw)
- (n.<= (hex "+31BF") raw))
+ (and (n/>= (hex "+2FF0") raw)
+ (n/<= (hex "+31BF") raw))
## From "Katakana Phonetic Extensions" to "CJK Unified Ideographs"
- (and (n.>= (hex "+31F0") raw)
- (n.<= (hex "+9FAF") raw))
+ (and (n/>= (hex "+31F0") raw)
+ (n/<= (hex "+9FAF") raw))
## From "Yi Syllables" to "Yi Radicals"
- (and (n.>= (hex "+A000") raw)
- (n.<= (hex "+A4CF") raw))
+ (and (n/>= (hex "+A000") raw)
+ (n/<= (hex "+A4CF") raw))
(within? Hangul-Syllables raw)
## From "CJK Compatibility Ideographs" to "Arabic Presentation Forms-A"
- (and (n.>= (hex "+F900") raw)
- (n.<= (hex "+FDFF") raw))
+ (and (n/>= (hex "+F900") raw)
+ (n/<= (hex "+FDFF") raw))
## From "Combining Half Marks" to "Halfwidth and Fullwidth Forms"
- (and (n.>= (hex "+FE20") raw)
- (n.<= (hex "+FFEF") raw))
+ (and (n/>= (hex "+FE20") raw)
+ (n/<= (hex "+FFEF") raw))
## From "Linear B Syllabary" to "Aegean Numbers"
- (and (n.>= (hex "+10000") raw)
- (n.<= (hex "+1013F") raw))
+ (and (n/>= (hex "+10000") raw)
+ (n/<= (hex "+1013F") raw))
## From "Old Italic" to "Osmanya"
- (and (n.>= (hex "+10300") raw)
- (n.<= (hex "+104AF") raw))
+ (and (n/>= (hex "+10300") raw)
+ (n/<= (hex "+104AF") raw))
(within? Cypriot-Syllabary raw)
## From "Byzantine Musical Symbols" to "Musical Symbols"
- (and (n.>= (hex "+1D000") raw)
- (n.<= (hex "+1D1FF") raw))
+ (and (n/>= (hex "+1D000") raw)
+ (n/<= (hex "+1D1FF") raw))
(within? Tai-Xuan-Jing-Symbols raw)
(within? Mathematical-Alphanumeric-Symbols raw)
(within? CJK-Unified-Ideographs-Extension-B raw)
@@ -262,10 +262,10 @@
(do-template [<name> <type> <zero> <plus>]
[(def: #export (<name> size value-gen)
(All [a] (-> Nat (Random a) (Random (<type> a))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
[x value-gen
- xs (<name> (n.dec size) value-gen)]
+ xs (<name> (n/dec size) value-gen)]
(wrap (<plus> x xs)))
(:: Monad<Random> wrap <zero>)))]
@@ -287,29 +287,29 @@
(def: #export (set Hash<a> size value-gen)
(All [a] (-> (Hash a) Nat (Random a) (Random (Set a))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
- [xs (set Hash<a> (n.dec size) value-gen)]
+ [xs (set Hash<a> (n/dec size) value-gen)]
(loop [_ []]
(do @
[x value-gen
#let [xs+ (set;add x xs)]]
- (if (n.= size (set;size xs+))
+ (if (n/= size (set;size xs+))
(wrap xs+)
(recur [])))))
(:: Monad<Random> wrap (set;new Hash<a>))))
(def: #export (dict Hash<a> size key-gen value-gen)
(All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dict k v))))
- (if (n.> +0 size)
+ (if (n/> +0 size)
(do Monad<Random>
- [kv (dict Hash<a> (n.dec size) key-gen value-gen)]
+ [kv (dict Hash<a> (n/dec size) key-gen value-gen)]
(loop [_ []]
(do @
[k key-gen
v value-gen
#let [kv+ (dict;put k v kv)]]
- (if (n.= size (dict;size kv+))
+ (if (n/= size (dict;size kv+))
(wrap kv+)
(recur [])))))
(:: Monad<Random> wrap (dict;new Hash<a>))))
@@ -318,9 +318,6 @@
(All [a] (-> PRNG (Random a) [PRNG a]))
(calc prng))
-## PCG32 http://www.pcg-random.org/
-## Based on this Java implementation: https://github.com/alexeyr/pcg-java
-
(def: pcg-32-magic-mult Nat +6364136223846793005)
(def: #export (pcg-32 [inc seed])
@@ -329,20 +326,19 @@
For more information, please see: http://www.pcg-random.org/"}
(-> [Nat Nat] PRNG)
(function [_]
- (let [seed' (|> seed (n.* pcg-32-magic-mult) (n.+ inc))
+ (let [seed' (|> seed (n/* pcg-32-magic-mult) (n/+ inc))
xor-shifted (|> seed (bit;shift-right +18) (bit;xor seed) (bit;shift-right +27))
rot (|> seed (bit;shift-right +59))]
[(pcg-32 [inc seed']) (bit;rotate-right rot xor-shifted)]
)))
-## Xoroshiro128+ http://xoroshiro.di.unimi.it/
(def: #export (xoroshiro-128+ [s0 s1])
{#;doc "An implementation of the Xoroshiro128+ algorithm.
For more information, please see: http://xoroshiro.di.unimi.it/"}
(-> [Nat Nat] PRNG)
(function [_]
- (let [result (n.+ s0 s1)
+ (let [result (n/+ s0 s1)
s01 (bit;xor s0 s1)
s0' (|> (bit;rotate-left +55 s0)
(bit;xor s01)
@@ -365,9 +361,9 @@
(function [idx vec]
(do Monad<Random>
[rand nat]
- (wrap (swap idx (n.% _size rand) vec))))
+ (wrap (swap idx (n/% _size rand) vec))))
sequence
- (list;n.range +0 (n.dec _size)))]
+ (list;n/range +0 (n/dec _size)))]
(|> _shuffle
(run (pcg-32 [+123 seed]))
product;right)))
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index f8cfa9871..10672afaf 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -47,7 +47,7 @@
(def: (add-counters [s f] [ts tf])
(-> Counters Counters Counters)
- [(n.+ s ts) (n.+ f tf)])
+ [(n/+ s ts) (n/+ f tf)])
(def: #export (fail message)
(All [a] (-> Text Test))
@@ -91,7 +91,7 @@
(def: failed?
(-> Counters Bool)
- (|>. product;right (n.> +0)))
+ (|>. product;right (n/> +0)))
(def: #export (seed value test)
(-> Seed Test Test)
@@ -102,10 +102,10 @@
(def: #export (times amount test)
(-> Nat Test Test)
- (cond (n.= +0 amount)
+ (cond (n/= +0 amount)
(fail "Cannot try a test 0 times.")
- (n.= +1 amount)
+ (n/= +1 amount)
test
## else
@@ -117,7 +117,7 @@
[[counters documentation] instance]
(if (failed? counters)
(wrap [counters (format "Failed with this seed: " (%n seed) "\n" documentation)])
- (product;right (r;run prng' (times (n.dec amount) test)))))])))))
+ (product;right (r;run prng' (times (n/dec amount) test)))))])))))
## [Syntax]
(def: #hidden _code/text_ code;text)
@@ -127,11 +127,11 @@
(context: "Simple macros and constructs"
($_ seq
(test "Can write easy loops for iterative programming."
- (i.= 1000
+ (i/= 1000
(loop [counter 0
value 1]
- (if (i.< 3 counter)
- (recur (i.inc counter) (i.* 10 value))
+ (if (i/< 3 counter)
+ (recur (i/inc counter) (i/* 10 value))
value))))
(test "Can create lists easily through macros."
@@ -238,20 +238,20 @@
(~ g!total-failures) +0]
(~@ (list/join (list/map (function [group]
(list (` [(~ g!successes) (~ g!failures)]) (` (run' (list (~@ group))))
- (' #let) (` [(~ g!total-successes) (n.+ (~ g!successes) (~ g!total-successes))
- (~ g!total-failures) (n.+ (~ g!failures) (~ g!total-failures))])))
+ (' #let) (` [(~ g!total-successes) (n/+ (~ g!successes) (~ g!total-successes))
+ (~ g!total-failures) (n/+ (~ g!failures) (~ g!total-failures))])))
groups)))]
(exec (log! ($_ _composeT_
"Test-suite finished."
"\n"
(_%i_ (nat-to-int (~ g!total-successes)))
" out of "
- (_%i_ (nat-to-int (n.+ (~ g!total-failures)
+ (_%i_ (nat-to-int (n/+ (~ g!total-failures)
(~ g!total-successes))))
" tests passed."
"\n"
(_%i_ (nat-to-int (~ g!total-failures))) " tests failed."))
- (promise;future (if (n.> +0 (~ g!total-failures))
+ (promise;future (if (n/> +0 (~ g!total-failures))
;;die
;;exit))))
[])))))))))
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 5b124a669..36719b45f 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -73,10 +73,10 @@
[(def: (<name> reference sample)
(<comp> (month-to-nat reference) (month-to-nat sample)))]
- [< n.<]
- [<= n.<=]
- [> n.>]
- [>= n.>=]
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
))
(struct: #export _ (Enum Month)
@@ -153,10 +153,10 @@
[(def: (<name> reference sample)
(<comp> (day-to-nat reference) (day-to-nat sample)))]
- [< n.<]
- [<= n.<=]
- [> n.>]
- [>= n.>=]
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
))
(struct: #export _ (Enum Day)
@@ -187,22 +187,22 @@
(struct: #export _ (Eq Date)
(def: (= reference sample)
- (and (i.= (get@ #year reference)
+ (and (i/= (get@ #year reference)
(get@ #year sample))
(:: Eq<Month> =
(get@ #month reference)
(get@ #month sample))
- (n.= (get@ #day reference)
+ (n/= (get@ #day reference)
(get@ #day sample)))))
(def: (date.< reference sample)
(-> Date Date Bool)
- (or (i.< (get@ #year reference)
+ (or (i/< (get@ #year reference)
(get@ #year sample))
(:: Order<Month> <
(get@ #month reference)
(get@ #month sample))
- (n.< (get@ #day reference)
+ (n/< (get@ #day reference)
(get@ #day sample))))
(struct: #export _ (Order Date)
@@ -220,7 +220,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)))
@@ -228,7 +228,7 @@
(-> Date Text)
($_ text/compose
(int/encode year) "-"
- (pad (|> month month-to-nat n.inc nat-to-int)) "-"
+ (pad (|> month month-to-nat n/inc nat-to-int)) "-"
(pad (|> day nat-to-int))))
(def: lex-year
@@ -239,7 +239,7 @@
#let [signum (case sign?
#;None 1
(#;Some _) -1)]]
- (wrap (i.* signum raw-year))))
+ (wrap (i/* signum raw-year))))
(def: lex-section
(l;Lexer Int)
@@ -247,9 +247,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
(Sequence Nat)
@@ -260,11 +260,11 @@
(def: leap-year-months
(Sequence Nat)
- (sequence;update [+1] n.inc normal-months))
+ (sequence;update [+1] n/inc normal-months))
(def: (divisible? factor input)
(-> Int Int Bool)
- (|> input (i.% factor) (i.= 0)))
+ (|> input (i/% factor) (i/= 0)))
(def: (leap-year? year)
(-> Int Bool)
@@ -280,19 +280,19 @@
_ (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)
month-days (|> months
- (sequence;nth (int-to-nat (i.dec utc-month)))
+ (sequence;nth (int-to-nat (i/dec utc-month)))
maybe;assume)]
_ (l;this "-")
utc-day lex-section
_ (p;assert "Invalid day."
- (and (i.>= 1 utc-day)
- (i.<= (nat-to-int month-days) utc-day)))]
+ (and (i/>= 1 utc-day)
+ (i/<= (nat-to-int month-days) utc-day)))]
(wrap {#year utc-year
#month (case utc-month
1 #January
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 283b48c91..642550bc3 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -28,21 +28,21 @@
(-> Duration Duration Duration)
(@opaque (<op> (@repr param) (@repr subject))))]
- [merge i.+]
- [frame i.%]
+ [merge i/+]
+ [frame i/%]
)
(def: #export (scale scalar duration)
(-> Int Duration Duration)
- (@opaque (i.* scalar (@repr duration))))
+ (@opaque (i/* scalar (@repr duration))))
(def: #export (query param subject)
(-> Duration Duration Int)
- (i./ (@repr param) (@repr subject)))
+ (i// (@repr param) (@repr subject)))
(struct: #export _ (Eq Duration)
(def: (= param subject)
- (i.= (@repr param) (@repr subject))))
+ (i/= (@repr param) (@repr subject))))
(struct: #export _ (Order Duration)
(def: eq Eq<Duration>)
@@ -50,10 +50,10 @@
[(def: (<name> param subject)
(<op> (@repr param) (@repr subject)))]
- [< i.<]
- [<= i.<=]
- [> i.>]
- [>= i.>=]
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]
))
(do-template [<name> <op>]
@@ -61,9 +61,9 @@
(-> Duration Bool)
(<op> 0 (@repr duration)))]
- [positive? i.>]
- [negative? i.<]
- [neutral? i.=])
+ [positive? i/>]
+ [negative? i/<]
+ [neutral? i/=])
)
(def: #export empty Duration (from-millis 0))
@@ -94,11 +94,11 @@
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)
@@ -111,21 +111,21 @@
(l;Lexer Duration)
(do p;Monad<Parser>
[signed? (l;this? "-")
- #let [sign (function [raw] (if signed? (i.* -1 raw) raw))]
+ #let [sign (function [raw] (if signed? (i/* -1 raw) 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))
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 83b415024..2429d0bee 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -32,11 +32,11 @@
(def: #export (span from to)
(-> Instant Instant duration;Duration)
- (duration;from-millis (i.- (@repr from) (@repr to))))
+ (duration;from-millis (i/- (@repr from) (@repr to))))
(def: #export (shift duration instant)
(-> duration;Duration Instant Instant)
- (@opaque (i.+ (duration;to-millis duration) (@repr instant))))
+ (@opaque (i/+ (duration;to-millis duration) (@repr instant))))
(def: #export (relative instant)
(-> Instant duration;Duration)
@@ -77,7 +77,7 @@
## Codec::encode
(def: (divisible? factor input)
(-> Int Int Bool)
- (|> input (i.% factor) (i.= 0)))
+ (|> input (i/% factor) (i/= 0)))
(def: (leap-year? year)
(-> Int Bool)
@@ -94,11 +94,11 @@
(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 (i.inc reference) (duration;merge (duration;scale -1 year) time-left))
- (recur (i.dec reference) (duration;merge year time-left)))
+ (recur (i/inc reference) (duration;merge (duration;scale -1 year) time-left))
+ (recur (i/dec reference) (duration;merge year time-left)))
))))
(def: normal-months
@@ -110,29 +110,29 @@
(def: leap-year-months
(Sequence Nat)
- (sequence;update [+1] n.inc normal-months))
+ (sequence;update [+1] n/inc normal-months))
(def: (find-month months time)
(-> (Sequence Nat) duration;Duration [Nat duration;Duration])
(if (duration/>= duration;empty time)
(sequence/fold (function [month-days [current-month time-left]]
(let [month-duration (duration;scale (nat-to-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]
- [(n.inc current-month) (duration;merge (duration;scale -1 month-duration) time-left)])))
+ [(n/inc current-month) (duration;merge (duration;scale -1 month-duration) time-left)])))
[+0 time]
months)
(sequence/fold (function [month-days [current-month time-left]]
(let [month-duration (duration;scale (nat-to-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]
- [(n.dec current-month) (duration;merge month-duration time-left)])))
+ [(n/dec current-month) (duration;merge month-duration time-left)])))
[+11 time]
(sequence;reverse months))))
(def: (pad value)
(-> Int Text)
- (if (i.< 10 value)
+ (if (i/< 10 value)
(text/compose "0" (int/encode value))
(int/encode value)))
@@ -144,10 +144,10 @@
(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))
@@ -157,36 +157,36 @@
(-> 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)
+ z (|> seconds (i// seconds-per-day) (i/+ days-up-to-epoch))
+ 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
- (i.dec days-of-year))
- mp (|> days-of-year (i.* 5) (i.+ 2) (i./ 153))
+ (i/dec days-of-year))
+ 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)
+ (i/+ (if (i/< 10 mp)
3
-9)))
- year (if (i.<= 2 month)
- (i.inc year)
+ year (if (i/<= 2 month)
+ (i/inc year)
year)]
[[year month day]
day-time]))
@@ -219,7 +219,7 @@
#let [signum (case sign?
#;None 1
(#;Some _) -1)]]
- (wrap (i.* signum raw-year))))
+ (wrap (i/* signum raw-year))))
(def: lex-section
(l;Lexer Int)
@@ -234,9 +234,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))))
## Based on: https://stackoverflow.com/a/3309340/6823464
(def: lex-instant
@@ -246,48 +246,48 @@
_ (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)
month-days (|> months
- (sequence;nth (int-to-nat (i.dec utc-month)))
+ (sequence;nth (int-to-nat (i/dec utc-month)))
maybe;assume)]
_ (l;this "-")
utc-day lex-section
_ (p;assert "Invalid day."
- (and (i.>= 1 utc-day)
- (i.<= (nat-to-int month-days) utc-day)))
+ (and (i/>= 1 utc-day)
+ (i/<= (nat-to-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 (i.dec utc-year)))
- year-days-so-far (|> (i.* 365 years-since-epoch)
- (i.+ previous-leap-days))
+ #let [years-since-epoch (i/- epoch-year utc-year)
+ previous-leap-days (i/- (leap-years epoch-year)
+ (leap-years (i/dec utc-year)))
+ year-days-so-far (|> (i/* 365 years-since-epoch)
+ (i/+ previous-leap-days))
month-days-so-far (|> months
sequence;to-list
- (list;take (int-to-nat (i.dec utc-month)))
- (L/fold n.+ +0))
+ (list;take (int-to-nat (i/dec utc-month)))
+ (L/fold n/+ +0))
total-days (|> year-days-so-far
- (i.+ (nat-to-int month-days-so-far))
- (i.+ (i.dec utc-day)))]]
+ (i/+ (nat-to-int month-days-so-far))
+ (i/+ (i/dec utc-day)))]]
(wrap (|> epoch
(shift (duration;scale total-days duration;day))
(shift (duration;scale utc-hour duration;hour))
@@ -315,7 +315,7 @@
(-> Instant date;Date)
(let [[[year month day] _] (extract-date instant)]
{#date;year year
- #date;month (case (i.dec month)
+ #date;month (case (i/dec month)
0 #date;January
1 #date;February
2 #date;March
@@ -343,14 +343,14 @@
day-time (duration;frame duration;day offset)
days (if (and (duration;negative? offset)
(not (duration;neutral? day-time)))
- (i.dec days)
+ (i/dec days)
days)
## 1970/01/01 was a Thursday
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))
+ (i/+ 7) (i/% 7))
0 #date;Sunday
1 #date;Monday
2 #date;Tuesday
diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux
index e23a5c8dd..fb08f0a0b 100644
--- a/stdlib/source/lux/type/implicit.lux
+++ b/stdlib/source/lux/type/implicit.lux
@@ -20,7 +20,7 @@
(def: (find-type-var id env)
(-> Nat Type-Context (Meta Type))
- (case (list;find (|>. product;left (n.= id))
+ (case (list;find (|>. product;left (n/= id))
(get@ #;var-bindings env))
(#;Some [_ (#;Some type)])
(case type
@@ -64,12 +64,12 @@
(find-member-type idx sig-type'))
(#;Product left right)
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(:: Monad<Check> wrap left)
- (find-member-type (n.dec idx) right))
+ (find-member-type (n/dec idx) right))
_
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(:: Monad<Check> wrap sig-type)
(tc;fail (format "Cannot find member type " (%n idx) " for " (%type sig-type))))))
@@ -324,10 +324,10 @@
(::: eq;= x y)
"(List Nat) equality"
(::: =
- (list;n.range +1 +10)
- (list;n.range +1 +10))
+ (list;n/range +1 +10)
+ (list;n/range +1 +10))
"(Functor List) map"
- (::: map n.inc (list;n.range +0 +9))
+ (::: map n/inc (list;n/range +0 +9))
"Caveat emptor: You need to make sure to import the module of any structure you want to use."
"Otherwise, this macro will not find it.")}
(case args
diff --git a/stdlib/source/lux/type/object.lux b/stdlib/source/lux/type/object.lux
index a7945b41a..461e836a3 100644
--- a/stdlib/source/lux/type/object.lux
+++ b/stdlib/source/lux/type/object.lux
@@ -34,7 +34,7 @@
(do p;Monad<Parser>
[raw parser
_ (p;assert "Cannot repeat the names of type variables/parameters."
- (n.= (set;size (var-set raw))
+ (n/= (set;size (var-set raw))
(list;size raw)))]
(wrap raw)))
@@ -64,8 +64,8 @@
(if (list;empty? ancestors)
(list)
(|> (list;size ancestors)
- n.dec
- (list;n.range +0)
+ n/dec
+ (list;n/range +0)
(L/map (|>. %n (format "ancestor") code;local-symbol)))))
## [Methods]
@@ -166,7 +166,7 @@
currentT newT]
(case currentT
(#;UnivQ _ bodyT)
- (recur (n.inc depth) bodyT)
+ (recur (n/inc depth) bodyT)
(#;Function inputT outputT)
(let [[stateT+ objectT] (type;flatten-function currentT)]
@@ -182,9 +182,9 @@
typeC
size
- (|> (n.dec size)
- (list;n.range +0)
- (L/map (|>. (n.* +2) n.inc code;nat (~) #;Bound (`)))
+ (|> (n/dec size)
+ (list;n/range +0)
+ (L/map (|>. (n/* +2) n/inc code;nat (~) #;Bound (`)))
(list;zip2 (list;reverse mappings))
(L/fold (function [[mappingC boundC] genericC]
(code;replace boundC mappingC genericC))
diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux
index ef8f5410a..c2a4629c0 100644
--- a/stdlib/source/lux/type/unit.lux
+++ b/stdlib/source/lux/type/unit.lux
@@ -81,10 +81,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 [(int-to-nat numerator) (int-to-nat denominator)]))))
(syntax: #export (scale: [export csr;export]
@@ -99,13 +99,13 @@
(;;Scale (~ g!scale))
(def: (~' scale)
(|>. ;;out
- (i.* (~ (code;int (nat-to-int numerator))))
- (i./ (~ (code;int (nat-to-int denominator))))
+ (i/* (~ (code;int (nat-to-int numerator))))
+ (i// (~ (code;int (nat-to-int denominator))))
(;;in (:! ((~ g!scale) ($ +0)) []))))
(def: (~' de-scale)
(|>. ;;out
- (i.* (~ (code;int (nat-to-int denominator))))
- (i./ (~ (code;int (nat-to-int numerator))))
+ (i/* (~ (code;int (nat-to-int denominator))))
+ (i// (~ (code;int (nat-to-int numerator))))
(;;in (:! ($ +0) []))))
(def: (~' ratio)
[(~ (code;nat numerator)) (~ (code;nat denominator))])))
@@ -116,31 +116,31 @@
(All [unit] (-> (Qty unit) (Qty unit) (Qty unit)))
(|> (out subject) (<op> (out param)) (in (carrier subject))))]
- [++ i.+]
- [-- i.-]
+ [u+ i/+]
+ [u- i/-]
)
-(def: #export (// param subject)
+(def: #export (u/ param subject)
(All [p s] (-> (Qty p) (Qty s) (|> (Qty s) (Per (Qty p)))))
(function [input]
(|> (out subject)
- (i.* (out input))
- (i./ (out param))
+ (i/* (out input))
+ (i// (out param))
(in (carrier subject)))))
-(def: #export (** param subject)
+(def: #export (u* param subject)
(All [p s] (-> (Qty p) (Qty s) (Product (Qty p) (Qty s))))
(function [input]
(|> (out subject)
- (i.* (out (input param)))
+ (i/* (out (input param)))
(in (carrier subject)))))
(def: #export (re-scale from to quantity)
(All [si so u] (-> (Scale si) (Scale so) (Qty (si u)) (Qty (so u))))
(let [[numerator denominator] (|> (:: to ratio) (r;q./ (:: from ratio)))]
(|> quantity out
- (i.* (nat-to-int numerator))
- (i./ (nat-to-int denominator))
+ (i/* (nat-to-int numerator))
+ (i// (nat-to-int denominator))
(in (:! (($ +1) ($ +2)) [])))))
(scale: #export Kilo [1 1_000])
@@ -163,7 +163,7 @@
(struct: #export Eq<Unit> (All [unit] (Eq (Qty unit)))
(def: (= reference sample)
- (i.= (out reference) (out sample))))
+ (i/= (out reference) (out sample))))
(struct: #export Order<Unit> (All [unit] (Order (Qty unit)))
(def: eq Eq<Unit>)
@@ -172,12 +172,12 @@
[(def: (<name> reference sample)
(<func> (out reference) (out sample)))]
- [< i.<]
- [<= i.<=]
- [> i.>]
- [>= i.>=]))
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]))
(struct: #export Enum<Unit> (All [unit] (Enum (Qty unit)))
(def: order Order<Unit>)
- (def: (succ qty) (|> (out qty) i.inc (in (carrier qty))))
- (def: (pred qty) (|> (out qty) i.dec (in (carrier qty)))))
+ (def: (succ qty) (|> (out qty) i/inc (in (carrier qty))))
+ (def: (pred qty) (|> (out qty) i/dec (in (carrier qty)))))
diff --git a/stdlib/source/lux/world/blob.jvm.lux b/stdlib/source/lux/world/blob.jvm.lux
index c31feb8e5..f6dcb1f6e 100644
--- a/stdlib/source/lux/world/blob.jvm.lux
+++ b/stdlib/source/lux/world/blob.jvm.lux
@@ -20,7 +20,7 @@
(def: byte-mask
Nat
- (|> +1 (bit;shift-left +8) n.dec))
+ (|> +1 (bit;shift-left +8) n/dec))
(def: byte-to-nat
(-> (primitive java.lang.Byte) Nat)
@@ -32,45 +32,45 @@
(def: #export (read-8 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) idx)
+ (if (n/< (host;array-length blob) idx)
(|> (host;array-read idx blob) byte-to-nat #E;Success)
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-16 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +1 idx))
+ (if (n/< (host;array-length blob) (n/+ +1 idx))
(#E;Success ($_ bit;or
(bit;shift-left +8 (byte-to-nat (host;array-read idx blob)))
- (byte-to-nat (host;array-read (n.+ +1 idx) blob))))
+ (byte-to-nat (host;array-read (n/+ +1 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-32 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +3 idx))
+ (if (n/< (host;array-length blob) (n/+ +3 idx))
(#E;Success ($_ bit;or
(bit;shift-left +24 (byte-to-nat (host;array-read idx blob)))
- (bit;shift-left +16 (byte-to-nat (host;array-read (n.+ +1 idx) blob)))
- (bit;shift-left +8 (byte-to-nat (host;array-read (n.+ +2 idx) blob)))
- (byte-to-nat (host;array-read (n.+ +3 idx) blob))))
+ (bit;shift-left +16 (byte-to-nat (host;array-read (n/+ +1 idx) blob)))
+ (bit;shift-left +8 (byte-to-nat (host;array-read (n/+ +2 idx) blob)))
+ (byte-to-nat (host;array-read (n/+ +3 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (read-64 idx blob)
(-> Nat Blob (E;Error Nat))
- (if (n.< (host;array-length blob) (n.+ +7 idx))
+ (if (n/< (host;array-length blob) (n/+ +7 idx))
(#E;Success ($_ bit;or
(bit;shift-left +56 (byte-to-nat (host;array-read idx blob)))
- (bit;shift-left +48 (byte-to-nat (host;array-read (n.+ +1 idx) blob)))
- (bit;shift-left +40 (byte-to-nat (host;array-read (n.+ +2 idx) blob)))
- (bit;shift-left +32 (byte-to-nat (host;array-read (n.+ +3 idx) blob)))
- (bit;shift-left +24 (byte-to-nat (host;array-read (n.+ +4 idx) blob)))
- (bit;shift-left +16 (byte-to-nat (host;array-read (n.+ +5 idx) blob)))
- (bit;shift-left +8 (byte-to-nat (host;array-read (n.+ +6 idx) blob)))
- (byte-to-nat (host;array-read (n.+ +7 idx) blob))))
+ (bit;shift-left +48 (byte-to-nat (host;array-read (n/+ +1 idx) blob)))
+ (bit;shift-left +40 (byte-to-nat (host;array-read (n/+ +2 idx) blob)))
+ (bit;shift-left +32 (byte-to-nat (host;array-read (n/+ +3 idx) blob)))
+ (bit;shift-left +24 (byte-to-nat (host;array-read (n/+ +4 idx) blob)))
+ (bit;shift-left +16 (byte-to-nat (host;array-read (n/+ +5 idx) blob)))
+ (bit;shift-left +8 (byte-to-nat (host;array-read (n/+ +6 idx) blob)))
+ (byte-to-nat (host;array-read (n/+ +7 idx) blob))))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-8 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) idx)
+ (if (n/< (host;array-length blob) idx)
(exec (|> blob
(host;array-write idx (host;l2b (:! Int value))))
(#E;Success []))
@@ -78,36 +78,36 @@
(def: #export (write-16 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +1 idx))
+ (if (n/< (host;array-length blob) (n/+ +1 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-32 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +3 idx))
+ (if (n/< (host;array-length blob) (n/+ +3 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +24 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
- (host;array-write (n.+ +2 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +3 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
+ (host;array-write (n/+ +2 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
+ (host;array-write (n/+ +3 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
(def: #export (write-64 idx value blob)
(-> Nat Nat Blob (E;Error Unit))
- (if (n.< (host;array-length blob) (n.+ +7 idx))
+ (if (n/< (host;array-length blob) (n/+ +7 idx))
(exec (|> blob
(host;array-write idx (host;l2b (:! Int (bit;shift-right +56 value))))
- (host;array-write (n.+ +1 idx) (host;l2b (:! Int (bit;shift-right +48 value))))
- (host;array-write (n.+ +2 idx) (host;l2b (:! Int (bit;shift-right +40 value))))
- (host;array-write (n.+ +3 idx) (host;l2b (:! Int (bit;shift-right +32 value))))
- (host;array-write (n.+ +4 idx) (host;l2b (:! Int (bit;shift-right +24 value))))
- (host;array-write (n.+ +5 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
- (host;array-write (n.+ +6 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
- (host;array-write (n.+ +7 idx) (host;l2b (:! Int value))))
+ (host;array-write (n/+ +1 idx) (host;l2b (:! Int (bit;shift-right +48 value))))
+ (host;array-write (n/+ +2 idx) (host;l2b (:! Int (bit;shift-right +40 value))))
+ (host;array-write (n/+ +3 idx) (host;l2b (:! Int (bit;shift-right +32 value))))
+ (host;array-write (n/+ +4 idx) (host;l2b (:! Int (bit;shift-right +24 value))))
+ (host;array-write (n/+ +5 idx) (host;l2b (:! Int (bit;shift-right +16 value))))
+ (host;array-write (n/+ +6 idx) (host;l2b (:! Int (bit;shift-right +8 value))))
+ (host;array-write (n/+ +7 idx) (host;l2b (:! Int value))))
(#E;Success []))
(ex;throw Index-Out-Of-Bounds (%n idx))))
@@ -119,19 +119,19 @@
(-> Nat Nat Blob (E;Error Blob))
(with-expansions [<description> (as-is (format "from = " (%n from) " | " "to = " (%n to)))]
(let [size (host;array-length blob)]
- (cond (not (n.<= to from))
+ (cond (not (n/<= to from))
(ex;throw Inverted-Range <description>)
- (not (and (n.< size from)
- (n.< size to)))
+ (not (and (n/< size from)
+ (n/< size to)))
(ex;throw Index-Out-Of-Bounds <description>)
## else
- (#E;Success (Arrays.copyOfRange [blob (:! Int from) (:! Int (n.inc to))]))))))
+ (#E;Success (Arrays.copyOfRange [blob (:! Int from) (:! Int (n/inc to))]))))))
(def: #export (slice' from blob)
(-> Nat Blob (E;Error Blob))
- (slice from (n.dec (host;array-length blob)) blob))
+ (slice from (n/dec (host;array-length blob)) blob))
(struct: #export _ (eq;Eq Blob)
(def: (= reference sample)
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 1c968b888..1e95e7354 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -71,7 +71,7 @@
stream (FileInputStream.new [file'])
bytes-read (InputStream.read [data] stream)
_ (AutoCloseable.close [] stream)]
- (if (i.= size bytes-read)
+ (if (i/= size bytes-read)
(wrap data)
(io;io (ex;throw Could-Not-Read-All-Data file))))))
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index addc7a33a..d73f0c5a9 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -14,7 +14,7 @@
(context: "Value identity."
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
x (r;text size)
y (r;text size)]
($_ seq
@@ -52,8 +52,8 @@
(and (|> value inc even?)
(|> value dec even?)))))))]
- ["Nat" r;nat n.inc n.dec n.even? n.odd? n.= n.< n.>]
- ["Int" r;int i.inc i.dec i.even? i.odd? i.= i.< i.>]
+ ["Nat" r;nat n/inc n/dec n/even? n/odd? n/= n/< n/>]
+ ["Int" r;int i/inc i/dec i/even? i/odd? i/= i/< i/>]
)
(do-template [category rand-gen = < > <= >= min max]
@@ -80,10 +80,10 @@
(>= y (max x y)))
)))))]
- ["Int" r;int i.= i.< i.> i.<= i.>= i.min i.max]
- ["Nat" r;nat n.= n.< n.> n.<= n.>= n.min n.max]
- ["Frac" r;frac f.= f.< f.> f.<= f.>= f.min f.max]
- ["Deg" r;deg d.= d.< d.> d.<= d.>= d.min d.max]
+ ["Int" r;int i/= i/< i/> i/<= i/>= i/min i/max]
+ ["Nat" r;nat n/= n/< n/> n/<= n/>= n/min n/max]
+ ["Frac" r;frac f/= f/< f/> f/<= f/>= f/min f/max]
+ ["Deg" r;deg d/= d/< d/> d/<= d/>= d/min d/max]
)
(do-template [category rand-gen = + - * / <%> > <0> <1> <factor> %x <cap> <prep>]
@@ -136,10 +136,10 @@
(|> x' (/ y) (* y) (= x'))))
))))]
- ["Nat" r;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id]
- ["Int" r;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id]
- ["Frac" r;frac f.= f.+ f.- f.* f./ f.% f.> 0.0 1.0 1000000.0 %r id math;floor]
- ["Deg" r;deg d.= d.+ d.- d.* d./ d.% d.> .0 ("lux deg max") ("lux deg max") %f id id]
+ ["Nat" r;nat n/= n/+ n/- n/* n// n/% n/> +0 +1 +1000000 %n (n/% +1000) id]
+ ["Int" r;int i/= i/+ i/- i/* i// i/% i/> 0 1 1000000 %i (i/% 1000) id]
+ ["Frac" r;frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1000000.0 %r id math;floor]
+ ["Deg" r;deg d/= d/+ d/- d/* d// d/% d/> .0 ("lux deg max") ("lux deg max") %f id id]
)
(do-template [category rand-gen -> <- = <cap> %a %z]
@@ -151,21 +151,21 @@
(test ""
(|> value -> <- (= value))))))]
- ["Int->Nat" r;int int-to-nat nat-to-int i.= (i.% 1000000) %i %n]
- ["Nat->Int" r;nat nat-to-int int-to-nat n.= (n.% +1000000) %n %i]
- ["Int->Frac" r;int int-to-frac frac-to-int i.= (i.% 1000000) %i %r]
- ["Frac->Int" r;frac frac-to-int int-to-frac f.= math;floor %r %i]
- ## [r;frac frac-to-deg deg-to-frac f.= (f.% 1.0) %r %f]
+ ["Int->Nat" r;int int-to-nat nat-to-int i/= (i/% 1000000) %i %n]
+ ["Nat->Int" r;nat nat-to-int int-to-nat n/= (n/% +1000000) %n %i]
+ ["Int->Frac" r;int int-to-frac frac-to-int i/= (i/% 1000000) %i %r]
+ ["Frac->Int" r;frac frac-to-int int-to-frac f/= math;floor %r %i]
+ ## [r;frac frac-to-deg deg-to-frac f/= (f/% 1.0) %r %f]
)
(context: "Simple macros and constructs"
($_ seq
(test "Can write easy loops for iterative programming."
- (i.= 1000
+ (i/= 1000
(loop [counter 0
value 1]
- (if (i.< 3 counter)
- (recur (i.inc counter) (i.* 10 value))
+ (if (i/< 3 counter)
+ (recur (i/inc counter) (i/* 10 value))
value))))
(test "Can create lists easily through macros."
@@ -192,7 +192,7 @@
))
(template: (hypotenuse x y)
- (i.+ (i.* x x) (i.* y y)))
+ (i/+ (i/* x x) (i/* y y)))
(context: "Templates."
(<| (times +100)
@@ -200,7 +200,7 @@
[x r;int
y r;int]
(test "Template application is a stand-in for the templated code."
- (i.= (i.+ (i.* x x) (i.* y y))
+ (i/= (i/+ (i/* x x) (i/* y y))
(hypotenuse x y))))))
(context: "Cross-platform support."
diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux
index 35400da79..bb3765e63 100644
--- a/stdlib/test/test/lux/cli.lux
+++ b/stdlib/test/test/lux/cli.lux
@@ -18,7 +18,7 @@
(context: "CLI"
(<| (times +100)
(do @
- [num-args (|> r;nat (:: @ map (n.% +10)))
+ [num-args (|> r;nat (:: @ map (n/% +10)))
#let [(^open "Nat/") number;Codec<Text,Nat>
gen-arg (:: @ map Nat/encode r;nat)]
yes gen-arg
diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux
index 8abcae045..450f3b399 100644
--- a/stdlib/test/test/lux/concurrency/actor.lux
+++ b/stdlib/test/test/lux/concurrency/actor.lux
@@ -28,7 +28,7 @@
(message: #export Counter
(count! [increment Nat] state self Nat)
- (let [state' (n.+ increment state)]
+ (let [state' (n/+ increment state)]
(T;return [state' state'])))
(context: "Actors"
@@ -74,9 +74,9 @@
output-1 (count! +1 counter)
output-2 (count! +1 counter)
output-3 (count! +1 counter)]
- (wrap (and (n.= +1 output-1)
- (n.= +2 output-2)
- (n.= +3 output-3))))]
+ (wrap (and (n/= +1 output-1)
+ (n/= +2 output-2)
+ (n/= +3 output-3))))]
(assert "Can send messages to actors."
(case result
(#E;Success outcome)
diff --git a/stdlib/test/test/lux/concurrency/atom.lux b/stdlib/test/test/lux/concurrency/atom.lux
index 039546436..c7e2c42b3 100644
--- a/stdlib/test/test/lux/concurrency/atom.lux
+++ b/stdlib/test/test/lux/concurrency/atom.lux
@@ -18,17 +18,17 @@
#let [box (&;atom value)]]
($_ seq
(test "Can obtain the value of an atom."
- (n.= value (io;run (&;read box))))
+ (n/= value (io;run (&;read box))))
(test "Can swap the value of an atom."
(and (io;run (&;compare-and-swap value swap-value box))
- (n.= swap-value (io;run (&;read box)))))
+ (n/= swap-value (io;run (&;read box)))))
(test "Can update the value of an atom."
- (exec (io;run (&;update n.inc box))
- (n.= (n.inc swap-value) (io;run (&;read box)))))
+ (exec (io;run (&;update n/inc box))
+ (n/= (n/inc swap-value) (io;run (&;read box)))))
(test "Can immediately set the value of an atom."
(exec (io;run (&;write set-value box))
- (n.= set-value (io;run (&;read box)))))
+ (n/= set-value (io;run (&;read box)))))
))))
diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux
index 3fb3d847a..5faa404e9 100644
--- a/stdlib/test/test/lux/concurrency/frp.lux
+++ b/stdlib/test/test/lux/concurrency/frp.lux
@@ -43,7 +43,7 @@
false))))
(wrap (do P;Monad<Promise>
- [elems (&;consume (&;filter i.even? (to-channel (list 0 1 2 3 4 5))))]
+ [elems (&;consume (&;filter i/even? (to-channel (list 0 1 2 3 4 5))))]
(assert "Can filter a channel's elements."
(case elems
(^ (list 0 2 4))
@@ -64,9 +64,9 @@
false))))
(wrap (do P;Monad<Promise>
- [output (&;fold (function [base input] (P/wrap (i.+ input base))) 0 (to-channel (list 0 1 2 3 4 5)))]
+ [output (&;fold (function [base input] (P/wrap (i/+ input base))) 0 (to-channel (list 0 1 2 3 4 5)))]
(assert "Can fold over a channel."
- (i.= 15 output))))
+ (i/= 15 output))))
(wrap (do P;Monad<Promise>
[elems (&;consume (&;distinct number;Eq<Int> (to-channel (list 0 0 0 1 2 2 3 3 3 3 4 4 4 5 5))))]
@@ -89,7 +89,7 @@
false))))
(wrap (do P;Monad<Promise>
- [elems (&;consume (:: &;Functor<Channel> map i.inc (to-channel (list 0 1 2 3 4 5))))]
+ [elems (&;consume (:: &;Functor<Channel> map i/inc (to-channel (list 0 1 2 3 4 5))))]
(assert "Functor goes over every element in a channel."
(case elems
(^ (list 1 2 3 4 5 6))
@@ -100,7 +100,7 @@
(wrap (do P;Monad<Promise>
[elems (&;consume (let [(^open) &;Applicative<Channel>]
- (apply (wrap i.inc) (wrap 12345))))]
+ (apply (wrap i/inc) (wrap 12345))))]
(assert "Applicative works over all channel values."
(case elems
(^ (list 12346))
@@ -111,7 +111,7 @@
(wrap (do P;Monad<Promise>
[elems (&;consume (do &;Monad<Channel>
- [f (wrap i.inc)
+ [f (wrap i/inc)
a (wrap 12345)]
(wrap (f a))))]
(assert "Monad works over all channel values."
diff --git a/stdlib/test/test/lux/concurrency/space.lux b/stdlib/test/test/lux/concurrency/space.lux
index d99733958..1e71d03c1 100644
--- a/stdlib/test/test/lux/concurrency/space.lux
+++ b/stdlib/test/test/lux/concurrency/space.lux
@@ -20,4 +20,4 @@
#Pong #Ping)
where
self)]
- (wrap (update@ #hits n.inc state))))
+ (wrap (update@ #hits n/inc state))))
diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux
index 96c486e67..75354b374 100644
--- a/stdlib/test/test/lux/concurrency/stm.lux
+++ b/stdlib/test/test/lux/concurrency/stm.lux
@@ -24,7 +24,7 @@
(&;read _var)))
output3 (&;commit (do &;Monad<STM>
[temp (&;read _var)
- _ (&;update (i.* 3) _var)]
+ _ (&;update (i/* 3) _var)]
(&;read _var)))
?c1+changes' changes
#let [[c1 changes'] (maybe;default [-1 changes] ?c1+changes')]
@@ -34,18 +34,18 @@
Can write STM vars.
Can update STM vars.
Can follow all the changes to STM vars."
- (and (i.= 0 output1)
- (i.= 5 output2)
- (i.= 15 output3)
- (and (i.= 5 c1) (i.= 15 c2))))))
+ (and (i/= 0 output1)
+ (i/= 5 output2)
+ (i/= 15 output3)
+ (and (i/= 5 c1) (i/= 15 c2))))))
(wrap (let [_concurrency-var (&;var 0)]
(do promise;Monad<Promise>
[_ (M;seq @
(map (function [_]
- (M;map @ (function [_] (&;commit (&;update i.inc _concurrency-var)))
- (list;i.range 1 iterations/processes)))
- (list;i.range 1 (nat-to-int promise;concurrency-level))))
+ (M;map @ (function [_] (&;commit (&;update i/inc _concurrency-var)))
+ (list;i/range 1 iterations/processes)))
+ (list;i/range 1 (nat-to-int promise;concurrency-level))))
last-val (&;commit (&;read _concurrency-var))]
(assert "Can modify STM vars concurrently from multiple threads."
- (i.= (i.* iterations/processes (nat-to-int promise;concurrency-level))
+ (i/= (i/* iterations/processes (nat-to-int promise;concurrency-level))
last-val)))))))
diff --git a/stdlib/test/test/lux/control/cont.lux b/stdlib/test/test/lux/control/cont.lux
index 23b3a9bf3..c0fd26ccc 100644
--- a/stdlib/test/test/lux/control/cont.lux
+++ b/stdlib/test/test/lux/control/cont.lux
@@ -19,22 +19,22 @@
elems (r;list +3 r;nat)]
($_ seq
(test "Can run continuations to compute their values."
- (n.= sample (&;run (&/wrap sample))))
+ (n/= sample (&;run (&/wrap sample))))
(test "Can use functor."
- (n.= (n.inc sample) (&;run (&/map n.inc (&/wrap sample)))))
+ (n/= (n/inc sample) (&;run (&/map n/inc (&/wrap sample)))))
(test "Can use applicative."
- (n.= (n.inc sample) (&;run (&/apply (&/wrap n.inc) (&/wrap sample)))))
+ (n/= (n/inc sample) (&;run (&/apply (&/wrap n/inc) (&/wrap sample)))))
(test "Can use monad."
- (n.= (n.inc sample) (&;run (do &;Monad<Cont>
- [func (wrap n.inc)
+ (n/= (n/inc sample) (&;run (do &;Monad<Cont>
+ [func (wrap n/inc)
arg (wrap sample)]
(wrap (func arg))))))
(test "Can use the current-continuation as a escape hatch."
- (n.= (n.* +2 sample)
+ (n/= (n/* +2 sample)
(&;run (do &;Monad<Cont>
[value (&;call/cc
(function [k]
@@ -42,16 +42,16 @@
[temp (k sample)]
## If this code where to run,
## the output would be
- ## (n.* +4 sample)
+ ## (n/* +4 sample)
(k temp))))]
- (wrap (n.* +2 value))))))
+ (wrap (n/* +2 value))))))
(test "Can use the current-continuation to build a time machine."
- (n.= (n.+ +100 sample)
+ (n/= (n/+ +100 sample)
(&;run (do &;Monad<Cont>
[[restart [output idx]] (&;portal [sample +0])]
- (if (n.< +10 idx)
- (restart [(n.+ +10 output) (n.inc idx)])
+ (if (n/< +10 idx)
+ (restart [(n/+ +10 output) (n/inc idx)])
(wrap output))))))
(test "Can use delimited continuations with shifting."
diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux
index 144a08b1f..e7adbe93b 100644
--- a/stdlib/test/test/lux/control/exception.lux
+++ b/stdlib/test/test/lux/control/exception.lux
@@ -46,4 +46,4 @@
(&;catch Another-Exception (function [ex] another-val))
(&;otherwise (function [ex] otherwise-val)))]]
(test "Catch and otherwhise handlers can properly handle the flow of exception-handling."
- (n.= expected actual)))))
+ (n/= expected actual)))))
diff --git a/stdlib/test/test/lux/control/interval.lux b/stdlib/test/test/lux/control/interval.lux
index 589063961..a8d5c3c9e 100644
--- a/stdlib/test/test/lux/control/interval.lux
+++ b/stdlib/test/test/lux/control/interval.lux
@@ -60,13 +60,13 @@
(r;Random (&;Interval Int))
(do r;Monad<Random>
[bottom r;int
- top (|> r;int (r;filter (|>. (i.= bottom) not)))]
+ top (|> r;int (r;filter (|>. (i/= bottom) not)))]
(if (<cmp> top bottom)
(wrap (&;between number;Enum<Int> bottom top))
(wrap (&;between number;Enum<Int> top bottom)))))]
- [gen-inner i.<]
- [gen-outer i.>]
+ [gen-inner i/<]
+ [gen-outer i/>]
)
(def: gen-singleton
@@ -143,7 +143,7 @@
(do @
[[l m r] (|> (r;set number;Hash<Int> +3 r;int)
(:: @ map (|>. S;to-list
- (L;sort i.<)
+ (L;sort i/<)
(case> (^ (list b t1 t2))
[b t1 t2]
@@ -165,7 +165,7 @@
(do @
[[b t1 t2] (|> (r;set number;Hash<Int> +3 r;int)
(:: @ map (|>. S;to-list
- (L;sort i.<)
+ (L;sort i/<)
(case> (^ (list b t1 t2))
[b t1 t2]
@@ -192,7 +192,7 @@
[some-interval gen-interval
[x0 x1 x2 x3] (|> (r;set number;Hash<Int> +4 r;int)
(:: @ map (|>. S;to-list
- (L;sort i.<)
+ (L;sort i/<)
(case> (^ (list x0 x1 x2 x3))
[x0 x1 x2 x3]
diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux
index 0f6b4a4b1..b5ec72dc5 100644
--- a/stdlib/test/test/lux/control/parser.lux
+++ b/stdlib/test/test/lux/control/parser.lux
@@ -106,14 +106,19 @@
(&;many s;nat)))))
(test "Can use either parser."
- (and (match 123
- (&;run (list (code;int 123) (code;int 456) (code;int 789))
- (&;either s;pos-int s;int)))
- (match -123
- (&;run (list (code;int -123) (code;int 456) (code;int 789))
- (&;either s;pos-int s;int)))
- (fails? (&;run (list (code;bool true) (code;int 456) (code;int 789))
- (&;either s;pos-int s;int)))))
+ (let [positive (: (s;Syntax Int)
+ (do &;Monad<Parser>
+ [value s;int
+ _ (&;assert "" (i/> 0 value))]
+ (wrap value)))]
+ (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))
+ (&;either positive s;int)))
+ (fails? (&;run (list (code;bool true) (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))
diff --git a/stdlib/test/test/lux/control/pipe.lux b/stdlib/test/test/lux/control/pipe.lux
index 527db91c3..9147f501e 100644
--- a/stdlib/test/test/lux/control/pipe.lux
+++ b/stdlib/test/test/lux/control/pipe.lux
@@ -15,44 +15,44 @@
($_ seq
(test "Can dismiss previous pipeline results and begin a new line."
(|> 20
- (i.* 3)
- (i.+ 4)
- (new> 0 i.inc)
- (i.= 1)))
+ (i/* 3)
+ (i/+ 4)
+ (new> 0 i/inc)
+ (i/= 1)))
(test "Can give names to piped values within a pipeline's scope."
(|> 5
- (let> X [(i.+ X X)])
- (i.= 10)))
+ (let> X [(i/+ X X)])
+ (i/= 10)))
(test "Can do branching in pipelines."
(and (|> 5
- (cond> [i.even?] [(i.* 2)]
- [i.odd?] [(i.* 3)]
+ (cond> [i/even?] [(i/* 2)]
+ [i/odd?] [(i/* 3)]
[(new> -1)])
- (i.= 15))
+ (i/= 15))
(|> 4
- (cond> [i.even?] [(i.* 2)]
- [i.odd?] [(i.* 3)])
- (i.= 8))
+ (cond> [i/even?] [(i/* 2)]
+ [i/odd?] [(i/* 3)])
+ (i/= 8))
(|> 5
- (cond> [i.even?] [(i.* 2)]
+ (cond> [i/even?] [(i/* 2)]
[(new> -1)])
- (i.= -1))))
+ (i/= -1))))
(test "Can loop within pipelines."
(|> 1
- (loop> [(i.< 10)]
- [i.inc])
- (i.= 10)))
+ (loop> [(i/< 10)]
+ [i/inc])
+ (i/= 10)))
(test "Can use monads within pipelines."
(|> 5
(do> Monad<Identity>
- [(i.* 3)]
- [(i.+ 4)]
- [i.inc])
- (i.= 20)))
+ [(i/* 3)]
+ [(i/+ 4)]
+ [i/inc])
+ (i/= 20)))
(test "Can pattern-match against piped values."
(|> 5
diff --git a/stdlib/test/test/lux/control/reader.lux b/stdlib/test/test/lux/control/reader.lux
index 6a6133aa1..804660a2c 100644
--- a/stdlib/test/test/lux/control/reader.lux
+++ b/stdlib/test/test/lux/control/reader.lux
@@ -11,14 +11,14 @@
(context: "Readers"
($_ seq
- (test "" (i.= 123 (&;run 123 &;ask)))
- (test "" (i.= 246 (&;run 123 (&;local (i.* 2) &;ask))))
- (test "" (i.= 134 (&;run 123 (:: &;Functor<Reader> map i.inc (i.+ 10)))))
- (test "" (i.= 10 (&;run 123 (:: &;Applicative<Reader> wrap 10))))
- (test "" (i.= 30 (&;run 123 (let [(^open "&/") &;Applicative<Reader>]
- (&/apply (&/wrap (i.+ 10)) (&/wrap 20))))))
- (test "" (i.= 30 (&;run 123 (do &;Monad<Reader>
- [f (wrap i.+)
+ (test "" (i/= 123 (&;run 123 &;ask)))
+ (test "" (i/= 246 (&;run 123 (&;local (i/* 2) &;ask))))
+ (test "" (i/= 134 (&;run 123 (:: &;Functor<Reader> map i/inc (i/+ 10)))))
+ (test "" (i/= 10 (&;run 123 (:: &;Applicative<Reader> wrap 10))))
+ (test "" (i/= 30 (&;run 123 (let [(^open "&/") &;Applicative<Reader>]
+ (&/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))))))))
@@ -29,7 +29,7 @@
(|> (do (&;ReaderT io;Monad<IO>)
[a (&;lift (io/wrap 123))
b (wrap 456)]
- (wrap (i.+ a b)))
+ (wrap (i/+ a b)))
(&;run "")
io;run
(case> 579 true
diff --git a/stdlib/test/test/lux/control/state.lux b/stdlib/test/test/lux/control/state.lux
index e2b25d051..070f3425c 100644
--- a/stdlib/test/test/lux/control/state.lux
+++ b/stdlib/test/test/lux/control/state.lux
@@ -16,7 +16,7 @@
(|> computation
(&;run state)
product;right
- (n.= output)))
+ (n/= output)))
(context: "Basics"
(<| (times +100)
@@ -33,16 +33,16 @@
[_ (&;put value)]
&;get)))
(test "Can update the state."
- (with-conditions [state (n.* value state)]
+ (with-conditions [state (n/* value state)]
(do &;Monad<State>
- [_ (&;update (n.* value))]
+ [_ (&;update (n/* value))]
&;get)))
(test "Can use the state."
- (with-conditions [state (n.inc state)]
- (&;use n.inc)))
+ (with-conditions [state (n/inc state)]
+ (&;use n/inc)))
(test "Can use a temporary (local) state."
- (with-conditions [state (n.* value state)]
- (&;local (n.* value)
+ (with-conditions [state (n/* value state)]
+ (&;local (n/* value)
&;get)))
))))
@@ -53,20 +53,20 @@
value r;nat]
($_ seq
(test "Can use functor."
- (with-conditions [state (n.inc state)]
- (:: &;Functor<State> map n.inc &;get)))
+ (with-conditions [state (n/inc state)]
+ (:: &;Functor<State> map n/inc &;get)))
(test "Can use applicative."
(let [(^open "&/") &;Applicative<State>]
(and (with-conditions [state value]
(&/wrap value))
- (with-conditions [state (n.+ value value)]
- (&/apply (&/wrap (n.+ value))
+ (with-conditions [state (n/+ value value)]
+ (&/apply (&/wrap (n/+ value))
(&/wrap value))))))
(test "Can use monad."
- (with-conditions [state (n.+ value value)]
+ (with-conditions [state (n/+ value value)]
(: (&;State Nat Nat)
(do &;Monad<State>
- [f (wrap n.+)
+ [f (wrap n/+)
x (wrap value)
y (wrap value)]
(wrap (f x y))))))
@@ -84,32 +84,32 @@
(do (&;StateT io;Monad<IO>)
[a (&;lift io;Monad<IO> (io/wrap left))
b (wrap right)]
- (wrap (n.+ a b))))
+ (wrap (n/+ a b))))
(&;run' state)
io;run
(case> [state' output']
- (and (n.= state state')
- (n.= (n.+ left right) output')))))
+ (and (n/= state state')
+ (n/= (n/+ left right) output')))))
))))
(context: "Loops"
(<| (times +100)
(do @
- [limit (|> r;nat (:: @ map (n.% +10)))
+ [limit (|> r;nat (:: @ map (n/% +10)))
#let [condition (do &;Monad<State>
[state &;get]
- (wrap (n.< limit state)))]]
+ (wrap (n/< limit state)))]]
($_ seq
(test "'while' will only execute if the condition is true."
- (|> (&;while condition (&;update n.inc))
+ (|> (&;while condition (&;update n/inc))
(&;run +0)
(case> [state' output']
- (n.= limit state'))))
+ (n/= limit state'))))
(test "'do-while' will execute at least once."
- (|> (&;do-while condition (&;update n.inc))
+ (|> (&;do-while condition (&;update n/inc))
(&;run +0)
(case> [state' output']
- (or (n.= limit state')
- (and (n.= +0 limit)
- (n.= +1 state'))))))
+ (or (n/= limit state')
+ (and (n/= +0 limit)
+ (n/= +1 state'))))))
))))
diff --git a/stdlib/test/test/lux/control/writer.lux b/stdlib/test/test/lux/control/writer.lux
index 8c9e1c676..cbabbb6cd 100644
--- a/stdlib/test/test/lux/control/writer.lux
+++ b/stdlib/test/test/lux/control/writer.lux
@@ -13,15 +13,15 @@
(let [(^open "&/") (&;Monad<Writer> text;Monoid<Text>)]
($_ seq
(test "Functor respects Writer."
- (i.= 11 (product;right (&/map i.inc ["" 10]))))
+ (i/= 11 (product;right (&/map i/inc ["" 10]))))
(test "Applicative 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.+)
+ (i/= 30 (product;right (do (&;Monad<Writer> text;Monoid<Text>)
+ [f (wrap i/+)
a (wrap 10)
b (wrap 20)]
(wrap (f a b))))))
@@ -37,7 +37,7 @@
(|> (io;run (do (&;WriterT text;Monoid<Text> io;Monad<IO>)
[a (lift (io/wrap 123))
b (wrap 456)]
- (wrap (i.+ a b))))
+ (wrap (i/+ a b))))
(case> ["" 579] true
_ false)))
))
diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux
index 62bc2ce0b..ac80f9b06 100644
--- a/stdlib/test/test/lux/data/bit.lux
+++ b/stdlib/test/test/lux/data/bit.lux
@@ -11,14 +11,14 @@
(<| (times +100)
(do @
[pattern r;nat
- idx (:: @ map (n.% &;width) r;nat)]
+ idx (:: @ map (n/% &;width) r;nat)]
($_ seq
(test "Clearing and settings bits should alter the count."
- (and (n.< (&;count (&;set idx pattern))
+ (and (n/< (&;count (&;set idx pattern))
(&;count (&;clear idx pattern)))
- (n.<= (&;count pattern)
+ (n/<= (&;count pattern)
(&;count (&;clear idx pattern)))
- (n.>= (&;count pattern)
+ (n/>= (&;count pattern)
(&;count (&;set idx pattern)))))
(test "Can query whether a bit is set."
(and (or (and (&;set? idx pattern)
@@ -31,41 +31,41 @@
(and (not (&;set? idx pattern))
(&;set? idx (&;flip idx pattern))))))
(test "The negation of a bit pattern should have a complementary bit count."
- (n.= &;width
- (n.+ (&;count pattern)
+ (n/= &;width
+ (n/+ (&;count pattern)
(&;count (&;not pattern)))))
(test "Can do simple binary boolean logic."
- (and (n.= +0
+ (and (n/= +0
(&;and pattern
(&;not pattern)))
- (n.= (&;not +0)
+ (n/= (&;not +0)
(&;or pattern
(&;not pattern)))
- (n.= (&;not +0)
+ (n/= (&;not +0)
(&;xor pattern
(&;not pattern)))
- (n.= +0
+ (n/= +0
(&;xor pattern
pattern))))
(test "rotate-left and rotate-right are inverses of one another."
(and (|> pattern
(&;rotate-left idx)
(&;rotate-right idx)
- (n.= pattern))
+ (n/= pattern))
(|> pattern
(&;rotate-right idx)
(&;rotate-left idx)
- (n.= pattern))))
+ (n/= pattern))))
(test "Rotate as many spaces as the bit-pattern's width leaves the pattern unchanged."
(and (|> pattern
(&;rotate-left &;width)
- (n.= pattern))
+ (n/= pattern))
(|> pattern
(&;rotate-right &;width)
- (n.= pattern))))
+ (n/= pattern))))
(test "Shift right respect the sign of ints."
(let [value (nat-to-int pattern)]
- (if (i.< 0 value)
- (i.< 0 (&;signed-shift-right idx value))
- (i.>= 0 (&;signed-shift-right idx value)))))
+ (if (i/< 0 value)
+ (i/< 0 (&;signed-shift-right idx value))
+ (i/>= 0 (&;signed-shift-right idx value)))))
))))
diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux
index 5f679b910..663592c34 100644
--- a/stdlib/test/test/lux/data/coll/array.lux
+++ b/stdlib/test/test/lux/data/coll/array.lux
@@ -13,7 +13,7 @@
(def: bounded-size
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (|>. (n.% +100) (n.+ +1)))))
+ (:: r;Monad<Random> map (|>. (n/% +100) (n/+ +1)))))
(context: "Arrays and their copies"
(<| (times +100)
@@ -27,7 +27,7 @@
(@;new size))]]
($_ seq
(test "Size function must correctly return size of array."
- (n.= size (@;size original)))
+ (n/= size (@;size original)))
(test "Cloning an array should yield and identical array, but not the same one."
(and (:: (@;Eq<Array> number;Eq<Nat>) = original clone)
(not (is original clone))))
@@ -39,7 +39,7 @@
(exec (:: @;Fold<Array> fold
(function [x idx]
(exec (@;write idx x manual-copy)
- (n.inc idx)))
+ (n/inc idx)))
+0
original)
(:: (@;Eq<Array> number;Eq<Nat>) = original manual-copy)))
@@ -53,9 +53,9 @@
(<| (times +100)
(do @
[size bounded-size
- idx (:: @ map (n.% size) r;nat)
+ idx (:: @ map (n/% size) r;nat)
array (|> (r;array size r;nat)
- (r;filter (|>. @;to-list (list;any? n.odd?))))
+ (r;filter (|>. @;to-list (list;any? n/odd?))))
#let [value (maybe;assume (@;read idx array))]]
($_ seq
(test "Shouldn't be able to find a value in an unoccupied cell."
@@ -64,16 +64,16 @@
#;None true))
(test "You should be able to access values put into the array."
(case (@;read idx (@;write idx value array))
- (#;Some value') (n.= value' value)
+ (#;Some value') (n/= value' value)
#;None false))
(test "All cells should be occupied on a full array."
- (and (n.= size (@;occupied array))
- (n.= +0 (@;vacant array))))
+ (and (n/= size (@;occupied array))
+ (n/= +0 (@;vacant array))))
(test "Filtering mutates the array to remove invalid values."
- (exec (@;filter n.even? array)
- (and (n.< size (@;occupied array))
- (n.> +0 (@;vacant array))
- (n.= size (n.+ (@;occupied array)
+ (exec (@;filter n/even? array)
+ (and (n/< size (@;occupied array))
+ (n/> +0 (@;vacant array))
+ (n/= size (n/+ (@;occupied array)
(@;vacant array))))))
))))
@@ -82,16 +82,16 @@
(do @
[size bounded-size
array (|> (r;array size r;nat)
- (r;filter (|>. @;to-list (list;any? n.even?))))]
+ (r;filter (|>. @;to-list (list;any? n/even?))))]
($_ seq
(test "Can find values inside arrays."
- (|> (@;find n.even? array)
+ (|> (@;find n/even? array)
(case> (#;Some _) true
#;None false)))
(test "Can find values inside arrays (with access to indices)."
(|> (@;find+ (function [idx n]
- (and (n.even? n)
- (n.< size idx)))
+ (and (n/even? n)
+ (n/< size idx)))
array)
(case> (#;Some _) true
#;None false)))))))
@@ -109,8 +109,8 @@
(and (= array copy)
(not (is array copy)))))
(test "Functor should go over all available array elements."
- (let [there (map n.inc array)
- back-again (map n.dec there)]
+ (let [there (map n/inc array)
+ back-again (map n/dec there)]
(and (not (= array there))
(= array back-again)))))))))
@@ -126,7 +126,7 @@
fusion (compose left right)]]
($_ seq
(test "Appending two arrays should produce a new one twice as large."
- (n.= (n.+ sizeL sizeR) (@;size fusion)))
+ (n/= (n/+ sizeL sizeR) (@;size fusion)))
(test "First elements of fused array should equal the first array."
(|> (: (Array Nat)
(@;new sizeL))
diff --git a/stdlib/test/test/lux/data/coll/dict.lux b/stdlib/test/test/lux/data/coll/dict.lux
index ddc1ddd2d..4f1b94478 100644
--- a/stdlib/test/test/lux/data/coll/dict.lux
+++ b/stdlib/test/test/lux/data/coll/dict.lux
@@ -15,17 +15,17 @@
(context: "Dictionaries."
(<| (times +100)
(do @
- [#let [capped-nat (:: r;Monad<Random> map (n.% +100) r;nat)]
+ [#let [capped-nat (:: r;Monad<Random> map (n/% +100) r;nat)]
size capped-nat
dict (r;dict number;Hash<Nat> size r;nat capped-nat)
non-key (|> r;nat (r;filter (function [key] (not (&;contains? key dict)))))
test-val (|> r;nat (r;filter (function [val] (not (list;member? number;Eq<Nat> (&;values dict) val)))))]
($_ seq
(test "Size function should correctly represent Dict size."
- (n.= size (&;size dict)))
+ (n/= size (&;size dict)))
(test "Dicts of size 0 should be considered empty."
- (if (n.= +0 size)
+ (if (n/= +0 size)
(&;empty? dict)
(not (&;empty? dict))))
@@ -52,19 +52,19 @@
(test "Should be able to put and then get a value."
(case (&;get non-key (&;put non-key test-val dict))
- (#;Some v) (n.= test-val v)
+ (#;Some v) (n/= test-val v)
_ true))
(test "Should be able to put~ and then get a value."
(case (&;get non-key (&;put~ non-key test-val dict))
- (#;Some v) (n.= test-val v)
+ (#;Some v) (n/= test-val v)
_ true))
(test "Shouldn't be able to put~ an existing key."
- (or (n.= +0 size)
+ (or (n/= +0 size)
(let [first-key (|> dict &;keys list;head maybe;assume)]
(case (&;get first-key (&;put~ first-key test-val dict))
- (#;Some v) (not (n.= test-val v))
+ (#;Some v) (not (n/= test-val v))
_ true))))
(test "Removing a key should make it's value inaccessible."
@@ -74,10 +74,10 @@
(test "Should be possible to update values via their keys."
(let [base (&;put non-key test-val dict)
- updt (&;update non-key n.inc base)]
+ updt (&;update non-key n/inc base)]
(case [(&;get non-key base) (&;get non-key updt)]
[(#;Some x) (#;Some y)]
- (n.= (n.inc x) y)
+ (n/= (n/inc x) y)
_
false)))
@@ -85,8 +85,8 @@
(test "Additions and removals to a Dict should affect its size."
(let [plus (&;put non-key test-val dict)
base (&;remove non-key plus)]
- (and (n.= (n.inc (&;size dict)) (&;size plus))
- (n.= (n.dec (&;size plus)) (&;size base)))))
+ (and (n/= (n/inc (&;size dict)) (&;size plus))
+ (n/= (n/dec (&;size plus)) (&;size base)))))
(test "A Dict should equal itself & going to<->from lists shouldn't change that."
(let [(^open) (&;Eq<Dict> number;Eq<Nat>)]
@@ -99,30 +99,30 @@
(test "If you merge, and the second dict has overlapping keys, it should overwrite yours."
(let [dict' (|> dict &;entries
- (list/map (function [[k v]] [k (n.inc v)]))
+ (list/map (function [[k v]] [k (n/inc v)]))
(&;from-list number;Hash<Nat>))
(^open) (&;Eq<Dict> number;Eq<Nat>)]
(= dict' (&;merge dict' dict))))
(test "Can merge values in such a way that they become combined."
- (list;every? (function [[x x*2]] (n.= (n.* +2 x) x*2))
+ (list;every? (function [[x x*2]] (n/= (n/* +2 x) x*2))
(list;zip2 (&;values dict)
- (&;values (&;merge-with n.+ dict dict)))))
+ (&;values (&;merge-with n/+ dict dict)))))
(test "Should be able to select subset of keys from dict."
(|> dict
(&;put non-key test-val)
(&;select (list non-key))
&;size
- (n.= +1)))
+ (n/= +1)))
(test "Should be able to re-bind existing values to different keys."
- (or (n.= +0 size)
+ (or (n/= +0 size)
(let [first-key (|> dict &;keys list;head maybe;assume)
rebound (&;re-bind first-key non-key dict)]
- (and (n.= (&;size dict) (&;size rebound))
+ (and (n/= (&;size dict) (&;size rebound))
(&;contains? non-key rebound)
(not (&;contains? first-key rebound))
- (n.= (maybe;assume (&;get first-key dict))
+ (n/= (maybe;assume (&;get first-key dict))
(maybe;assume (&;get non-key rebound)))))))
))))
diff --git a/stdlib/test/test/lux/data/coll/list.lux b/stdlib/test/test/lux/data/coll/list.lux
index c1e69445f..942a2aa56 100644
--- a/stdlib/test/test/lux/data/coll/list.lux
+++ b/stdlib/test/test/lux/data/coll/list.lux
@@ -15,13 +15,13 @@
(def: bounded-size
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (|>. (n.% +100) (n.+ +10)))))
+ (:: r;Monad<Random> map (|>. (n/% +100) (n/+ +10)))))
(context: "Lists: Part 1"
(<| (times +100)
(do @
[size bounded-size
- idx (:: @ map (n.% size) r;nat)
+ idx (:: @ map (n/% size) r;nat)
sample (r;list size r;nat)
other-size bounded-size
other-sample (r;list other-size r;nat)
@@ -30,13 +30,13 @@
(^open "&/") &;Functor<List>]]
($_ seq
(test "The size function should correctly portray the size of the list."
- (n.= size (&;size sample)))
+ (n/= size (&;size sample)))
(test "The repeat function should produce as many elements as asked of it."
- (n.= size (&;size (&;repeat size []))))
+ (n/= size (&;size (&;repeat size []))))
(test "Reversing a list does not change it's size."
- (n.= (&;size sample)
+ (n/= (&;size sample)
(&;size (&;reverse sample))))
(test "Reversing a list twice results in the original list."
@@ -44,19 +44,19 @@
(&;reverse (&;reverse sample))))
(test "Filtering by a predicate and its complement should result in a number of elements equal to the original list."
- (and (n.= (&;size sample)
- (n.+ (&;size (&;filter n.even? sample))
- (&;size (&;filter (bool;complement n.even?) sample))))
- (let [[plus minus] (&;partition n.even? sample)]
- (n.= (&;size sample)
- (n.+ (&;size plus)
+ (and (n/= (&;size sample)
+ (n/+ (&;size (&;filter n/even? sample))
+ (&;size (&;filter (bool;complement n/even?) sample))))
+ (let [[plus minus] (&;partition n/even? sample)]
+ (n/= (&;size sample)
+ (n/+ (&;size plus)
(&;size minus))))))
(test "If every element in a list satisfies a predicate, there can't be any that satisfy its complement."
- (if (&;every? n.even? sample)
- (and (not (&;any? (bool;complement n.even?) sample))
- (&;empty? (&;filter (bool;complement n.even?) sample)))
- (&;any? (bool;complement n.even?) sample)))
+ (if (&;every? n/even? sample)
+ (and (not (&;any? (bool;complement n/even?) sample))
+ (&;empty? (&;filter (bool;complement n/even?) sample)))
+ (&;any? (bool;complement n/even?) sample)))
(test "Any element of the list can be considered its member."
(let [elem (maybe;assume (&;nth idx sample))]
@@ -67,7 +67,7 @@
(<| (times +100)
(do @
[size bounded-size
- idx (:: @ map (n.% size) r;nat)
+ idx (:: @ map (n/% size) r;nat)
sample (r;list size r;nat)
other-size bounded-size
other-sample (r;list other-size r;nat)
@@ -90,15 +90,15 @@
(test "Functor should go over every element of the list."
(let [(^open) &;Functor<List>
- there (map n.inc sample)
- back-again (map n.dec there)]
+ there (map n/inc sample)
+ back-again (map n/dec there)]
(and (not (= sample there))
(= sample back-again))))
(test "Splitting a list into chunks and re-appending them should yield the original list."
(let [(^open) &;Monoid<List>
[left right] (&;split idx sample)
- [left' right'] (&;split-with n.even? sample)]
+ [left' right'] (&;split-with n/even? sample)]
(and (= sample
(compose left right))
(= sample
@@ -107,28 +107,28 @@
(compose (&;take idx sample)
(&;drop idx sample)))
(= sample
- (compose (&;take-while n.even? sample)
- (&;drop-while n.even? sample)))
+ (compose (&;take-while n/even? sample)
+ (&;drop-while n/even? sample)))
)))
(test "Segmenting the list in pairs should yield as many elements as N/2."
- (n.= (n./ +2 size)
+ (n/= (n// +2 size)
(&;size (&;as-pairs sample))))
(test "Sorting a list shouldn't change it's size."
- (n.= (&;size sample)
- (&;size (&;sort n.< sample))))
+ (n/= (&;size sample)
+ (&;size (&;sort n/< sample))))
(test "Sorting a list with one order should yield the reverse of sorting it with the opposite order."
- (= (&;sort n.< sample)
- (&;reverse (&;sort n.> sample))))
+ (= (&;sort n/< sample)
+ (&;reverse (&;sort n/> sample))))
))))
(context: "Lists: Part 3"
(<| (times +100)
(do @
[size bounded-size
- idx (:: @ map (n.% size) r;nat)
+ idx (:: @ map (n/% size) r;nat)
sample (r;list size r;nat)
other-size bounded-size
other-sample (r;list other-size r;nat)
@@ -137,8 +137,8 @@
(^open "&/") &;Functor<List>]]
($_ seq
(test "If you zip 2 lists, the result's size will be that of the smaller list."
- (n.= (&;size (&;zip2 sample other-sample))
- (n.min (&;size sample) (&;size other-sample))))
+ (n/= (&;size (&;zip2 sample other-sample))
+ (n/min (&;size sample) (&;size other-sample))))
(test "I can pair-up elements of a list in order."
(let [(^open) &;Functor<List>
@@ -150,21 +150,21 @@
(test "You can generate indices for any size, and they will be in ascending order."
(let [(^open) &;Functor<List>
indices (&;indices size)]
- (and (n.= size (&;size indices))
+ (and (n/= size (&;size indices))
(= indices
- (&;sort n.< indices))
- (&;every? (n.= (n.dec size))
- (&;zip2-with n.+
+ (&;sort n/< indices))
+ (&;every? (n/= (n/dec size))
+ (&;zip2-with n/+
indices
- (&;sort n.> indices)))
+ (&;sort n/> indices)))
)))
(test "The 'interpose' function places a value between every member of a list."
(let [(^open) &;Functor<List>
sample+ (&;interpose separator sample)]
- (and (n.= (|> size (n.* +2) n.dec)
+ (and (n/= (|> size (n/* +2) n/dec)
(&;size sample+))
- (|> sample+ &;as-pairs (map product;right) (&;every? (n.= separator))))))
+ (|> sample+ &;as-pairs (map product;right) (&;every? (n/= separator))))))
(test "List append is a monoid."
(let [(^open) &;Monoid<List>]
@@ -177,8 +177,8 @@
(test "Applicative allows you to create singleton lists, and apply lists of functions to lists of values."
(let [(^open) &;Applicative<List>]
(and (= (list separator) (wrap separator))
- (= (map n.inc sample)
- (apply (wrap n.inc) sample)))))
+ (= (map n/inc sample)
+ (apply (wrap n/inc) sample)))))
(test "List concatenation is a monad."
(let [(^open) &;Monad<List>
@@ -187,19 +187,19 @@
(join (list sample other-sample)))))
(test "You can find any value that satisfies some criterium, if such values exist in the list."
- (case (&;find n.even? sample)
+ (case (&;find n/even? sample)
(#;Some found)
- (and (n.even? found)
- (&;any? n.even? sample)
- (not (&;every? (bool;complement n.even?) sample)))
+ (and (n/even? found)
+ (&;any? n/even? sample)
+ (not (&;every? (bool;complement n/even?) sample)))
#;None
- (and (not (&;any? n.even? sample))
- (&;every? (bool;complement n.even?) sample))))
+ (and (not (&;any? n/even? sample))
+ (&;every? (bool;complement n/even?) sample))))
(test "You can iteratively construct a list, generating values until you're done."
- (= (&;n.range +0 (n.dec size))
- (&;iterate (function [n] (if (n.< size n) (#;Some (n.inc n)) #;None))
+ (= (&;n/range +0 (n/dec size))
+ (&;iterate (function [n] (if (n/< size n) (#;Some (n/inc n)) #;None))
+0)))
(test "Can enumerate all elements in a list."
@@ -217,7 +217,7 @@
(|> (io;run (do (&;ListT io;Monad<IO>)
[a (lift (io/wrap 123))
b (wrap 456)]
- (wrap (i.+ a b))))
+ (wrap (i/+ a b))))
(case> (^ (list 579)) true
_ false)))
))
diff --git a/stdlib/test/test/lux/data/coll/ordered/dict.lux b/stdlib/test/test/lux/data/coll/ordered/dict.lux
index 49e4f2678..93774eb99 100644
--- a/stdlib/test/test/lux/data/coll/ordered/dict.lux
+++ b/stdlib/test/test/lux/data/coll/ordered/dict.lux
@@ -15,7 +15,7 @@
(context: "Dict"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (n.% +100)))
+ [size (|> r;nat (:: @ map (n/% +100)))
keys (r;set number;Hash<Nat> size r;nat)
values (r;set number;Hash<Nat> size r;nat)
extra-key (|> r;nat (r;filter (|>. (s;member? keys) not)))
@@ -24,13 +24,13 @@
(s;to-list values))
sample (&;from-list number;Order<Nat> pairs)
sorted-pairs (list;sort (function [[left _] [right _]]
- (n.< left right))
+ (n/< left right))
pairs)
sorted-values (L/map product;right sorted-pairs)
(^open "&/") (&;Eq<Dict> number;Eq<Nat>)]]
($_ seq
(test "Can query the size of a dictionary."
- (n.= size (&;size sample)))
+ (n/= size (&;size sample)))
(test "Can query value for minimum key."
(case [(&;min sample) (list;head sorted-values)]
@@ -38,7 +38,7 @@
true
[(#;Some reference) (#;Some sample)]
- (n.= reference sample)
+ (n/= reference sample)
_
false))
@@ -49,7 +49,7 @@
true
[(#;Some reference) (#;Some sample)]
- (n.= reference sample)
+ (n/= reference sample)
_
false))
@@ -62,8 +62,8 @@
(test "Order is preserved."
(let [(^open "L/") (list;Eq<List> (: (Eq [Nat Nat])
(function [[kr vr] [ks vs]]
- (and (n.= kr ks)
- (n.= vr vs)))))]
+ (and (n/= kr ks)
+ (n/= vr vs)))))]
(L/= (&;entries sample)
sorted-pairs)))
@@ -80,7 +80,7 @@
(case [(&;get extra-key sample')
(&;get extra-key sample'')]
[(#;Some found) #;None]
- (n.= extra-value found)
+ (n/= extra-value found)
_
false)))
diff --git a/stdlib/test/test/lux/data/coll/ordered/set.lux b/stdlib/test/test/lux/data/coll/ordered/set.lux
index f01db29a5..87c720597 100644
--- a/stdlib/test/test/lux/data/coll/ordered/set.lux
+++ b/stdlib/test/test/lux/data/coll/ordered/set.lux
@@ -13,7 +13,7 @@
(def: gen-nat
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (n.% +100))))
+ (:: r;Monad<Random> map (n/% +100))))
(context: "Sets"
(<| (times +100)
@@ -25,12 +25,12 @@
#let [(^open "&/") &;Eq<Set>
setL (&;from-list number;Order<Nat> listL)
setR (&;from-list number;Order<Nat> listR)
- sortedL (list;sort n.< listL)
+ sortedL (list;sort n/< listL)
minL (list;head sortedL)
maxL (list;last sortedL)]]
($_ seq
(test "I can query the size of a set."
- (n.= sizeL (&;size setL)))
+ (n/= sizeL (&;size setL)))
(test "Can query minimum value."
(case [(&;min setL) minL]
@@ -38,7 +38,7 @@
true
[(#;Some reference) (#;Some sample)]
- (n.= reference sample)
+ (n/= reference sample)
_
false))
@@ -49,7 +49,7 @@
true
[(#;Some reference) (#;Some sample)]
- (n.= reference sample)
+ (n/= reference sample)
_
false))
@@ -63,7 +63,7 @@
(let [listL (&;to-list setL)
(^open "L/") (list;Eq<List> number;Eq<Nat>)]
(L/= listL
- (list;sort n.< listL))))
+ (list;sort n/< listL))))
(test "Every set is a sub-set of the union of itself with another."
(let [setLR (&;union setL setR)]
diff --git a/stdlib/test/test/lux/data/coll/priority-queue.lux b/stdlib/test/test/lux/data/coll/priority-queue.lux
index 7a3d5a659..f1f7999a0 100644
--- a/stdlib/test/test/lux/data/coll/priority-queue.lux
+++ b/stdlib/test/test/lux/data/coll/priority-queue.lux
@@ -22,19 +22,19 @@
(context: "Queues"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (n.% +100)))
+ [size (|> r;nat (:: @ map (n/% +100)))
sample (gen-queue size)
non-member-priority r;nat
non-member (|> r;nat (r;filter (|>. (&;member? number;Eq<Nat> sample) not)))]
($_ seq
(test "I can query the size of a queue (and empty queues have size 0)."
- (n.= size (&;size sample)))
+ (n/= size (&;size sample)))
(test "Enqueueing and dequeing affects the size of queues."
- (and (n.= (n.inc size)
+ (and (n/= (n/inc size)
(&;size (&;push non-member-priority non-member sample)))
- (or (n.= +0 (&;size sample))
- (n.= (n.dec size)
+ (or (n/= +0 (&;size sample))
+ (n/= (n/dec size)
(&;size (&;pop sample))))))
(test "I can query whether an element belongs to a queue."
@@ -42,7 +42,7 @@
(&;member? number;Eq<Nat>
(&;push non-member-priority non-member sample)
non-member))
- (or (n.= +0 (&;size sample))
+ (or (n/= +0 (&;size sample))
(and (&;member? number;Eq<Nat>
sample
(maybe;assume (&;peek sample)))
diff --git a/stdlib/test/test/lux/data/coll/queue.lux b/stdlib/test/test/lux/data/coll/queue.lux
index bf04cd90c..1a6f884cf 100644
--- a/stdlib/test/test/lux/data/coll/queue.lux
+++ b/stdlib/test/test/lux/data/coll/queue.lux
@@ -10,21 +10,21 @@
(context: "Queues"
(<| (times +100)
(do @
- [size (:: @ map (n.% +100) r;nat)
+ [size (:: @ map (n/% +100) r;nat)
sample (r;queue size r;nat)
non-member (|> r;nat
(r;filter (. not (&;member? number;Eq<Nat> sample))))]
($_ seq
(test "I can query the size of a queue (and empty queues have size 0)."
- (if (n.= +0 size)
+ (if (n/= +0 size)
(&;empty? sample)
- (n.= size (&;size sample))))
+ (n/= size (&;size sample))))
(test "Enqueueing and dequeing affects the size of queues."
- (and (n.= (n.inc size) (&;size (&;push non-member sample)))
+ (and (n/= (n/inc size) (&;size (&;push non-member sample)))
(or (&;empty? sample)
- (n.= (n.dec size) (&;size (&;pop sample))))
- (n.= size (&;size (&;pop (&;push non-member sample))))))
+ (n/= (n/dec size) (&;size (&;pop sample))))
+ (n/= size (&;size (&;pop (&;push non-member sample))))))
(test "Transforming to/from list can't change the queue."
(let [(^open "&/") (&;Eq<Queue> number;Eq<Nat>)]
diff --git a/stdlib/test/test/lux/data/coll/sequence.lux b/stdlib/test/test/lux/data/coll/sequence.lux
index f52cb3abf..234456d1e 100644
--- a/stdlib/test/test/lux/data/coll/sequence.lux
+++ b/stdlib/test/test/lux/data/coll/sequence.lux
@@ -14,8 +14,8 @@
(context: "Sequences"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +1))))
- idx (|> r;nat (:: @ map (n.% size)))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +1))))
+ idx (|> r;nat (:: @ map (n/% size)))
sample (r;sequence size r;nat)
other-sample (r;sequence size r;nat)
non-member (|> r;nat (r;filter (. not (&;member? number;Eq<Nat> sample))))
@@ -26,13 +26,13 @@
($_ seq
(test "Can query size of sequence."
(if (&;empty? sample)
- (and (n.= +0 size)
- (n.= +0 (&;size sample)))
- (n.= size (&;size sample))))
+ (and (n/= +0 size)
+ (n/= +0 (&;size sample)))
+ (n/= size (&;size sample))))
(test "Can add and remove elements to sequences."
- (and (n.= (n.inc size) (&;size (&;add non-member sample)))
- (n.= (n.dec size) (&;size (&;pop sample)))))
+ (and (n/= (n/inc size) (&;size (&;add non-member sample)))
+ (n/= (n/dec size) (&;size (&;pop sample)))))
(test "Can put and get elements into sequences."
(|> sample
@@ -43,9 +43,9 @@
(test "Can update elements of sequences."
(|> sample
- (&;put idx non-member) (&;update idx n.inc)
+ (&;put idx non-member) (&;update idx n/inc)
(&;nth idx) maybe;assume
- (n.= (n.inc non-member))))
+ (n/= (n/inc non-member))))
(test "Can safely transform to/from lists."
(|> sample &;to-list &;from-list (&/= sample)))
@@ -55,18 +55,18 @@
(&;member? number;Eq<Nat> (&;add non-member sample) non-member)))
(test "Can fold over elements of sequence."
- (n.= (List/fold n.+ +0 (&;to-list sample))
- (&/fold n.+ +0 sample)))
+ (n/= (List/fold n/+ +0 (&;to-list sample))
+ (&/fold n/+ +0 sample)))
(test "Functor goes over every element."
- (let [there (&/map n.inc sample)
- back-again (&/map n.dec there)]
+ (let [there (&/map n/inc sample)
+ back-again (&/map n/dec there)]
(and (not (&/= sample there))
(&/= sample back-again))))
(test "Applicative allows you to create singleton sequences, and apply sequences of functions to sequences of values."
(and (&/= (&;sequence non-member) (&/wrap non-member))
- (&/= (&/map n.inc sample) (&/apply (&/wrap n.inc) sample))))
+ (&/= (&/map n/inc sample) (&/apply (&/wrap n/inc) sample))))
(test "Sequence concatenation is a monad."
(&/= (&/compose sample other-sample)
diff --git a/stdlib/test/test/lux/data/coll/set.lux b/stdlib/test/test/lux/data/coll/set.lux
index c13f60f25..48b0905fa 100644
--- a/stdlib/test/test/lux/data/coll/set.lux
+++ b/stdlib/test/test/lux/data/coll/set.lux
@@ -11,7 +11,7 @@
(def: gen-nat
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (n.% +100))))
+ (:: r;Monad<Random> map (n/% +100))))
(context: "Sets"
(<| (times +100)
@@ -25,8 +25,8 @@
#let [(^open "&/") &;Eq<Set>]]
($_ seq
(test "I can query the size of a set."
- (and (n.= sizeL (&;size setL))
- (n.= sizeR (&;size setR))))
+ (and (n/= sizeL (&;size setL))
+ (n/= sizeR (&;size setR))))
(test "Converting sets to/from lists can't change their values."
(|> setL
diff --git a/stdlib/test/test/lux/data/coll/stack.lux b/stdlib/test/test/lux/data/coll/stack.lux
index 069a9258b..d9e365d61 100644
--- a/stdlib/test/test/lux/data/coll/stack.lux
+++ b/stdlib/test/test/lux/data/coll/stack.lux
@@ -12,7 +12,7 @@
(def: gen-nat
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (n.% +100))))
+ (:: r;Monad<Random> map (n/% +100))))
(context: "Stacks"
(<| (times +100)
@@ -22,7 +22,7 @@
new-top gen-nat]
($_ seq
(test "Can query the size of a stack."
- (n.= size (&;size sample)))
+ (n/= size (&;size sample)))
(test "Can peek inside non-empty stacks."
(case (&;peek sample)
@@ -32,14 +32,14 @@
(test "Popping empty stacks doesn't change anything.
But, if they're non-empty, the top of the stack is removed."
(let [sample' (&;pop sample)]
- (or (n.= (&;size sample) (n.inc (&;size sample')))
+ (or (n/= (&;size sample) (n/inc (&;size sample')))
(and (&;empty? sample) (&;empty? sample')))
))
(test "Pushing onto a stack always increases it by 1, adding a new value at the top."
(and (is sample
(&;pop (&;push new-top sample)))
- (n.= (n.inc (&;size sample)) (&;size (&;push new-top sample)))
+ (n/= (n/inc (&;size sample)) (&;size (&;push new-top sample)))
(|> (&;push new-top sample) &;peek maybe;assume
(is new-top))))
))))
diff --git a/stdlib/test/test/lux/data/coll/stream.lux b/stdlib/test/test/lux/data/coll/stream.lux
index fdb7965b2..8c3db3ac4 100644
--- a/stdlib/test/test/lux/data/coll/stream.lux
+++ b/stdlib/test/test/lux/data/coll/stream.lux
@@ -16,60 +16,60 @@
(context: "Streams"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +2))))
- offset (|> r;nat (:: @ map (n.% +100)))
- factor (|> r;nat (:: @ map (|>. (n.% +100) (n.max +2))))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +2))))
+ offset (|> r;nat (:: @ map (n/% +100)))
+ factor (|> r;nat (:: @ map (|>. (n/% +100) (n/max +2))))
elem r;nat
cycle-seed (r;list size r;nat)
- cycle-sample-idx (|> r;nat (:: @ map (n.% +1000)))
+ cycle-sample-idx (|> r;nat (:: @ map (n/% +1000)))
#let [(^open "List/") (list;Eq<List> number;Eq<Nat>)
- sample0 (&;iterate n.inc +0)
- sample1 (&;iterate n.inc offset)]]
+ sample0 (&;iterate n/inc +0)
+ sample1 (&;iterate n/inc offset)]]
($_ seq
(test "Can move along a stream and take slices off it."
- (and (and (List/= (list;n.range +0 (n.dec size))
+ (and (and (List/= (list;n/range +0 (n/dec size))
(&;take size sample0))
- (List/= (list;n.range offset (n.dec (n.+ offset size)))
+ (List/= (list;n/range offset (n/dec (n/+ offset size)))
(&;take size (&;drop offset sample0)))
(let [[drops takes...] (&;split size sample0)]
- (and (List/= (list;n.range +0 (n.dec size))
+ (and (List/= (list;n/range +0 (n/dec size))
drops)
- (List/= (list;n.range size (n.dec (n.* +2 size)))
+ (List/= (list;n/range size (n/dec (n/* +2 size)))
(&;take size takes...)))))
- (and (List/= (list;n.range +0 (n.dec size))
- (&;take-while (n.< size) sample0))
- (List/= (list;n.range offset (n.dec (n.+ offset size)))
- (&;take-while (n.< (n.+ offset size))
- (&;drop-while (n.< offset) sample0)))
- (let [[drops takes...] (&;split-while (n.< size) sample0)]
- (and (List/= (list;n.range +0 (n.dec size))
+ (and (List/= (list;n/range +0 (n/dec size))
+ (&;take-while (n/< size) sample0))
+ (List/= (list;n/range offset (n/dec (n/+ offset size)))
+ (&;take-while (n/< (n/+ offset size))
+ (&;drop-while (n/< offset) sample0)))
+ (let [[drops takes...] (&;split-while (n/< size) sample0)]
+ (and (List/= (list;n/range +0 (n/dec size))
drops)
- (List/= (list;n.range size (n.dec (n.* +2 size)))
- (&;take-while (n.< (n.* +2 size)) takes...)))))
+ (List/= (list;n/range size (n/dec (n/* +2 size)))
+ (&;take-while (n/< (n/* +2 size)) takes...)))))
))
(test "Can repeat any element and infinite number of times."
- (n.= elem (&;nth offset (&;repeat elem))))
+ (n/= elem (&;nth offset (&;repeat elem))))
(test "Can obtain the head & tail of a stream."
- (and (n.= offset (&;head sample1))
- (List/= (list;n.range (n.inc offset) (n.+ offset size))
+ (and (n/= offset (&;head sample1))
+ (List/= (list;n/range (n/inc offset) (n/+ offset size))
(&;take size (&;tail sample1)))))
(test "Can filter streams."
- (and (n.= (n.* +2 offset)
+ (and (n/= (n/* +2 offset)
(&;nth offset
- (&;filter n.even? sample0)))
- (let [[evens odds] (&;partition n.even? (&;iterate n.inc +0))]
- (and (n.= (n.* +2 offset)
+ (&;filter n/even? sample0)))
+ (let [[evens odds] (&;partition n/even? (&;iterate n/inc +0))]
+ (and (n/= (n/* +2 offset)
(&;nth offset evens))
- (n.= (n.inc (n.* +2 offset))
+ (n/= (n/inc (n/* +2 offset))
(&;nth offset odds))))))
(test "Functor goes over 'all' elements in a stream."
(let [(^open "&/") &;Functor<Stream>
- there (&/map (n.* factor) sample0)
- back-again (&/map (n./ factor) there)]
+ there (&/map (n/* factor) sample0)
+ back-again (&/map (n// factor) there)]
(and (not (List/= (&;take size sample0)
(&;take size there)))
(List/= (&;take size sample0)
@@ -77,26 +77,26 @@
(test "CoMonad produces a value for every element in a stream."
(let [(^open "&/") &;Functor<Stream>]
- (List/= (&;take size (&/map (n.* factor) sample1))
+ (List/= (&;take size (&/map (n/* factor) sample1))
(&;take size
(be &;CoMonad<Stream>
[inputs sample1]
- (n.* factor (&;head inputs)))))))
+ (n/* factor (&;head inputs)))))))
(test "'unfold' generalizes 'iterate'."
(let [(^open "&/") &;Functor<Stream>
(^open "List/") (list;Eq<List> text;Eq<Text>)]
(List/= (&;take size
- (&/map Nat/encode (&;iterate n.inc offset)))
+ (&/map Nat/encode (&;iterate n/inc offset)))
(&;take size
- (&;unfold (function [n] [(n.inc n) (Nat/encode n)])
+ (&;unfold (function [n] [(n/inc n) (Nat/encode n)])
offset)))))
(test "Can cycle over the same elements as an infinite stream."
(|> (&;cycle cycle-seed)
maybe;assume
(&;nth cycle-sample-idx)
- (n.= (|> cycle-seed
- (list;nth (n.% size cycle-sample-idx))
+ (n/= (|> cycle-seed
+ (list;nth (n/% size cycle-sample-idx))
maybe;assume))))
))))
diff --git a/stdlib/test/test/lux/data/coll/tree/rose.lux b/stdlib/test/test/lux/data/coll/tree/rose.lux
index 7a69fbf0e..09f3f13f6 100644
--- a/stdlib/test/test/lux/data/coll/tree/rose.lux
+++ b/stdlib/test/test/lux/data/coll/tree/rose.lux
@@ -18,11 +18,11 @@
(r;either (:: r;Monad<Random> map (|>. &;leaf [+1]) r;nat)
(do r;Monad<Random>
[value r;nat
- num-children (|> r;nat (:: @ map (n.% +3)))
+ num-children (|> r;nat (:: @ map (n/% +3)))
children' (r;list num-children gen-tree)
- #let [size' (L/fold n.+ +0 (L/map product;left children'))
+ #let [size' (L/fold n/+ +0 (L/map product;left children'))
children (L/map product;right children')]]
- (wrap [(n.inc size')
+ (wrap [(n/inc size')
(&;branch value children)]))
))))
@@ -38,7 +38,7 @@
(&/= sample sample))
(test "Can flatten a tree to get all the nodes as a flat tree."
- (n.= size
+ (n/= size
(list;size (&;flatten sample))))
(test "Can fold trees."
diff --git a/stdlib/test/test/lux/data/coll/tree/zipper.lux b/stdlib/test/test/lux/data/coll/tree/zipper.lux
index 691510885..f184090db 100644
--- a/stdlib/test/test/lux/data/coll/tree/zipper.lux
+++ b/stdlib/test/test/lux/data/coll/tree/zipper.lux
@@ -18,7 +18,7 @@
(r;rec (function [gen-tree]
(do r;Monad<Random>
## Each branch can have, at most, 1 child.
- [size (|> r;nat (:: @ map (n.% +2)))]
+ [size (|> r;nat (:: @ map (n/% +2)))]
(r;seq r;nat
(r;list size gen-tree))))))
@@ -95,7 +95,7 @@
#;None true))))))
(test "Can set and update the value of a node."
- (|> sample &;zip (&;set new-val) &;value (n.= new-val)))
+ (|> sample &;zip (&;set new-val) &;value (n/= new-val)))
(test "Zipper traversal follows the outline of the tree depth-first."
(L/= (rose;flatten sample)
diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux
index ba0772349..6a97b0e72 100644
--- a/stdlib/test/test/lux/data/color.lux
+++ b/stdlib/test/test/lux/data/color.lux
@@ -23,10 +23,10 @@
(-> @;Color @;Color Frac)
(let [[fr fg fb] (@;unpack from)
[tr tg tb] (@;unpack to)]
- (math;root2 ($_ f.+
- (|> (scale tr) (f.- (scale fr)) square)
- (|> (scale tg) (f.- (scale fg)) square)
- (|> (scale tb) (f.- (scale fb)) square)))))
+ (math;root2 ($_ 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)
@@ -48,33 +48,33 @@
(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 equality."
(:: @;Eq<Color> = any any))
(test "Can convert to/from HSL."
(|> any @;to-hsl @;from-hsl
(distance any)
- (f.<= error-margin)))
+ (f/<= error-margin)))
(test "Can convert to/from HSB."
(|> any @;to-hsb @;from-hsb
(distance any)
- (f.<= error-margin)))
+ (f/<= error-margin)))
(test "Can convert to/from CMYK."
(|> any @;to-cmyk @;from-cmyk
(distance any)
- (f.<= error-margin)))
+ (f/<= error-margin)))
(test "Can interpolate between 2 colors."
- (and (f.<= (distance colorful black)
+ (and (f/<= (distance colorful black)
(distance (@;darker ratio colorful) black))
- (f.<= (distance colorful white)
+ (f/<= (distance colorful white)
(distance (@;brighter ratio colorful) white))))
(test "Can calculate complement."
(let [~any (@;complement any)
@@ -82,17 +82,17 @@
(and (not (@/= any ~any))
(@/= any (@;complement ~any)))))
(test "Can saturate color."
- (f.> (saturation mediocre)
+ (f/> (saturation mediocre)
(saturation (@;saturate ratio mediocre))))
(test "Can de-saturate color."
- (f.< (saturation mediocre)
+ (f/< (saturation mediocre)
(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))
+ (f/- (luminance mediocre))
frac/abs
- (f.<= error-margin)))))
+ (f/<= error-margin)))))
))))
diff --git a/stdlib/test/test/lux/data/error.lux b/stdlib/test/test/lux/data/error.lux
index a72a45403..9eeec4fbc 100644
--- a/stdlib/test/test/lux/data/error.lux
+++ b/stdlib/test/test/lux/data/error.lux
@@ -12,31 +12,31 @@
($_ seq
(test "Functor correctly handles both cases."
(and (|> (: (&;Error Int) (#&;Success 10))
- (&/map i.inc)
+ (&/map i/inc)
(case> (#&;Success 11) true _ false))
(|> (: (&;Error Int) (#&;Error "YOLO"))
- (&/map i.inc)
+ (&/map i/inc)
(case> (#&;Error "YOLO") true _ false))
))
(test "Applicative correctly handles both cases."
(and (|> (&/wrap 20)
(case> (#&;Success 20) true _ false))
- (|> (&/apply (&/wrap i.inc) (&/wrap 10))
+ (|> (&/apply (&/wrap i/inc) (&/wrap 10))
(case> (#&;Success 11) true _ false))
- (|> (&/apply (&/wrap i.inc) (#&;Error "YOLO"))
+ (|> (&/apply (&/wrap i/inc) (#&;Error "YOLO"))
(case> (#&;Error "YOLO") true _ false))))
(test "Monad correctly handles both cases."
(and (|> (do &;Monad<Error>
- [f (wrap i.+)
+ [f (wrap i/+)
a (wrap 10)
b (wrap 20)]
(wrap (f a b)))
(case> (#&;Success 30) true _ false))
(|> (do &;Monad<Error>
- [f (wrap i.+)
+ [f (wrap i/+)
a (#&;Error "YOLO")
b (wrap 20)]
(wrap (f a b)))
@@ -51,6 +51,6 @@
(|> (io;run (do (&;ErrorT io;Monad<IO>)
[a (lift (io/wrap 123))
b (wrap 456)]
- (wrap (i.+ a b))))
+ (wrap (i/+ a b))))
(case> (#&;Success 579) true
_ false)))))
diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux
index 167e80555..c8ba05f1d 100644
--- a/stdlib/test/test/lux/data/format/json.lux
+++ b/stdlib/test/test/lux/data/format/json.lux
@@ -11,7 +11,7 @@
["e" error]
[bool]
[maybe]
- [number "i/" Number<Int>]
+ [number]
(format ["@" json])
(coll [sequence #+ sequence]
["d" dict]
@@ -37,11 +37,11 @@
(r;Random @;JSON)
(r;rec (function [gen-json]
(do r;Monad<Random>
- [size (:: @ map (n.% +2) r;nat)]
+ [size (:: @ map (n/% +2) r;nat)]
($_ r;alt
(:: @ wrap [])
r;bool
- (|> r;frac (:: @ map (f.* 1_000_000.0)))
+ (|> r;frac (:: @ map (f/* 1_000_000.0)))
(r;text size)
(r;sequence size gen-json)
(r;dict text;Hash<Text> size (r;text size) gen-json)
@@ -108,7 +108,7 @@
(def: gen-record
(r;Random Record)
(do r;Monad<Random>
- [size (:: @ map (n.% +2) r;nat)]
+ [size (:: @ map (n/% +2) r;nat)]
($_ r;seq
## (:: @ wrap [])
## r;bool
@@ -139,12 +139,12 @@
(:: text;Eq<Text> = left' right')
[(#Case2 left') (#Case2 right')]
- (f.= left' right')
+ (f/= left' right')
_
false))]
(and ## (:: bool;Eq<Bool> = (get@ #bool recL) (get@ #bool recR))
- ## (f.= (get@ #frac recL) (get@ #frac recR))
+ ## (f/= (get@ #frac recL) (get@ #frac recR))
## (:: text;Eq<Text> = (get@ #text recL) (get@ #text recR))
## (:: (maybe;Eq<Maybe> number;Eq<Frac>) = (get@ #maybe recL) (get@ #maybe recR))
## (:: (list;Eq<List> number;Eq<Frac>) = (get@ #list recL) (get@ #list recR))
@@ -152,7 +152,7 @@
## (let [[tL0 tL1 tL2] (get@ #tuple recL)
## [tR0 tR1 tR2] (get@ #tuple recR)]
## (and (:: bool;Eq<Bool> = tL0 tR0)
- ## (f.= tL1 tR1)
+ ## (f/= tL1 tR1)
## (:: text;Eq<Text> = tL2 tR2)))
## (:: (d;Eq<Dict> number;Eq<Frac>) = (get@ #dict recL) (get@ #dict recR))
## (:: Eq<Recursive> = (get@ #recursive recL) (get@ #recursive recR))
@@ -163,7 +163,8 @@
))))
(context: "Polytypism"
- (<| (times +100)
+ (<| (seed +10473881104006775240)
+ ## (times +100)
(do @
[sample gen-record
#let [(^open "@/") Eq<Record>
diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux
index 817c7159e..bcbf63f9e 100644
--- a/stdlib/test/test/lux/data/format/xml.lux
+++ b/stdlib/test/test/lux/data/format/xml.lux
@@ -25,12 +25,12 @@
(def: xml-char^
(r;Random Nat)
(do r;Monad<Random>
- [idx (|> r;nat (:: @ map (n.% (text;size char-range))))]
+ [idx (|> r;nat (:: @ map (n/% (text;size char-range))))]
(wrap (maybe;assume (text;nth idx char-range)))))
(def: (size^ bottom top)
(-> Nat Nat (r;Random Nat))
- (let [constraint (|>. (n.% top) (n.max bottom))]
+ (let [constraint (|>. (n/% top) (n/max bottom))]
(r/map constraint r;nat)))
(def: (xml-text^ bottom top)
@@ -78,7 +78,7 @@
(<| (times +100)
(do @
[text (xml-text^ +1 +10)
- num-children (|> r;nat (:: @ map (n.% +5)))
+ num-children (|> r;nat (:: @ map (n/% +5)))
children (r;list num-children (xml-text^ +1 +10))
tag xml-identifier^
attr xml-identifier^
diff --git a/stdlib/test/test/lux/data/ident.lux b/stdlib/test/test/lux/data/ident.lux
index 24b06c7c7..f03cfa9a2 100644
--- a/stdlib/test/test/lux/data/ident.lux
+++ b/stdlib/test/test/lux/data/ident.lux
@@ -17,14 +17,14 @@
(<| (times +100)
(do @
[## First Ident
- sizeM1 (|> r;nat (:: @ map (n.% +100)))
- sizeN1 (|> r;nat (:: @ map (|>. (n.% +100) (n.max +1))))
+ sizeM1 (|> r;nat (:: @ map (n/% +100)))
+ sizeN1 (|> r;nat (:: @ map (|>. (n/% +100) (n/max +1))))
module1 (gen-part sizeM1)
name1 (gen-part sizeN1)
#let [ident1 [module1 name1]]
## Second Ident
- sizeM2 (|> r;nat (:: @ map (n.% +100)))
- sizeN2 (|> r;nat (:: @ map (|>. (n.% +100) (n.max +1))))
+ sizeM2 (|> r;nat (:: @ map (n/% +100)))
+ sizeN2 (|> r;nat (:: @ map (|>. (n/% +100) (n/max +1))))
module2 (gen-part sizeM2)
name2 (gen-part sizeN2)
#let [ident2 [module2 name2]]
diff --git a/stdlib/test/test/lux/data/lazy.lux b/stdlib/test/test/lux/data/lazy.lux
index ce0e6a79a..52e850d80 100644
--- a/stdlib/test/test/lux/data/lazy.lux
+++ b/stdlib/test/test/lux/data/lazy.lux
@@ -11,11 +11,11 @@
(do @
[left r;nat
right r;nat
- #let [lazy (&;freeze (n.* left right))
- expected (n.* left right)]]
+ #let [lazy (&;freeze (n/* left right))
+ expected (n/* left right)]]
($_ seq
(test "Lazying does not alter the expected value."
- (n.= expected
+ (n/= expected
(&;thaw lazy)))
(test "Lazy values only evaluate once."
(and (not (is expected
@@ -31,27 +31,27 @@
($_ seq
(test "Functor map."
(|> (&;freeze sample)
- (:: &;Functor<Lazy> map n.inc)
+ (:: &;Functor<Lazy> map n/inc)
&;thaw
- (n.= (n.inc sample))))
+ (n/= (n/inc sample))))
(test "Applicative wrap."
(|> sample
(:: &;Applicative<Lazy> wrap)
&;thaw
- (n.= sample)))
+ (n/= sample)))
(test "Applicative apply."
(let [(^open "&/") &;Applicative<Lazy>]
- (|> (&/apply (&/wrap n.inc) (&/wrap sample))
+ (|> (&/apply (&/wrap n/inc) (&/wrap sample))
&;thaw
- (n.= (n.inc sample)))))
+ (n/= (n/inc sample)))))
(test "Monad."
(|> (do &;Monad<Lazy>
- [f (wrap n.inc)
+ [f (wrap n/inc)
a (wrap sample)]
(wrap (f a)))
&;thaw
- (n.= (n.inc sample))))
+ (n/= (n/inc sample))))
))))
diff --git a/stdlib/test/test/lux/data/maybe.lux b/stdlib/test/test/lux/data/maybe.lux
index fed83c4b9..16d5c850d 100644
--- a/stdlib/test/test/lux/data/maybe.lux
+++ b/stdlib/test/test/lux/data/maybe.lux
@@ -51,6 +51,6 @@
(|> (io;run (do (&;MaybeT io;Monad<IO>)
[a (lift (io/wrap 123))
b (wrap 456)]
- (wrap (i.+ a b))))
+ (wrap (i/+ a b))))
(case> (#;Some 579) true
_ false)))))
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux
index c5ff11668..2fe050740 100644
--- a/stdlib/test/test/lux/data/number.lux
+++ b/stdlib/test/test/lux/data/number.lux
@@ -84,7 +84,7 @@
["Nat" r;nat Number<Nat> Order<Nat> Interval<Nat> (function [_] true)]
["Int" r;int Number<Int> Order<Int> Interval<Int> (function [_] true)]
## Both min and max values will be positive (thus, greater than zero)
- ["Frac" r;frac Number<Frac> Order<Frac> Interval<Frac> (f.> 0.0)]
+ ["Frac" r;frac Number<Frac> Order<Frac> Interval<Frac> (f/> 0.0)]
["Deg" r;deg Number<Deg> Order<Deg> Interval<Deg> (function [_] true)]
)
@@ -101,22 +101,22 @@
(= x (compose x identity))
(= identity (compose identity identity)))))))]
- ["Nat/Add" r;nat Number<Nat> Order<Nat> Add@Monoid<Nat> (n.% +1000) (function [_] true)]
- ["Nat/Mul" r;nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n.% +1000) (function [_] true)]
- ["Nat/Min" r;nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n.% +1000) (function [_] true)]
- ["Nat/Max" r;nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n.% +1000) (function [_] true)]
- ["Int/Add" r;int Number<Int> Order<Int> Add@Monoid<Int> (i.% 1000) (function [_] true)]
- ["Int/Mul" r;int Number<Int> Order<Int> Mul@Monoid<Int> (i.% 1000) (function [_] true)]
- ["Int/Min" r;int Number<Int> Order<Int> Min@Monoid<Int> (i.% 1000) (function [_] true)]
- ["Int/Max" r;int Number<Int> Order<Int> Max@Monoid<Int> (i.% 1000) (function [_] true)]
- ["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)]
- ["Deg/Add" r;deg Number<Deg> Order<Deg> Add@Monoid<Deg> (d.% .125) (function [_] true)]
- ## ["Deg/Mul" r;deg Number<Deg> Order<Deg> Mul@Monoid<Deg> (d.% .125) (function [_] true)]
- ["Deg/Min" r;deg Number<Deg> Order<Deg> Min@Monoid<Deg> (d.% .125) (function [_] true)]
- ["Deg/Max" r;deg Number<Deg> Order<Deg> Max@Monoid<Deg> (d.% .125) (function [_] true)]
+ ["Nat/Add" r;nat Number<Nat> Order<Nat> Add@Monoid<Nat> (n/% +1000) (function [_] true)]
+ ["Nat/Mul" r;nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n/% +1000) (function [_] true)]
+ ["Nat/Min" r;nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n/% +1000) (function [_] true)]
+ ["Nat/Max" r;nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n/% +1000) (function [_] true)]
+ ["Int/Add" r;int Number<Int> Order<Int> Add@Monoid<Int> (i/% 1000) (function [_] true)]
+ ["Int/Mul" r;int Number<Int> Order<Int> Mul@Monoid<Int> (i/% 1000) (function [_] true)]
+ ["Int/Min" r;int Number<Int> Order<Int> Min@Monoid<Int> (i/% 1000) (function [_] true)]
+ ["Int/Max" r;int Number<Int> Order<Int> Max@Monoid<Int> (i/% 1000) (function [_] true)]
+ ["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)]
+ ["Deg/Add" r;deg Number<Deg> Order<Deg> Add@Monoid<Deg> (d/% .125) (function [_] true)]
+ ## ["Deg/Mul" r;deg Number<Deg> Order<Deg> Mul@Monoid<Deg> (d/% .125) (function [_] true)]
+ ["Deg/Min" r;deg Number<Deg> Order<Deg> Min@Monoid<Deg> (d/% .125) (function [_] true)]
+ ["Deg/Max" r;deg Number<Deg> Order<Deg> Max@Monoid<Deg> (d/% .125) (function [_] true)]
)
(do-template [<category> <rand-gen> <Eq> <Codec>]
@@ -159,7 +159,7 @@
(<| (times +100)
(do @
[raw r;frac
- factor (|> r;nat (:: @ map (|>. (n.% +1000) (n.max +1))))
- #let [sample (|> factor nat-to-int int-to-frac (f.* raw))]]
+ factor (|> r;nat (:: @ map (|>. (n/% +1000) (n/max +1))))
+ #let [sample (|> factor nat-to-int int-to-frac (f/* raw))]]
(test "Can convert frac values to/from their bit patterns."
- (|> sample frac-to-bits bits-to-frac (f.= sample))))))
+ (|> sample frac-to-bits bits-to-frac (f/= sample))))))
diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux
index 410fa1cb9..c7b0691df 100644
--- a/stdlib/test/test/lux/data/number/complex.lux
+++ b/stdlib/test/test/lux/data/number/complex.lux
@@ -3,12 +3,9 @@
(lux [io]
(control [monad #+ do Monad]
pipe)
- (data [text "Text/" Monoid<Text>]
- text/format
- [bool "b/" Eq<Bool>]
- [number "f/" Number<Frac>]
+ (data [number "frac/" Number<Frac>]
["&" number/complex]
- (coll [list "List/" Fold<List> Functor<List>])
+ (coll [list "list/" Functor<List>])
[product])
[math]
["r" math/random])
@@ -18,19 +15,19 @@
(def: (within? margin standard value)
(-> Frac &;Complex &;Complex Bool)
- (let [real-dist (f/abs (f.- (get@ #&;real standard)
- (get@ #&;real value)))
- imgn-dist (f/abs (f.- (get@ #&;imaginary standard)
- (get@ #&;imaginary value)))]
- (and (f.< margin real-dist)
- (f.< margin imgn-dist))))
+ (let [real-dist (frac/abs (f/- (get@ #&;real standard)
+ (get@ #&;real value)))
+ imgn-dist (frac/abs (f/- (get@ #&;imaginary standard)
+ (get@ #&;imaginary value)))]
+ (and (f/< margin real-dist)
+ (f/< margin imgn-dist))))
(def: gen-dim
(r;Random Frac)
(do r;Monad<Random>
- [factor (|> r;nat (:: @ map (|>. (n.% +1000) (n.max +1))))
- measure (|> r;frac (r;filter (f.> 0.0)))]
- (wrap (f.* (|> factor nat-to-int int-to-frac)
+ [factor (|> r;nat (:: @ map (|>. (n/% +1000) (n/max +1))))
+ measure (|> r;frac (r;filter (f/> 0.0)))]
+ (wrap (f/* (|> factor nat-to-int int-to-frac)
measure))))
(def: gen-complex
@@ -48,8 +45,8 @@
($_ seq
(test "Can build and tear apart complex numbers"
(let [r+i (&;complex real imaginary)]
- (and (f.= real (get@ #&;real r+i))
- (f.= imaginary (get@ #&;imaginary r+i)))))
+ (and (f/= real (get@ #&;real r+i))
+ (f/= imaginary (get@ #&;imaginary r+i)))))
(test "If either the real part or the imaginary part is NaN, the composite is NaN."
(and (&;not-a-number? (&;complex number;not-a-number imaginary))
@@ -65,18 +62,18 @@
(test "Absolute value of complex >= absolute value of any of the parts."
(let [r+i (&;complex real imaginary)
abs (get@ #&;real (&;c.abs r+i))]
- (and (f.>= (f/abs real) abs)
- (f.>= (f/abs imaginary) abs))))
+ (and (f/>= (frac/abs real) abs)
+ (f/>= (frac/abs imaginary) abs))))
(test "The absolute value of a complex number involving a NaN on either dimension, results in a NaN value."
(and (number;not-a-number? (get@ #&;real (&;c.abs (&;complex number;not-a-number imaginary))))
(number;not-a-number? (get@ #&;real (&;c.abs (&;complex real number;not-a-number))))))
(test "The absolute value of a complex number involving an infinity on either dimension, results in an infinite value."
- (and (f.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;positive-infinity imaginary))))
- (f.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;positive-infinity))))
- (f.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;negative-infinity imaginary))))
- (f.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;negative-infinity))))))
+ (and (f/= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;positive-infinity imaginary))))
+ (f/= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;positive-infinity))))
+ (f/= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;negative-infinity imaginary))))
+ (f/= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;negative-infinity))))))
))))
(context: "Addidion, substraction, multiplication and division"
@@ -89,17 +86,17 @@
(test "Adding 2 complex numbers is the same as adding their parts."
(let [z (&;c.+ y x)]
(and (&;c.= z
- (&;complex (f.+ (get@ #&;real y)
+ (&;complex (f/+ (get@ #&;real y)
(get@ #&;real x))
- (f.+ (get@ #&;imaginary y)
+ (f/+ (get@ #&;imaginary y)
(get@ #&;imaginary x)))))))
(test "Subtracting 2 complex numbers is the same as adding their parts."
(let [z (&;c.- y x)]
(and (&;c.= z
- (&;complex (f.- (get@ #&;real y)
+ (&;complex (f/- (get@ #&;real y)
(get@ #&;real x))
- (f.- (get@ #&;imaginary y)
+ (f/- (get@ #&;imaginary y)
(get@ #&;imaginary x)))))))
(test "Subtraction is the inverse of addition."
@@ -130,9 +127,9 @@
($_ seq
(test "Conjugate has same real part as original, and opposite of imaginary part."
(let [cx (&;conjugate x)]
- (and (f.= (get@ #&;real x)
+ (and (f/= (get@ #&;real x)
(get@ #&;real cx))
- (f.= (f/negate (get@ #&;imaginary x))
+ (f/= (frac/negate (get@ #&;imaginary x))
(get@ #&;imaginary cx)))))
(test "The reciprocal functions is its own inverse."
@@ -143,9 +140,9 @@
(test "Absolute value of signum is always root2(2), 1 or 0."
(let [signum-abs (|> x &;c.signum &;c.abs (get@ #&;real))]
- (or (f.= 0.0 signum-abs)
- (f.= 1.0 signum-abs)
- (f.= (math;root2 2.0) signum-abs))))
+ (or (f/= 0.0 signum-abs)
+ (f/= 1.0 signum-abs)
+ (f/= (math;root2 2.0) signum-abs))))
(test "Negation is its own inverse."
(let [there (&;c.negate x)
@@ -154,7 +151,7 @@
(&;c.= back-again x))))
(test "Negation doesn't change the absolute value."
- (f.= (get@ #&;real (&;c.abs x))
+ (f/= (get@ #&;real (&;c.abs x))
(get@ #&;real (&;c.abs (&;c.negate x)))))
))))
@@ -188,9 +185,9 @@
(<| (times +100)
(do @
[sample gen-complex
- degree (|> r;nat (:: @ map (|>. (n.max +1) (n.% +5))))]
+ degree (|> r;nat (:: @ map (|>. (n/max +1) (n/% +5))))]
(test "Can calculate the N roots for any complex number."
(|> sample
(&;nth-roots degree)
- (List/map (&;pow' (|> degree nat-to-int int-to-frac)))
+ (list/map (&;pow' (|> degree nat-to-int int-to-frac)))
(list;every? (within? margin-of-error sample)))))))
diff --git a/stdlib/test/test/lux/data/number/ratio.lux b/stdlib/test/test/lux/data/number/ratio.lux
index 3e65ddd13..0cd1f58ea 100644
--- a/stdlib/test/test/lux/data/number/ratio.lux
+++ b/stdlib/test/test/lux/data/number/ratio.lux
@@ -14,15 +14,15 @@
(def: gen-part
(r;Random Nat)
- (|> r;nat (:: r;Monad<Random> map (|>. (n.% +1000) (n.max +1)))))
+ (|> r;nat (:: r;Monad<Random> map (|>. (n/% +1000) (n/max +1)))))
(def: gen-ratio
(r;Random &;Ratio)
(do r;Monad<Random>
[numerator gen-part
denominator (|> gen-part
- (r;filter (|>. (n.= +0) not))
- (r;filter (. not (n.= numerator))))]
+ (r;filter (|>. (n/= +0) not))
+ (r;filter (. not (n/= numerator))))]
(wrap (&;ratio numerator denominator))))
(context: "Normalization"
@@ -66,7 +66,7 @@
(let [remainder (&;q.% min max)
multiple (&;q.- remainder max)
factor (&;q./ min multiple)]
- (and (|> factor (get@ #&;denominator) (n.= +1))
+ (and (|> factor (get@ #&;denominator) (n/= +1))
(|> factor (&;q.* min) (&;q.+ remainder) (&;q.= max)))))
))))
diff --git a/stdlib/test/test/lux/data/product.lux b/stdlib/test/test/lux/data/product.lux
index de424fe9a..11f394af6 100644
--- a/stdlib/test/test/lux/data/product.lux
+++ b/stdlib/test/test/lux/data/product.lux
@@ -10,11 +10,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))))
+ (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 90c679ad1..b5e4db76e 100644
--- a/stdlib/test/test/lux/data/sum.lux
+++ b/stdlib/test/test/lux/data/sum.lux
@@ -28,10 +28,10 @@
(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)
+ (and (i/= 10 (either (function [_] 10)
(function [_] 20)
(: (| Text Text) (+0 ""))))
- (i.= 20 (either (function [_] 10)
+ (i/= 20 (either (function [_] 10)
(function [_] 20)
(: (| Text Text) (+1 ""))))))
)))
diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux
index 10f51708e..a0747866e 100644
--- a/stdlib/test/test/lux/data/text.lux
+++ b/stdlib/test/test/lux/data/text.lux
@@ -13,22 +13,22 @@
(context: "Size"
(<| (times +100)
(do @
- [size (:: @ map (n.% +100) r;nat)
+ [size (:: @ map (n/% +100) r;nat)
sample (r;text size)]
- (test "" (or (and (n.= +0 size)
+ (test "" (or (and (n/= +0 size)
(&;empty? sample))
- (n.= size (&;size sample)))))))
+ (n/= size (&;size sample)))))))
(def: bounded-size
(r;Random Nat)
(|> r;nat
- (:: r;Monad<Random> map (|>. (n.% +20) (n.+ +1)))))
+ (:: r;Monad<Random> map (|>. (n/% +20) (n/+ +1)))))
(context: "Locations"
(<| (times +100)
(do @
[size bounded-size
- idx (:: @ map (n.% size) r;nat)
+ idx (:: @ map (n/% size) r;nat)
sample (r;text size)]
(test "" (|> sample
(&;nth idx)
@@ -40,11 +40,11 @@
(&;last-index-of' char idx sample)]
[(#;Some io) (#;Some lio)
(#;Some io') (#;Some lio')]])
- (and (n.<= idx io)
- (n.>= idx lio)
+ (and (n/<= idx io)
+ (n/>= idx lio)
- (n.= idx io')
- (n.>= idx lio')
+ (n/= idx io')
+ (n/>= idx lio')
(&;contains? char sample))
@@ -104,7 +104,7 @@
#let [## The wider unicode charset includes control characters that
## can make text replacement work improperly.
## Because of that, I restrict the charset.
- normal-char-gen (|> r;nat (:: @ map (|>. (n.% +128) (n.max +1))))]
+ normal-char-gen (|> r;nat (:: @ map (|>. (n/% +128) (n/max +1))))]
sep1 (r;text' normal-char-gen +1)
sep2 (r;text' normal-char-gen +1)
#let [part-gen (|> (r;text' normal-char-gen sizeP)
@@ -115,7 +115,7 @@
(^open "&/") &;Eq<Text>]]
($_ seq
(test "Can split text through a separator."
- (n.= (list;size parts)
+ (n/= (list;size parts)
(list;size (&;split-all-with sep1 sample1))))
(test "Can replace occurrences of a piece of text inside a larger text."
diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux
index 81422af4b..bdac87f89 100644
--- a/stdlib/test/test/lux/data/text/lexer.lux
+++ b/stdlib/test/test/lux/data/text/lexer.lux
@@ -72,7 +72,7 @@
(context: "Literals"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
sample (r;text size)
non-sample (|> (r;text size)
(r;filter (|>. (text/= sample) not)))]
diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux
index 070457799..97f13f2df 100644
--- a/stdlib/test/test/lux/host.jvm.lux
+++ b/stdlib/test/test/lux/host.jvm.lux
@@ -67,9 +67,9 @@
(with-expansions
[<int-convs> (do-template [<to> <from> <message>]
[(test <message>
- (or (|> sample <to> <from> (i.= sample))
+ (or (|> sample <to> <from> (i/= sample))
(let [capped-sample (|> sample <to> <from>)]
- (|> capped-sample <to> <from> (i.= capped-sample)))))]
+ (|> capped-sample <to> <from> (i/= capped-sample)))))]
[&;l2b &;b2l "Can succesfully convert to/from byte."]
[&;l2s &;s2l "Can succesfully convert to/from short."]
@@ -112,14 +112,14 @@
(context: "Arrays"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +1))))
- idx (|> r;nat (:: @ map (n.% size)))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +1))))
+ idx (|> r;nat (:: @ map (n/% size)))
value r;int]
($_ seq
(test "Can create arrays of some length."
- (n.= size (&;array-length (&;array Long size))))
+ (n/= size (&;array-length (&;array Long size))))
(test "Can set and get array values."
(let [arr (&;array Long size)]
(exec (&;array-write idx value arr)
- (i.= value (&;array-read idx arr)))))))))
+ (i/= value (&;array-read idx arr)))))))))
diff --git a/stdlib/test/test/lux/io.lux b/stdlib/test/test/lux/io.lux
index 7a76a2ac9..30eda396f 100644
--- a/stdlib/test/test/lux/io.lux
+++ b/stdlib/test/test/lux/io.lux
@@ -10,12 +10,12 @@
(context: "I/O"
($_ seq
(test "" (Text/= "YOLO" (&;run (&;io "YOLO"))))
- (test "" (i.= 11 (&;run (:: &;Functor<IO> map i.inc (&;io 10)))))
- (test "" (i.= 10 (&;run (:: &;Applicative<IO> wrap 10))))
- (test "" (i.= 30 (&;run (let [(^open "&/") &;Applicative<IO>]
- (&/apply (&/wrap (i.+ 10)) (&/wrap 20))))))
- (test "" (i.= 30 (&;run (do &;Monad<IO>
- [f (wrap i.+)
+ (test "" (i/= 11 (&;run (:: &;Functor<IO> map i/inc (&;io 10)))))
+ (test "" (i/= 10 (&;run (:: &;Applicative<IO> wrap 10))))
+ (test "" (i/= 30 (&;run (let [(^open "&/") &;Applicative<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/lang/syntax.lux b/stdlib/test/test/lux/lang/syntax.lux
index 4a7c16807..e93ef3f83 100644
--- a/stdlib/test/test/lux/lang/syntax.lux
+++ b/stdlib/test/test/lux/lang/syntax.lux
@@ -31,7 +31,7 @@
(r;filter (function [sample]
(not (text;contains? (text;from-code sample)
invalid-range)))))]
- size (|> r;nat (:: @ map (|>. (n.% +20) (n.max +1))))]
+ size (|> r;nat (:: @ map (|>. (n/% +20) (n/max +1))))]
(r;text' char-gen size)))
(def: ident^
@@ -50,7 +50,7 @@
textual^ (: (r;Random Code)
($_ r;either
(do r;Monad<Random>
- [size (|> r;nat (r/map (n.% +20)))]
+ [size (|> r;nat (r/map (n/% +20)))]
(|> (r;text size) (r/map (|>. #;Text [default-cursor]))))
(|> ident^ (r/map (|>. #;Symbol [default-cursor])))
(|> ident^ (r/map (|>. #;Tag [default-cursor])))))
@@ -61,14 +61,14 @@
(r;rec
(function [code^]
(let [multi^ (do r;Monad<Random>
- [size (|> r;nat (r/map (n.% +3)))]
+ [size (|> r;nat (r/map (n/% +3)))]
(r;list size code^))
composite^ (: (r;Random Code)
($_ r;either
(|> multi^ (r/map (|>. #;Form [default-cursor])))
(|> multi^ (r/map (|>. #;Tuple [default-cursor])))
(do r;Monad<Random>
- [size (|> r;nat (r/map (n.% +3)))]
+ [size (|> r;nat (r/map (n/% +3)))]
(|> (r;list size (r;seq code^ code^))
(r/map (|>. #;Record [default-cursor]))))))]
(r;either simple^
@@ -113,10 +113,10 @@
(context: "Frac special syntax."
(<| (times +100)
(do @
- [numerator (|> r;nat (:: @ map (|>. (n.% +100) nat-to-frac)))
- denominator (|> r;nat (:: @ map (|>. (n.% +100) (n.max +1) nat-to-frac)))
+ [numerator (|> r;nat (:: @ map (|>. (n/% +100) nat-to-frac)))
+ denominator (|> r;nat (:: @ map (|>. (n/% +100) (n/max +1) nat-to-frac)))
signed? r;bool
- #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
@@ -125,7 +125,7 @@
"/"
(%i (frac-to-int denominator)))])
(#e;Success [_ [_ (#;Frac actual)]])
- (f.= expected actual)
+ (f/= expected actual)
_
false)
@@ -134,13 +134,13 @@
(context: "Nat special syntax."
(<| (times +100)
(do @
- [expected (|> r;nat (:: @ map (n.% +1_000)))]
+ [expected (|> r;nat (:: @ map (n/% +1_000)))]
(test "Can parse nat char syntax."
(case (&;read "" (dict;new text;Hash<Text>)
[default-cursor +0
(format "#" (%t (text;from-code expected)) "")])
(#e;Success [_ [_ (#;Nat actual)]])
- (n.= expected actual)
+ (n/= expected actual)
_
false)
@@ -150,11 +150,11 @@
(r;Random Text)
(let [char-gen (|> r;nat (r;filter (function [value]
(not (or (text;space? value)
- (n.= (char "#") value)
- (n.= (char "(") value)
- (n.= (char ")") value))))))]
+ (n/= (char "#") value)
+ (n/= (char "(") value)
+ (n/= (char ")") value))))))]
(do r;Monad<Random>
- [size (|> r;nat (r/map (n.% +20)))]
+ [size (|> r;nat (r/map (n/% +20)))]
(r;text' char-gen size))))
(def: comment^
@@ -169,15 +169,16 @@
(wrap (format "#( " comment " )#")))))))
(context: "Multi-line text & comments."
- (<| (times +100)
+ (<| (seed +6749851812188286456)
+ ## (times +100)
(do @
[#let [char-gen (|> r;nat (r;filter (function [value]
(not (or (text;space? value)
- (n.= (char "\"") value))))))]
+ (n/= (char "\"") value))))))]
x char-gen
y char-gen
z char-gen
- offset-size (|> r;nat (r/map (|>. (n.% +10) (n.max +1))))
+ offset-size (|> r;nat (r/map (|>. (n/% +10) (n/max +1))))
#let [offset (text;join-with "" (list;repeat offset-size " "))]
sample code^
comment comment^
@@ -203,7 +204,7 @@
(text;from-code y) "\n"
(text;from-code z))]
(case (&;read "" (dict;new text;Hash<Text>)
- [(|> default-cursor (update@ #;column (n.+ (n.dec offset-size))))
+ [(|> default-cursor (update@ #;column (n/+ (n/dec offset-size))))
+0
(format "\"" good-input "\"")])
(#e;Error error)
diff --git a/stdlib/test/test/lux/lang/type.lux b/stdlib/test/test/lux/lang/type.lux
index a592df312..81a0a3cd9 100644
--- a/stdlib/test/test/lux/lang/type.lux
+++ b/stdlib/test/test/lux/lang/type.lux
@@ -16,7 +16,7 @@
(def: gen-name
(r;Random Text)
(do r;Monad<Random>
- [size (|> r;nat (:: @ map (n.% +10)))]
+ [size (|> r;nat (:: @ map (n/% +10)))]
(r;text size)))
(def: gen-ident
@@ -83,7 +83,7 @@
(context: "Type construction [structs]"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (n.% +3)))
+ [size (|> r;nat (:: @ map (n/% +3)))
members (|> gen-type
(r;filter (function [type]
(case type
@@ -114,7 +114,7 @@
(context: "Type construction [parameterized]"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (n.% +3)))
+ [size (|> r;nat (:: @ map (n/% +3)))
members (M;seq @ (list;repeat size gen-type))
extra (|> gen-type
(r;filter (function [type]
@@ -134,13 +134,13 @@
(test "Can build and tear-down application types."
(let [[tfunc tparams] (|> extra (&;application members) &;flatten-application)]
- (n.= (list;size members) (list;size tparams))))
+ (n/= (list;size members) (list;size tparams))))
))))
(context: "Type construction [higher order]"
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (n.% +3)))
+ [size (|> r;nat (:: @ map (n/% +3)))
extra (|> gen-type
(r;filter (function [type]
(case type
@@ -154,7 +154,7 @@
[<quant-tests> (do-template [<desc> <ctor> <dtor>]
[(test (format "Can build and tear-down " <desc> " types.")
(let [[flat-size flat-body] (|> extra (<ctor> size) <dtor>)]
- (and (n.= size flat-size)
+ (and (n/= size flat-size)
(&/= extra flat-body))))]
["universally-quantified" &;univ-q &;flatten-univ-q]
diff --git a/stdlib/test/test/lux/lang/type/check.lux b/stdlib/test/test/lux/lang/type/check.lux
index 32f7e832b..06c5c3d6b 100644
--- a/stdlib/test/test/lux/lang/type/check.lux
+++ b/stdlib/test/test/lux/lang/type/check.lux
@@ -19,7 +19,7 @@
(def: gen-name
(r;Random Text)
(do r;Monad<Random>
- [size (|> r;nat (:: @ map (n.% +10)))]
+ [size (|> r;nat (:: @ map (n/% +10)))]
(r;text size)))
(def: gen-ident
@@ -206,7 +206,7 @@
(context: "Rings of type variables."
(<| (times +100)
(do @
- [num-connections (|> r;nat (:: @ map (n.% +100)))
+ [num-connections (|> r;nat (:: @ map (n/% +100)))
boundT (|> gen-type (r;filter (|>. (case> (#;Var _) false _ true))))
pick-pcg (r;seq r;nat r;nat)]
($_ seq
@@ -218,10 +218,10 @@
tailR (@;ring tail-id)]
(@;assert ""
(let [same-rings? (:: set;Eq<Set> = headR tailR)
- expected-size? (n.= (n.inc num-connections) (set;size headR))
+ expected-size? (n/= (n/inc num-connections) (set;size headR))
same-vars? (|> (set;to-list headR)
- (list;sort n.<)
- (:: (list;Eq<List> number;Eq<Nat>) = (list;sort n.< (#;Cons head-id ids))))]
+ (list;sort n/<)
+ (:: (list;Eq<List> number;Eq<Nat>) = (list;sort n/< (#;Cons head-id ids))))]
(and same-rings?
expected-size?
same-vars?))))))
@@ -254,7 +254,7 @@
headRR-post (@;ring head-idR)]
(@;assert ""
(let [same-rings? (:: set;Eq<Set> = headRL-post headRR-post)
- expected-size? (n.= (n.* +2 (n.inc num-connections))
+ expected-size? (n/= (n/* +2 (n/inc num-connections))
(set;size headRL-post))
union? (:: set;Eq<Set> = headRL-post (set;union headRL-pre headRR-pre))]
(and same-rings?
diff --git a/stdlib/test/test/lux/macro/poly/eq.lux b/stdlib/test/test/lux/macro/poly/eq.lux
index e1d7604e7..e071ba043 100644
--- a/stdlib/test/test/lux/macro/poly/eq.lux
+++ b/stdlib/test/test/lux/macro/poly/eq.lux
@@ -5,7 +5,7 @@
[eq #+ Eq])
(data text/format
[bool]
- [number "i/" Number<Int>]
+ [number "int/" Number<Int>]
[text]
[maybe]
(coll [list]))
@@ -46,8 +46,8 @@
(def: gen-record
(r;Random Record)
(do r;Monad<Random>
- [size (:: @ map (n.% +2) r;nat)
- #let [gen-int (|> r;int (:: @ map (|>. i/abs (i.% 1_000_000))))]]
+ [size (:: @ map (n/% +2) r;nat)
+ #let [gen-int (|> r;int (:: @ map (|>. int/abs (i/% 1_000_000))))]]
($_ r;seq
(:: @ wrap [])
r;bool
diff --git a/stdlib/test/test/lux/macro/poly/functor.lux b/stdlib/test/test/lux/macro/poly/functor.lux
index 45e54bae7..d1c42cde5 100644
--- a/stdlib/test/test/lux/macro/poly/functor.lux
+++ b/stdlib/test/test/lux/macro/poly/functor.lux
@@ -7,7 +7,7 @@
[state])
(data text/format
[bool]
- [number "i/" Number<Int>]
+ [number]
[text]
[identity])
["r" math/random]
diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux
index a2ef96186..c79720956 100644
--- a/stdlib/test/test/lux/math.lux
+++ b/stdlib/test/test/lux/math.lux
@@ -1,31 +1,24 @@
(;module:
lux
(lux [io]
- (control ["M" monad #+ do Monad])
- (data [text "Text/" Monoid<Text>]
- text/format
- [bool "b/" Eq<Bool>]
- [number "f/" Number<Frac>]
- (coll [list "List/" Fold<List> Functor<List>])
- [product])
+ (control [monad #+ do Monad])
+ (data [bool "bool/" Eq<Bool>]
+ [number "frac/" Number<Frac>])
["r" math/random]
["&" math])
lux/test)
(def: (within? margin-of-error standard value)
(-> Frac Frac Frac Bool)
- (f.< margin-of-error
- (f/abs (f.- standard value))))
+ (f/< margin-of-error
+ (frac/abs (f/- standard value))))
(def: margin Frac 0.0000001)
-## The JVM trigonometry functions sometimes give me funky results.
-## I won't be testing this, until I can figure out what's going on, or
-## come up with my own implementation
(context: "Trigonometry"
- (<| (times +100)
+ (<| (seed +4611737486687492590)
(do @
- [angle (|> r;frac (:: @ map (f.* &;tau)))]
+ [angle (|> r;frac (:: @ map (f/* &;tau)))]
($_ seq
(test "Sine and arc-sine are inverse functions."
(|> angle &;sin &;asin (within? margin angle)))
@@ -40,66 +33,66 @@
(context: "Roots"
(<| (times +100)
(do @
- [factor (|> r;nat (:: @ map (|>. (n.% +1000)
- (n.max +1)
+ [factor (|> r;nat (:: @ map (|>. (n/% +1000)
+ (n/max +1)
nat-to-int
int-to-frac)))
- base (|> r;frac (:: @ map (f.* factor)))]
+ base (|> r;frac (:: @ map (f/* factor)))]
($_ seq
(test "Square-root is inverse of square."
- (|> base (&;pow 2.0) &;root2 (f.= base)))
+ (|> base (&;pow 2.0) &;root2 (f/= base)))
(test "Cubic-root is inverse of cube."
- (|> base (&;pow 3.0) &;root3 (f.= base)))
+ (|> base (&;pow 3.0) &;root3 (f/= base)))
))))
(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)))))
+ (and (|> ceil'd frac-to-int int-to-frac (f/= ceil'd))
+ (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)))))
+ (and (|> floor'd frac-to-int int-to-frac (f/= floor'd))
+ (f/<= sample floor'd)
+ (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 (f/abs (f.- sample round'd))))))
+ (and (|> round'd frac-to-int int-to-frac (f/= 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))))))
(context: "Greatest-Common-Divisor and Least-Common-Multiple"
(<| (times +100)
(do @
- [#let [gen-nat (|> r;nat (:: @ map (|>. (n.% +1000) (n.max +1))))]
+ [#let [gen-nat (|> r;nat (:: @ map (|>. (n/% +1000) (n/max +1))))]
x gen-nat
y gen-nat]
($_ (test "GCD"
(let [gcd (&;gcd x y)]
- (and (n.= +0 (n.% gcd x))
- (n.= +0 (n.% gcd y))
- (n.>= +1 gcd))))
+ (and (n/= +0 (n/% gcd x))
+ (n/= +0 (n/% gcd y))
+ (n/>= +1 gcd))))
(test "LCM"
(let [lcm (&;lcm x y)]
- (and (n.= +0 (n.% x lcm))
- (n.= +0 (n.% y lcm))
- (n.<= (n.* x y) lcm))))
+ (and (n/= +0 (n/% x lcm))
+ (n/= +0 (n/% y lcm))
+ (n/<= (n/* x y) lcm))))
))))
(context: "Infix syntax"
@@ -109,32 +102,32 @@
y r;nat
z r;nat
theta r;frac
- #let [top (|> x (n.max y) (n.max z))
- bottom (|> x (n.min y) (n.min z))]]
+ #let [top (|> x (n/max y) (n/max z))
+ bottom (|> x (n/min y) (n/min z))]]
($_ seq
(test "Constant values don't change."
- (n.= x
+ (n/= x
(&;infix x)))
(test "Can call binary functions."
- (n.= (&;gcd y x)
+ (n/= (&;gcd y x)
(&;infix [x &;gcd y])))
(test "Can call unary functions."
- (f.= (&;sin theta)
+ (f/= (&;sin theta)
(&;infix [&;sin theta])))
(test "Can use regular syntax in the middle of infix code."
- (n.= (&;gcd +450 (n.* +3 +9))
- (&;infix [(n.* +3 +9) &;gcd +450])))
+ (n/= (&;gcd +450 (n/* +3 +9))
+ (&;infix [(n/* +3 +9) &;gcd +450])))
(test "Can use non-numerical functions/macros as operators."
- (b/= (and (n.< y x) (n.< z y))
- (&;infix [[x n.< y] and [y n.< z]])))
+ (bool/= (and (n/< y x) (n/< z y))
+ (&;infix [[x n/< y] and [y n/< z]])))
(test "Can combine boolean operations in special ways via special keywords."
- (and (b/= (and (n.< y x) (n.< z y))
- (&;infix [#and x n.< y n.< z]))
- (b/= (and (n.< y x) (n.> z y))
- (&;infix [#and x n.< y n.> z]))))
+ (and (bool/= (and (n/< y x) (n/< z y))
+ (&;infix [#and x n/< y n/< z]))
+ (bool/= (and (n/< y x) (n/> z y))
+ (&;infix [#and x n/< y n/> z]))))
))))
diff --git a/stdlib/test/test/lux/math/logic/continuous.lux b/stdlib/test/test/lux/math/logic/continuous.lux
index 5df89cfef..0bf2aabcf 100644
--- a/stdlib/test/test/lux/math/logic/continuous.lux
+++ b/stdlib/test/test/lux/math/logic/continuous.lux
@@ -14,20 +14,20 @@
($_ seq
(test "AND is the minimum."
(let [result (&;~and left right)]
- (and (d.<= left result)
- (d.<= right result))))
+ (and (d/<= left result)
+ (d/<= right result))))
(test "OR is the maximum."
(let [result (&;~or left right)]
- (and (d.>= left result)
- (d.>= right result))))
+ (and (d/>= left result)
+ (d/>= right result))))
(test "Double negation results in the original value."
- (d.= left (&;~not (&;~not left))))
+ (d/= left (&;~not (&;~not left))))
(test "Every value is equivalent to itself."
- (and (d.>= left
+ (and (d/>= left
(&;~= left left))
- (d.>= right
+ (d/>= right
(&;~= right right))))
))))
diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux
index 3c7ff926e..7be4d05f0 100644
--- a/stdlib/test/test/lux/math/logic/fuzzy.lux
+++ b/stdlib/test/test/lux/math/logic/fuzzy.lux
@@ -33,25 +33,25 @@
triangle (<triangle> x y z)]]
($_ seq
(test "The middle value will always have maximum membership."
- (d.= ~true (&;membership middle triangle)))
+ (d/= ~true (&;membership middle triangle)))
(test "Boundary values will always have 0 membership."
- (and (d.= ~false (&;membership bottom triangle))
- (d.= ~false (&;membership top triangle))))
+ (and (d/= ~false (&;membership bottom triangle))
+ (d/= ~false (&;membership top triangle))))
(test "Values within range, will have membership > 0."
- (B/= (d.> ~false (&;membership sample triangle))
+ (B/= (d/> ~false (&;membership sample triangle))
(and (<gt> bottom sample)
(<lt> top sample))))
(test "Values outside of range, will have membership = 0."
- (B/= (d.= ~false (&;membership sample triangle))
+ (B/= (d/= ~false (&;membership sample triangle))
(or (<lte> bottom sample)
(<gte> top sample))))
))))]
- ["Frac" number;Hash<Frac> r;frac &;f.triangle f.< f.<= f.> f.>=]
- ["Deg" number;Hash<Deg> r;deg &;d.triangle d.< d.<= d.> d.>=]
+ ["Frac" number;Hash<Frac> r;frac &;f/triangle f/< f/<= f/> f/>=]
+ ["Deg" number;Hash<Deg> r;deg &;d/triangle d/< d/<= d/> d/>=]
)
(do-template [<desc> <hash> <gen> <trapezoid> <lt> <lte> <gt> <gte>]
@@ -75,41 +75,41 @@
trapezoid (<trapezoid> w x y z)]]
($_ seq
(test "The middle values will always have maximum membership."
- (and (d.= ~true (&;membership middle-bottom trapezoid))
- (d.= ~true (&;membership middle-top trapezoid))))
+ (and (d/= ~true (&;membership middle-bottom trapezoid))
+ (d/= ~true (&;membership middle-top trapezoid))))
(test "Boundary values will always have 0 membership."
- (and (d.= ~false (&;membership bottom trapezoid))
- (d.= ~false (&;membership top trapezoid))))
+ (and (d/= ~false (&;membership bottom trapezoid))
+ (d/= ~false (&;membership top trapezoid))))
(test "Values within inner range will have membership = 1"
- (B/= (d.= ~true (&;membership sample trapezoid))
+ (B/= (d/= ~true (&;membership sample trapezoid))
(and (<gte> middle-bottom sample)
(<lte> middle-top sample))))
(test "Values within range, will have membership > 0."
- (B/= (d.> ~false (&;membership sample trapezoid))
+ (B/= (d/> ~false (&;membership sample trapezoid))
(and (<gt> bottom sample)
(<lt> top sample))))
(test "Values outside of range, will have membership = 0."
- (B/= (d.= ~false (&;membership sample trapezoid))
+ (B/= (d/= ~false (&;membership sample trapezoid))
(or (<lte> bottom sample)
(<gte> top sample))))
))))]
- ["Frac" number;Hash<Frac> r;frac &;f.trapezoid f.< f.<= f.> f.>=]
- ["Deg" number;Hash<Deg> r;deg &;d.trapezoid d.< d.<= d.> d.>=]
+ ["Frac" number;Hash<Frac> r;frac &;f/trapezoid f/< f/<= f/> f/>=]
+ ["Deg" number;Hash<Deg> r;deg &;d/trapezoid d/< d/<= d/> d/>=]
)
(context: "Gaussian"
(<| (times +100)
(do @
- [deviation (|> r;frac (r;filter (f.> 0.0)))
+ [deviation (|> r;frac (r;filter (f/> 0.0)))
center r;frac
#let [gaussian (&;gaussian deviation center)]]
(test "The center value will always have maximum membership."
- (d.= ~true (&;membership center gaussian))))))
+ (d/= ~true (&;membership center gaussian))))))
(def: gen-triangle
(r;Random (&;Fuzzy Frac))
@@ -117,7 +117,7 @@
[x r;frac
y r;frac
z r;frac]
- (wrap (&;f.triangle x y z))))
+ (wrap (&;f/triangle x y z))))
(context: "Combinators"
(<| (times +100)
@@ -129,44 +129,44 @@
(test "Union membership as as high as membership in any of its members."
(let [combined (&;union left right)
combined-membership (&;membership sample combined)]
- (and (d.>= (&;membership sample left)
+ (and (d/>= (&;membership sample left)
combined-membership)
- (d.>= (&;membership sample right)
+ (d/>= (&;membership sample right)
combined-membership))))
(test "Intersection membership as as low as membership in any of its members."
(let [combined (&;intersection left right)
combined-membership (&;membership sample combined)]
- (and (d.<= (&;membership sample left)
+ (and (d/<= (&;membership sample left)
combined-membership)
- (d.<= (&;membership sample right)
+ (d/<= (&;membership sample right)
combined-membership))))
(test "Complement membership is the opposite of normal membership."
- (d.= (&;membership sample left)
+ (d/= (&;membership sample left)
(~not (&;membership sample (&;complement left)))))
(test "Membership in the difference will never be higher than in the set being subtracted."
- (B/= (d.> (&;membership sample right)
+ (B/= (d/> (&;membership sample right)
(&;membership sample left))
- (d.< (&;membership sample left)
+ (d/< (&;membership sample left)
(&;membership sample (&;difference left right)))))
))))
(context: "From predicates and sets"
(<| (times +100)
(do @
- [#let [set-10 (set;from-list number;Hash<Nat> (list;n.range +0 +10))]
- sample (|> r;nat (:: @ map (n.% +20)))]
+ [#let [set-10 (set;from-list number;Hash<Nat> (list;n/range +0 +10))]
+ sample (|> r;nat (:: @ map (n/% +20)))]
($_ seq
(test "Values that satisfy a predicate have membership = 1.
Values that don't have membership = 0."
- (B/= (d.= ~true (&;membership sample (&;from-predicate n.even?)))
- (n.even? sample)))
+ (B/= (d/= ~true (&;membership sample (&;from-predicate n/even?)))
+ (n/even? sample)))
(test "Values that belong to a set have membership = 1.
Values that don't have membership = 0."
- (B/= (d.= ~true (&;membership sample (&;from-set set-10)))
+ (B/= (d/= ~true (&;membership sample (&;from-set set-10)))
(set;member? set-10 sample)))
))))
@@ -180,10 +180,10 @@
member? (&;to-predicate threshold fuzzy)]]
($_ seq
(test "Can increase the threshold of membership of a fuzzy set."
- (B/= (d.> ~false (&;membership sample vip-fuzzy))
- (d.> threshold (&;membership sample fuzzy))))
+ (B/= (d/> ~false (&;membership sample vip-fuzzy))
+ (d/> threshold (&;membership sample fuzzy))))
(test "Can turn fuzzy sets into predicates through a threshold."
(B/= (member? sample)
- (d.> threshold (&;membership sample fuzzy))))
+ (d/> threshold (&;membership sample fuzzy))))
))))
diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux
index 5efacca05..9aefcc8f7 100644
--- a/stdlib/test/test/lux/math/random.lux
+++ b/stdlib/test/test/lux/math/random.lux
@@ -17,7 +17,7 @@
(context: "Random."
(<| (times +100)
(do @
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ [size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
_list (r;list size r;nat)
_sequence (r;sequence size r;nat)
_array (r;array size r;nat)
@@ -26,28 +26,28 @@
_set (r;set number;Hash<Nat> size r;nat)
_dict (r;dict number;Hash<Nat> size r;nat r;nat)
top r;nat
- filtered (|> r;nat (r;filter (n.<= top)))
+ filtered (|> r;nat (r;filter (n/<= top)))
shuffle-seed r;nat
- #let [sorted (|> _sequence sequence;to-list (list;sort n.<))
+ #let [sorted (|> _sequence sequence;to-list (list;sort n/<))
shuffled (|> sorted sequence;from-list (r;shuffle shuffle-seed))
- re-sorted (|> shuffled sequence;to-list (list;sort n.<))]]
+ re-sorted (|> shuffled sequence;to-list (list;sort n/<))]]
($_ seq
(test "Can produce lists."
- (n.= size (list;size _list)))
+ (n/= size (list;size _list)))
(test "Can produce sequences."
- (n.= size (sequence;size _sequence)))
+ (n/= size (sequence;size _sequence)))
(test "Can produce arrays."
- (n.= size (array;size _array)))
+ (n/= size (array;size _array)))
(test "Can produce queues."
- (n.= size (queue;size _queue)))
+ (n/= size (queue;size _queue)))
(test "Can produce stacks."
- (n.= size (stack;size _stack)))
+ (n/= size (stack;size _stack)))
(test "Can produce sets."
- (n.= size (set;size _set)))
+ (n/= size (set;size _set)))
(test "Can produce dicts."
- (n.= size (dict;size _dict)))
+ (n/= size (dict;size _dict)))
(test "Can filter values."
- (n.<= top filtered))
+ (n/<= top filtered))
(test "Can shuffle sequences."
(let [(^open "v/") (sequence;Eq<Sequence> number;Eq<Nat>)
sorted (sequence;from-list sorted)]
diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux
index ef891fcf6..b56e828bf 100644
--- a/stdlib/test/test/lux/time/duration.lux
+++ b/stdlib/test/test/lux/time/duration.lux
@@ -16,7 +16,7 @@
(do @
[millis r;int]
(test "Can convert from/to milliseconds."
- (|> millis @;from-millis @;to-millis (i.= millis))))))
+ (|> millis @;from-millis @;to-millis (i/= millis))))))
(context: "Equality"
(<| (times +100)
@@ -43,11 +43,11 @@
(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)))
+ (|> sample (@;scale factor) (@;query sample) (i/= factor)))
(test "Scaling a duration by one does not change it."
(|> sample (@;scale 1) (@/= sample)))
(test "Merging with the empty duration changes nothing."
diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux
index 95a2ce441..db99c8628 100644
--- a/stdlib/test/test/lux/time/instant.lux
+++ b/stdlib/test/test/lux/time/instant.lux
@@ -18,14 +18,14 @@
(def: #export instant
(r;Random @;Instant)
- (|> r;int (:: r;Monad<Random> map (|>. (i.% boundary) @;from-millis))))
+ (|> r;int (:: r;Monad<Random> map (|>. (i/% boundary) @;from-millis))))
(context: "Conversion."
(<| (times +100)
(do @
[millis r;int]
(test "Can convert from/to milliseconds."
- (|> millis @;from-millis @;to-millis (i.= millis))))))
+ (|> millis @;from-millis @;to-millis (i/= millis))))))
(context: "Equality"
(<| (times +100)
@@ -78,7 +78,8 @@
(|> @;epoch (@;shift (@;relative sample)) (@/= sample)))))))
(context: "Codec"
- (<| (times +100)
+ (<| (seed +9863552679229274604)
+ ## (times +100)
(do @
[sample instant
#let [(^open "@/") @;Eq<Instant>
diff --git a/stdlib/test/test/lux/type/implicit.lux b/stdlib/test/test/lux/type/implicit.lux
index 138a16b2e..662c2df80 100644
--- a/stdlib/test/test/lux/type/implicit.lux
+++ b/stdlib/test/test/lux/type/implicit.lux
@@ -22,17 +22,17 @@
(let [(^open "list/") (list;Eq<List> number;Eq<Nat>)]
(and (bool/= (:: number;Eq<Nat> = x y)
(::: = x y))
- (list/= (list;n.range +1 +10)
- (::: map n.inc (list;n.range +0 +9)))
+ (list/= (list;n/range +1 +10)
+ (::: map n/inc (list;n/range +0 +9)))
)))
(test "Can automatically select second-order structures."
(::: =
- (list;n.range +1 +10)
- (list;n.range +1 +10)))
+ (list;n/range +1 +10)
+ (list;n/range +1 +10)))
(test "Can automatically select third-order structures."
- (let [lln (::: map (list;n.range +1)
- (list;n.range +1 +10))]
+ (let [lln (::: map (list;n/range +1)
+ (list;n/range +1 +10))]
(::: = lln lln)))
))))
diff --git a/stdlib/test/test/lux/type/object.lux b/stdlib/test/test/lux/type/object.lux
index c85ff5770..96c71a75c 100644
--- a/stdlib/test/test/lux/type/object.lux
+++ b/stdlib/test/test/lux/type/object.lux
@@ -12,7 +12,7 @@
Nat
(def: inc
- (update@Counter n.inc))
+ (update@Counter n/inc))
(def: read
get@Counter))
@@ -63,7 +63,7 @@
(def: (poly1 counter)
(-> Resettable-Counter Nat)
- (n.+ (read counter)
+ (n/+ (read counter)
(read (reset counter))))
(def: poly1-0 Nat (poly1 (new@NatRC +0 [])))
@@ -77,7 +77,7 @@
(def: (poly3 counter)
(-> NatRC Nat)
- (n.+ (read counter)
+ (n/+ (read counter)
(read (reset counter))))
(def: poly3-0 Nat (poly3 (new@NatRC +0 [])))
diff --git a/stdlib/test/test/lux/world/blob.lux b/stdlib/test/test/lux/world/blob.lux
index d523f5823..3986a6a23 100644
--- a/stdlib/test/test/lux/world/blob.lux
+++ b/stdlib/test/test/lux/world/blob.lux
@@ -25,35 +25,35 @@
(do r;Monad<Random>
[]
(loop [idx +0]
- (if (n.< size idx)
+ (if (n/< size idx)
(do @
[byte r;nat]
(exec (E;assume (@;write-8 idx byte blob))
- (recur (n.inc idx))))
+ (recur (n/inc idx))))
(wrap blob))))))
(context: "Blob."
(<| (times +100)
(do @
- [blob-size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +8))))
+ [blob-size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +8))))
random-blob (blob blob-size)
#let [clean-blob (@;create blob-size)
size (@;size clean-blob)]
value r;nat
- idx (|> r;nat (:: @ map (n.% size)))
- [from to] (|> (r;list +2 (|> r;nat (:: @ map (n.% size))))
+ idx (|> r;nat (:: @ map (n/% size)))
+ [from to] (|> (r;list +2 (|> r;nat (:: @ map (n/% size))))
(:: @ map
- (|>. (list;sort n.<)
+ (|>. (list;sort n/<)
(pipe;case> (^ (list from to))
[from to]
_
(undefined)))))
- #let [value-8 (n.% (bit;shift-left +8 +1) value)
- value-16 (n.% (bit;shift-left +16 +1) value)
- value-32 (n.% (bit;shift-left +32 +1) value)
+ #let [value-8 (n/% (bit;shift-left +8 +1) value)
+ value-16 (n/% (bit;shift-left +16 +1) value)
+ value-32 (n/% (bit;shift-left +32 +1) value)
value-64 value
- slice-size (|> to (n.- from) n.inc)
+ slice-size (|> to (n/- from) n/inc)
random-slice (E;assume (@;slice from to random-blob))]]
($_ seq
(test "Has equality."
@@ -62,48 +62,48 @@
(E;assume (@;slice from to clean-blob))
(E;assume (@;slice from to clean-blob)))))
(test "Can get size of blob."
- (n.= blob-size size))
+ (n/= blob-size size))
(test "Can read/write 8-bit values."
(succeed
(do E;Monad<Error>
[_ (@;write-8 idx value-8 clean-blob)
output-8 (@;read-8 idx clean-blob)]
- (wrap (n.= value-8 output-8)))))
+ (wrap (n/= value-8 output-8)))))
(test "Can read/write 16-bit values."
- (or (n.>= size (n.+ +1 idx))
+ (or (n/>= size (n/+ +1 idx))
(succeed
(do E;Monad<Error>
[_ (@;write-16 idx value-16 clean-blob)
output-16 (@;read-16 idx clean-blob)]
- (wrap (n.= value-16 output-16))))))
+ (wrap (n/= value-16 output-16))))))
(test "Can read/write 32-bit values."
- (or (n.>= size (n.+ +3 idx))
+ (or (n/>= size (n/+ +3 idx))
(succeed
(do E;Monad<Error>
[_ (@;write-32 idx value-32 clean-blob)
output-32 (@;read-32 idx clean-blob)]
- (wrap (n.= value-32 output-32))))))
+ (wrap (n/= value-32 output-32))))))
(test "Can read/write 64-bit values."
- (or (n.>= size (n.+ +7 idx))
+ (or (n/>= size (n/+ +7 idx))
(succeed
(do E;Monad<Error>
[_ (@;write-64 idx value-64 clean-blob)
output-64 (@;read-64 idx clean-blob)]
- (wrap (n.= value-64 output-64))))))
+ (wrap (n/= value-64 output-64))))))
(test "Can slice blobs."
- (and (n.= slice-size (@;size random-slice))
+ (and (n/= slice-size (@;size random-slice))
(loop [idx +0]
(let [loop-recur recur]
- (if (n.< slice-size idx)
+ (if (n/< slice-size idx)
(and (succeed
(do E;Monad<Error>
- [reference (@;read-8 (n.+ from idx) random-blob)
+ [reference (@;read-8 (n/+ from idx) random-blob)
sample (@;read-8 idx random-slice)]
- (wrap (n.= reference sample))))
- (loop-recur (n.inc idx)))
+ (wrap (n/= reference sample))))
+ (loop-recur (n/inc idx)))
true)))))
(test "Slicing the whole blob does not change anything."
(:: @;Eq<Blob> =
random-blob
- (E;assume (@;slice +0 (n.dec blob-size) random-blob))))
+ (E;assume (@;slice +0 (n/dec blob-size) random-blob))))
))))
diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux
index 4af26b095..5c68c1097 100644
--- a/stdlib/test/test/lux/world/file.lux
+++ b/stdlib/test/test/lux/world/file.lux
@@ -17,11 +17,11 @@
(// ["_;" blob]))
(def: truncate-millis
- (|>. (i./ 1_000) (i.* 1_000)))
+ (|>. (i// 1_000) (i/* 1_000)))
(context: "File system."
(do @
- [file-size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ [file-size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
dataL (_blob;blob file-size)
dataR (_blob;blob file-size)
code r;nat
@@ -31,7 +31,7 @@
i;absolute)))]
($_ seq
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +0 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +0 code)))]
result (do T;Monad<Task>
[pre (@;exists? file)
_ (@;write dataL file)
@@ -43,7 +43,7 @@
(assert "Can create/delete files."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +1 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +1 code)))]
result (do T;Monad<Task>
[_ (@;write dataL file)
output (@;read file)
@@ -52,29 +52,29 @@
(assert "Can write/read files."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +2 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +2 code)))]
result (do T;Monad<Task>
[_ (@;write dataL file)
read-size (@;size file)
_ (@;delete file)]
- (wrap (n.= file-size read-size)))]
+ (wrap (n/= file-size read-size)))]
(assert "Can read file size."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +3 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +3 code)))]
result (do T;Monad<Task>
[_ (@;write dataL file)
_ (@;append dataR file)
output (@;read file)
read-size (@;size file)
_ (@;delete file)]
- (wrap (and (n.= (n.* +2 file-size) read-size)
- (:: blob;Eq<Blob> = dataL (E;assume (blob;slice +0 (n.dec file-size) output)))
- (:: blob;Eq<Blob> = dataR (E;assume (blob;slice file-size (n.dec read-size) output))))))]
+ (wrap (and (n/= (n/* +2 file-size) read-size)
+ (:: blob;Eq<Blob> = dataL (E;assume (blob;slice +0 (n/dec file-size) output)))
+ (:: blob;Eq<Blob> = dataR (E;assume (blob;slice file-size (n/dec read-size) output))))))]
(assert "Can append to files."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [dir (format "temp_dir_" (%n (n.+ +4 code)))]
+ [#let [dir (format "temp_dir_" (%n (n/+ +4 code)))]
result (do T;Monad<Task>
[pre (@;exists? dir)
_ (@;make-dir dir)
@@ -86,8 +86,8 @@
(assert "Can create/delete directories."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +5 code)))
- dir (format "temp_dir_" (%n (n.+ +5 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +5 code)))
+ dir (format "temp_dir_" (%n (n/+ +5 code)))]
result (do T;Monad<Task>
[_ (@;write dataL file)
file-is-file (@;file? file)
@@ -102,8 +102,8 @@
(assert "Can differentiate files from directories."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +6 code)))
- dir (format "temp_dir_" (%n (n.+ +6 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +6 code)))
+ dir (format "temp_dir_" (%n (n/+ +6 code)))]
result (do T;Monad<Task>
[_ (@;make-dir dir)
#let [file' (format dir "/" file)]
@@ -111,14 +111,14 @@
read-size (@;size file')
deleted-file (@;delete file')
deleted-dir (@;delete dir)]
- (wrap (and (n.= file-size read-size)
+ (wrap (and (n/= file-size read-size)
deleted-file
deleted-dir)))]
(assert "Can create files inside of directories."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +7 code)))
- dir (format "temp_dir_" (%n (n.+ +7 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +7 code)))
+ dir (format "temp_dir_" (%n (n/+ +7 code)))]
result (do T;Monad<Task>
[_ (@;make-dir dir)
#let [file' (format dir "/" file)]
@@ -135,7 +135,7 @@
(assert "Can list files inside a directory."
(E;default false result))))
(wrap (do P;Monad<Promise>
- [#let [file (format "temp_file_" (%n (n.+ +8 code)))]
+ [#let [file (format "temp_file_" (%n (n/+ +8 code)))]
result (do T;Monad<Task>
[_ (@;write dataL file)
was-modified? (@;set-last-modified last-modified file)
@@ -146,8 +146,8 @@
(assert "Can change the time of last modification."
(E;default false result))))
(wrap (do P;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 (do T;Monad<Task>
[_ (@;write dataL file0)
pre (@;exists? file0)
diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux
index d07f5e200..c18d3929b 100644
--- a/stdlib/test/test/lux/world/net/tcp.lux
+++ b/stdlib/test/test/lux/world/net/tcp.lux
@@ -21,8 +21,8 @@
(r;Random net;Port)
(|> r;nat
(:: r;Monad<Random> map
- (|>. (n.% +1000)
- (n.+ +8000)))))
+ (|>. (n/% +1000)
+ (n/+ +8000)))))
(exception: Empty-Channel)
@@ -40,7 +40,7 @@
(context: "TCP networking."
(do @
[port ;;port
- size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
from (_blob;blob size)
to (_blob;blob size)
#let [temp (blob;create size)]]
@@ -53,12 +53,12 @@
_ (@;write from +0 size client)
socket (head server)
bytes-from (@;read temp +0 size socket)
- #let [from-worked? (and (n.= size bytes-from)
+ #let [from-worked? (and (n/= size bytes-from)
(:: blob;Eq<Blob> = from temp))]
####################
_ (@;write to +0 size socket)
bytes-to (@;read temp +0 size client)
- #let [to-worked? (and (n.= size bytes-to)
+ #let [to-worked? (and (n/= size bytes-to)
(:: blob;Eq<Blob> = to temp))]
####################
_ (@;close client)
diff --git a/stdlib/test/test/lux/world/net/udp.lux b/stdlib/test/test/lux/world/net/udp.lux
index 988db0471..a4707744e 100644
--- a/stdlib/test/test/lux/world/net/udp.lux
+++ b/stdlib/test/test/lux/world/net/udp.lux
@@ -21,8 +21,8 @@
(r;Random net;Port)
(|> r;nat
(:: r;Monad<Random> map
- (|>. (n.% +1000)
- (n.+ +8000)))))
+ (|>. (n/% +1000)
+ (n/+ +8000)))))
(exception: Empty-Channel)
@@ -40,7 +40,7 @@
(context: "UDP networking."
(do @
[port ;;port
- size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ size (|> r;nat (:: @ map (|>. (n/% +100) (n/max +10))))
from (_blob;blob size)
to (_blob;blob size)
#let [temp (blob;create size)]]
@@ -52,14 +52,14 @@
####################
_ (@;write localhost port from +0 size client)
[bytes-from from-address from-port] (@;read temp +0 size server)
- #let [from-worked? (and (n.= size bytes-from)
+ #let [from-worked? (and (n/= size bytes-from)
(:: blob;Eq<Blob> = from temp))]
####################
_ (@;write from-address from-port to +0 size server)
[bytes-to to-address to-port] (@;read temp +0 size client)
- #let [to-worked? (and (n.= size bytes-to)
+ #let [to-worked? (and (n/= size bytes-to)
(:: blob;Eq<Blob> = to temp)
- (n.= port to-port))]
+ (n/= port to-port))]
####################
_ (@;close client)
_ (@;close server)]