aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
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/source
parent55e411f34d81d8deb0b7d0e25c987dbe16035354 (diff)
- Changed the names of math op functions to make them more consistent and similar.
Diffstat (limited to 'stdlib/source')
-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
39 files changed, 638 insertions, 690 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))