aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2016-12-02 21:39:11 -0400
committerEduardo Julian2016-12-02 21:39:11 -0400
commit60d3952d9550cc4d6fd0f5fc8312104b21024799 (patch)
tree9f73d65b332e87214267055bc71e8e1be593688d /stdlib
parent55e411f34d81d8deb0b7d0e25c987dbe16035354 (diff)
- Changed the names of math op functions to make them more consistent and similar.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux324
-rw-r--r--stdlib/source/lux/codata/struct/stream.lux8
-rw-r--r--stdlib/source/lux/compiler.lux2
-rw-r--r--stdlib/source/lux/concurrency/actor.lux20
-rw-r--r--stdlib/source/lux/concurrency/frp.lux6
-rw-r--r--stdlib/source/lux/concurrency/promise.lux12
-rw-r--r--stdlib/source/lux/concurrency/stm.lux14
-rw-r--r--stdlib/source/lux/control/comonad.lux4
-rw-r--r--stdlib/source/lux/control/effect.lux2
-rw-r--r--stdlib/source/lux/control/ord.lux2
-rw-r--r--stdlib/source/lux/data/bit.lux6
-rw-r--r--stdlib/source/lux/data/char.lux6
-rw-r--r--stdlib/source/lux/data/format/json.lux8
-rw-r--r--stdlib/source/lux/data/ident.lux2
-rw-r--r--stdlib/source/lux/data/log.lux4
-rw-r--r--stdlib/source/lux/data/number.lux58
-rw-r--r--stdlib/source/lux/data/struct/array.lux52
-rw-r--r--stdlib/source/lux/data/struct/dict.lux76
-rw-r--r--stdlib/source/lux/data/struct/list.lux46
-rw-r--r--stdlib/source/lux/data/struct/queue.lux4
-rw-r--r--stdlib/source/lux/data/struct/set.lux4
-rw-r--r--stdlib/source/lux/data/struct/vector.lux82
-rw-r--r--stdlib/source/lux/data/struct/zipper.lux8
-rw-r--r--stdlib/source/lux/data/text.lux24
-rw-r--r--stdlib/source/lux/host.lux4
-rw-r--r--stdlib/source/lux/lexer.lux10
-rw-r--r--stdlib/source/lux/macro/poly.lux26
-rw-r--r--stdlib/source/lux/macro/poly/functor.lux6
-rw-r--r--stdlib/source/lux/macro/syntax.lux14
-rw-r--r--stdlib/source/lux/math.lux4
-rw-r--r--stdlib/source/lux/math/complex.lux232
-rw-r--r--stdlib/source/lux/math/random.lux44
-rw-r--r--stdlib/source/lux/math/ratio.lux124
-rw-r--r--stdlib/source/lux/pipe.lux28
-rw-r--r--stdlib/source/lux/regex.lux8
-rw-r--r--stdlib/source/lux/test.lux22
-rw-r--r--stdlib/source/lux/type.lux6
-rw-r--r--stdlib/source/lux/type/auto.lux8
-rw-r--r--stdlib/source/lux/type/check.lux18
-rw-r--r--stdlib/test/test/lux.lux42
-rw-r--r--stdlib/test/test/lux/cli.lux24
-rw-r--r--stdlib/test/test/lux/codata/env.lux8
-rw-r--r--stdlib/test/test/lux/codata/io.lux6
-rw-r--r--stdlib/test/test/lux/codata/state.lux12
-rw-r--r--stdlib/test/test/lux/codata/struct/stream.lux32
-rw-r--r--stdlib/test/test/lux/concurrency/actor.lux4
-rw-r--r--stdlib/test/test/lux/concurrency/frp.lux8
-rw-r--r--stdlib/test/test/lux/concurrency/stm.lux4
-rw-r--r--stdlib/test/test/lux/data/bit.lux56
-rw-r--r--stdlib/test/test/lux/data/error.lux12
-rw-r--r--stdlib/test/test/lux/data/error/exception.lux12
-rw-r--r--stdlib/test/test/lux/data/format/json.lux12
-rw-r--r--stdlib/test/test/lux/data/ident.lux8
-rw-r--r--stdlib/test/test/lux/data/log.lux16
-rw-r--r--stdlib/test/test/lux/data/number.lux24
-rw-r--r--stdlib/test/test/lux/data/product.lux8
-rw-r--r--stdlib/test/test/lux/data/struct/array.lux40
-rw-r--r--stdlib/test/test/lux/data/struct/dict.lux36
-rw-r--r--stdlib/test/test/lux/data/struct/list.lux100
-rw-r--r--stdlib/test/test/lux/data/struct/queue.lux12
-rw-r--r--stdlib/test/test/lux/data/struct/set.lux6
-rw-r--r--stdlib/test/test/lux/data/struct/stack.lux8
-rw-r--r--stdlib/test/test/lux/data/struct/tree.lux2
-rw-r--r--stdlib/test/test/lux/data/struct/vector.lux28
-rw-r--r--stdlib/test/test/lux/data/struct/zipper.lux4
-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/math.lux24
-rw-r--r--stdlib/test/test/lux/pipe.lux26
69 files changed, 938 insertions, 990 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 2b66cdbe1..e2782012b 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -2006,11 +2006,6 @@
(-> Int Int Bool)
(_lux_proc ["jvm" "leq"] [x y]))
-(def:''' (n= x y)
- #Nil
- (-> Nat Nat Bool)
- (_lux_proc ["nat" "="] [x y]))
-
(def:''' (->Text x)
#Nil
(-> (host java.lang.Object) Text)
@@ -2021,10 +2016,10 @@
(do-template [<name> <diff>]
[(def: #export <name>
(-> Int Int)
- (+ <diff>))]
+ (i.+ <diff>))]
- [inc 1]
- [dec -1])")])
+ [i.inc 1]
+ [i.dec -1])")])
(_lux_case tokens
(#Cons [[_ (#TupleS bindings)] (#Cons [[_ (#TupleS templates)] data])])
(_lux_case [(mapM Monad<Maybe> get-name bindings)
@@ -2045,53 +2040,106 @@
_
(fail "Wrong syntax for do-template")))
+(do-template [<type> <category> <=-name> <=> <lt-name> <lte-name> <lt> <gt-name> <gte-name>
+ <eq-doc> <<-doc> <<=-doc> <>-doc> <>=-doc>]
+ [(def:''' #export (<=-name> test subject)
+ (list [["lux" "doc"] (#TextM <eq-doc>)])
+ (-> <type> <type> Bool)
+ (_lux_proc [<category> <=>] [subject test]))
+
+ (def:''' #export (<lt-name> test subject)
+ (list [["lux" "doc"] (#TextM <<-doc>)])
+ (-> <type> <type> Bool)
+ (_lux_proc [<category> <lt>] [subject test]))
-(do-template [<name> <cmp> <type>]
- [(def:''' (<name> x y)
- #Nil
+ (def:''' #export (<lte-name> test subject)
+ (list [["lux" "doc"] (#TextM <<=-doc>)])
+ (-> <type> <type> Bool)
+ (if (_lux_proc [<category> <lt>] [subject test])
+ true
+ (_lux_proc [<category> <=>] [subject test])))
+
+ (def:''' #export (<gt-name> test subject)
+ (list [["lux" "doc"] (#TextM <>-doc>)])
+ (-> <type> <type> Bool)
+ (_lux_proc [<category> <lt>] [test subject]))
+
+ (def:''' #export (<gte-name> test subject)
+ (list [["lux" "doc"] (#TextM <>=-doc>)])
(-> <type> <type> Bool)
- (_lux_proc ["jvm" <cmp>] [x y]))]
+ (if (_lux_proc [<category> <lt>] [test subject])
+ true
+ (_lux_proc [<category> <=>] [subject test])))]
- ## [i= "leq" Int]
- [i> "lgt" Int]
- [i< "llt" Int]
+ [ Nat "nat" n.= "=" n.< n.<= "<" n.> n.>=
+ "Natural equality." "Natural less-than." "Natural less-than-equal." "Natural greater-than." "Natural greater-than-equal."]
+
+ [ Int "jvm" i.= "leq" i.< i.<= "llt" i.> i.>=
+ "Integer equality." "Integer less-than." "Integer less-than-equal." "Integer greater-than." "Integer greater-than-equal."]
+
+ [Frac "frac" f.= "=" f.< f.<= "<" f.> f.>=
+ "Fractional equality." "Fractional less-than." "Fractional less-than-equal." "Fractional greater-than." "Fractional greater-than-equal."]
+
+ [Real "jvm" r.= "deq" r.< r.<= "dlt" r.> r.>=
+ "Real equality." "Real less-than." "Real less-than-equal." "Real greater-than." "Real greater-than-equal."]
)
-(do-template [<name> <cmp> <eq> <type>]
- [(def:''' (<name> x y)
- #Nil
- (-> <type> <type> Bool)
- (if (<cmp> x y)
- true
- (<eq> x y)))]
+(do-template [<type> <name> <op> <doc>]
+ [(def:''' #export (<name> param subject)
+ (list [["lux" "doc"] (#TextM <doc>)])
+ (-> <type> <type> <type>)
+ (_lux_proc <op> [subject param]))]
- [i>= i> i= Int]
- [i<= i< i= Int]
+ [ Nat n.+ ["nat" "+"] "Nat(ural) addition."]
+ [ Nat n.- ["nat" "-"] "Nat(ural) substraction."]
+ [ Nat n.* ["nat" "*"] "Nat(ural) multiplication."]
+ [ Nat n./ ["nat" "/"] "Nat(ural) division."]
+ [ Nat n.% ["nat" "%"] "Nat(ural) remainder."]
+
+ [ Int i.+ ["jvm" "ladd"] "Int(eger) addition."]
+ [ Int i.- ["jvm" "lsub"] "Int(eger) substraction."]
+ [ Int i.* ["jvm" "lmul"] "Int(eger) multiplication."]
+ [ Int i./ ["jvm" "ldiv"] "Int(eger) division."]
+ [ Int i.% ["jvm" "lrem"] "Int(eger) remainder."]
+
+ [Frac f.+ ["frac" "+"] "Frac(tional) addition."]
+ [Frac f.- ["frac" "-"] "Frac(tional) substraction."]
+ [Frac f.* ["frac" "*"] "Frac(tional) multiplication."]
+ [Frac f./ ["frac" "/"] "Frac(tional) division."]
+ [Frac f.% ["frac" "%"] "Frac(tional) remainder."]
+
+ [Real r.+ ["jvm" "dadd"] "Real addition."]
+ [Real r.- ["jvm" "dsub"] "Real substraction."]
+ [Real r.* ["jvm" "dmul"] "Real multiplication."]
+ [Real r./ ["jvm" "ddiv"] "Real division."]
+ [Real r.% ["jvm" "drem"] "Real remainder."]
)
-(do-template [<name> <op> <type>]
- [(def:''' (<name> x y)
- #Nil
+(do-template [<name> <type> <test> <doc>]
+ [(def:''' #export (<name> left right)
+ (list [["lux" "doc"] (#TextM <doc>)])
(-> <type> <type> <type>)
- (_lux_proc <op> [x y]))]
-
- [i+ ["jvm" "ladd"] Int]
- [i- ["jvm" "lsub"] Int]
- [i* ["jvm" "lmul"] Int]
- [i/ ["jvm" "ldiv"] Int]
- [i% ["jvm" "lrem"] Int]
-
- [n+ ["nat" "+"] Nat]
- [n- ["nat" "-"] Nat]
- [n* ["nat" "*"] Nat]
- [n/ ["nat" "/"] Nat]
- [n% ["nat" "%"] Nat]
+ (if (<test> right left)
+ left
+ right))]
+
+ [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."]
+
+ [f.min Frac f.< "Frac(tional) minimum."]
+ [f.max Frac f.> "Frac(tional) maximum."]
+
+ [r.min Real r.< "Real minimum."]
+ [r.max Real r.> "Real minimum."]
)
(def:''' (multiple? div n)
#Nil
(-> Int Int Bool)
- (i= 0 (i% n div)))
+ (i.= 0 (i.% div n)))
(def:''' #export (not x)
#Nil
@@ -2411,7 +2459,7 @@
#scope-type-vars scope-type-vars}
(#Right {#info info #source source #modules modules
#scopes scopes #type-vars 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/append "__gensym__" prefix (->Text seed))]))))
@@ -2601,7 +2649,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 ($_ * x y z))
+ (#Some ($_ i.* x y z))
_
#None)")])
@@ -2619,7 +2667,7 @@
## It's a special macro meant to be used with case.
(case (: (List Int) (list 1 2 3))
(^ (list x y z))
- (#Some ($_ * x y z))
+ (#Some ($_ i.* x y z))
_
#None)")])
@@ -3098,24 +3146,24 @@
(def: (split-text splitter input)
(-> Text Text (List Text))
(let [idx (index-of splitter input)]
- (if (i< idx 0)
+ (if (i.< 0 idx)
(#Cons input #Nil)
(#Cons (substring2 0 idx input)
- (split-text splitter (substring1 (i+ 1 idx) input))))))
+ (split-text splitter (substring1 (i.+ 1 idx) input))))))
(def: (split-module-contexts module)
(-> Text (List Text))
(#Cons module (let [idx (last-index-of "/" module)]
- (if (i< idx 0)
+ (if (i.< 0 idx)
#Nil
(split-module-contexts (substring2 0 idx module))))))
(def: (split-module module)
(-> Text (List Text))
(let [idx (index-of "/" module)]
- (if (i< idx 0)
+ (if (i.< 0 idx)
(list module)
- (list& (substring2 0 idx module) (split-module (substring1 (i+ 1 idx) module))))))
+ (list& (substring2 0 idx module) (split-module (substring1 (i.+ 1 idx) module))))))
(def: (at idx xs)
(All [a]
@@ -3125,9 +3173,9 @@
#None
(#Cons x xs')
- (if (i= idx 0)
+ (if (i.= idx 0)
(#Some x)
- (at (i- idx 1) xs')
+ (at (i.- 1 idx) xs')
)))
(def: (beta-reduce env type)
@@ -3749,7 +3797,7 @@
parts
(let [[ups parts'] (split-with (Text/= "..") parts)
num-ups (length ups)]
- (if (i= num-ups 0)
+ (if (i.= num-ups 0)
(return module)
(case (at num-ups (split-module-contexts module-name))
#None
@@ -4086,7 +4134,7 @@
(odd? num) \"odd\"
## else-branch
\"???\")"}
- (if (i= 0 (i% (length tokens) 2))
+ (if (i.= 0 (i.% 2 (length tokens)))
(fail "cond requires an even number of arguments.")
(case (reverse tokens)
(^ (list& else branches'))
@@ -4104,7 +4152,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))
@@ -4136,7 +4184,7 @@
(#Some members)
(let [pattern (record$ (map (: (-> [Ident [Nat Type]] [AST AST])
(lambda [[[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))))]
@@ -4459,7 +4507,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat AST] [AST AST])
(lambda [[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'))]
@@ -4511,7 +4559,7 @@
(macro: #export (update@ tokens)
{#;doc "## Modifies the value of a record at a given tag, based on some function.
- (update@ #age inc person)
+ (update@ #age i.inc person)
## Can also work with multiple levels of nesting:
(update@ [#foo #bar #baz] func my-record)
@@ -4545,7 +4593,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat AST] [AST AST])
(lambda [[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'))]
@@ -4628,7 +4676,7 @@
(do Monad<Maybe>
[bindings' (mapM Monad<Maybe> get-name bindings)
data' (mapM Monad<Maybe> tuple->list data)]
- (if (every? (i= (length bindings')) (map length data'))
+ (if (every? (i.= (length bindings')) (map length data'))
(let [apply (: (-> RepEnv (List AST))
(lambda [env] (map (apply-template env) templates)))]
(|> data'
@@ -4653,100 +4701,6 @@
[int-to-real Int Real "l2d"]
)
-(do-template [<type> <category> <=-name> <=> <lt-name> <lte-name> <lt> <gt-name> <gte-name>
- <eq-doc> <<-doc> <<=-doc> <>-doc> <>=-doc>]
- [(def: #export (<=-name> test subject)
- {#;doc <eq-doc>}
- (-> <type> <type> Bool)
- (_lux_proc [<category> <=>] [subject test]))
-
- (def: #export (<lt-name> test subject)
- {#;doc <<-doc>}
- (-> <type> <type> Bool)
- (_lux_proc [<category> <lt>] [subject test]))
-
- (def: #export (<lte-name> test subject)
- {#;doc <<=-doc>}
- (-> <type> <type> Bool)
- (or (_lux_proc [<category> <lt>] [subject test])
- (_lux_proc [<category> <=>] [subject test])))
-
- (def: #export (<gt-name> test subject)
- {#;doc <>-doc>}
- (-> <type> <type> Bool)
- (_lux_proc [<category> <lt>] [test subject]))
-
- (def: #export (<gte-name> test subject)
- {#;doc <>=-doc>}
- (-> <type> <type> Bool)
- (or (_lux_proc [<category> <lt>] [test subject])
- (_lux_proc [<category> <=>] [subject test])))]
-
- [ Nat "nat" =+ "=" <+ <=+ "<" >+ >=+
- "Natural equality." "Natural less-than." "Natural less-than-equal." "Natural greater-than." "Natural greater-than-equal."]
-
- [ Int "jvm" = "leq" < <= "llt" > >=
- "Integer equality." "Integer less-than." "Integer less-than-equal." "Integer greater-than." "Integer greater-than-equal."]
-
- [Frac "frac" =.. "=" <.. <=.. "<" >.. >=..
- "Fractional equality." "Fractional less-than." "Fractional less-than-equal." "Fractional greater-than." "Fractional greater-than-equal."]
-
- [Real "jvm" =. "deq" <. <=. "dlt" >. >=.
- "Real equality." "Real less-than." "Real less-than-equal." "Real greater-than." "Real greater-than-equal."]
- )
-
-(do-template [<type> <name> <op> <doc>]
- [(def: #export (<name> param subject)
- {#;doc <doc>}
- (-> <type> <type> <type>)
- (_lux_proc <op> [subject param]))]
-
- [ Nat ++ ["nat" "+"] "Nat(ural) addition."]
- [ Nat -+ ["nat" "-"] "Nat(ural) substraction."]
- [ Nat *+ ["nat" "*"] "Nat(ural) multiplication."]
- [ Nat /+ ["nat" "/"] "Nat(ural) division."]
- [ Nat %+ ["nat" "%"] "Nat(ural) remainder."]
-
- [ Int + ["jvm" "ladd"] "Int(eger) addition."]
- [ Int - ["jvm" "lsub"] "Int(eger) substraction."]
- [ Int * ["jvm" "lmul"] "Int(eger) multiplication."]
- [ Int / ["jvm" "ldiv"] "Int(eger) division."]
- [ Int % ["jvm" "lrem"] "Int(eger) remainder."]
-
- [Frac +.. ["frac" "+"] "Frac(tional) addition."]
- [Frac -.. ["frac" "-"] "Frac(tional) substraction."]
- [Frac *.. ["frac" "*"] "Frac(tional) multiplication."]
- [Frac /.. ["frac" "/"] "Frac(tional) division."]
- [Frac %.. ["frac" "%"] "Frac(tional) remainder."]
-
- [Real +. ["jvm" "dadd"] "Real addition."]
- [Real -. ["jvm" "dsub"] "Real substraction."]
- [Real *. ["jvm" "dmul"] "Real multiplication."]
- [Real /. ["jvm" "ddiv"] "Real division."]
- [Real %. ["jvm" "drem"] "Real remainder."]
- )
-
-(do-template [<name> <type> <test> <doc>]
- [(def: #export (<name> left right)
- {#;doc <doc>}
- (-> <type> <type> <type>)
- (if (<test> right left)
- left
- right))]
-
- [min+ Nat <+ "Nat(ural) minimum."]
- [max+ Nat >+ "Nat(ural) maximum."]
-
- [min Int < "Int(eger) minimum."]
- [max Int > "Int(eger) maximum."]
-
- [min.. Frac <.. "Frac(tional) minimum."]
- [max.. Frac >.. "Frac(tional) maximum."]
-
- [min. Real <. "Real minimum."]
- [max. Real >. "Real minimum."]
- )
-
(def: (find-baseline-column ast)
(-> AST Int)
(case ast
@@ -4765,12 +4719,12 @@
(^template [<tag>]
[[_ _ column] (<tag> parts)]
- (fold min column (map find-baseline-column parts)))
+ (fold i.min column (map find-baseline-column parts)))
([#FormS]
[#TupleS])
[[_ _ column] (#RecordS pairs)]
- (fold min column
+ (fold i.min column
(List/append (map (. find-baseline-column first) pairs)
(map (. find-baseline-column second) pairs)))
))
@@ -4814,13 +4768,15 @@
)]
($_ Text/append "\"" escaped "\"")))
-(do-template [<name> <diff>]
- [(def: #export <name>
- (-> Int Int)
- (i+ <diff>))]
+(do-template [<name> <op> <one> <type>]
+ [(def: #export (<name> value)
+ (-> <type> <type>)
+ (<op> <one> value))]
- [inc 1]
- [dec -1])
+ [i.inc i.+ 1 Int]
+ [i.dec i.- 1 Int]
+ [n.inc n.+ +1 Nat]
+ [n.dec n.- +1 Nat])
(def: tag->Text
(-> Ident Text)
@@ -4828,16 +4784,16 @@
(def: (repeat n x)
(All [a] (-> Int a (List a)))
- (if (i> n 0)
- (#;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])
(-> Int Cursor Cursor Text)
- (if (i= old-line new-line)
- (Text/join (repeat (i- new-column old-column) " "))
- (let [extra-lines (Text/join (repeat (i- new-line old-line) "\n"))
- space-padding (Text/join (repeat (i- new-column baseline) " "))]
+ (if (i.= old-line new-line)
+ (Text/join (repeat (i.- old-column new-column) " "))
+ (let [extra-lines (Text/join (repeat (i.- old-line new-line) "\n"))
+ space-padding (Text/join (repeat (i.- baseline new-column) " "))]
(Text/append extra-lines space-padding))))
(def: (Text/size x)
@@ -4851,11 +4807,11 @@
(def: (update-cursor [file line column] ast-text)
(-> Cursor Text Cursor)
- [file line (i+ column (Text/size ast-text))])
+ [file line (i.+ column (Text/size ast-text))])
(def: (delim-update-cursor [file line column])
(-> Cursor Cursor)
- [file line (inc column)])
+ [file line (i.inc column)])
(def: rejoin-all-pairs
(-> (List [AST AST]) (List AST))
@@ -4926,7 +4882,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (inc count) (f x))
+ (recur (i.inc count) (f x))
x)))"}
(return (list (` (#;TextM (~ (|> tokens
(map (. doc-fragment->Text identify-doc-fragment))
@@ -4998,7 +4954,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (inc count) (f x))
+ (recur (i.inc count) (f x))
x)))}
(case tokens
(^ (list [_ (#TupleS bindings)] body))
@@ -5351,14 +5307,14 @@
(do-template [<type> <even> <odd> <%> <=> <0> <2>]
[(def: #export (<even> n)
(-> <type> Bool)
- (<=> <0> (<%> n <2>)))
+ (<=> <0> (<%> <2> n)))
(def: #export (<odd> n)
(-> <type> Bool)
(not (<even> n)))]
- [Nat even?+ odd?+ n% n= +0 +2]
- [Int even? 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)
(Lux (List Nat))
@@ -5371,19 +5327,19 @@
))
(def: (list-at idx xs)
- (All [a] (-> Int (List a) (Maybe a)))
+ (All [a] (-> Nat (List a) (Maybe a)))
(case xs
#;Nil
#;None
(#;Cons x xs')
- (if (i= 0 idx)
+ (if (n.= +0 idx)
(#;Some x)
- (list-at (dec idx) xs'))))
+ (list-at (n.dec idx) xs'))))
(macro: #export ($ tokens)
(case tokens
- (^ (list [_ (#IntS idx)]))
+ (^ (list [_ (#NatS idx)]))
(do Monad<Lux>
[stvs get-scope-type-vars]
(case (list-at idx (reverse stvs))
@@ -5403,14 +5359,14 @@
(== 5 5))
"This one should fail:"
- (== 5 (+ 2 3)))}
+ (== 5 (i.+ 2 3)))}
(All [a] (-> a a Bool))
(_lux_proc ["lux" "=="] [left right]))
(macro: #export (^@ tokens)
{#;doc (doc "Allows you to simultaneously bind and de-structure a value."
(def: (hash (^@ set [a/Hash _]))
- (List/fold (lambda [elem acc] (+ (:: a/Hash hash elem) acc))
+ (List/fold (lambda [elem acc] (i.+ (:: a/Hash hash elem) acc))
0
(->List set))))}
(case tokens
@@ -5531,11 +5487,3 @@
[real-to-frac ["real" "to-frac"] Real Frac]
[frac-to-real ["frac" "to-real"] Frac Real]
)
-
-(do-template [<name> <op>]
- [(def: #export <name>
- (-> Nat Nat)
- (<op> +1))]
-
- [inc+ ++]
- [dec+ -+])
diff --git a/stdlib/source/lux/codata/struct/stream.lux b/stdlib/source/lux/codata/struct/stream.lux
index 8814ec460..2fd962b38 100644
--- a/stdlib/source/lux/codata/struct/stream.lux
+++ b/stdlib/source/lux/codata/struct/stream.lux
@@ -56,8 +56,8 @@
(def: #export (at idx s)
(All [a] (-> Nat (Stream a) a))
(let [[h t] (cont;run s)]
- (if (>+ +0 idx)
- (at (dec+ idx) t)
+ (if (n.> +0 idx)
+ (at (n.dec idx) t)
h)))
(do-template [<taker> <dropper> <splitter> <pred-type> <pred-test> <pred-step>]
@@ -86,8 +86,8 @@
[(#;Cons [x tail]) next])
[(list) xs])))]
- [take-while drop-while split-with (-> a Bool) (pred x) pred]
- [take drop split Nat (>+ +0 pred) (dec+ pred)]
+ [take-while drop-while split-with (-> a Bool) (pred x) pred]
+ [take drop split Nat (n.> +0 pred) (n.dec pred)]
)
(def: #export (unfold step init)
diff --git a/stdlib/source/lux/compiler.lux b/stdlib/source/lux/compiler.lux
index d7b072a56..66391a5a1 100644
--- a/stdlib/source/lux/compiler.lux
+++ b/stdlib/source/lux/compiler.lux
@@ -339,7 +339,7 @@
(def: #export (gensym prefix)
(-> Text (Lux AST))
(lambda [state]
- (#;Right [(update@ #;seed inc+ state)
+ (#;Right [(update@ #;seed n.inc state)
(ast;symbol ["" ($_ Text/append "__gensym__" prefix (:: number;Codec<Text,Nat> encode (get@ #;seed state)))])])))
(def: (get-local-symbol ast)
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux
index 1eb3cee21..b195a8d6c 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -36,9 +36,9 @@
(def: #export (spawn init [proc on-death])
{#;doc "Given a procedure and initial state, launches an actor and returns it."}
(All [s m] (-> s (Proc s m) (IO (Actor s m))))
- (io (let [mailbox (stm;var (:! ($ 1) []))
+ (io (let [mailbox (stm;var (:! ($ +1) []))
kill-signal (promise;promise Unit)
- obituary (promise;promise [(Maybe Text) ($ 0) (List ($ 1))])
+ obituary (promise;promise [(Maybe Text) ($ +0) (List ($ +1))])
self {#mailbox mailbox
#kill-signal kill-signal
#obituary obituary}
@@ -109,7 +109,7 @@
{#;doc "Given initial-state and a procedure, launches and actor that will reboot if it dies of errors.
However, it can still be killed."}
(All [s m] (-> s (Proc s m) (IO (Actor s m))))
- (io (let [ka-actor (: (Actor (Actor ($ 0) ($ 1)) ($ 1))
+ (io (let [ka-actor (: (Actor (Actor ($ +0) ($ +1)) ($ +1))
(io;run (spawn (io;run (spawn init proc))
{#step (lambda [*self* message server]
(do Monad<Promise>
@@ -126,9 +126,9 @@
(wrap (#;Right new-server))))
))))
#end (lambda [_ server] (exec (io;run (poison server))
- (:: Monad<Promise> wrap [])))})))]
- (update@ #obituary (: (-> (promise;Promise [(Maybe Text) (Actor ($ 0) ($ 1)) (List ($ 1))])
- (promise;Promise [(Maybe Text) ($ 0) (List ($ 1))]))
+ (:: Monad<Promise> wrap [])))})))]
+ (update@ #obituary (: (-> (promise;Promise [(Maybe Text) (Actor ($ +0) ($ +1)) (List ($ +1))])
+ (promise;Promise [(Maybe Text) ($ +0) (List ($ +1))]))
(lambda [process]
(do Monad<Promise>
[[_ server unprocessed-messages-0] process
@@ -205,7 +205,7 @@
[Int Int]
(if (>= 0 to-add)
(do Monad<Promise>
- [#let [new-state (+ to-add *state*)]]
+ [#let [new-state (i.+ to-add *state*)]]
(wrap (#;Right [new-state [*state* new-state]])))
(do Monad<Promise>
[]
@@ -223,7 +223,7 @@
methods)
protocol-pm (List/map (: (-> Method [AST AST])
(lambda [(^slots [#name #vars #args #return #body])]
- (let [arg-names (|> (list;size args) (list;range+ +1) (List/map (|>. Nat/encode [""] ast;symbol)))
+ (let [arg-names (|> (list;size args) (list;n.range +1) (List/map (|>. Nat/encode [""] ast;symbol)))
body-func (` (: (-> (~ g!state-name) (~@ (List/map product;right args)) (promise;Promise (Error [(~ g!state-name) (~ return)])))
(lambda (~ (ast;symbol ["" _name])) [(~ g!state) (~@ (List/map (|>. product;left [""] ast;symbol) args))]
(do promise;Monad<Promise>
@@ -243,7 +243,7 @@
methods)
g!proc (` {#step (lambda [(~ g!self) (~ g!message) (~ g!state)]
(case (~ g!message)
- (~@ (if (=+ +1 (list;size protocol-pm))
+ (~@ (if (n.= +1 (list;size protocol-pm))
(List/join (List/map (lambda [[pattern clause]]
(list pattern clause))
protocol-pm))
@@ -259,7 +259,7 @@
g!actor-name (ast;symbol ["" _name])
g!methods (List/map (: (-> Method AST)
(lambda [(^slots [#name #vars #args #return #body])]
- (let [arg-names (|> (list;size args) (list;range+ +1) (List/map (|>. Nat/encode [""] ast;symbol)))
+ (let [arg-names (|> (list;size args) (list;n.range +1) (List/map (|>. Nat/encode [""] ast;symbol)))
type (` (-> (~@ (List/map product;right args))
(~ g!actor-name)
(promise;Promise (~ return))))]
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux
index 0efa9f837..70f5c38e1 100644
--- a/stdlib/source/lux/concurrency/frp.lux
+++ b/stdlib/source/lux/concurrency/frp.lux
@@ -101,7 +101,7 @@
(def: #export (merge xss)
(All [a] (-> (List (Chan a)) (Chan a)))
- (let [output (chan ($ 0))]
+ (let [output (chan ($ +0))]
(exec (do &;Monad<Promise>
[_ (mapM @ (lambda [input] (pipe' input output)) xss)]
(exec (io;run (close output))
@@ -176,7 +176,7 @@
(wrap (#;Some [a (wrap #;None)]))))
(def: (apply ff fa)
- (let [fb (chan ($ 1))]
+ (let [fb (chan ($ +1))]
(exec (let [(^open) Functor<Chan>]
(map (lambda [f] (pipe (map f fa) fb))
ff))
@@ -186,7 +186,7 @@
(def: applicative Applicative<Chan>)
(def: (join mma)
- (let [output (chan ($ 0))]
+ (let [output (chan ($ +0))]
(exec (let [(^open) Functor<Chan>]
(map (lambda [ma]
(pipe ma output))
diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux
index b765acc4d..2e0c12a15 100644
--- a/stdlib/source/lux/concurrency/promise.lux
+++ b/stdlib/source/lux/concurrency/promise.lux
@@ -125,7 +125,7 @@
(struct: #export _ (Functor Promise)
(def: (map f fa)
- (let [fb (promise ($ 1))]
+ (let [fb (promise ($ +1))]
(exec (await (lambda [a] (do Monad<IO>
[_ (resolve (f a) fb)]
(wrap [])))
@@ -140,7 +140,7 @@
#observers (list)}))
(def: (apply ff fa)
- (let [fb (promise ($ 1))]
+ (let [fb (promise ($ +1))]
(exec (await (lambda [f]
(io (await (lambda [a] (do Monad<IO>
[_ (resolve (f a) fb)]
@@ -154,7 +154,7 @@
(def: applicative Applicative<Promise>)
(def: (join mma)
- (let [ma (promise ($ 0))]
+ (let [ma (promise ($ +0))]
(exec (await (lambda [ma']
(io (await (lambda [a']
(do Monad<IO>
@@ -175,7 +175,7 @@
(def: #export (alt left right)
{#;doc "Heterogeneous alternative combinator."}
(All [a b] (-> (Promise a) (Promise b) (Promise (| a b))))
- (let [a|b (promise (Either ($ 0) ($ 1)))]
+ (let [a|b (promise (Either ($ +0) ($ +1)))]
(let% [<sides> (do-template [<promise> <tag>]
[(await (lambda [value]
(do Monad<IO>
@@ -192,7 +192,7 @@
(def: #export (either left right)
{#;doc "Homogeneous alternative combinator."}
(All [a] (-> (Promise a) (Promise a) (Promise a)))
- (let [left||right (promise ($ 0))]
+ (let [left||right (promise ($ +0))]
(let% [<sides> (do-template [<promise>]
[(await [(lambda [value]
(do Monad<IO>
@@ -209,7 +209,7 @@
(def: #export (future computation)
{#;doc "Runs computation on it's own process and returns an Promise that will eventually host it's result."}
(All [a] (-> (IO a) (Promise a)))
- (let [!out (promise ($ 0))]
+ (let [!out (promise ($ +0))]
(exec (Thread.start [] (Thread.new [(runnable (io;run (resolve (io;run computation)
!out)))]))
!out)))
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index 80633a41e..cf9624409 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -52,7 +52,7 @@
(def: (find-var-value var tx)
(All [a] (-> (Var a) Tx (Maybe a)))
- (:! (Maybe ($ 0))
+ (:! (Maybe ($ +0))
(find (: (-> (Ex [a] (Tx-Frame a))
(Maybe Unit))
(lambda [[_var _original _current]]
@@ -89,11 +89,11 @@
#;Nil
(#;Cons [_var _original _current] tx')
- (if (== (:! (Var ($ 0)) var)
- (:! (Var ($ 0)) _var))
- (#;Cons [(:! (Var ($ 0)) _var)
- (:! ($ 0) _original)
- (:! ($ 0) _current)]
+ (if (== (:! (Var ($ +0)) var)
+ (:! (Var ($ +0)) _var))
+ (#;Cons [(:! (Var ($ +0)) _var)
+ (:! ($ +0) _original)
+ (:! ($ +0) _current)]
tx')
(#;Cons [_var _original _current]
(update-tx-value var value tx')))
@@ -138,7 +138,7 @@
(def: #export (follow label target)
{#;doc "Creates a channel (identified by a given text) that will receive all changes to the value of the given var."}
(All [a] (-> Text (Var a) (IO (frp;Chan a))))
- (let [head (frp;chan ($ 0))
+ (let [head (frp;chan ($ +0))
chan-var (var head)
observer (lambda [value]
(case (io;run (|> chan-var raw-read (frp;write value)))
diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux
index 801dbb479..420771d23 100644
--- a/stdlib/source/lux/control/comonad.lux
+++ b/stdlib/source/lux/control/comonad.lux
@@ -22,9 +22,9 @@
## [Syntax]
(macro: #export (be tokens state)
{#;doc (doc "A co-monadic parallel to the \"do\" macro."
- (let [square (lambda [n] (* n n))]
+ (let [square (lambda [n] (i.* n n))]
(be CoMonad<Stream>
- [inputs (iterate inc 2)]
+ [inputs (iterate i.inc 2)]
(square (head inputs)))))}
(case tokens
(#;Cons comonad (#;Cons [_ (#;TupleS bindings)] (#;Cons body #;Nil)))
diff --git a/stdlib/source/lux/control/effect.lux b/stdlib/source/lux/control/effect.lux
index cbd24c7f9..142e308ea 100644
--- a/stdlib/source/lux/control/effect.lux
+++ b/stdlib/source/lux/control/effect.lux
@@ -181,7 +181,7 @@
g!params (: (List AST)
(case (list;size (get@ #inputs op))
+0 (list)
- s (|> (list;range+ +0 (dec+ s))
+ s (|> (list;n.range +0 (n.dec s))
(List/map (|>. Nat/encode
(format "_")
[""]
diff --git a/stdlib/source/lux/control/ord.lux b/stdlib/source/lux/control/ord.lux
index 0021cbe1b..7acc97172 100644
--- a/stdlib/source/lux/control/ord.lux
+++ b/stdlib/source/lux/control/ord.lux
@@ -4,7 +4,7 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;module:
- [lux #- min max]
+ lux
(.. eq)
lux/codata/function)
diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux
index 72a92507c..2562adc2d 100644
--- a/stdlib/source/lux/data/bit.lux
+++ b/stdlib/source/lux/data/bit.lux
@@ -49,7 +49,7 @@
(def: #export (set? idx input)
(-> Nat Nat Bool)
- (|> input (& (<< idx +1)) (=+ +0) not))
+ (|> input (& (<< idx +1)) (n.= +0) not))
(def: rot-top Nat +64)
@@ -57,8 +57,8 @@
[(def: #export (<name> distance input)
(-> Nat Nat Nat)
(| (<main> distance input)
- (<comp> (-+ (%+ rot-top distance)
- rot-top)
+ (<comp> (n.- (n.% rot-top distance)
+ rot-top)
input)))]
[rotate-left << >>>]
diff --git a/stdlib/source/lux/data/char.lux b/stdlib/source/lux/data/char.lux
index 6af987408..9c9baaf20 100644
--- a/stdlib/source/lux/data/char.lux
+++ b/stdlib/source/lux/data/char.lux
@@ -62,9 +62,9 @@
(let [size (text;size y)]
(if (and (text;starts-with? "#\"" y)
(text;ends-with? "\"" y)
- (or (=+ +4 size)
- (=+ +5 size)))
- (if (=+ +4 size)
+ (or (n.= +4 size)
+ (n.= +5 size)))
+ (if (n.= +4 size)
(case (text;at +2 y)
#;None
(#;Left (Text/append "Wrong syntax for Char: " y))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index d48b5b97a..04e462feb 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -602,7 +602,7 @@
(-> Nat (Parser Unit))
(case json
(#Array parts)
- (if (=+ array-size (vector;size parts))
+ (if (n.= array-size (vector;size parts))
(#;Right [])
(#;Left (format "JSON array does no have size " (%n array-size) " " (show-json json))))
@@ -614,7 +614,7 @@
(case json
(#Object kvs)
(let [actual-fields (dict;keys kvs)]
- (if (and (=+ (list;size wanted-fields) (list;size actual-fields))
+ (if (and (n.= (list;size wanted-fields) (list;size actual-fields))
(list;every? (list;member? text;Eq<Text> wanted-fields)
actual-fields))
(#;Right [])
@@ -638,7 +638,7 @@
[#String text;Eq<Text>])
[(#Array xs) (#Array ys)]
- (and (=+ (vector;size xs) (vector;size ys))
+ (and (n.= (vector;size xs) (vector;size ys))
(fold (lambda [idx prev]
(and prev
(default false
@@ -650,7 +650,7 @@
(list;indices (vector;size xs))))
[(#Object xs) (#Object ys)]
- (and (=+ (dict;size xs) (dict;size ys))
+ (and (n.= (dict;size xs) (dict;size ys))
(fold (lambda [[xk xv] prev]
(and prev
(case (dict;get xk ys)
diff --git a/stdlib/source/lux/data/ident.lux b/stdlib/source/lux/data/ident.lux
index 4f85da77d..1d87546fb 100644
--- a/stdlib/source/lux/data/ident.lux
+++ b/stdlib/source/lux/data/ident.lux
@@ -54,4 +54,4 @@
(def: (hash [module name])
(let [(^open) text;Hash<Text>]
- (*+ (hash module) (hash name)))))
+ (n.* (hash module) (hash name)))))
diff --git a/stdlib/source/lux/data/log.lux b/stdlib/source/lux/data/log.lux
index 9e6be6d56..6b6cd2095 100644
--- a/stdlib/source/lux/data/log.lux
+++ b/stdlib/source/lux/data/log.lux
@@ -48,9 +48,9 @@
(def: applicative (A;compA (get@ #M;applicative Monad<M>) (Applicative<Log> Monoid<l>)))
(def: (join MlMla)
(do Monad<M>
- [[l1 Mla] (: (($ 1) (Log ($ 0) (($ 1) (Log ($ 0) ($ 2)))))
+ [[l1 Mla] (: (($ +1) (Log ($ +0) (($ +1) (Log ($ +0) ($ +2)))))
MlMla)
- [l2 a] (: (($ 1) (Log ($ 0) ($ 2)))
+ [l2 a] (: (($ +1) (Log ($ +0) ($ +2)))
Mla)]
(wrap [(:: Monoid<l> append l1 l2) a]))))
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 41c75402e..88cdc4eaf 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -20,10 +20,10 @@
[(struct: #export _ (Eq <type>)
(def: = <test>))]
- [ Nat =+]
- [ Int =]
- [Frac =..]
- [Real =.]
+ [ Nat n.=]
+ [ Int i.=]
+ [Frac f.=]
+ [Real r.=]
)
(do-template [<type> <eq> <lt> <lte> <gt> <gte>]
@@ -34,19 +34,19 @@
(def: > <gt>)
(def: >= <gte>))]
- [ Nat Eq<Nat> <+ <=+ >+ >=+]
- [ Int Eq<Int> < <= > >=]
- [Frac Eq<Frac> <.. <=.. >.. >=..]
- [Real Eq<Real> <. <=. >. >=.]
+ [ Nat Eq<Nat> n.< n.<= n.> n.>=]
+ [ Int Eq<Int> i.< i.<= i.> i.>=]
+ [Frac Eq<Frac> f.< f.<= f.> f.>=]
+ [Real Eq<Real> r.< r.<= r.> r.>=]
)
(struct: #export _ (Number Nat)
(def: ord Ord<Nat>)
- (def: + ++)
- (def: - -+)
- (def: * *+)
- (def: / /+)
- (def: % %+)
+ (def: + n.+)
+ (def: - n.-)
+ (def: * n.*)
+ (def: / n./)
+ (def: % n.%)
(def: negate id)
(def: abs id)
(def: (signum x)
@@ -75,8 +75,8 @@
<1>))
)]
- [ Int Ord<Int> + - * / % = < 0 1 -1]
- [Real Ord<Real> +. -. *. /. %. =. <. 0.0 1.0 -1.0]
+ [ Int Ord<Int> i.+ i.- i.* i./ i.% i.= i.< 0 1 -1]
+ [Real Ord<Real> r.+ r.- r.* r./ r.% r.= r.< 0.0 1.0 -1.0]
)
(do-template [<type> <ord> <succ> <pred>]
@@ -85,8 +85,8 @@
(def: succ <succ>)
(def: pred <pred>))]
- [Nat Ord<Nat> (++ +1) (-+ +1)]
- [Int Ord<Int> inc dec]
+ [Nat Ord<Nat> n.inc n.dec]
+ [Int Ord<Int> i.inc i.dec]
)
(do-template [<type> <top> <bottom>]
@@ -103,18 +103,18 @@
(def: unit <unit>)
(def: (append x y) (<append> x y)))]
- [ Add@Monoid<Nat> Nat +0 ++]
- [ Mul@Monoid<Nat> Nat +1 *+]
- [ Max@Monoid<Nat> Nat (:: Bounded<Nat> bottom) max+]
- [ Min@Monoid<Nat> Nat (:: Bounded<Nat> top) min+]
- [ Add@Monoid<Int> Int 0 +]
- [ Mul@Monoid<Int> Int 1 *]
- [ Max@Monoid<Int> Int (:: Bounded<Int> bottom) max]
- [ Min@Monoid<Int> Int (:: Bounded<Int> top) min]
- [Add@Monoid<Real> Real 0.0 +.]
- [Mul@Monoid<Real> Real 1.0 *.]
- [Max@Monoid<Real> Real (:: Bounded<Real> bottom) max.]
- [Min@Monoid<Real> Real (:: Bounded<Real> top) min.]
+ [ Add@Monoid<Nat> Nat +0 n.+]
+ [ Mul@Monoid<Nat> Nat +1 n.*]
+ [ Max@Monoid<Nat> Nat (:: Bounded<Nat> bottom) n.max]
+ [ Min@Monoid<Nat> Nat (:: Bounded<Nat> top) n.min]
+ [ Add@Monoid<Int> Int 0 i.+]
+ [ Mul@Monoid<Int> Int 1 i.*]
+ [ Max@Monoid<Int> Int (:: Bounded<Int> bottom) i.max]
+ [ Min@Monoid<Int> Int (:: Bounded<Int> top) i.min]
+ [Add@Monoid<Real> Real 0.0 r.+]
+ [Mul@Monoid<Real> Real 1.0 r.*]
+ [Max@Monoid<Real> Real (:: Bounded<Real> bottom) r.max]
+ [Min@Monoid<Real> Real (:: Bounded<Real> top) r.min]
)
(def: (text.replace pattern value template)
diff --git a/stdlib/source/lux/data/struct/array.lux b/stdlib/source/lux/data/struct/array.lux
index 6c81683d3..3a3c6bfaa 100644
--- a/stdlib/source/lux/data/struct/array.lux
+++ b/stdlib/source/lux/data/struct/array.lux
@@ -47,17 +47,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 (=+ +0 length)
+ (if (n.= +0 length)
dest-array
(List/fold (lambda [offset target]
- (case (get (++ offset src-start) src-array)
+ (case (get (n.+ offset src-start) src-array)
#;None
target
(#;Some value)
- (put (++ offset dest-start) value target)))
+ (put (n.+ offset dest-start) value target)))
dest-array
- (list;range+ +0 (dec+ length)))))
+ (list;n.range +0 (n.dec length)))))
(def: #export (occupied array)
{#;doc "Finds out how many cells in an array are occupied."}
@@ -68,19 +68,19 @@
count
(#;Some _)
- (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))
- (-+ (occupied array) (size array)))
+ (n.- (occupied array) (size array)))
(def: #export (filter p xs)
(All [a]
(-> (-> a Bool) (Array a) (Array a)))
- (List/fold (: (-> Nat (Array ($ 0)) (Array ($ 0)))
+ (List/fold (: (-> Nat (Array ($ +0)) (Array ($ +0)))
(lambda [idx xs']
(case (get idx xs)
#;None
@@ -98,15 +98,15 @@
(-> (-> a Bool) (Array a) (Maybe a)))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (<+ arr-size idx)
+ (if (n.< arr-size idx)
(case (get idx xs)
#;None
- (recur (inc+ idx))
+ (recur (n.inc idx))
(#;Some x)
(if (p x)
(#;Some x)
- (recur (inc+ idx))))
+ (recur (n.inc idx))))
#;None))))
(def: #export (find+ p xs)
@@ -115,15 +115,15 @@
(-> (-> Nat a Bool) (Array a) (Maybe [Nat a])))
(let [arr-size (size xs)]
(loop [idx +0]
- (if (<+ arr-size idx)
+ (if (n.< arr-size idx)
(case (get idx xs)
#;None
- (recur (inc+ idx))
+ (recur (n.inc idx))
(#;Some x)
(if (p idx x)
(#;Some [idx x])
- (recur (inc+ idx))))
+ (recur (n.inc idx))))
#;None))))
(def: #export (clone xs)
@@ -142,7 +142,7 @@
(def: #export (from-list xs)
(All [a] (-> (List a) (Array a)))
(product;right (List/fold (lambda [x [idx arr]]
- [(inc+ idx) (put idx x arr)])
+ [(n.inc idx) (put idx x arr)])
[+0 (new (list;size xs))]
xs)))
@@ -152,11 +152,11 @@
(product;right (List/fold (lambda [_ [idx tail]]
(case (get idx array)
(#;Some head)
- [(dec+ idx) (#;Cons head tail)]
+ [(n.dec idx) (#;Cons head tail)]
#;None
- [(dec+ idx) tail]))
- [(dec+ _size) #;Nil]
+ [(n.dec idx) tail]))
+ [(n.dec _size) #;Nil]
(list;repeat _size [])
))))
@@ -166,7 +166,7 @@
(def: (= xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (and (lux;=+ sxy sxs)
+ (and (n.= sxy sxs)
(List/fold (lambda [idx prev]
(and prev
(case [(get idx xs) (get idx ys)]
@@ -179,7 +179,7 @@
_
false)))
true
- (list;range+ +0 (dec+ sxs)))))
+ (list;n.range +0 (n.dec sxs)))))
))
(struct: #export Monoid<Array> (All [a]
@@ -189,16 +189,16 @@
(def: (append xs ys)
(let [sxs (size xs)
sxy (size ys)]
- (|> (new (++ 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 (=+ +0 arr-size)
+ (if (n.= +0 arr-size)
(new arr-size)
- (List/fold (: (-> Nat (Array ($ 1)) (Array ($ 1)))
+ (List/fold (: (-> Nat (Array ($ +1)) (Array ($ +1)))
(lambda [idx mb]
(case (get idx ma)
#;None
@@ -207,18 +207,18 @@
(#;Some x)
(put idx (f x) mb))))
(new arr-size)
- (list;range+ +0 (dec+ arr-size)))))))
+ (list;n.range +0 (n.dec arr-size)))))))
(struct: #export _ (Fold Array)
(def: (fold f init xs)
(let [arr-size (size xs)]
(loop [so-far init
idx +0]
- (if (<+ arr-size idx)
+ (if (n.< arr-size idx)
(case (get idx xs)
#;None
- (recur so-far (inc+ idx))
+ (recur so-far (n.inc idx))
(#;Some value)
- (recur (f value so-far) (inc+ idx)))
+ (recur (f value so-far) (n.inc idx)))
so-far)))))
diff --git a/stdlib/source/lux/data/struct/dict.lux b/stdlib/source/lux/data/struct/dict.lux
index a10e30dca..d4cbaa7ec 100644
--- a/stdlib/source/lux/data/struct/dict.lux
+++ b/stdlib/source/lux/data/struct/dict.lux
@@ -103,13 +103,13 @@
## which is 1/4 of the branching factor (or a left-shift 2).
(def: demotion-threshold
Nat
- (bit;<< (-+ +2 branching-exponent) +1))
+ (bit;<< (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;<< (-+ +1 branching-exponent) +1))
+ (bit;<< (n.- +1 branching-exponent) +1))
## The size of hierarchy-nodes, which is 2^(branching-exponent).
(def: hierarchy-nodes-size
@@ -126,11 +126,11 @@
(def: (insert! idx value old-array)
(All [a] (-> Index a (Array a) (Array a)))
(let [old-size (array;size old-array)]
- (|> (: (Array ($ 0))
- (array;new (inc+ old-size)))
+ (|> (: (Array ($ +0))
+ (array;new (n.inc old-size)))
(array;copy idx +0 old-array +0)
(array;put idx value)
- (array;copy (-+ idx old-size) idx old-array (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)
@@ -145,23 +145,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 (dec+ (array;size array))]
+ (let [new-size (n.dec (array;size array))]
(|> (array;new new-size)
(array;copy idx +0 array +0)
- (array;copy (-+ idx new-size) (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))
- (|>. dec+ (list;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)
- (++ branching-exponent))
+ (n.+ branching-exponent))
-(def: hierarchy-mask BitMap (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.
@@ -182,12 +182,12 @@
(def: (bit-position-is-set? bit bitmap)
(-> BitPosition BitMap Bool)
- (not (=+ clean-bitmap (bit;& bit bitmap))))
+ (not (n.= clean-bitmap (bit;& bit bitmap))))
## Figures out whether a bitmap only contains a single bit-position.
(def: only-bit-position?
(-> BitPosition BitMap Bool)
- =+)
+ n.=)
(def: (set-bit-position bit bitmap)
(-> BitPosition BitMap BitMap)
@@ -208,7 +208,7 @@
## associated with it.
(def: bit-position-mask
(-> BitPosition BitMap)
- dec+)
+ n.dec)
## The index on the base array, based on it's bit-position.
(def: (base-index bit-position bitmap)
@@ -231,14 +231,14 @@
(List/fold (lambda [idx (^@ node [bitmap base])]
(case (array;get idx h-array)
#;None node
- (#;Some sub-node) (if (=+ except-idx idx)
+ (#;Some sub-node) (if (n.= except-idx idx)
node
[(set-bit-position (->bit-position idx) bitmap)
(array;put idx (#;Left sub-node) base)])
))
[clean-bitmap
- (: (Base ($ 0) ($ 1))
- (array;new (dec+ h-size)))]
+ (: (Base ($ +0) ($ +1))
+ (array;new (n.dec h-size)))]
(list;indices (array;size h-array))))
## When #Base nodes grow too large, they're promoted to #Hierarchy to
@@ -252,7 +252,7 @@
(product;right (List/fold (lambda [hierarchy-idx (^@ default [base-idx h-array])]
(if (bit-position-is-set? (->bit-position hierarchy-idx)
bitmap)
- [(inc+ base-idx)
+ [(n.inc base-idx)
(case (array;get base-idx base)
(#;Some (#;Left sub-node))
(array;put hierarchy-idx sub-node h-array)
@@ -266,7 +266,7 @@
(undefined))]
default))
[+0
- (: (Array (Node ($ 0) ($ 1)))
+ (: (Array (Node ($ +0) ($ +1)))
(array;new hierarchy-nodes-size))]
(indices-for hierarchy-nodes-size))))
@@ -289,13 +289,13 @@
## a sub-node. If impossible, I introduced a new singleton sub-node.
(#Hierarchy _size hierarchy)
(let [idx (level-index level hash)
- [_size' sub-node] (: [Nat (Node ($ 0) ($ 1))]
+ [_size' sub-node] (: [Nat (Node ($ +0) ($ +1))]
(case (array;get idx hierarchy)
(#;Some sub-node)
[_size sub-node]
_
- [(inc+ _size) empty]))]
+ [(n.inc _size) empty]))]
(#Hierarchy _size'
(update! idx (put' (level-up level) hash key val Hash<K> sub-node)
hierarchy)))
@@ -324,12 +324,12 @@
## Otherwise, I compare the hashes of the keys.
(#Base bitmap (update! idx
(#;Left (let [hash' (:: Hash<K> hash key')]
- (if (=+ hash hash')
+ (if (n.= hash hash')
## If the hashes are
## the same, a new
## #Collisions node
## is added.
- (#Collisions hash (|> (: (Array [($ 0) ($ 1)])
+ (#Collisions hash (|> (: (Array [($ +0) ($ +1)])
(array;new +2))
(array;put +0 [key' val'])
(array;put +1 [key val])))
@@ -346,10 +346,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 (>=+ 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 (inc+ base-count)
+ (#Hierarchy (n.inc base-count)
(|> (promote-base put' Hash<K> level bitmap base)
(array;put (level-index level hash)
(put' (level-up level) hash key val Hash<K> empty))))
@@ -360,7 +360,7 @@
## For #Collisions nodes, I compare the hashes.
(#Collisions _hash _colls)
- (if (=+ 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)
@@ -375,7 +375,7 @@
## If the hashes are not equal, I create a new #Base node that
## contains the old #Collisions node, plus the new KV-pair.
(|> (#Base (bit-position level _hash)
- (|> (: (Base ($ 0) ($ 1))
+ (|> (: (Base ($ +0) ($ +1))
(array;new +1))
(array;put +0 (#;Left node))))
(put' level hash key val Hash<K>)))
@@ -403,11 +403,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 (<=+ 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 (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)))))))
@@ -465,7 +465,7 @@
## But if so, then check the size of the collisions list.
(#;Some idx)
- (if (=+ +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
@@ -510,14 +510,14 @@
(All [K V] (-> (Node K V) Nat))
(case node
(#Hierarchy _size hierarchy)
- (Array/fold ++ +0 (Array/map size' hierarchy))
+ (Array/fold n.+ +0 (Array/map size' hierarchy))
(#Base _ base)
- (Array/fold ++ +0 (Array/map (lambda [sub-node']
- (case sub-node'
- (#;Left sub-node) (size' sub-node)
- (#;Right _) +1))
- base))
+ (Array/fold n.+ +0 (Array/map (lambda [sub-node']
+ (case sub-node'
+ (#;Left sub-node) (size' sub-node)
+ (#;Right _) +1))
+ base))
(#Collisions hash colls)
(array;size colls)
@@ -599,7 +599,7 @@
(def: #export empty?
(All [K V] (-> (Dict K V) Bool))
- (|>. size (=+ +0)))
+ (|>. size (n.= +0)))
(def: #export (entries dict)
(All [K V] (-> (Dict K V) (List [K V])))
@@ -663,8 +663,8 @@
## [Structures]
(struct: #export (Eq<Dict> Eq<v>) (All [k v] (-> (Eq v) (Eq (Dict k v))))
(def: (= test subject)
- (and (=+ (size test)
- (size subject))
+ (and (n.= (size test)
+ (size subject))
(list;every? (lambda [k]
(case [(get k test) (get k subject)]
[(#;Some tk) (#;Some sk)]
diff --git a/stdlib/source/lux/data/struct/list.lux b/stdlib/source/lux/data/struct/list.lux
index 7d71e4faa..acd48d730 100644
--- a/stdlib/source/lux/data/struct/list.lux
+++ b/stdlib/source/lux/data/struct/list.lux
@@ -69,7 +69,7 @@
[(def: #export (<name> n xs)
(All [a]
(-> Nat (List a) (List a)))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(case xs
#;Nil
#;Nil
@@ -78,8 +78,8 @@
<then>)
<else>))]
- [take (#;Cons [x (take (-+ +1 n) xs')]) #;Nil]
- [drop (drop (-+ +1 n) xs') xs]
+ [take (#;Cons [x (take (n.dec n) xs')]) #;Nil]
+ [drop (drop (n.dec n) xs') xs]
)
(do-template [<name> <then> <else>]
@@ -102,13 +102,13 @@
(def: #export (split n xs)
(All [a]
(-> Nat (List a) [(List a) (List a)]))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(case xs
#;Nil
[#;Nil #;Nil]
(#;Cons [x xs'])
- (let [[tail rest] (split (-+ +1 n) xs')]
+ (let [[tail rest] (split (n.dec n) xs')]
[(#;Cons [x tail]) rest]))
[#;Nil xs]))
@@ -143,8 +143,8 @@
(def: #export (repeat n x)
(All [a]
(-> Nat a (List a)))
- (if (>+ +0 n)
- (#;Cons [x (repeat (dec+ n) x)])
+ (if (n.> +0 n)
+ (#;Cons [x (repeat (n.dec n) x)])
#;Nil))
(def: (iterate' f x)
@@ -194,7 +194,7 @@
(def: #export (size list)
(All [a] (-> (List a) Nat))
- (fold (lambda [_ acc] (++ +1 acc)) +0 list))
+ (fold (lambda [_ acc] (n.+ +1 acc)) +0 list))
(do-template [<name> <init> <op>]
[(def: #export (<name> p xs)
@@ -213,9 +213,9 @@
#;None
(#;Cons [x xs'])
- (if (=+ +0 i)
+ (if (n.= +0 i)
(#;Some x)
- (at (-+ +1 i) xs'))))
+ (at (n.dec i) xs'))))
## [Structures]
(struct: #export (Eq<List> (^open "a:"))
@@ -293,8 +293,8 @@
(list& from (<name> (<inc> from) to))
(list)))]
- [range Int <= inc]
- [range+ Nat <=+ inc+]
+ [i.range Int i.<= i.inc]
+ [n.range Nat n.<= n.inc]
)
(def: #export (empty? xs)
@@ -336,16 +336,16 @@
((zip 3) xs ys zs))}
(case tokens
(^ (list [_ (#;IntS num-lists)]))
- (if (> 0 num-lists)
+ (if (i.> 0 num-lists)
(let [(^open) Functor<List>
- indices (range 0 (dec num-lists))
+ indices (i.range 0 (i.dec num-lists))
type-vars (: (List AST) (map (. symbol$ Int/encode) indices))
zip-type (` (All [(~@ type-vars)]
(-> (~@ (map (: (-> AST AST) (lambda [var] (` (List (~ var)))))
type-vars))
(List [(~@ type-vars)]))))
vars+lists (|> indices
- (map inc)
+ (map i.inc)
(map (lambda [idx]
[(symbol$ (Int/encode idx))
(symbol$ (Int/encode (Int/negate idx)))])))
@@ -376,12 +376,12 @@
{#;doc (doc "Create list zip-with`s with the specified number of input lists."
(def: #export zip2-with (zip-with 2))
(def: #export zip3-with (zip-with 3))
- ((zip-with 2) + xs ys))}
+ ((zip-with 2) i.+ xs ys))}
(case tokens
(^ (list [_ (#;IntS num-lists)]))
- (if (> 0 num-lists)
+ (if (i.> 0 num-lists)
(let [(^open) Functor<List>
- indices (range 0 (dec num-lists))
+ indices (i.range 0 (i.dec num-lists))
g!return-type (symbol$ "\treturn-type\t")
g!func (symbol$ "\tfunc\t")
type-vars (: (List AST) (map (. symbol$ Int/encode) indices))
@@ -391,7 +391,7 @@
type-vars))
(List (~ g!return-type)))))
vars+lists (|> indices
- (map inc)
+ (map i.inc)
(map (lambda [idx]
[(symbol$ (Int/encode idx))
(symbol$ (Int/encode (Int/negate idx)))])))
@@ -458,7 +458,7 @@
(def: (join MlMla)
(do Monad<M>
[lMla MlMla
- lla (: (($ 0) (List (List ($ 1))))
+ lla (: (($ +0) (List (List ($ +1))))
(mapM @ join lMla))]
(wrap (concat lla)))))
@@ -473,7 +473,7 @@
#;Nil
(#;Cons x xs')
- (#;Cons [idx x] (enumerate' (inc+ idx) xs'))))
+ (#;Cons [idx x] (enumerate' (n.inc idx) xs'))))
(def: #export (enumerate xs)
(All [a] (-> (List a) (List [Nat a])))
@@ -482,6 +482,6 @@
(def: #export (indices size)
{#;doc "Produces all the valid indices for a given size."}
(All [a] (-> Nat (List Nat)))
- (if (=+ +0 size)
+ (if (n.= +0 size)
(list)
- (|> size dec+ (range+ +0))))
+ (|> size n.dec (n.range +0))))
diff --git a/stdlib/source/lux/data/struct/queue.lux b/stdlib/source/lux/data/struct/queue.lux
index 61b97c9cd..e22f0bb81 100644
--- a/stdlib/source/lux/data/struct/queue.lux
+++ b/stdlib/source/lux/data/struct/queue.lux
@@ -36,8 +36,8 @@
(def: #export (size queue)
(All [a] (-> (Queue a) Nat))
(let [(^slots [#front #rear]) queue]
- (++ (list;size front)
- (list;size rear))))
+ (n.+ (list;size front)
+ (list;size rear))))
(def: #export empty?
(All [a] (-> (Queue a) Bool))
diff --git a/stdlib/source/lux/data/struct/set.lux b/stdlib/source/lux/data/struct/set.lux
index 085c0f047..44a383e7c 100644
--- a/stdlib/source/lux/data/struct/set.lux
+++ b/stdlib/source/lux/data/struct/set.lux
@@ -53,7 +53,7 @@
(def: #export (empty? set)
(All [a] (-> (Set a) Bool))
- (=+ +0 (dict;size set)))
+ (n.= +0 (dict;size set)))
(def: #export to-list
(All [a] (-> (Set a) (List a)))
@@ -80,6 +80,6 @@
(def: eq Eq<Set>)
(def: (hash (^@ set [Hash<a> _]))
- (List/fold (lambda [elem acc] (++ (:: Hash<a> hash elem) acc))
+ (List/fold (lambda [elem acc] (n.+ (:: Hash<a> hash elem) acc))
+0
(to-list set))))
diff --git a/stdlib/source/lux/data/struct/vector.lux b/stdlib/source/lux/data/struct/vector.lux
index 9c04bc173..7e00a00b7 100644
--- a/stdlib/source/lux/data/struct/vector.lux
+++ b/stdlib/source/lux/data/struct/vector.lux
@@ -51,8 +51,8 @@
(-> Level Level)
(<op> branching-exponent))]
- [level-up ++]
- [level-down -+]
+ [level-up n.+]
+ [level-down n.-]
)
(def: full-node-size
@@ -61,7 +61,7 @@
(def: branch-idx-mask
Nat
- (dec+ full-node-size))
+ (n.dec full-node-size))
(def: branch-idx
(-> Index Index)
@@ -73,32 +73,32 @@
(def: (tail-off vec-size)
(-> Nat Nat)
- (if (<+ full-node-size vec-size)
+ (if (n.< full-node-size vec-size)
+0
- (|> (dec+ vec-size)
+ (|> (n.dec vec-size)
(bit;>>> branching-exponent)
(bit;<< branching-exponent))))
(def: (new-path level tail)
(All [a] (-> Level (Base a) (Node a)))
- (if (=+ +0 level)
+ (if (n.= +0 level)
(#Base tail)
- (|> (: (Hierarchy ($ 0))
+ (|> (: (Hierarchy ($ +0))
(new-hierarchy []))
(array;put +0 (new-path (level-down level) tail))
#Hierarchy)))
(def: (new-tail singleton)
(All [a] (-> a (Base a)))
- (|> (: (Base ($ 0))
+ (|> (: (Base ($ +0))
(array;new +1))
(array;put +0 singleton)))
(def: (push-tail size level tail parent)
(All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a)))
- (let [sub-idx (branch-idx (bit;>>> level (dec+ size)))
+ (let [sub-idx (branch-idx (bit;>>> level (n.dec size)))
## If we're currently on a bottom node
- sub-node (if (=+ 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
@@ -119,8 +119,8 @@
(def: (expand-tail val tail)
(All [a] (-> a (Base a) (Base a)))
(let [tail-size (array;size tail)]
- (|> (: (Base ($ 0))
- (array;new (inc+ tail-size)))
+ (|> (: (Base ($ +0))
+ (array;new (n.inc tail-size)))
(array;copy tail-size +0 tail +0)
(array;put tail-size val)
)))
@@ -134,7 +134,7 @@
(array;put sub-idx (#Hierarchy (put' (level-down level) idx val sub-node))))
(^=> (#;Some (#Base base))
- (=+ +0 (level-down level)))
+ (n.= +0 (level-down level)))
(|> (array;clone hierarchy)
(array;put sub-idx (|> (array;clone base)
(array;put (branch-idx idx) val)
@@ -145,11 +145,11 @@
(def: (pop-tail size level hierarchy)
(All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a))))
- (let [sub-idx (branch-idx (bit;>>> level (-+ +2 size)))]
- (cond (=+ +0 sub-idx)
+ (let [sub-idx (branch-idx (bit;>>> level (n.- +2 size)))]
+ (cond (n.= +0 sub-idx)
#;None
- (>+ branching-exponent level)
+ (n.> branching-exponent level)
(do Monad<Maybe>
[base|hierarchy (array;get sub-idx hierarchy)
sub (case base|hierarchy
@@ -204,20 +204,20 @@
(All [a] (-> a (Vector a) (Vector a)))
## Check if there is room in the tail.
(let [vec-size (get@ #size vec)]
- (if (|> vec-size (-+ (tail-off vec-size)) (<+ full-node-size))
+ (if (|> vec-size (n.- (tail-off vec-size)) (n.< full-node-size))
## If so, append to it.
(|> vec
- (update@ #size 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 (>+ (bit;<< (get@ #level vec) +1)
- (bit;>>> branching-exponent vec-size))
+ (|> (if (n.> (bit;<< (get@ #level vec) +1)
+ (bit;>>> branching-exponent vec-size))
## If so, a brand-new root must be established, that is
## 1-level taller.
(|> vec
- (set@ #root (|> (: (Hierarchy ($ 0))
+ (set@ #root (|> (: (Hierarchy ($ +0))
(new-hierarchy []))
(array;put +0 (#Hierarchy (get@ #root vec)))
(array;put +1 (new-path (get@ #level vec) (get@ #tail vec)))))
@@ -227,20 +227,20 @@
(update@ #root (push-tail vec-size (get@ #level vec) (get@ #tail vec)))))
## Finally, update the size of the Vector and grow a new
## tail with the new element as it's sole member.
- (update@ #size inc+)
+ (update@ #size n.inc)
(set@ #tail (new-tail val)))
)))
(def: (base-for idx vec)
(All [a] (-> Index (Vector a) (Maybe (Base a))))
(let [vec-size (get@ #size vec)]
- (if (and (>=+ +0 idx)
- (<+ vec-size idx))
- (if (>=+ (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 [(>+ branching-exponent level)
+ (case [(n.> branching-exponent level)
(array;get (branch-idx (bit;>>> level idx)) hierarchy)]
[true (#;Some (#Hierarchy sub))]
(recur (level-down level) sub)
@@ -264,11 +264,11 @@
(def: #export (put idx val vec)
(All [a] (-> Nat a (Vector a) (Vector a)))
(let [vec-size (get@ #size vec)]
- (if (and (>=+ +0 idx)
- (<+ vec-size idx))
- (if (>=+ (tail-off vec-size) idx)
+ (if (and (n.>= +0 idx)
+ (n.< vec-size idx))
+ (if (n.>= (tail-off vec-size) idx)
(|> vec
- (update@ #tail (: (-> (Base ($ 0)) (Base ($ 0)))
+ (update@ #tail (: (-> (Base ($ +0)) (Base ($ +0)))
(|>. array;clone (array;put (branch-idx idx) val)))))
(|> vec
(update@ #root (put' (get@ #level vec) idx val))))
@@ -293,23 +293,23 @@
empty
vec-size
- (if (|> vec-size (-+ (tail-off vec-size)) (>+ +1))
+ (if (|> vec-size (n.- (tail-off vec-size)) (n.> +1))
(let [old-tail (get@ #tail vec)
- new-tail-size (dec+ (array;size old-tail))]
+ new-tail-size (n.dec (array;size old-tail))]
(|> vec
- (update@ #size dec+)
+ (update@ #size n.dec)
(set@ #tail (|> (array;new new-tail-size)
(array;copy new-tail-size +0 old-tail +0)))))
(default (undefined)
(do Monad<Maybe>
- [new-tail (base-for (-+ +2 vec-size) vec)
- #let [[level' root'] (: [Level (Hierarchy ($ 0))]
+ [new-tail (base-for (n.- +2 vec-size) vec)
+ #let [[level' root'] (: [Level (Hierarchy ($ +0))]
(let [init-level (get@ #level vec)]
(loop [level init-level
- root (: (Hierarchy ($ 0))
+ root (: (Hierarchy ($ +0))
(default (new-hierarchy [])
(pop-tail vec-size init-level (get@ #root vec))))]
- (if (>+ branching-exponent level)
+ (if (n.> branching-exponent level)
(case [(array;get +1 root) (array;get +0 root)]
[#;None (#;Some (#Hierarchy sub-node))]
(recur (level-down level) sub-node)
@@ -321,7 +321,7 @@
[level root])
[level root]))))]]
(wrap (|> vec
- (update@ #size dec+)
+ (update@ #size n.dec)
(set@ #level level')
(set@ #root root')
(set@ #tail new-tail))))))
@@ -335,7 +335,7 @@
(def: #export (from-list list)
(All [a] (-> (List a) (Vector a)))
(List/fold add
- (: (Vector ($ 0))
+ (: (Vector ($ +0))
empty)
list))
@@ -345,7 +345,7 @@
(def: #export empty?
(All [a] (-> (Vector a) Bool))
- (|>. (get@ #size) (=+ +0)))
+ (|>. (get@ #size) (n.= +0)))
## [Syntax]
(syntax: #export (vector {elems (s;some s;any)})
@@ -364,7 +364,7 @@
(struct: #export (Eq<Vector> Eq<a>) (All [a] (-> (Eq a) (Eq (Vector a))))
(def: (= v1 v2)
- (and (=+ (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/struct/zipper.lux b/stdlib/source/lux/data/struct/zipper.lux
index eb98409b4..ddd8ae703 100644
--- a/stdlib/source/lux/data/struct/zipper.lux
+++ b/stdlib/source/lux/data/struct/zipper.lux
@@ -73,7 +73,7 @@
(#;Some parent)
(|> parent
- (update@ #node (: (-> (Tree ($ 0)) (Tree ($ 0)))
+ (update@ #node (: (-> (Tree ($ +0)) (Tree ($ +0)))
(lambda [node]
(set@ #tree;children (List/append (list;reverse (get@ #lefts zipper))
(#;Cons (get@ #node zipper)
@@ -121,7 +121,7 @@
(All [a] (-> a (Zipper a) (Zipper a)))
(update@ [#node #tree;children]
(lambda [children]
- (#;Cons (tree;tree ($ 0) {value []})
+ (#;Cons (tree;tree ($ +0) {value []})
children))
zipper))
@@ -130,7 +130,7 @@
(update@ [#node #tree;children]
(lambda [children]
(List/append children
- (list (tree;tree ($ 0) {value []}))))
+ (list (tree;tree ($ +0) {value []}))))
zipper))
(def: #export (remove zipper)
@@ -160,7 +160,7 @@
_
(#;Some (|> zipper
(update@ <side> (lambda [side]
- (#;Cons (tree;tree ($ 0) {value []})
+ (#;Cons (tree;tree ($ +0) {value []})
side)))))))]
[insert-left #lefts]
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index 97507ba3b..b1e751861 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -21,7 +21,7 @@
(def: #export (at idx x)
(-> Nat Text (Maybe Char))
- (if (<+ (size x) idx)
+ (if (n.< (size x) idx)
(#;Some (_lux_proc ["jvm" "invokevirtual:java.lang.String:charAt:int"] [x (_lux_proc ["jvm" "l2i"] [(nat-to-int idx)])]))
#;None))
@@ -40,8 +40,8 @@
(def: #export (sub from to x)
(-> Nat Nat Text (Maybe Text))
- (if (and (<+ to from)
- (<=+ (size x) to))
+ (if (and (n.< to from)
+ (n.<= (size x) to))
(#;Some (_lux_proc ["jvm" "invokevirtual:java.lang.String:substring:int,int"]
[x
(_lux_proc ["jvm" "l2i"] [(nat-to-int from)])
@@ -65,7 +65,7 @@
(def: #export (<general> pattern from x)
(-> Text Nat Text (Maybe Nat))
- (if (<+ (size x) from)
+ (if (n.< (size x) from)
(case (_lux_proc ["jvm" "i2l"] [(_lux_proc ["jvm" <general-proc>] [x pattern (_lux_proc ["jvm" "l2i"] [(nat-to-int from)])])])
-1 #;None
idx (#;Some (int-to-nat idx)))
@@ -88,15 +88,15 @@
(-> Text Text Bool)
(case (last-index-of postfix x)
(#;Some n)
- (=+ (size x)
- (++ (size postfix) n))
+ (n.= (size x)
+ (n.+ (size postfix) n))
_
false))
(def: #export (split at x)
(-> Nat Text (Maybe [Text Text]))
- (if (<=+ (size x) at)
+ (if (n.<= (size x) at)
(let [pre (_lux_proc ["jvm" "invokevirtual:java.lang.String:substring:int,int"] [x (_lux_proc ["jvm" "l2i"] [0]) (_lux_proc ["jvm" "l2i"] [(nat-to-int at)])])
post (_lux_proc ["jvm" "invokevirtual:java.lang.String:substring:int"] [x (_lux_proc ["jvm" "l2i"] [(nat-to-int at)])])]
(#;Some [pre post]))
@@ -135,10 +135,10 @@
(<op> 0
(_lux_proc ["jvm" "i2l"] [(_lux_proc ["jvm" "invokevirtual:java.lang.String:compareTo:java.lang.String"] [subject test])])))]
- [< ;<]
- [<= ;<=]
- [> ;>]
- [>= ;>=]))
+ [< i.<]
+ [<= i.<=]
+ [> i.>]
+ [>= i.>=]))
(struct: #export _ (Monoid Text)
(def: unit "")
@@ -163,7 +163,7 @@
(def: (decode input)
(if (and (starts-with? "\"" input)
(ends-with? "\"" input))
- (case (sub +1 (dec+ (size input)) input)
+ (case (sub +1 (n.dec (size input)) input)
(#;Some input')
(|> input'
(replace "\\\\" "\\")
diff --git a/stdlib/source/lux/host.lux b/stdlib/source/lux/host.lux
index ecc33227a..ca4958771 100644
--- a/stdlib/source/lux/host.lux
+++ b/stdlib/source/lux/host.lux
@@ -360,7 +360,7 @@
(def: (stack-trace->text trace)
(-> StackTrace Text)
(let [size (_lux_proc ["jvm" "arraylength"] [trace])
- idxs (list;range+ +0 (dec+ size))]
+ idxs (list;n.range +0 (n.dec size))]
(|> idxs
(map (: (-> Nat Text)
(lambda [idx]
@@ -1357,7 +1357,7 @@
(let [sleeper (java.util.List.get [(l2i idx)] sleepers)]
(Executor.execute [(@runnable (lux.Function.apply [(:! Object value)] sleeper))]
executor)))
- (range 0 (dec (i2l sleepers-count)))))
+ (i.range 0 (i.dec (i2l sleepers-count)))))
(:= .waitingList (null))
true)))))
(#public poll [] [] A
diff --git a/stdlib/source/lux/lexer.lux b/stdlib/source/lux/lexer.lux
index 77ce0ce93..ee364d819 100644
--- a/stdlib/source/lux/lexer.lux
+++ b/stdlib/source/lux/lexer.lux
@@ -177,16 +177,16 @@
(def: #export (exactly n p)
(All [a] (-> Nat (Lexer a) (Lexer (List a))))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(do Monad<Lexer>
[x p
- xs (exactly (dec+ n) p)]
+ xs (exactly (n.dec n) p)]
(wrap (#;Cons x xs)))
(:: Monad<Lexer> wrap (list))))
(def: #export (at-most n p)
(All [a] (-> Nat (Lexer a) (Lexer (List a))))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(lambda [input]
(case (p input)
(#;Left msg)
@@ -194,7 +194,7 @@
(#;Right [input' x])
(run' (do Monad<Lexer>
- [xs (at-most (dec+ n) p)]
+ [xs (at-most (n.dec n) p)]
(wrap (#;Cons x xs)))
input')
))
@@ -211,7 +211,7 @@
(All [a] (-> Nat Nat (Lexer a) (Lexer (List a))))
(do Monad<Lexer>
[min-xs (exactly from p)
- max-xs (at-most (-+ from to) p)]
+ max-xs (at-most (n.- from to) p)]
(wrap (list;concat (list min-xs max-xs)))))
(def: #export (opt p)
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index 914575cc0..bb5c068f7 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -87,7 +87,7 @@
(Matcher (List Type))
(lambda [:type:]
(let [members (<flattener> (type;un-name :type:))]
- (if (>+ +1 (list;size members))
+ (if (n.> +1 (list;size members))
(:: compiler;Monad<Lux> wrap members)
(compiler;fail (format "Not a " ($AST$ <tag>) " type: " (type;type-to-text :type:)))))))]
@@ -109,7 +109,7 @@
(Matcher [(List Type) Type])
(lambda [:type:]
(let [[ins out] (type;flatten-function (type;un-name :type:))]
- (if (>+ +0 (list;size ins))
+ (if (n.> +0 (list;size ins))
(:: compiler;Monad<Lux> wrap [ins out])
(compiler;fail (format "Not a LambdaT type: " (type;type-to-text :type:)))))))
@@ -146,12 +146,12 @@
(lambda [:type:]
(do compiler;Monad<Lux>
[[tags :type:] (tagged :type:)
- _ (compiler;assert (>+ +0 (list;size tags)) "Records and variants must have tags.")
+ _ (compiler;assert (n.> +0 (list;size tags)) "Records and variants must have tags.")
[vars :type:] (polymorphic :type:)
members (<sub-comb> :type:)
#let [num-tags (list;size tags)
- [init-tags last-tag] (list;split (dec+ num-tags) tags)
- [init-types last-types] (list;split (dec+ num-tags) members)]]
+ [init-tags last-tag] (list;split (n.dec num-tags) tags)
+ [init-types last-types] (list;split (n.dec num-tags) members)]]
(wrap [vars (list;concat (;list (list;zip2 init-tags init-types)
(;list [(default (undefined)
(list;head last-tag))
@@ -214,10 +214,10 @@
(def: (adjusted-idx env idx)
(-> Env Nat Nat)
- (let [env-level (/+ +2 (dict;size env))
- bound-level (/+ +2 idx)
- bound-idx (%+ +2 idx)]
- (|> env-level dec+ (-+ bound-level) (*+ +2) (++ 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 env)
(-> Env (Matcher AST))
@@ -239,7 +239,7 @@
(lambda [:type:]
(case :type:
(^=> (#;BoundT idx)
- (=+ var-id (adjusted-idx env idx)))
+ (n.= var-id (adjusted-idx env idx)))
(:: compiler;Monad<Lux> wrap [])
_
@@ -259,8 +259,8 @@
(^=> (#;Cons (#;BoundT idx) :parts:')
{(adjusted-idx env idx)
idx'}
- (=+ base idx'))
- (recur (inc+ base) :parts:')
+ (n.= base idx'))
+ (recur (n.inc base) :parts:')
_
(compiler;fail (format "Type is not a recursive instance: " (type;type-to-text :type:)))))
@@ -277,7 +277,7 @@
(let [current-size (dict;size env)]
(|> env
(dict;put current-size type-func)
- (dict;put (inc+ current-size) tvar)
+ (dict;put (n.inc current-size) tvar)
(extend-env (` (#;AppT (~ type-func) (~ tvar))) type-vars')
))))
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux
index 78b668f2c..c9de93cbb 100644
--- a/stdlib/source/lux/macro/poly/functor.lux
+++ b/stdlib/source/lux/macro/poly/functor.lux
@@ -34,7 +34,7 @@
[g!vars _] (poly;polymorphic :x:)
#let [num-vars (list;size g!vars)
new-env (poly;extend-env g!type-fun g!vars env)]
- _ (compiler;assert (>+ +0 num-vars)
+ _ (compiler;assert (n.> +0 num-vars)
"Functors must have at least 1 type-variable.")]
(let [->Functor (: (-> AST AST)
(lambda [.type.] (` (functor;Functor (~ .type.)))))
@@ -47,7 +47,7 @@
(wrap value))
## Type-var
(do @
- [_ (poly;var new-env (dec+ num-vars) :type:)]
+ [_ (poly;var new-env (n.dec num-vars) :type:)]
(wrap (` ((~ g!func) (~ value)))))
## Tuples/records
(do @
@@ -116,7 +116,7 @@
(~ .out.))))))))))
## No structure (as you'd expect from Identity)
(do @
- [_ (poly;var new-env (dec+ num-vars) :x:)]
+ [_ (poly;var new-env (n.dec num-vars) :x:)]
(wrap (` (: (~ (->Functor (type;type-to-ast :x:)))
(struct (def: ((~ g!map) (~ g!func) (~ g!input))
((~ g!func) (~ g!input))))))))
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index 367dc10b6..c32d5d105 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -151,8 +151,8 @@
_ (assert (<comp> 0 n) <error>)]
(wrap n)))]
- [pos-int > "Expected a positive integer: N > 0"]
- [neg-int < "Expected a negative integer: N < 0"]
+ [pos-int i.> "Expected a positive integer: N > 0"]
+ [neg-int i.< "Expected a negative integer: N < 0"]
)
(do-template [<name> <tag> <desc>]
@@ -287,10 +287,10 @@
(def: #export (exactly n p)
(All [a] (-> Nat (Syntax a) (Syntax (List a))))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(do Monad<Syntax>
[x p
- xs (exactly (dec+ n) p)]
+ xs (exactly (n.dec n) p)]
(wrap (#;Cons x xs)))
(:: Monad<Syntax> wrap (list))))
@@ -303,7 +303,7 @@
(def: #export (at-most n p)
(All [a] (-> Nat (Syntax a) (Syntax (List a))))
- (if (>+ +0 n)
+ (if (n.> +0 n)
(lambda [input]
(case (p input)
(#;Left msg)
@@ -312,7 +312,7 @@
(#;Right [input' x])
(run input'
(do Monad<Syntax>
- [xs (at-most (dec+ n) p)]
+ [xs (at-most (n.dec n) p)]
(wrap (#;Cons x xs))))
))
(:: Monad<Syntax> wrap (list))))
@@ -321,7 +321,7 @@
(All [a] (-> Nat Nat (Syntax a) (Syntax (List a))))
(do Monad<Syntax>
[min-xs (exactly from p)
- max-xs (at-most (-+ from to) p)]
+ max-xs (at-most (n.- from to) p)]
(wrap (:: Monad<List> join (list min-xs max-xs)))))
(def: #export (sep-by sep p)
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index ffc13818f..1ed87f1e8 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -80,7 +80,7 @@
(-> Int Int Int)
(case b
0 a
- _ (gcd' b (% b a))))
+ _ (gcd' b (i.% b a))))
(def: #export (gcd a b)
{#;doc "Greatest Common Divisor."}
@@ -95,7 +95,7 @@
0
_
- (|> x (/ (gcd x y)) (* y) Int/abs)
+ (|> x (i./ (gcd x y)) (i.* y) Int/abs)
))
## [Syntax]
diff --git a/stdlib/source/lux/math/complex.lux b/stdlib/source/lux/math/complex.lux
index eb7796bb2..8e82d957f 100644
--- a/stdlib/source/lux/math/complex.lux
+++ b/stdlib/source/lux/math/complex.lux
@@ -37,12 +37,12 @@
(def: #export zero Complex (complex 0.0 0.0))
-(def: #export (c= param input)
+(def: #export (c.= param input)
(-> Complex Complex Bool)
- (and (=. (get@ #real param)
- (get@ #real input))
- (=. (get@ #imaginary param)
- (get@ #imaginary input))))
+ (and (r.= (get@ #real param)
+ (get@ #real input))
+ (r.= (get@ #imaginary param)
+ (get@ #imaginary input))))
(do-template [<name> <op>]
[(def: #export (<name> param input)
@@ -52,12 +52,12 @@
#imaginary (<op> (get@ #imaginary param)
(get@ #imaginary input))})]
- [c+ +.]
- [c- -.]
+ [c.+ r.+]
+ [c.- r.-]
)
(struct: #export _ (Eq Complex)
- (def: = c=))
+ (def: = c.=))
(def: #export negate
(-> Complex Complex)
@@ -73,107 +73,107 @@
(-> Complex Complex)
(update@ #imaginary r:negate))
-(def: #export (c*' param input)
+(def: #export (c.*' param input)
(-> Real Complex Complex)
- {#real (*. param
- (get@ #real input))
- #imaginary (*. param
- (get@ #imaginary input))})
+ {#real (r.* param
+ (get@ #real input))
+ #imaginary (r.* param
+ (get@ #imaginary input))})
-(def: #export (c* param input)
+(def: #export (c.* param input)
(-> Complex Complex Complex)
- {#real (-. (*. (get@ #imaginary param)
- (get@ #imaginary input))
- (*. (get@ #real param)
- (get@ #real input)))
- #imaginary (+. (*. (get@ #real param)
- (get@ #imaginary input))
- (*. (get@ #imaginary param)
- (get@ #real input)))})
-
-(def: #export (c/ (^slots [#real #imaginary]) input)
+ {#real (r.- (r.* (get@ #imaginary param)
+ (get@ #imaginary input))
+ (r.* (get@ #real param)
+ (get@ #real input)))
+ #imaginary (r.+ (r.* (get@ #real param)
+ (get@ #imaginary input))
+ (r.* (get@ #imaginary param)
+ (get@ #real input)))})
+
+(def: #export (c./ (^slots [#real #imaginary]) input)
(-> Complex Complex Complex)
- (if (<. (r:abs imaginary)
- (r:abs real))
- (let [quot (/. imaginary real)
- denom (|> real (*. quot) (+. imaginary))]
- {#real (|> (get@ #real input) (*. quot) (+. (get@ #imaginary input)) (/. denom))
- #imaginary (|> (get@ #imaginary input) (*. quot) (-. (get@ #real input)) (/. denom))})
- (let [quot (/. real imaginary)
- denom (|> imaginary (*. quot) (+. real))]
- {#real (|> (get@ #imaginary input) (*. quot) (+. (get@ #real input)) (/. denom))
- #imaginary (|> (get@ #imaginary input) (-. (*. quot (get@ #real input))) (/. denom))})))
-
-(def: #export (c/' param (^slots [#real #imaginary]))
+ (if (r.< (r:abs imaginary)
+ (r:abs real))
+ (let [quot (r./ imaginary real)
+ denom (|> real (r.* quot) (r.+ imaginary))]
+ {#real (|> (get@ #real input) (r.* quot) (r.+ (get@ #imaginary input)) (r./ denom))
+ #imaginary (|> (get@ #imaginary input) (r.* quot) (r.- (get@ #real input)) (r./ denom))})
+ (let [quot (r./ real imaginary)
+ denom (|> imaginary (r.* quot) (r.+ real))]
+ {#real (|> (get@ #imaginary input) (r.* quot) (r.+ (get@ #real input)) (r./ denom))
+ #imaginary (|> (get@ #imaginary input) (r.- (r.* quot (get@ #real input))) (r./ denom))})))
+
+(def: #export (c./' param (^slots [#real #imaginary]))
(-> Real Complex Complex)
- {#real (/. param real)
- #imaginary (/. param imaginary)})
+ {#real (r./ param real)
+ #imaginary (r./ param imaginary)})
(def: #export (cos (^slots [#real #imaginary]))
(-> Complex Complex)
- {#real (*. (math;cosh imaginary)
- (math;cos real))
- #imaginary (*. (math;sinh imaginary)
- (r:negate (math;sin real)))})
+ {#real (r.* (math;cosh imaginary)
+ (math;cos real))
+ #imaginary (r.* (math;sinh imaginary)
+ (r:negate (math;sin real)))})
(def: #export (cosh (^slots [#real #imaginary]))
(-> Complex Complex)
- {#real (*. (math;cos imaginary)
- (math;cosh real))
- #imaginary (*. (math;sin imaginary)
- (math;sinh real))})
+ {#real (r.* (math;cos imaginary)
+ (math;cosh real))
+ #imaginary (r.* (math;sin imaginary)
+ (math;sinh real))})
(def: #export (sin (^slots [#real #imaginary]))
(-> Complex Complex)
- {#real (*. (math;cosh imaginary)
- (math;sin real))
- #imaginary (*. (math;sinh imaginary)
- (math;cos real))})
+ {#real (r.* (math;cosh imaginary)
+ (math;sin real))
+ #imaginary (r.* (math;sinh imaginary)
+ (math;cos real))})
(def: #export (sinh (^slots [#real #imaginary]))
(-> Complex Complex)
- {#real (*. (math;cos imaginary)
- (math;sinh real))
- #imaginary (*. (math;sin imaginary)
- (math;cosh real))})
+ {#real (r.* (math;cos imaginary)
+ (math;sinh real))
+ #imaginary (r.* (math;sin imaginary)
+ (math;cosh real))})
(def: #export (tan (^slots [#real #imaginary]))
(-> Complex Complex)
- (let [r2 (*. 2.0 real)
- i2 (*. 2.0 imaginary)
- d (+. (math;cos r2) (math;cosh i2))]
- {#real (/. d (math;sin r2))
- #imaginary (/. d (math;sinh i2))}))
+ (let [r2 (r.* 2.0 real)
+ i2 (r.* 2.0 imaginary)
+ d (r.+ (math;cos r2) (math;cosh i2))]
+ {#real (r./ d (math;sin r2))
+ #imaginary (r./ d (math;sinh i2))}))
(def: #export (tanh (^slots [#real #imaginary]))
(-> Complex Complex)
- (let [r2 (*. 2.0 real)
- i2 (*. 2.0 imaginary)
- d (+. (math;cosh r2) (math;cos i2))]
- {#real (/. d (math;sinh r2))
- #imaginary (/. d (math;sin i2))}))
+ (let [r2 (r.* 2.0 real)
+ i2 (r.* 2.0 imaginary)
+ d (r.+ (math;cosh r2) (math;cos i2))]
+ {#real (r./ d (math;sinh r2))
+ #imaginary (r./ d (math;sin i2))}))
(def: #export (abs (^slots [#real #imaginary]))
(-> Complex Real)
- (if (<. (r:abs imaginary)
- (r:abs real))
- (if (=. 0.0 imaginary)
+ (if (r.< (r:abs imaginary)
+ (r:abs real))
+ (if (r.= 0.0 imaginary)
(r:abs real)
- (let [q (/. imaginary real)]
- (*. (math;sqrt (+. 1.0 (*. q q)))
- (r:abs imaginary))))
- (if (=. 0.0 real)
+ (let [q (r./ imaginary real)]
+ (r.* (math;sqrt (r.+ 1.0 (r.* q q)))
+ (r:abs imaginary))))
+ (if (r.= 0.0 real)
(r:abs imaginary)
- (let [q (/. real imaginary)]
- (*. (math;sqrt (+. 1.0 (*. q q)))
- (r:abs real))))
+ (let [q (r./ real imaginary)]
+ (r.* (math;sqrt (r.+ 1.0 (r.* q q)))
+ (r:abs real))))
))
(def: #export (exp (^slots [#real #imaginary]))
(-> Complex Complex)
(let [r-exp (math;exp real)]
- {#real (*. r-exp (math;cos imaginary))
- #imaginary (*. r-exp (math;sin imaginary))}))
+ {#real (r.* r-exp (math;cos imaginary))
+ #imaginary (r.* r-exp (math;sin imaginary))}))
(def: #export (log (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
@@ -185,66 +185,66 @@
(-> <type> Complex Complex)
(|> input log (<op> param) exp))]
- [pow Complex c*]
- [pow' Real c*']
+ [pow Complex c.*]
+ [pow' Real c.*']
)
(def: (copy-sign sign magnitude)
(-> Real Real Real)
- (*. (r:signum sign) magnitude))
+ (r.* (r:signum sign) magnitude))
(def: #export (sqrt (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
- (let [t (|> input abs (+. (r:abs real)) (/. 2.0) math;sqrt)]
- (if (>=. 0.0 real)
+ (let [t (|> input abs (r.+ (r:abs real)) (r./ 2.0) math;sqrt)]
+ (if (r.>= 0.0 real)
{#real t
- #imaginary (/. (*. 2.0 t)
- imaginary)}
- {#real (/. (*. 2.0 t)
- (r:abs imaginary))
- #imaginary (*. t (copy-sign imaginary 1.0))})))
+ #imaginary (r./ (r.* 2.0 t)
+ imaginary)}
+ {#real (r./ (r.* 2.0 t)
+ (r:abs imaginary))
+ #imaginary (r.* t (copy-sign imaginary 1.0))})))
(def: #export (sqrt-1z input)
(-> Complex Complex)
- (|> (complex 1.0) (c- (c* input input)) sqrt))
+ (|> (complex 1.0) (c.- (c.* input input)) sqrt))
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
- (if (<. (r:abs imaginary)
- (r:abs real))
- (let [q (/. imaginary real)
- scale (/. (|> real (*. q) (+. imaginary))
- 1.0)]
- {#real (*. q scale)
+ (if (r.< (r:abs imaginary)
+ (r:abs real))
+ (let [q (r./ imaginary real)
+ scale (r./ (|> real (r.* q) (r.+ imaginary))
+ 1.0)]
+ {#real (r.* q scale)
#imaginary (r:negate scale)})
- (let [q (/. real imaginary)
- scale (/. (|> imaginary (*. q) (+. real))
- 1.0)]
+ (let [q (r./ real imaginary)
+ scale (r./ (|> imaginary (r.* q) (r.+ real))
+ 1.0)]
{#real scale
- #imaginary (|> scale r:negate (*. q))})))
+ #imaginary (|> scale r:negate (r.* q))})))
(def: #export (acos input)
(-> Complex Complex)
(|> input
- (c+ (|> input sqrt-1z (c* i)))
+ (c.+ (|> input sqrt-1z (c.* i)))
log
- (c* (negate i))))
+ (c.* (negate i))))
(def: #export (asin input)
(-> Complex Complex)
(|> input
sqrt-1z
- (c+ (c* i input))
+ (c.+ (c.* i input))
log
- (c* (negate i))))
+ (c.* (negate i))))
(def: #export (atan input)
(-> Complex Complex)
(|> input
- (c+ i)
- (c/ (c- input i))
+ (c.+ i)
+ (c./ (c.- input i))
log
- (c* (c/ (complex 2.0) i))))
+ (c.* (c./ (complex 2.0) i))))
(def: #export (argument (^slots [#real #imaginary]))
(-> Complex Real)
@@ -252,22 +252,22 @@
(def: #export (nth-root nth input)
(-> Nat Complex (List Complex))
- (if (=+ +0 nth)
+ (if (n.= +0 nth)
(list)
(let [r-nth (|> nth nat-to-int int-to-real)
- nth-root-of-abs (math;pow (/. r-nth 1.0)
+ nth-root-of-abs (math;pow (r./ r-nth 1.0)
(abs input))
- nth-phi (|> input argument (/. r-nth))
- slice (|> math;pi (*. 2.0) (/. r-nth))]
- (|> (list;range+ +0 (dec+ nth))
+ nth-phi (|> input argument (r./ r-nth))
+ slice (|> math;pi (r.* 2.0) (r./ r-nth))]
+ (|> (list;n.range +0 (n.dec nth))
(List/map (lambda [nth']
(let [inner (|> nth' nat-to-int int-to-real
- (*. slice)
- (+. nth-phi))
- real (*. nth-root-of-abs
- (math;cos inner))
- imaginary (*. nth-root-of-abs
- (math;sin inner))]
+ (r.* slice)
+ (r.+ nth-phi))
+ real (r.* nth-root-of-abs
+ (math;cos inner))
+ imaginary (r.* nth-root-of-abs
+ (math;sin inner))]
{#real real
#imaginary imaginary})))))))
@@ -277,7 +277,7 @@
(def: (decode input)
(case (do Monad<Maybe>
- [input' (text;sub +1 (-+ +1 (text;size input)) input)]
+ [input' (text;sub +1 (n.- +1 (text;size input)) input)]
(text;split-with "," input'))
#;None
(#;Left (Text/append "Wrong syntax for complex numbers: " input))
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index 41481a284..9fe4f4fd6 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -64,28 +64,28 @@
(lambda [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (++ (bit;<< +32 left)
- right)])))
+ [prng (n.+ (bit;<< +32 left)
+ right)])))
(def: #export int
(Random Int)
(lambda [prng]
(let [[prng left] (prng [])
[prng right] (prng [])]
- [prng (nat-to-int (++ (bit;<< +32 left)
- right))])))
+ [prng (nat-to-int (n.+ (bit;<< +32 left)
+ right))])))
(def: #export bool
(Random Bool)
(lambda [prng]
(let [[prng output] (prng [])]
- [prng (|> output (bit;& +1) (=+ +1))])))
+ [prng (|> output (bit;& +1) (n.= +1))])))
(def: (bits n)
(-> Nat (Random Nat))
(lambda [prng]
(let [[prng output] (prng [])]
- [prng (bit;>>> (-+ n +64) output)])))
+ [prng (bit;>>> (n.- n +64) output)])))
(def: #export real
(Random Real)
@@ -93,10 +93,10 @@
[left (bits +26)
right (bits +27)]
(wrap (|> right
- (++ (bit;<< +27 left))
+ (n.+ (bit;<< +27 left))
nat-to-int
int-to-real
- (/. (|> +1 (bit;<< +53) nat-to-int int-to-real))))))
+ (r./ (|> +1 (bit;<< +53) nat-to-int int-to-real))))))
(def: #export frac
(Random Frac)
@@ -110,11 +110,11 @@
(def: #export (text' char-gen size)
(-> (Random Char) Nat (Random Text))
- (if (=+ +0 size)
+ (if (n.= +0 size)
(:: Monad<Random> wrap "")
(do Monad<Random>
[x char-gen
- xs (text' char-gen (dec+ size))]
+ xs (text' char-gen (n.dec size))]
(wrap (Text/append (char;as-text x) xs)))))
(def: #export (text size)
@@ -187,10 +187,10 @@
(do-template [<name> <type> <zero> <plus>]
[(def: #export (<name> size value-gen)
(All [a] (-> Nat (Random a) (Random (<type> a))))
- (if (>+ +0 size)
+ (if (n.> +0 size)
(do Monad<Random>
[x value-gen
- xs (<name> (dec+ size) value-gen)]
+ xs (<name> (n.dec size) value-gen)]
(wrap (<plus> x xs)))
(:: Monad<Random> wrap <zero>)))]
@@ -212,29 +212,29 @@
(def: #export (set a/Hash size value-gen)
(All [a] (-> (Hash a) Nat (Random a) (Random (S;Set a))))
- (if (>+ +0 size)
+ (if (n.> +0 size)
(do Monad<Random>
- [xs (set a/Hash (dec+ size) value-gen)]
+ [xs (set a/Hash (n.dec size) value-gen)]
(loop [_ []]
(do @
[x value-gen
#let [xs+ (S;add x xs)]]
- (if (=+ size (S;size xs+))
+ (if (n.= size (S;size xs+))
(wrap xs+)
(recur [])))))
(:: Monad<Random> wrap (S;new a/Hash))))
(def: #export (dict a/Hash size key-gen value-gen)
(All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (D;Dict k v))))
- (if (>+ +0 size)
+ (if (n.> +0 size)
(do Monad<Random>
- [kv (dict a/Hash (dec+ size) key-gen value-gen)]
+ [kv (dict a/Hash (n.dec size) key-gen value-gen)]
(loop [_ []]
(do @
[k key-gen
v value-gen
#let [kv+ (D;put k v kv)]]
- (if (=+ size (D;size kv+))
+ (if (n.= size (D;size kv+))
(wrap kv+)
(recur [])))))
(:: Monad<Random> wrap (D;new a/Hash))))
@@ -252,7 +252,7 @@
(def: #export (pcg-32 [inc seed])
(-> [Nat Nat] PRNG)
(lambda [_]
- (let [seed' (|> seed (*+ pcg-32-magic-mult) (++ inc))
+ (let [seed' (|> seed (n.* pcg-32-magic-mult) (n.+ inc))
xor-shifted (|> seed (bit;>>> +18) (bit;^ seed) (bit;>>> +27))
rot (|> seed (bit;>>> +59))]
[(pcg-32 [inc seed']) (bit;rotate-right rot xor-shifted)]
@@ -262,7 +262,7 @@
(def: #export (xoroshiro-128+ [s0 s1])
(-> [Nat Nat] PRNG)
(lambda [_]
- (let [result (++ s0 s1)
+ (let [result (n.+ s0 s1)
s01 (bit;^ s0 s1)
s0' (|> (bit;rotate-left +55 s0)
(bit;^ s01)
@@ -285,9 +285,9 @@
(lambda [idx vec]
(do Monad<Random>
[rand nat]
- (wrap (swap idx (%+ _size rand) vec))))
+ (wrap (swap idx (n.% _size rand) vec))))
vector
- (list;range+ +0 (dec+ _size)))]
+ (list;n.range +0 (n.dec _size)))]
(|> _shuffle
(run (pcg-32 [+123 seed]))
product;right)))
diff --git a/stdlib/source/lux/math/ratio.lux b/stdlib/source/lux/math/ratio.lux
index 89d93aa5d..5fb82c8a5 100644
--- a/stdlib/source/lux/math/ratio.lux
+++ b/stdlib/source/lux/math/ratio.lux
@@ -25,93 +25,93 @@
(def: #hidden (normalize (^slots [#numerator #denominator]))
(-> Ratio Ratio)
(let [common (math;gcd numerator denominator)
- numerator (/ common numerator)
- denominator (/ common denominator)]
- {#numerator (if (and (< 0 numerator)
- (< 0 denominator))
+ numerator (i./ common numerator)
+ denominator (i./ common denominator)]
+ {#numerator (if (and (i.< 0 numerator)
+ (i.< 0 denominator))
(i:abs numerator)
numerator)
#denominator (i:abs denominator)}))
-(def: #export (r* param input)
+(def: #export (q.* param input)
(-> Ratio Ratio Ratio)
- (normalize [(* (get@ #numerator param)
- (get@ #numerator input))
- (* (get@ #denominator param)
- (get@ #denominator input))]))
+ (normalize [(i.* (get@ #numerator param)
+ (get@ #numerator input))
+ (i.* (get@ #denominator param)
+ (get@ #denominator input))]))
-(def: #export (r/ param input)
+(def: #export (q./ param input)
(-> Ratio Ratio Ratio)
- (normalize [(* (get@ #denominator param)
- (get@ #numerator input))
- (* (get@ #numerator param)
- (get@ #denominator input))]))
+ (normalize [(i.* (get@ #denominator param)
+ (get@ #numerator input))
+ (i.* (get@ #numerator param)
+ (get@ #denominator input))]))
-(def: #export (r+ param input)
+(def: #export (q.+ param input)
(-> Ratio Ratio Ratio)
- (normalize [(+ (* (get@ #denominator input)
- (get@ #numerator param))
- (* (get@ #denominator param)
- (get@ #numerator input)))
- (* (get@ #denominator param)
- (get@ #denominator input))]))
-
-(def: #export (r- param input)
+ (normalize [(i.+ (i.* (get@ #denominator input)
+ (get@ #numerator param))
+ (i.* (get@ #denominator param)
+ (get@ #numerator input)))
+ (i.* (get@ #denominator param)
+ (get@ #denominator input))]))
+
+(def: #export (q.- param input)
(-> Ratio Ratio Ratio)
- (normalize [(- (* (get@ #denominator input)
- (get@ #numerator param))
- (* (get@ #denominator param)
- (get@ #numerator input)))
- (* (get@ #denominator param)
- (get@ #denominator input))]))
-
-(def: #export (r% param input)
+ (normalize [(i.- (i.* (get@ #denominator input)
+ (get@ #numerator param))
+ (i.* (get@ #denominator param)
+ (get@ #numerator input)))
+ (i.* (get@ #denominator param)
+ (get@ #denominator input))]))
+
+(def: #export (q.% param input)
(-> Ratio Ratio Ratio)
- (let [quot (/ (* (get@ #denominator input)
- (get@ #numerator param))
- (* (get@ #denominator param)
- (get@ #numerator input)))]
- (r- (update@ #numerator (* quot) param)
- input)))
-
-(def: #export (r= param input)
+ (let [quot (i./ (i.* (get@ #denominator input)
+ (get@ #numerator param))
+ (i.* (get@ #denominator param)
+ (get@ #numerator input)))]
+ (q.- (update@ #numerator (i.* quot) param)
+ input)))
+
+(def: #export (q.= param input)
(-> Ratio Ratio Bool)
- (and (= (get@ #numerator param)
- (get@ #numerator input))
- (= (get@ #denominator param)
- (get@ #denominator input))))
+ (and (i.= (get@ #numerator param)
+ (get@ #numerator input))
+ (i.= (get@ #denominator param)
+ (get@ #denominator input))))
(do-template [<name> <op>]
[(def: #export (<name> param input)
(-> Ratio Ratio Bool)
- (and (<op> (* (get@ #denominator input)
- (get@ #numerator param))
- (* (get@ #denominator param)
- (get@ #numerator input)))))]
-
- [r< <]
- [r<= <=]
- [r> >]
- [r>= >=]
+ (and (<op> (i.* (get@ #denominator input)
+ (get@ #numerator param))
+ (i.* (get@ #denominator param)
+ (get@ #numerator input)))))]
+
+ [q.< i.<]
+ [q.<= i.<=]
+ [q.> i.>]
+ [q.>= i.>=]
)
(struct: #export _ (Eq Ratio)
- (def: = r=))
+ (def: = q.=))
(struct: #export _ (ord;Ord Ratio)
(def: eq Eq<Ratio>)
- (def: < r<)
- (def: <= r<=)
- (def: > r>)
- (def: >= r>=))
+ (def: < q.<)
+ (def: <= q.<=)
+ (def: > q.>)
+ (def: >= q.>=))
(struct: #export _ (Number Ratio)
(def: ord Ord<Ratio>)
- (def: + r+)
- (def: - r-)
- (def: * r*)
- (def: / r/)
- (def: % r%)
+ (def: + q.+)
+ (def: - q.-)
+ (def: * q.*)
+ (def: / q./)
+ (def: % q.%)
(def: negate (|>. (update@ #numerator i:negate) normalize))
(def: abs (|>. (update@ #numerator i:abs) (update@ #denominator i:abs)))
(def: (signum x)
diff --git a/stdlib/source/lux/pipe.lux b/stdlib/source/lux/pipe.lux
index b1316f238..0d07f5a62 100644
--- a/stdlib/source/lux/pipe.lux
+++ b/stdlib/source/lux/pipe.lux
@@ -21,9 +21,9 @@
(syntax: #export (_> {tokens (s;at-least +2 s;any)})
{#;doc (doc "Ignores the piped argument, and begins a new pipe."
(|> 20
- (* 3)
- (+ 4)
- (_> 0 inc)))}
+ (i.* 3)
+ (i.+ 4)
+ (_> 0 i.inc)))}
(case (list;reverse tokens)
(^ (list& _ r-body))
(wrap (list (` (|> (~@ (list;reverse r-body))))))
@@ -35,7 +35,7 @@
prev)
{#;doc (doc "Gives the name '@' to the piped-argument, within the given expression."
(|> 5
- (@> [(+ @ @)])))}
+ (@> [(i.+ @ @)])))}
(wrap (list (fold (lambda [next prev]
(` (let% [(~' @) (~ prev)]
(~ next))))
@@ -49,8 +49,8 @@
"Both the tests and the bodies are piped-code, and must be given inside a tuple."
"If a last else-pipe isn't given, the piped-argument will be used instead."
(|> 5
- (?> [even?] [(* 2)]
- [odd?] [(* 3)]
+ (?> [i.even?] [(i.* 2)]
+ [i.odd?] [(i.* 3)]
[(_> -1)])))}
(with-gensyms [g!temp]
(wrap (list (` (let% [(~ g!temp) (~ prev)]
@@ -70,8 +70,8 @@
"Loops for pipes."
"Both the testing and calculating steps are pipes and must be given inside tuples."
(|> 1
- (!> [(< 10)]
- [inc])))}
+ (!> [(i.< 10)]
+ [i.inc])))}
(with-gensyms [g!temp]
(wrap (list (` (loop [(~ g!temp) (~ prev)]
(if (|> (~ g!temp) (~@ test))
@@ -83,9 +83,9 @@
"Each steps in the monadic computation is a pipe and must be given inside a tuple."
(|> 5
(%> Id/Monad
- [(* 3)]
- [(+ 4)]
- [inc])))}
+ [(i.* 3)]
+ [(i.+ 4)]
+ [i.inc])))}
(with-gensyms [g!temp]
(case (list;reverse steps)
(^ (list& last-step prev-steps))
@@ -105,7 +105,7 @@
"Will generate piped computations, but their results won't be used in the larger scope."
(|> 5
(~> [int-to-nat %n log!])
- (* 10)))}
+ (i.* 10)))}
(do @
[g!temp (compiler;gensym "")]
(wrap (list (` (let [(~ g!temp) (~ prev)]
@@ -116,8 +116,8 @@
{#;doc (doc "Parallel branching for pipes."
"Allows to run multiple pipelines for a value and gives you a tuple of the outputs."
(|> 5
- (&> [(* 10)]
- [dec (/ 2)]
+ (&> [(i.* 10)]
+ [i.dec (i./ 2)]
[Int/encode]))
"Will become: [50 2 \"5\"]")}
(do @
diff --git a/stdlib/source/lux/regex.lux b/stdlib/source/lux/regex.lux
index 1d98d6bf5..3bcf95106 100644
--- a/stdlib/source/lux/regex.lux
+++ b/stdlib/source/lux/regex.lux
@@ -311,8 +311,8 @@
[idx (ast;symbol ["" _name])]
#;None
- [(inc idx) (ast;symbol ["" (Int/encode idx)])])
- access (if (>+ +0 num-captures)
+ [(i.inc idx) (ast;symbol ["" (Int/encode idx)])])
+ access (if (n.> +0 num-captures)
(` (product;left (~ name!)))
name!)]
[idx!
@@ -370,7 +370,7 @@
(def: (prep-alternative [num-captures alt])
(-> [Nat AST] AST)
- (if (>+ +0 num-captures)
+ (if (n.> +0 num-captures)
alt
(` (unflatten^ (~ alt)))))
@@ -388,7 +388,7 @@
(` |||_^))]]
(if (list;empty? tail)
(wrap head)
- (wrap [(fold max+ (product;left head) (List/map product;left tail))
+ (wrap [(fold n.max (product;left head) (List/map product;left tail))
(` ($_ (~ g!op) (~ (prep-alternative head)) (~@ (List/map prep-alternative tail))))]))))
(def: (re-scoped^ current-module)
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index 8ff397d7a..161019d91 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -61,7 +61,7 @@
_
(exec (log! (format "Success: " (:: text;Codec<Text,Text> encode description) " @ " module
- " in " (%i (- pre post)) "ms"))
+ " in " (%i (i.- pre post)) "ms"))
(wrap []))))))
tests)]
(wrap [])))
@@ -88,7 +88,7 @@
(def: (repeat' seed times random-test)
(-> Seed Nat (R;Random Test) Test)
- (if (=+ +0 times)
+ (if (n.= +0 times)
(fail "Can't try a test 0 times.")
(do Monad<Promise>
[output (try seed random-test)]
@@ -97,9 +97,9 @@
(fail (format "Test failed with this seed: " (%n seed) "\n" error))
(#;Right seed')
- (if (=+ +1 times)
+ (if (n.= +1 times)
(wrap (#;Right []))
- (repeat' seed' (dec+ times) random-test))
+ (repeat' seed' (n.dec times) random-test))
))))
(def: #export (repeat times random-test)
@@ -139,14 +139,14 @@
{#;doc (doc "Macro for definint tests."
(test: "lux/pipe exports"
(all (match 1 (|> 20
- (* 3)
- (+ 4)
- (_> 0 inc)))
+ (i.* 3)
+ (i.+ 4)
+ (_> 0 i.inc)))
(match 10 (|> 5
- (@> (+ @ @))))
+ (@> (i.+ @ @))))
(match 15 (|> 5
- (?> [even?] [(* 2)]
- [odd?] [(* 3)]
+ (?> [i.even?] [(i.* 2)]
+ [i.odd?] [(i.* 3)]
[(_> -1)])))
)))}
(let [body (case body
@@ -201,7 +201,7 @@
#let [tests+ (List/map (lambda [[module-name test desc]]
(` [(~ (ast;text module-name)) (~ (ast;symbol [module-name test])) (~ (ast;text desc))]))
tests)
- groups (list;split-all (|> (list;size tests+) (/+ promise;concurrency-level) (++ +1) (min+ +16))
+ groups (list;split-all (|> (list;size tests+) (n./ promise;concurrency-level) (n.+ +1) (n.min +16))
tests+)]]
(wrap (list (` (: (IO Unit)
(io (exec (do Monad<Promise>
diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux
index fbd269daa..bdae9c2bb 100644
--- a/stdlib/source/lux/type.lux
+++ b/stdlib/source/lux/type.lux
@@ -59,7 +59,7 @@
(case [x y]
[(#;HostT xname xparams) (#;HostT yname yparams)]
(and (Text/= xname yname)
- (=+ (list;size yparams) (list;size xparams))
+ (n.= (list;size yparams) (list;size xparams))
(List/fold (lambda [[x y] prev] (and prev (= x y)))
true
(list;zip2 xparams yparams)))
@@ -71,7 +71,7 @@
(^template [<tag>]
[(<tag> xid) (<tag> yid)]
- (=+ yid xid))
+ (n.= yid xid))
([#;VarT] [#;ExT] [#;BoundT])
(^or [(#;LambdaT xleft xright) (#;LambdaT yleft yright)]
@@ -91,7 +91,7 @@
(^or [(#;UnivQ xenv xbody) (#;UnivQ yenv ybody)]
[(#;ExQ xenv xbody) (#;ExQ yenv ybody)])
- (and (=+ (list;size yenv) (list;size xenv))
+ (and (n.= (list;size yenv) (list;size xenv))
(= xbody ybody)
(List/fold (lambda [[x y] prev] (and prev (= x y)))
true
diff --git a/stdlib/source/lux/type/auto.lux b/stdlib/source/lux/type/auto.lux
index a1a795c80..f33314ac1 100644
--- a/stdlib/source/lux/type/auto.lux
+++ b/stdlib/source/lux/type/auto.lux
@@ -35,12 +35,12 @@
(find-member-type idx sig-type'))
(#;ProdT left right)
- (if (=+ +0 idx)
+ (if (n.= +0 idx)
(:: Monad<Check> wrap left)
- (find-member-type (dec+ idx) right))
+ (find-member-type (n.dec idx) right))
_
- (if (=+ +0 idx)
+ (if (n.= +0 idx)
(:: Monad<Check> wrap sig-type)
(tc;fail (format "Can't find member type " (%n idx) " for " (%type sig-type))))))
@@ -207,5 +207,5 @@
(wrap (list retry)))))
(comment
- (::: map inc (list 0 1 2 3 4))
+ (::: map i.inc (list 0 1 2 3 4))
)
diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux
index 9eb72cbcb..b4d90e004 100644
--- a/stdlib/source/lux/type/check.lux
+++ b/stdlib/source/lux/type/check.lux
@@ -111,7 +111,7 @@
(Check [Id Type])
(lambda [context]
(let [id (get@ #ex-id context)]
- (#;Right [(update@ #ex-id inc+ context)
+ (#;Right [(update@ #ex-id n.inc context)
[id (#;ExT id)]]))))
(def: (bound? id)
@@ -180,7 +180,7 @@
(-> Id Type (Check Type))
(case type
(#;VarT id)
- (if (=+ t-id id)
+ (if (n.= t-id id)
(do Monad<Check>
[? (bound? id)]
(if ?
@@ -194,7 +194,7 @@
==type (clean t-id =type)]
(case ==type
(#;VarT =id)
- (if (=+ t-id =id)
+ (if (n.= t-id =id)
(do Monad<Check>
[_ (unset-var id)]
(wrap type))
@@ -242,7 +242,7 @@
(lambda [context]
(let [id (get@ #var-id context)]
(#;Right [(|> context
- (update@ #var-id inc+)
+ (update@ #var-id n.inc)
(update@ #bindings (dict;put id #;None)))
[id (#;VarT id)]]))))
@@ -275,7 +275,7 @@
bindings get-bindings
bindings' (mapM @
(lambda [(^@ binding [b-id b-type])]
- (if (=+ id b-id)
+ (if (n.= id b-id)
(wrap binding)
(case b-type
#;None
@@ -284,7 +284,7 @@
(#;Some b-type')
(case b-type'
(#;VarT t-id)
- (if (=+ id t-id)
+ (if (n.= id t-id)
(wrap [b-id #;None])
(wrap binding))
@@ -363,7 +363,7 @@
success
(case [expected actual]
[(#;VarT e-id) (#;VarT a-id)]
- (if (=+ e-id a-id)
+ (if (n.= e-id a-id)
success
(do Monad<Check>
[ebound (attempt (deref e-id))
@@ -394,7 +394,7 @@
(check expected bound)))
[(#;AppT (#;ExT eid) eA) (#;AppT (#;ExT aid) aA)]
- (if (=+ eid aid)
+ (if (n.= eid aid)
(check eA aA)
(fail-check expected actual))
@@ -495,7 +495,7 @@
(check eO aO))
[(#;ExT e!id) (#;ExT a!id)]
- (if (=+ e!id a!id)
+ (if (n.= e!id a!id)
success
(fail-check expected actual))
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index f507e1e9a..a9f638c73 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -15,7 +15,7 @@
(macro ["s" syntax #+ syntax:])))
(test: "Value identity."
- [size (|> R;nat (:: @ map (|>. (%+ +100) (max+ +10))))
+ [size (|> R;nat (:: @ map (|>. (n.% +100) (n.max +10))))
x (R;text size)
y (R;text size)]
($_ seq
@@ -47,8 +47,8 @@
(and (|> value inc even?)
(|> value dec even?)))))]
- ["Nat" R;nat inc+ dec+ even?+ odd?+ =+ <+ >+]
- ["Int" R;int inc dec even? odd? = < >]
+ ["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]
@@ -71,10 +71,10 @@
(>= y (max x y)))
)))]
- ["Int" R;int = < > <= >= min max]
- ["Nat" R;nat =+ <+ >+ <=+ >=+ min+ max+]
- ["Real" R;real =. <. >. <=. >=. min. max.]
- ["Frac" R;frac =.. <.. >.. <=.. >=.. min.. 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]
+ ["Real" R;real r.= r.< r.> r.<= r.>= r.min r.max]
+ ["Frac" R;frac f.= f.< f.> f.<= f.>= f.min f.max]
)
(do-template [category rand-gen = + - * / <%> > <0> <1> <10> %x <cap> <prep>]
@@ -120,9 +120,9 @@
(|> x' (/ y) (* y) (= x')))
))]
- ["Nat" R;nat =+ ++ -+ *+ /+ ;%+ >+ +0 +1 +1000000 %n (;%+ +1000) id]
- ["Int" R;int = + - * / ;% > 0 1 1000000 %i (;% 1000) id]
- ["Real" R;real =. +. -. *. /. ;%. >. 0.0 1.0 1000000.0 %r id math;floor]
+ ["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]
+ ["Real" R;real r.= r.+ r.- r.* r./ r.% r.> 0.0 1.0 1000000.0 %r id math;floor]
)
(do-template [category rand-gen -> <- = <cap> %a %z]
@@ -132,22 +132,22 @@
(assert ""
(|> value -> <- (= value))))]
- ["Int->Nat" R;int int-to-nat nat-to-int = (;% 1000000) %i %n]
- ["Nat->Int" R;nat nat-to-int int-to-nat =+ (;%+ +1000000) %n %i]
- ["Int->Real" R;int int-to-real real-to-int = (;% 1000000) %i %r]
- ["Real->Int" R;real real-to-int int-to-real =. math;floor %r %i]
- ## [R;real real-to-frac frac-to-real =. (;%. 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->Real" R;int int-to-real real-to-int i.= (i.% 1000000) %i %r]
+ ["Real->Int" R;real real-to-int int-to-real r.= math;floor %r %i]
+ ## [R;real real-to-frac frac-to-real r.= (r.% 1.0) %r %f]
)
(test: "Simple macros and constructs"
($_ seq
(assert "Can write easy loops for iterative programming."
- (= 1000
- (loop [counter 0
- value 1]
- (if (< 3 counter)
- (recur (inc counter) (* 10 value))
- value))))
+ (i.= 1000
+ (loop [counter 0
+ value 1]
+ (if (i.< 3 counter)
+ (recur (i.inc counter) (i.* 10 value))
+ value))))
(assert "Can create lists easily through macros."
(and (case (list 1 2 3)
diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux
index 20a3cb5b6..cecc2306f 100644
--- a/stdlib/test/test/lux/cli.lux
+++ b/stdlib/test/test/lux/cli.lux
@@ -20,7 +20,7 @@
lux/test)
(test: "CLI"
- [num-args (:: @ map (%+ +10) R;nat)
+ [num-args (:: @ map (n.% +10) R;nat)
#let [(^open "Nat/") number;Codec<Text,Nat>
gen-arg (:: @ map Nat/encode R;nat)]
option-name (R;text +5)
@@ -29,22 +29,22 @@
(assert "Can read any argument."
(|> (&;run &;any args)
(case> (#;Left _)
- (=+ +0 num-args)
+ (n.= +0 num-args)
(#;Right arg)
- (and (not (=+ +0 num-args))
+ (and (not (n.= +0 num-args))
(Text/= arg (default (undefined)
(list;head args)))))))
(assert "Can safely fail parsing an argument."
(|> (&;run (&;opt &;any) args)
(case> (#;Right (#;Some arg))
- (and (not (=+ +0 num-args))
+ (and (not (n.= +0 num-args))
(Text/= arg (default (undefined)
(list;head args))))
(#;Right #;None)
- (=+ +0 num-args)
+ (n.= +0 num-args)
_
false)))
@@ -55,18 +55,18 @@
false
(#;Right args')
- (=+ num-args (list;size args'))))
+ (n.= num-args (list;size args'))))
(|> (&;run (&;many &;any) args)
(case> (#;Left _)
- (=+ +0 num-args)
+ (n.= +0 num-args)
(#;Right args')
- (=+ num-args (list;size args'))))))
+ (n.= num-args (list;size args'))))))
(assert "Can use custom token parsers."
(|> (&;run (&;parse Nat/decode) args)
(case> (#;Left _)
- (=+ +0 num-args)
+ (n.= +0 num-args)
(#;Right parsed)
(Text/= (Nat/encode parsed)
@@ -76,7 +76,7 @@
(assert "Can obtain option values."
(and (|> (&;run (&;option (list option-name)) (list& option-name args))
(case> (#;Left _)
- (=+ +0 num-args)
+ (n.= +0 num-args)
(#;Right value)
(Text/= value (default (undefined)
@@ -92,7 +92,7 @@
(assert "Can query if there are any more inputs."
(and (|> (&;run &;end args)
- (case> (#;Right []) (=+ +0 num-args) _ false))
+ (case> (#;Right []) (n.= +0 num-args) _ false))
(|> (&;run (&;not &;end) args)
- (case> (#;Right []) (not (=+ +0 num-args)) _ false))))
+ (case> (#;Right []) (not (n.= +0 num-args)) _ false))))
))
diff --git a/stdlib/test/test/lux/codata/env.lux b/stdlib/test/test/lux/codata/env.lux
index 7a374cd4d..0e24ddf75 100644
--- a/stdlib/test/test/lux/codata/env.lux
+++ b/stdlib/test/test/lux/codata/env.lux
@@ -11,13 +11,13 @@
(test: "lux/codata/env exports"
(test-all (match 123 (run 123 ask))
- (match 246 (run 123 (local (* 2) ask)))
- (match 134 (run 123 (:: Functor<Env> map inc (+ 10))))
+ (match 246 (run 123 (local (i.* 2) ask)))
+ (match 134 (run 123 (:: Functor<Env> map i.inc (i.+ 10))))
(match 10 (run 123 (:: Applicative<Env> wrap 10)))
(match 30 (run 123 (let [(^open) Applicative<Env>]
- (apply (wrap (+ 10)) (wrap 20)))))
+ (apply (wrap (i.+ 10)) (wrap 20)))))
(match 30 (run 123 (do Monad<Env>
- [f (wrap +)
+ [f (wrap i.+)
x (wrap 10)
y (wrap 20)]
(wrap (f x y)))))))
diff --git a/stdlib/test/test/lux/codata/io.lux b/stdlib/test/test/lux/codata/io.lux
index 5d521faff..916609226 100644
--- a/stdlib/test/test/lux/codata/io.lux
+++ b/stdlib/test/test/lux/codata/io.lux
@@ -10,12 +10,12 @@
(test: "lux/codata/io exports"
(test-all (match "YOLO" (run (io "YOLO")))
- (match 11 (run (:: Functor<IO> map inc (io 10))))
+ (match 11 (run (:: Functor<IO> map i.inc (io 10))))
(match 10 (run (:: Applicative<IO> wrap 10)))
(match 30 (run (let [(^open) Applicative<IO>]
- (apply (wrap (+ 10)) (wrap 20)))))
+ (apply (wrap (i.+ 10)) (wrap 20)))))
(match 30 (run (do Monad<IO>
- [f (wrap +)
+ [f (wrap i.+)
x (wrap 10)
y (wrap 20)]
(wrap (f x y)))))))
diff --git a/stdlib/test/test/lux/codata/state.lux b/stdlib/test/test/lux/codata/state.lux
index 054b59d45..84c90b5b1 100644
--- a/stdlib/test/test/lux/codata/state.lux
+++ b/stdlib/test/test/lux/codata/state.lux
@@ -16,17 +16,17 @@
[_ (put 321)]
get))))
(match 369 (product;right (run 123 (do Monad<State>
- [_ (update (* 3))]
+ [_ (update (i.* 3))]
get))))
- (match 124 (product;right (run 123 (use inc))))
- (match 246 (product;right (run 123 (local (* 2) get))))
- (match 124 (product;right (run 123 (:: Functor<State> map inc get))))
+ (match 124 (product;right (run 123 (use i.inc))))
+ (match 246 (product;right (run 123 (local (i.* 2) get))))
+ (match 124 (product;right (run 123 (:: Functor<State> map i.inc get))))
(match 10 (product;right (run 123 (:: Applicative<State> wrap 10))))
(match 30 (product;right (run 123 (let [(^open) Applicative<State>]
- (apply (wrap (+ 10)) (wrap 20))))))
+ (apply (wrap (i.+ 10)) (wrap 20))))))
(match 30 (product;right (run 123 (: (State Int Int)
(do Monad<State>
- [f (wrap +)
+ [f (wrap i.+)
x (wrap 10)
y (wrap 20)]
diff --git a/stdlib/test/test/lux/codata/struct/stream.lux b/stdlib/test/test/lux/codata/struct/stream.lux
index 28292a405..1da81aa02 100644
--- a/stdlib/test/test/lux/codata/struct/stream.lux
+++ b/stdlib/test/test/lux/codata/struct/stream.lux
@@ -14,21 +14,21 @@
(test: "lux/codata/stream exports"
(let% [<take+drop+split> (do-template [<take> <drop> <split> <arg>]
[(match (^ (list 0 1 2))
- (<take> <arg> (iterate inc 0)))
+ (<take> <arg> (iterate i.inc 0)))
(match (^=> (^stream& w x y z ...)
{[w x y z] [3 4 5 6]})
- (<drop> <arg> (iterate inc 0)))
+ (<drop> <arg> (iterate i.inc 0)))
(match (^=> (^ [(list 0 1 2) _stream_])
{_stream_ (^stream& w x y z ...)}
{[w x y z] [3 4 5 6]})
- (<split> <arg> (iterate inc 0)))]
+ (<split> <arg> (iterate i.inc 0)))]
[take drop split +3]
- [take-while drop-while split-with (< 3)])
+ [take-while drop-while split-with (i.< 3)])
]
(test-all (match (^=> (^stream& w x y z ...)
{[w x y z] [0 1 2 3]})
- (iterate inc 0))
+ (iterate i.inc 0))
(match (^=> (^stream& w x y z ...)
{[w x y z] [0 0 0 0]})
(repeat 0))
@@ -36,33 +36,33 @@
{the-stream (^stream& w x y z ...)}
{[w x y z] [0 1 0 1]})
(cycle (list 0 1)))
- (match 0 (head (iterate inc 0)))
+ (match 0 (head (iterate i.inc 0)))
(match (^=> (^stream& w x y z ...)
{[w x y z] [1 2 3 4]})
- (tail (iterate inc 0)))
- (match 9 (at +9 (iterate inc 0)))
- (match 0 (at +0 (iterate inc 0)))
+ (tail (iterate i.inc 0)))
+ (match 9 (at +9 (iterate i.inc 0)))
+ (match 0 (at +0 (iterate i.inc 0)))
<take+drop+split>
(match (^=> (^stream& w x y z ...)
{[w x y z] ["0" "1" "2" "3"]})
- (unfold (lambda [n] [(inc n) (Int/encode n)])
+ (unfold (lambda [n] [(i.inc n) (Int/encode n)])
0))
(match (^=> (^stream& w x y z ...)
{[w x y z] [0 2 4 6]})
- (filter even? (iterate inc 0)))
+ (filter even? (iterate i.inc 0)))
(match (^=> [e_stream o_stream]
{e_stream (^stream& w x y z ...)}
{o_stream (^stream& a b c d ...)}
{[w x y z a b c d] [0 2 4 6 1 3 5 7]})
- (partition even? (iterate inc 0)))
+ (partition even? (iterate i.inc 0)))
(match (^=> (^stream& w x y z ...)
{[w x y z] [0 1 4 9]})
- (let [square (lambda [n] (* n n))]
- (:: Functor<Stream> map square (iterate inc 0))))
+ (let [square (lambda [n] (i.* n n))]
+ (:: Functor<Stream> map square (iterate i.inc 0))))
(match (^=> (^stream& w x y z ...)
{[w x y z] [4 9 16 25]})
- (let [square (lambda [n] (* n n))]
+ (let [square (lambda [n] (i.* n n))]
(be CoMonad<Stream>
- [inputs (iterate inc 2)]
+ [inputs (iterate i.inc 2)]
(square (head inputs)))))
)))
diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux
index e9a19e8ea..718ce080a 100644
--- a/stdlib/test/test/lux/concurrency/actor.lux
+++ b/stdlib/test/test/lux/concurrency/actor.lux
@@ -15,7 +15,7 @@
(method: (add! {offset Int})
[Int Int]
- (let [*state*' (+ offset *state*)]
+ (let [*state*' (i.+ offset *state*)]
(wrap (#;Right [*state*' [*state* *state*']]))))
(stop:
@@ -26,7 +26,7 @@
(test: "lux/concurrency/actor exports"
(let [counter-proc (: (Proc Int (Promise Int))
[(lambda [self output state]
- (let [state' (inc state)]
+ (let [state' (i.inc state)]
(exec (io;run (promise;resolve state' output))
(Promise/wrap (#;Right state')))))
(lambda [?error state] (Promise/wrap []))])]
diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux
index 62ca0b57d..b163aaa3f 100644
--- a/stdlib/test/test/lux/concurrency/frp.lux
+++ b/stdlib/test/test/lux/concurrency/frp.lux
@@ -34,21 +34,21 @@
(match+ (^ (list 0 1 2 3 4 5 0 -1 -2 -3 -4 -5))
(from-promise (consume (merge (list (List->Chan (list 0 1 2 3 4 5))
(List->Chan (list 0 -1 -2 -3 -4 -5)))))))
- (match+ 15 (from-promise (fold (lambda [base input] (Promise/wrap (+ input base))) 0 (List->Chan (list 0 1 2 3 4 5)))))
+ (match+ 15 (from-promise (fold (lambda [base input] (Promise/wrap (i.+ input base))) 0 (List->Chan (list 0 1 2 3 4 5)))))
(match+ (^ (list 0 1 2 3 4 5))
(from-promise (consume (no-dups number;Eq<Int> (List->Chan (list 0 0 0 1 2 2 3 3 3 3 4 4 4 5 5))))))
(match+ (^ (list 12345))
(from-promise (consume (as-chan (:: promise;Monad<Promise> wrap 12345)))))
(match+ (^ (list 1 2 3 4 5 6))
- (from-promise (consume (:: Functor<Chan> map inc (List->Chan (list 0 1 2 3 4 5))))))
+ (from-promise (consume (:: Functor<Chan> map i.inc (List->Chan (list 0 1 2 3 4 5))))))
(match+ (^ (list 12345))
(from-promise (consume (:: Applicative<Chan> wrap 12345))))
(match+ (^ (list 12346))
(from-promise (consume (let [(^open) Applicative<Chan>]
- (apply (wrap inc) (wrap 12345))))))
+ (apply (wrap i.inc) (wrap 12345))))))
(match+ (^ (list 12346))
(from-promise (consume (do Monad<Chan>
- [f (wrap inc)
+ [f (wrap i.inc)
a (wrap 12345)]
(wrap (f a))))))
))
diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux
index e29a5294b..da3c10dca 100644
--- a/stdlib/test/test/lux/concurrency/stm.lux
+++ b/stdlib/test/test/lux/concurrency/stm.lux
@@ -23,7 +23,7 @@
(from-promise (do promise;Monad<Promise>
[_ (seqM @
(map (lambda [_]
- (mapM @ (lambda [_] (commit (update inc _concurrency-var)))
+ (mapM @ (lambda [_] (commit (update i.inc _concurrency-var)))
(list;range 1 iterations/processes)))
(list;range 1 processes/vars)))]
(commit (read _concurrency-var))))))
@@ -39,7 +39,7 @@
[value (read _var)]
(wrap (#;Right value)))))
(match+ 15 (commit (do Monad<STM>
- [_ (update (* 3) _var)
+ [_ (update (i.* 3) _var)
value (read _var)]
(wrap (#;Right value)))))
(match+ 15 (commit (do Monad<STM>
diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux
index a6d897519..5aca04332 100644
--- a/stdlib/test/test/lux/data/bit.lux
+++ b/stdlib/test/test/lux/data/bit.lux
@@ -16,14 +16,14 @@
(test: "Bitwise operations."
[pattern R;nat
- idx (:: @ map (%+ width) R;nat)]
+ idx (:: @ map (n.% width) R;nat)]
($_ seq
- (assert "" (and (<+ (&;count (&;set idx pattern))
- (&;count (&;clear idx pattern)))
- (<=+ (&;count pattern)
+ (assert "" (and (n.< (&;count (&;set idx pattern))
(&;count (&;clear idx pattern)))
- (>=+ (&;count pattern)
- (&;count (&;set idx pattern)))
+ (n.<= (&;count pattern)
+ (&;count (&;clear idx pattern)))
+ (n.>= (&;count pattern)
+ (&;count (&;set idx pattern)))
(or (and (&;set? idx pattern)
(not (&;set? idx (&;clear idx pattern))))
@@ -35,32 +35,32 @@
(and (not (&;set? idx pattern))
(&;set? idx (&;flip idx pattern))))
- (=+ width
- (++ (&;count pattern)
- (&;count (&;~ pattern))))
+ (n.= width
+ (n.+ (&;count pattern)
+ (&;count (&;~ pattern))))
- (=+ +0
- (&;& pattern
- (&;~ pattern)))
- (=+ (&;~ +0)
- (&;| pattern
- (&;~ pattern)))
- (=+ (&;~ +0)
- (&;^ pattern
- (&;~ pattern)))
- (=+ +0
- (&;^ pattern
- pattern))
+ (n.= +0
+ (&;& pattern
+ (&;~ pattern)))
+ (n.= (&;~ +0)
+ (&;| pattern
+ (&;~ pattern)))
+ (n.= (&;~ +0)
+ (&;^ pattern
+ (&;~ pattern)))
+ (n.= +0
+ (&;^ pattern
+ pattern))
- (|> pattern (&;rotate-left idx) (&;rotate-right idx) (=+ pattern))
- (|> pattern (&;rotate-right idx) (&;rotate-left idx) (=+ pattern))
- (|> pattern (&;rotate-left idx) (&;rotate-left (-+ idx width)) (=+ pattern))
- (|> pattern (&;rotate-right idx) (&;rotate-right (-+ idx width)) (=+ pattern))
+ (|> pattern (&;rotate-left idx) (&;rotate-right idx) (n.= pattern))
+ (|> pattern (&;rotate-right idx) (&;rotate-left idx) (n.= pattern))
+ (|> pattern (&;rotate-left idx) (&;rotate-left (n.- idx width)) (n.= pattern))
+ (|> pattern (&;rotate-right idx) (&;rotate-right (n.- idx width)) (n.= pattern))
))
(assert "Shift right respect the sign of ints."
(let [value (nat-to-int pattern)]
- (if (< 0 value)
- (< 0 (&;>> idx value))
- (>= 0 (&;>> idx value)))))
+ (if (i.< 0 value)
+ (i.< 0 (&;>> idx value))
+ (i.>= 0 (&;>> idx value)))))
))
diff --git a/stdlib/test/test/lux/data/error.lux b/stdlib/test/test/lux/data/error.lux
index cc92a1276..7cc7c2f4c 100644
--- a/stdlib/test/test/lux/data/error.lux
+++ b/stdlib/test/test/lux/data/error.lux
@@ -16,31 +16,31 @@
($_ seq
(assert "Functor correctly handles both cases."
(and (|> (: (&;Error Int) (#;Right 10))
- (&/map inc)
+ (&/map i.inc)
(case> (#;Right 11) true _ false))
(|> (: (&;Error Int) (#;Left "YOLO"))
- (&/map inc)
+ (&/map i.inc)
(case> (#;Left "YOLO") true _ false))
))
(assert "Applicative correctly handles both cases."
(and (|> (&/wrap 20)
(case> (#;Right 20) true _ false))
- (|> (&/apply (&/wrap inc) (&/wrap 10))
+ (|> (&/apply (&/wrap i.inc) (&/wrap 10))
(case> (#;Right 11) true _ false))
- (|> (&/apply (&/wrap inc) (#;Left "YOLO"))
+ (|> (&/apply (&/wrap i.inc) (#;Left "YOLO"))
(case> (#;Left "YOLO") true _ false))))
(assert "Monad correctly handles both cases."
(and (|> (do &;Monad<Error>
- [f (wrap +)
+ [f (wrap i.+)
a (wrap 10)
b (wrap 20)]
(wrap (f a b)))
(case> (#;Right 30) true _ false))
(|> (do &;Monad<Error>
- [f (wrap +)
+ [f (wrap i.+)
a (#;Left "YOLO")
b (wrap 20)]
(wrap (f a b)))
diff --git a/stdlib/test/test/lux/data/error/exception.lux b/stdlib/test/test/lux/data/error/exception.lux
index 16d09a626..92d73ae80 100644
--- a/stdlib/test/test/lux/data/error/exception.lux
+++ b/stdlib/test/test/lux/data/error/exception.lux
@@ -42,9 +42,9 @@
otherwise-val)
default-val)]]
(assert "Catch and otherwhise handlers can properly handle the flow of exception-handling."
- (=+ this-val (|> (if should-throw?
- (&;return default-val)
- (&;throw this-ex "Uh-oh..."))
- (&;catch Some-Exception (lambda [ex] some-val))
- (&;catch Another-Exception (lambda [ex] another-val))
- (&;otherwise (lambda [ex] otherwise-val))))))
+ (n.= this-val (|> (if should-throw?
+ (&;return default-val)
+ (&;throw this-ex "Uh-oh..."))
+ (&;catch Some-Exception (lambda [ex] some-val))
+ (&;catch Another-Exception (lambda [ex] another-val))
+ (&;otherwise (lambda [ex] otherwise-val))))))
diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux
index d7c622bd5..270a42358 100644
--- a/stdlib/test/test/lux/data/format/json.lux
+++ b/stdlib/test/test/lux/data/format/json.lux
@@ -34,7 +34,7 @@
(R;Random &;JSON)
(R;rec (lambda [gen-json]
(do R;Monad<Random>
- [size (:: @ map (%+ +2) R;nat)]
+ [size (:: @ map (n.% +2) R;nat)]
($_ R;alt
(:: @ wrap [])
R;bool
@@ -81,7 +81,7 @@
(def: gen-record
(R;Random Record)
(do R;Monad<Random>
- [size (:: @ map (%+ +2) R;nat)]
+ [size (:: @ map (n.% +2) R;nat)]
($_ R;seq
(:: @ wrap [])
R;bool
@@ -100,16 +100,16 @@
(struct: _ (Eq Record)
(def: (= recL recR)
(and (:: bool;Eq<Bool> = (get@ #bool recL) (get@ #bool recR))
- (;= (get@ #int recL) (get@ #int recR))
- (=. (get@ #real recL) (get@ #real recR))
+ (i.= (get@ #int recL) (get@ #int recR))
+ (r.= (get@ #real recL) (get@ #real recR))
(:: char;Eq<Char> = (get@ #char recL) (get@ #char recR))
(:: text;Eq<Text> = (get@ #text recL) (get@ #text recR))
(:: (maybe;Eq<Maybe> number;Eq<Int>) = (get@ #maybe recL) (get@ #maybe recR))
(:: (list;Eq<List> number;Eq<Int>) = (get@ #list recL) (get@ #list recR))
(let [[tL0 tL1 tL2] (get@ #tuple recL)
[tR0 tR1 tR2] (get@ #tuple recR)]
- (and (;= tL0 tR0)
- (=. tL1 tR1)
+ (and (i.= tL0 tR0)
+ (r.= tL1 tR1)
(:: char;Eq<Char> = tL2 tR2)))
)))
diff --git a/stdlib/test/test/lux/data/ident.lux b/stdlib/test/test/lux/data/ident.lux
index 53ce4968e..e3e313f1a 100644
--- a/stdlib/test/test/lux/data/ident.lux
+++ b/stdlib/test/test/lux/data/ident.lux
@@ -15,14 +15,14 @@
(test: "Idents"
[## First Ident
- sizeM1 (|> R;nat (:: @ map (%+ +100)))
- sizeN1 (|> R;nat (:: @ map (%+ +100)))
+ sizeM1 (|> R;nat (:: @ map (n.% +100)))
+ sizeN1 (|> R;nat (:: @ map (n.% +100)))
module1 (R;text sizeM1)
name1 (R;text sizeN1)
#let [ident1 [module1 name1]]
## Second Ident
- sizeM2 (|> R;nat (:: @ map (%+ +100)))
- sizeN2 (|> R;nat (:: @ map (%+ +100)))
+ sizeM2 (|> R;nat (:: @ map (n.% +100)))
+ sizeN2 (|> R;nat (:: @ map (n.% +100)))
module2 (R;text sizeM2)
name2 (R;text sizeN2)
#let [ident2 [module2 name2]]
diff --git a/stdlib/test/test/lux/data/log.lux b/stdlib/test/test/lux/data/log.lux
index 3a02638c7..2075e0232 100644
--- a/stdlib/test/test/lux/data/log.lux
+++ b/stdlib/test/test/lux/data/log.lux
@@ -18,18 +18,18 @@
(let [(^open "&/") (&;Monad<Log> text;Monoid<Text>)]
($_ seq
(assert "Functor respects Log."
- (= 11 (product;right (&/map inc ["" 10]))))
+ (i.= 11 (product;right (&/map i.inc ["" 10]))))
(assert "Applicative respects Log."
- (and (= 20 (product;right (&/wrap 20)))
- (= 30 (product;right (&/apply (&/wrap (+ 10)) (&/wrap 20))))))
+ (and (i.= 20 (product;right (&/wrap 20)))
+ (i.= 30 (product;right (&/apply (&/wrap (i.+ 10)) (&/wrap 20))))))
(assert "Monad respects Log."
- (= 30 (product;right (do (&;Monad<Log> text;Monoid<Text>)
- [f (wrap +)
- a (wrap 10)
- b (wrap 20)]
- (wrap (f a b))))))
+ (i.= 30 (product;right (do (&;Monad<Log> text;Monoid<Text>)
+ [f (wrap i.+)
+ a (wrap 10)
+ b (wrap 20)]
+ (wrap (f a b))))))
(assert "Can log any value."
(Text/= "YOLO" (product;left (&;log "YOLO"))))
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux
index adefb480a..513af2ddf 100644
--- a/stdlib/test/test/lux/data/number.lux
+++ b/stdlib/test/test/lux/data/number.lux
@@ -85,18 +85,18 @@
(= unit (append unit unit))
(>= x (append x x))))))]
- ["Nat/Add" R;nat Number<Nat> Add@Monoid<Nat> (;%+ +1000)]
- ["Nat/Mul" R;nat Number<Nat> Mul@Monoid<Nat> (;%+ +1000)]
- ["Nat/Min" R;nat Number<Nat> Min@Monoid<Nat> (;%+ +1000)]
- ["Nat/Max" R;nat Number<Nat> Max@Monoid<Nat> (;%+ +1000)]
- ["Int/Add" R;int Number<Int> Add@Monoid<Int> (;% 1000)]
- ["Int/Mul" R;int Number<Int> Mul@Monoid<Int> (;% 1000)]
- ["Int/Min" R;int Number<Int> Min@Monoid<Int> (;% 1000)]
- ["Int/Max" R;int Number<Int> Max@Monoid<Int> (;% 1000)]
- ["Real/Add" R;real Number<Real> Add@Monoid<Real> (;%. 1000.0)]
- ["Real/Mul" R;real Number<Real> Mul@Monoid<Real> (;%. 1000.0)]
- ["Real/Min" R;real Number<Real> Min@Monoid<Real> (;%. 1000.0)]
- ["Real/Max" R;real Number<Real> Max@Monoid<Real> (;%. 1000.0)]
+ ["Nat/Add" R;nat Number<Nat> Add@Monoid<Nat> (n.% +1000)]
+ ["Nat/Mul" R;nat Number<Nat> Mul@Monoid<Nat> (n.% +1000)]
+ ["Nat/Min" R;nat Number<Nat> Min@Monoid<Nat> (n.% +1000)]
+ ["Nat/Max" R;nat Number<Nat> Max@Monoid<Nat> (n.% +1000)]
+ ["Int/Add" R;int Number<Int> Add@Monoid<Int> (i.% 1000)]
+ ["Int/Mul" R;int Number<Int> Mul@Monoid<Int> (i.% 1000)]
+ ["Int/Min" R;int Number<Int> Min@Monoid<Int> (i.% 1000)]
+ ["Int/Max" R;int Number<Int> Max@Monoid<Int> (i.% 1000)]
+ ["Real/Add" R;real Number<Real> Add@Monoid<Real> (r.% 1000.0)]
+ ["Real/Mul" R;real Number<Real> Mul@Monoid<Real> (r.% 1000.0)]
+ ["Real/Min" R;real Number<Real> Min@Monoid<Real> (r.% 1000.0)]
+ ["Real/Max" R;real Number<Real> Max@Monoid<Real> (r.% 1000.0)]
)
(do-template [category rand-gen <Number> <Codec>]
diff --git a/stdlib/test/test/lux/data/product.lux b/stdlib/test/test/lux/data/product.lux
index f74c9a4d8..3d064f96e 100644
--- a/stdlib/test/test/lux/data/product.lux
+++ b/stdlib/test/test/lux/data/product.lux
@@ -16,11 +16,11 @@
(test: "Products"
($_ seq
(assert "Can access the sides of a pair."
- (and (= 1 (left [1 2]))
- (= 2 (right [1 2]))))
+ (and (i.= 1 (left [1 2]))
+ (i.= 2 (right [1 2]))))
(assert "Can swap the sides of a pair."
(let [[_left _right] (swap [1 2])]
- (and (= 2 _left)
- (= 1 _right))))
+ (and (i.= 2 _left)
+ (i.= 1 _right))))
))
diff --git a/stdlib/test/test/lux/data/struct/array.lux b/stdlib/test/test/lux/data/struct/array.lux
index ba4b5a3ae..6decd910f 100644
--- a/stdlib/test/test/lux/data/struct/array.lux
+++ b/stdlib/test/test/lux/data/struct/array.lux
@@ -17,7 +17,7 @@
(def: bounded-size
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (|>. (%+ +100) (++ +1)))))
+ (:: R;Monad<Random> map (|>. (n.% +100) (n.+ +1)))))
(test: "Arrays and their copies"
[size bounded-size
@@ -29,7 +29,7 @@
(&;new size))]]
($_ seq
(assert "Size function must correctly return size of array."
- (=+ size (&;size original)))
+ (n.= size (&;size original)))
(assert "Cloning an array should yield and identical array, but not the same one."
(and (:: (&;Eq<Array> number;Eq<Nat>) = original clone)
(not (== original clone))))
@@ -41,7 +41,7 @@
(exec (:: &;Fold<Array> fold
(lambda [x idx]
(exec (&;put idx x manual-copy)
- (inc+ idx)))
+ (n.inc idx)))
+0
original)
(:: (&;Eq<Array> number;Eq<Nat>) = original manual-copy)))
@@ -53,9 +53,9 @@
(test: "Array mutation"
[size bounded-size
- idx (:: @ map (%+ size) R;nat)
+ idx (:: @ map (n.% size) R;nat)
array (|> (R;array size R;nat)
- (R;filter (|>. &;to-list (list;any? odd?+))))
+ (R;filter (|>. &;to-list (list;any? n.odd?))))
#let [value (default (undefined)
(&;get idx array))]]
($_ seq
@@ -65,32 +65,32 @@
#;None true))
(assert "You should be able to access values put into the array."
(case (&;get idx (&;put idx value array))
- (#;Some value') (=+ value' value)
+ (#;Some value') (n.= value' value)
#;None false))
(assert "All cells should be occupied on a full array."
- (and (=+ size (&;occupied array))
- (=+ +0 (&;vacant array))))
+ (and (n.= size (&;occupied array))
+ (n.= +0 (&;vacant array))))
(assert "Filtering mutates the array to remove invalid values."
- (exec (&;filter even?+ array)
- (and (<+ size (&;occupied array))
- (>+ +0 (&;vacant array))
- (=+ size (++ (&;occupied array)
- (&;vacant array))))))
+ (exec (&;filter n.even? array)
+ (and (n.< size (&;occupied array))
+ (n.> +0 (&;vacant array))
+ (n.= size (n.+ (&;occupied array)
+ (&;vacant array))))))
))
(test: "Finding values."
[size bounded-size
array (|> (R;array size R;nat)
- (R;filter (|>. &;to-list (list;any? even?+))))]
+ (R;filter (|>. &;to-list (list;any? n.even?))))]
($_ seq
(assert "Can find values inside arrays."
- (|> (&;find even?+ array)
+ (|> (&;find n.even? array)
(case> (#;Some _) true
#;None false)))
(assert "Can find values inside arrays (with access to indices)."
(|> (&;find+ (lambda [idx n]
- (and (even?+ n)
- (<+ size idx)))
+ (and (n.even? n)
+ (n.< size idx)))
array)
(case> (#;Some _) true
#;None false)))))
@@ -106,8 +106,8 @@
(and (= array copy)
(not (== array copy)))))
(assert "Functor should go over all available array elements."
- (let [there (map inc+ array)
- back-again (map dec+ there)]
+ (let [there (map n.inc array)
+ back-again (map n.dec there)]
(and (not (= array there))
(= array back-again)))))))
@@ -121,7 +121,7 @@
fusion (append left right)]]
($_ seq
(assert "Appending two arrays should produce a new one twice as large."
- (=+ (++ sizeL sizeR) (&;size fusion)))
+ (n.= (n.+ sizeL sizeR) (&;size fusion)))
(assert "First elements of fused array should equal the first array."
(|> (: (&;Array Nat)
(&;new sizeL))
diff --git a/stdlib/test/test/lux/data/struct/dict.lux b/stdlib/test/test/lux/data/struct/dict.lux
index 2e14ddfff..acd878e8d 100644
--- a/stdlib/test/test/lux/data/struct/dict.lux
+++ b/stdlib/test/test/lux/data/struct/dict.lux
@@ -20,7 +20,7 @@
lux/test)
(test: "Dictionaries."
- [#let [capped-nat (:: R;Monad<Random> map (%+ +100) R;nat)]
+ [#let [capped-nat (:: R;Monad<Random> map (n.% +100) R;nat)]
size capped-nat
dict (R;dict char;Hash<Char> size R;char capped-nat)
non-key (|> R;char
@@ -29,10 +29,10 @@
(R;filter (lambda [val] (not (list;member? number;Eq<Nat> (&;values dict) val)))))]
($_ seq
(assert "Size function should correctly represent Dict size."
- (=+ size (&;size dict)))
+ (n.= size (&;size dict)))
(assert "Dicts of size 0 should be considered empty."
- (if (=+ +0 size)
+ (if (n.= +0 size)
(&;empty? dict)
(not (&;empty? dict))))
@@ -59,19 +59,19 @@
(assert "Should be able to put and then get a value."
(case (&;get non-key (&;put non-key test-val dict))
- (#;Some v) (=+ test-val v)
+ (#;Some v) (n.= test-val v)
_ true))
(assert "Should be able to put~ and then get a value."
(case (&;get non-key (&;put~ non-key test-val dict))
- (#;Some v) (=+ test-val v)
+ (#;Some v) (n.= test-val v)
_ true))
(assert "Shouldn't be able to put~ an existing key."
- (or (=+ +0 size)
+ (or (n.= +0 size)
(let [first-key (|> dict &;keys list;head (default (undefined)))]
(case (&;get first-key (&;put~ first-key test-val dict))
- (#;Some v) (not (=+ test-val v))
+ (#;Some v) (not (n.= test-val v))
_ true))))
(assert "Removing a key should make it's value inaccessible."
@@ -81,10 +81,10 @@
(assert "Should be possible to update values via their keys."
(let [base (&;put non-key test-val dict)
- updt (&;update non-key inc+ base)]
+ updt (&;update non-key n.inc base)]
(case [(&;get non-key base) (&;get non-key updt)]
[(#;Some x) (#;Some y)]
- (=+ (inc+ x) y)
+ (n.= (n.inc x) y)
_
false)))
@@ -92,8 +92,8 @@
(assert "Additions and removals to a Dict should affect its size."
(let [plus (&;put non-key test-val dict)
base (&;remove non-key plus)]
- (and (=+ (inc+ (&;size dict)) (&;size plus))
- (=+ (dec+ (&;size plus)) (&;size base)))))
+ (and (n.= (n.inc (&;size dict)) (&;size plus))
+ (n.= (n.dec (&;size plus)) (&;size base)))))
(assert "A Dict should equal itself & going to<->from lists shouldn't change that."
(let [(^open) (&;Eq<Dict> number;Eq<Nat>)]
@@ -106,31 +106,31 @@
(assert "If you merge, and the second dict has overlapping keys, it should overwrite yours."
(let [dict' (|> dict &;entries
- (List/map (lambda [[k v]] [k (inc+ v)]))
+ (List/map (lambda [[k v]] [k (n.inc v)]))
(&;from-list char;Hash<Char>))
(^open) (&;Eq<Dict> number;Eq<Nat>)]
(= dict' (&;merge dict' dict))))
(assert "Can merge values in such a way that they become combined."
- (list;every? (lambda [[x x*2]] (=+ (*+ +2 x) x*2))
+ (list;every? (lambda [[x x*2]] (n.= (n.* +2 x) x*2))
(list;zip2 (&;values dict)
- (&;values (&;merge-with ++ dict dict)))))
+ (&;values (&;merge-with n.+ dict dict)))))
(assert "Should be able to select subset of keys from dict."
(|> dict
(&;put non-key test-val)
(&;select (list non-key))
&;size
- (=+ +1)))
+ (n.= +1)))
(assert "Should be able to re-bind existing values to different keys."
- (or (=+ +0 size)
+ (or (n.= +0 size)
(let [first-key (|> dict &;keys list;head (default (undefined)))
rebound (&;re-bind first-key non-key dict)]
- (and (=+ (&;size dict) (&;size rebound))
+ (and (n.= (&;size dict) (&;size rebound))
(&;contains? non-key rebound)
(not (&;contains? first-key rebound))
- (=+ (default (undefined)
+ (n.= (default (undefined)
(&;get first-key dict))
(default (undefined)
(&;get non-key rebound)))))))
diff --git a/stdlib/test/test/lux/data/struct/list.lux b/stdlib/test/test/lux/data/struct/list.lux
index 5803e8615..aa269988b 100644
--- a/stdlib/test/test/lux/data/struct/list.lux
+++ b/stdlib/test/test/lux/data/struct/list.lux
@@ -19,11 +19,11 @@
(def: bounded-size
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (|>. (%+ +100) (++ +10)))))
+ (:: R;Monad<Random> map (|>. (n.% +100) (n.+ +10)))))
(test: "Lists: Part 1"
[size bounded-size
- idx (:: @ map (%+ 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)
@@ -32,33 +32,33 @@
(^open "&/") &;Functor<List>]]
($_ seq
(assert "The size function should correctly portray the size of the list."
- (=+ size (&;size sample)))
+ (n.= size (&;size sample)))
(assert "The repeat function should produce as many elements as asked of it."
- (=+ size (&;size (&;repeat size []))))
+ (n.= size (&;size (&;repeat size []))))
(assert "Reversing a list does not change it's size."
- (=+ (&;size sample)
- (&;size (&;reverse sample))))
+ (n.= (&;size sample)
+ (&;size (&;reverse sample))))
(assert "Reversing a list twice results in the original list."
(= sample
(&;reverse (&;reverse sample))))
(assert "Filtering by a predicate and its complement should result in a number of elements equal to the original list."
- (and (=+ (&;size sample)
- (++ (&;size (&;filter even?+ sample))
- (&;size (&;filter (bool;complement even?+) sample))))
- (let [[plus minus] (&;partition even?+ sample)]
- (=+ (&;size sample)
- (++ (&;size plus)
- (&;size minus))))))
+ (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))))))
(assert "If every element in a list satisfies a predicate, there can't be any that satisfy its complement."
- (if (&;every? even?+ sample)
- (and (not (&;any? (bool;complement even?+) sample))
- (&;empty? (&;filter (bool;complement even?+) sample)))
- (&;any? (bool;complement 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)))
(assert "Any element of the list can be considered it's member."
(let [elem (default (undefined)
@@ -68,7 +68,7 @@
(test: "Lists: Part 2"
[size bounded-size
- idx (:: @ map (%+ 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)
@@ -95,15 +95,15 @@
(assert "Functor should go over every element of the list."
(let [(^open) &;Functor<List>
- there (map inc+ sample)
- back-again (map dec+ there)]
+ there (map n.inc sample)
+ back-again (map n.dec there)]
(and (not (= sample there))
(= sample back-again))))
(assert "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 even?+ sample)]
+ [left' right'] (&;split-with n.even? sample)]
(and (= sample
(append left right))
(= sample
@@ -112,26 +112,26 @@
(append (&;take idx sample)
(&;drop idx sample)))
(= sample
- (append (&;take-while even?+ sample)
- (&;drop-while even?+ sample)))
+ (append (&;take-while n.even? sample)
+ (&;drop-while n.even? sample)))
)))
(assert "Segmenting the list in pairs should yield as many elements as N/2."
- (=+ (/+ +2 size)
- (&;size (&;as-pairs sample))))
+ (n.= (n./ +2 size)
+ (&;size (&;as-pairs sample))))
(assert "Sorting a list shouldn't change it's size."
- (=+ (&;size sample)
- (&;size (&;sort <+ sample))))
+ (n.= (&;size sample)
+ (&;size (&;sort n.< sample))))
(assert "Sorting a list with one order should yield the reverse of sorting it with the opposite order."
- (= (&;sort <+ sample)
- (&;reverse (&;sort >+ sample))))
+ (= (&;sort n.< sample)
+ (&;reverse (&;sort n.> sample))))
))
(test: "Lists: Part 3"
[size bounded-size
- idx (:: @ map (%+ 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)
@@ -140,8 +140,8 @@
(^open "&/") &;Functor<List>]]
($_ seq
(assert "If you zip 2 lists, the result's size will be that of the smaller list."
- (=+ (&;size (&;zip2 sample other-sample))
- (min+ (&;size sample) (&;size other-sample))))
+ (n.= (&;size (&;zip2 sample other-sample))
+ (n.min (&;size sample) (&;size other-sample))))
(assert "I can pair-up elements of a list in order."
(let [(^open) &;Functor<List>
@@ -153,21 +153,21 @@
(assert "You can generate indices for any size, and they will be in ascending order."
(let [(^open) &;Functor<List>
indices (&;indices size)]
- (and (=+ size (&;size indices))
+ (and (n.= size (&;size indices))
(= indices
- (&;sort <+ indices))
- (&;every? (=+ (dec+ size))
- (&;zip2-with ++
+ (&;sort n.< indices))
+ (&;every? (n.= (n.dec size))
+ (&;zip2-with n.+
indices
- (&;sort >+ indices)))
+ (&;sort n.> indices)))
)))
(assert "The 'interpose' function places a value between every member of a list."
(let [(^open) &;Functor<List>
sample+ (&;interpose separator sample)]
- (and (=+ (|> size (*+ +2) dec+)
- (&;size sample+))
- (|> sample+ &;as-pairs (map product;right) (&;every? (=+ separator))))))
+ (and (n.= (|> size (n.* +2) n.dec)
+ (&;size sample+))
+ (|> sample+ &;as-pairs (map product;right) (&;every? (n.= separator))))))
(assert "List append is a monoid."
(let [(^open) &;Monoid<List>]
@@ -180,8 +180,8 @@
(assert "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 inc+ sample)
- (apply (wrap inc+) sample)))))
+ (= (map n.inc sample)
+ (apply (wrap n.inc) sample)))))
(assert "List concatenation is a monad."
(let [(^open) &;Monad<List>
@@ -190,19 +190,19 @@
(join (list sample other-sample)))))
(assert "You can find any value that satisfies some criterium, if such values exist in the list."
- (case (&;find even?+ sample)
+ (case (&;find n.even? sample)
(#;Some found)
- (and (even?+ found)
- (&;any? even?+ sample)
- (not (&;every? (bool;complement even?+) sample)))
+ (and (n.even? found)
+ (&;any? n.even? sample)
+ (not (&;every? (bool;complement n.even?) sample)))
#;None
- (and (not (&;any? even?+ sample))
- (&;every? (bool;complement even?+) sample))))
+ (and (not (&;any? n.even? sample))
+ (&;every? (bool;complement n.even?) sample))))
(assert "You can iteratively construct a list, generating values until you're done."
- (= (&;range+ +0 (dec+ size))
- (&;iterate (lambda [n] (if (<+ size n) (#;Some (inc+ n)) #;None))
+ (= (&;n.range +0 (n.dec size))
+ (&;iterate (lambda [n] (if (n.< size n) (#;Some (n.inc n)) #;None))
+0)))
(assert "Can enumerate all elements in a list."
diff --git a/stdlib/test/test/lux/data/struct/queue.lux b/stdlib/test/test/lux/data/struct/queue.lux
index 5473532bc..98379e30a 100644
--- a/stdlib/test/test/lux/data/struct/queue.lux
+++ b/stdlib/test/test/lux/data/struct/queue.lux
@@ -14,21 +14,21 @@
lux/test)
(test: "Queues"
- [size (:: @ map (%+ +100) R;nat)
+ [size (:: @ map (n.% +100) R;nat)
sample (R;queue size R;nat)
non-member (|> R;nat
(R;filter (. not (&;enqueued? number;Eq<Nat> sample))))]
($_ seq
(assert "I can query the size of a queue (and empty queues have size 0)."
- (if (=+ +0 size)
+ (if (n.= +0 size)
(&;empty? sample)
- (=+ size (&;size sample))))
+ (n.= size (&;size sample))))
(assert "Enqueueing and dequeing affects the size of queues."
- (and (=+ (inc+ size) (&;size (&;enqueue non-member sample)))
+ (and (n.= (n.inc size) (&;size (&;enqueue non-member sample)))
(or (&;empty? sample)
- (=+ (dec+ size) (&;size (&;dequeue sample))))
- (=+ size (&;size (&;dequeue (&;enqueue non-member sample))))))
+ (n.= (n.dec size) (&;size (&;dequeue sample))))
+ (n.= size (&;size (&;dequeue (&;enqueue non-member sample))))))
(assert "Transforming to/from list can't change the queue."
(let [(^open "&/") (&;Eq<Queue> number;Eq<Nat>)]
diff --git a/stdlib/test/test/lux/data/struct/set.lux b/stdlib/test/test/lux/data/struct/set.lux
index 7a4663509..bc284dd4a 100644
--- a/stdlib/test/test/lux/data/struct/set.lux
+++ b/stdlib/test/test/lux/data/struct/set.lux
@@ -17,7 +17,7 @@
(def: gen-nat
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (%+ +100))))
+ (:: R;Monad<Random> map (n.% +100))))
(test: "Sets"
[sizeL gen-nat
@@ -29,8 +29,8 @@
#let [(^open "&/") &;Eq<Set>]]
($_ seq
(assert "I can query the size of a set."
- (and (=+ sizeL (&;size setL))
- (=+ sizeR (&;size setR))))
+ (and (n.= sizeL (&;size setL))
+ (n.= sizeR (&;size setR))))
(assert "Converting sets to/from lists can't change their values."
(|> setL
diff --git a/stdlib/test/test/lux/data/struct/stack.lux b/stdlib/test/test/lux/data/struct/stack.lux
index c33bc4012..427c5c04d 100644
--- a/stdlib/test/test/lux/data/struct/stack.lux
+++ b/stdlib/test/test/lux/data/struct/stack.lux
@@ -17,7 +17,7 @@
(def: gen-nat
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (%+ +100))))
+ (:: R;Monad<Random> map (n.% +100))))
(test: "Stacks"
[size gen-nat
@@ -25,7 +25,7 @@
new-top gen-nat]
($_ seq
(assert "Can query the size of a stack."
- (=+ size (&;size sample)))
+ (n.= size (&;size sample)))
(assert "Can peek inside non-empty stacks."
(case (&;peek sample)
@@ -35,14 +35,14 @@
(assert "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 (=+ (&;size sample) (inc+ (&;size sample')))
+ (or (n.= (&;size sample) (n.inc (&;size sample')))
(and (&;empty? sample) (&;empty? sample')))
))
(assert "Pushing onto a stack always increases it by 1, adding a new value at the top."
(and (== sample
(&;pop (&;push new-top sample)))
- (=+ (inc+ (&;size sample)) (&;size (&;push new-top sample)))
+ (n.= (n.inc (&;size sample)) (&;size (&;push new-top sample)))
(|> (&;push new-top sample) &;peek (default (undefined))
(== new-top))))
))
diff --git a/stdlib/test/test/lux/data/struct/tree.lux b/stdlib/test/test/lux/data/struct/tree.lux
index 90b80943a..3c60628e5 100644
--- a/stdlib/test/test/lux/data/struct/tree.lux
+++ b/stdlib/test/test/lux/data/struct/tree.lux
@@ -17,7 +17,7 @@
(def: gen-nat
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (%+ +100))))
+ (:: R;Monad<Random> map (n.% +100))))
(test: "Trees"
[leaf (:: @ map &;leaf R;nat)
diff --git a/stdlib/test/test/lux/data/struct/vector.lux b/stdlib/test/test/lux/data/struct/vector.lux
index c3f3a706e..fe1350ce0 100644
--- a/stdlib/test/test/lux/data/struct/vector.lux
+++ b/stdlib/test/test/lux/data/struct/vector.lux
@@ -18,8 +18,8 @@
lux/test)
(test: "Vectors"
- [size (|> R;nat (:: @ map (%+ +100)))
- idx (|> R;nat (:: @ map (%+ size)))
+ [size (|> R;nat (:: @ map (n.% +100)))
+ idx (|> R;nat (:: @ map (n.% size)))
sample (R;vector size R;nat)
other-sample (R;vector size R;nat)
non-member (|> R;nat (R;filter (. not (&;member? number;Eq<Nat> sample))))
@@ -30,13 +30,13 @@
($_ seq
(assert "Can query size of vector."
(if (&;empty? sample)
- (and (=+ +0 size)
- (=+ +0 (&;size sample)))
- (=+ size (&;size sample))))
+ (and (n.= +0 size)
+ (n.= +0 (&;size sample)))
+ (n.= size (&;size sample))))
(assert "Can add and remove elements to vectors."
- (and (=+ (inc+ size) (&;size (&;add non-member sample)))
- (=+ (dec+ size) (&;size (&;pop sample)))))
+ (and (n.= (n.inc size) (&;size (&;add non-member sample)))
+ (n.= (n.dec size) (&;size (&;pop sample)))))
(assert "Can put and get elements into vectors."
(|> sample
@@ -47,9 +47,9 @@
(assert "Can update elements of vectors."
(|> sample
- (&;put idx non-member) (&;update idx inc+)
+ (&;put idx non-member) (&;update idx n.inc)
(&;at idx) (default (undefined))
- (=+ (inc+ non-member))))
+ (n.= (n.inc non-member))))
(assert "Can safely transform to/from lists."
(|> sample &;to-list &;from-list (&/= sample)))
@@ -59,18 +59,18 @@
(&;member? number;Eq<Nat> (&;add non-member sample) non-member)))
(assert "Can fold over elements of vector."
- (=+ (List/fold ++ +0 (&;to-list sample))
- (&/fold ++ +0 sample)))
+ (n.= (List/fold n.+ +0 (&;to-list sample))
+ (&/fold n.+ +0 sample)))
(assert "Functor goes over every element."
- (let [there (&/map inc+ sample)
- back-again (&/map dec+ there)]
+ (let [there (&/map n.inc sample)
+ back-again (&/map n.dec there)]
(and (not (&/= sample there))
(&/= sample back-again))))
(assert "Applicative allows you to create singleton vectors, and apply vectors of functions to vectors of values."
(and (&/= (&;vector non-member) (&/wrap non-member))
- (&/= (&/map inc+ sample) (&/apply (&/wrap inc+) sample))))
+ (&/= (&/map n.inc sample) (&/apply (&/wrap n.inc) sample))))
(assert "Vector concatenation is a monad."
(&/= (&/append sample other-sample)
diff --git a/stdlib/test/test/lux/data/struct/zipper.lux b/stdlib/test/test/lux/data/struct/zipper.lux
index 62f167ffd..6e1a168c2 100644
--- a/stdlib/test/test/lux/data/struct/zipper.lux
+++ b/stdlib/test/test/lux/data/struct/zipper.lux
@@ -23,7 +23,7 @@
(R;rec (lambda [gen-tree]
(do R;Monad<Random>
## Each branch can have, at most, 1 child.
- [size (|> R;nat (:: @ map (%+ +2)))]
+ [size (|> R;nat (:: @ map (n.% +2)))]
(R;seq R;nat
(R;list size gen-tree))))))
@@ -99,7 +99,7 @@
#;None true))))))
(assert "Can set and update the value of a node."
- (|> sample &;from-tree (&;set new-val) &;value (=+ new-val)))
+ (|> sample &;from-tree (&;set new-val) &;value (n.= new-val)))
(assert "Zipper traversal follows the outline of the tree depth-first."
(List/= (tree;flatten sample)
diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux
index 049dff77c..2ff10dbf5 100644
--- a/stdlib/test/test/lux/data/sum.lux
+++ b/stdlib/test/test/lux/data/sum.lux
@@ -34,6 +34,6 @@
(list (+0 "0") (+1 "1") (+0 "2"))))))))
(assert "Can apply a function to an Either value depending on the case."
- (and (= 10 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+0 ""))))
- (= 20 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+1 ""))))))
+ (and (i.= 10 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+0 ""))))
+ (i.= 20 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+1 ""))))))
)))
diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux
index 8b315c8b0..46f9192dd 100644
--- a/stdlib/test/test/lux/data/text.lux
+++ b/stdlib/test/test/lux/data/text.lux
@@ -18,20 +18,20 @@
lux/test)
(test: "Size"
- [size (:: @ map (%+ +100) R;nat)
+ [size (:: @ map (n.% +100) R;nat)
sample (R;text size)]
- (assert "" (or (and (=+ +0 size)
+ (assert "" (or (and (n.= +0 size)
(&;empty? sample))
- (=+ size (&;size sample)))))
+ (n.= size (&;size sample)))))
(def: bounded-size
(R;Random Nat)
(|> R;nat
- (:: R;Monad<Random> map (|>. (%+ +100) (++ +1)))))
+ (:: R;Monad<Random> map (|>. (n.% +100) (n.+ +1)))))
(test: "Locations"
[size bounded-size
- idx (:: @ map (%+ size) R;nat)
+ idx (:: @ map (n.% size) R;nat)
sample (R;text size)]
(assert "" (|> sample
(&;at idx)
@@ -43,11 +43,11 @@
(&;last-index-of' char' idx sample)]
[(#;Some io) (#;Some lio)
(#;Some io') (#;Some lio')]})
- (and (<=+ idx io)
- (>=+ idx lio)
+ (and (n.<= idx io)
+ (n.>= idx lio)
- (=+ idx io')
- (>=+ idx lio')
+ (n.= idx io')
+ (n.>= idx lio')
(&;contains? char' sample))
@@ -109,8 +109,8 @@
#let [sample1 (&;concat (list;interpose sep1 parts))
sample2 (&;concat (list;interpose sep2 parts))
(^open) &;Eq<Text>]]
- (assert "" (and (=+ (list;size parts)
- (list;size (&;split-all-with sep1 sample1)))
+ (assert "" (and (n.= (list;size parts)
+ (list;size (&;split-all-with sep1 sample1)))
(= sample2
(&;replace sep1 sep2 sample1))
)))
diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux
index 3d5e053f7..8d96fcc41 100644
--- a/stdlib/test/test/lux/math.lux
+++ b/stdlib/test/test/lux/math.lux
@@ -13,14 +13,14 @@
(test: "lux/math exports"
(test-all (match 1.0 (cos 0.0))
- (match -1.0 (cos (/. 2.0 tau)))
- ## (match 0.0 (cos (/. 4.0 tau)))
- ## (match 0.0 (cos (*. (/. 4.0 3.0) tau)))
+ (match -1.0 (cos (r./ 2.0 tau)))
+ ## (match 0.0 (cos (r./ 4.0 tau)))
+ ## (match 0.0 (cos (r.* (r./ 4.0 3.0) tau)))
- (match 1.0 (sin (/. 4.0 tau)))
- (match -1.0 (sin (*. (/. 4.0 3.0) tau)))
+ (match 1.0 (sin (r./ 4.0 tau)))
+ (match -1.0 (sin (r.* (r./ 4.0 3.0) tau)))
## (match 0.0 (sin 0.0))
- ## (match 0.0 (sin (/. 2.0 tau)))
+ ## (match 0.0 (sin (r./ 2.0 tau)))
(match 4 (ceil 3.75))
(match 3 (floor 3.75))
@@ -30,16 +30,16 @@
(match 3.0 (cbrt 27.0))
(match 4.0 (sqrt 16.0))
- (match 90.0 (degrees (/. 4.0 tau)))
- (match true (=. tau (radians (degrees tau))))
+ (match 90.0 (degrees (r./ 4.0 tau)))
+ (match true (r.= tau (radians (degrees tau))))
(match 9 (gcd 450 27))
(match 40 (lcm 10 8))
(match 27 (infix 27))
(match 9 (infix [27 gcd 450]))
- (match 9 (infix [(* 3 9) gcd 450]))
- (match true (infix [#and 27 < 450 < 2000]))
- (match true (infix [#and 27 < 450 > 200]))
- (match true (infix [[27 < 450] and [200 < 2000]]))
+ (match 9 (infix [(i.* 3 9) gcd 450]))
+ (match true (infix [#and 27 i.< 450 i.< 2000]))
+ (match true (infix [#and 27 i.< 450 i.> 200]))
+ (match true (infix [[27 i.< 450] and [200 i.< 2000]]))
))
diff --git a/stdlib/test/test/lux/pipe.lux b/stdlib/test/test/lux/pipe.lux
index a601bbf98..681c4bf71 100644
--- a/stdlib/test/test/lux/pipe.lux
+++ b/stdlib/test/test/lux/pipe.lux
@@ -12,26 +12,26 @@
(test: "lux/pipe exports"
(test-all (match 1 (|> 20
- (* 3)
- (+ 4)
- (_> 0 inc)))
+ (i.* 3)
+ (i.+ 4)
+ (_> 0 i.inc)))
(match 10 (|> 5
- (@> [(+ @ @)])))
+ (@> [(i.+ @ @)])))
(match 15 (|> 5
- (?> [even?] [(* 2)]
- [odd?] [(* 3)]
+ (?> [i.even?] [(i.* 2)]
+ [i.odd?] [(i.* 3)]
[(_> -1)])))
(match 15 (|> 5
- (?> [even?] [(* 2)]
- [odd?] [(* 3)])))
+ (?> [i.even?] [(i.* 2)]
+ [i.odd?] [(i.* 3)])))
(match 10 (|> 1
- (!> [(< 10)]
- [inc])))
+ (!> [(i.< 10)]
+ [i.inc])))
(match 20 (|> 5
(%> Monad<Identity>
- [(* 3)]
- [(+ 4)]
- [inc])))
+ [(i.* 3)]
+ [(i.+ 4)]
+ [i.inc])))
(match "five" (|> 5
(case> 0 "zero"
1 "one"