aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux196
1 files changed, 98 insertions, 98 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 5521e2d0d..e5da4a105 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -2199,10 +2199,10 @@
(do-template [<name> <diff>]
[(def: #export <name>
(-> Int Int)
- (i.+ <diff>))]
+ (i/+ <diff>))]
- [i.inc 1]
- [i.dec -1])")])
+ [i/inc 1]
+ [i/dec -1])")])
("lux case" tokens
{(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])])
("lux case" [(monad/map Monad<Maybe> get-name bindings)
@@ -2256,16 +2256,16 @@
true
(<eq-proc> subject test)))]
- [ Nat "lux nat =" "lux nat <" n.= n.< n.<= n.> n.>=
+ [ Nat "lux nat =" "lux nat <" n/= n/< n/<= n/> n/>=
"Nat(ural) equality." "Nat(ural) less-than." "Nat(ural) less-than-equal." "Nat(ural) greater-than." "Nat(ural) greater-than-equal."]
- [ Int "lux int =" "lux int <" i.= i.< i.<= i.> i.>=
+ [ Int "lux int =" "lux int <" i/= i/< i/<= i/> i/>=
"Int(eger) equality." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."]
- [ Deg "lux deg =" "lux deg <" d.= d.< d.<= d.> d.>=
+ [ Deg "lux deg =" "lux deg <" d/= d/< d/<= d/> d/>=
"Deg(ree) equality." "Deg(ree) less-than." "Deg(ree) less-than-equal." "Deg(ree) greater-than." "Deg(ree) greater-than-equal."]
- [Frac "lux frac =" "lux frac <" f.= f.< f.<= f.> f.>=
+ [Frac "lux frac =" "lux frac <" f/= f/< f/<= f/> f/>=
"Frac(tion) equality." "Frac(tion) less-than." "Frac(tion) less-than-equal." "Frac(tion) greater-than." "Frac(tion) greater-than-equal."]
)
@@ -2275,29 +2275,29 @@
(-> <type> <type> <type>)
(<op> subject param))]
- [ Nat n.+ "lux nat +" "Nat(ural) addition."]
- [ Nat n.- "lux nat -" "Nat(ural) substraction."]
- [ Nat n.* "lux nat *" "Nat(ural) multiplication."]
- [ Nat n./ "lux nat /" "Nat(ural) division."]
- [ Nat n.% "lux nat %" "Nat(ural) remainder."]
+ [ Nat n/+ "lux nat +" "Nat(ural) addition."]
+ [ Nat n/- "lux nat -" "Nat(ural) substraction."]
+ [ Nat n/* "lux nat *" "Nat(ural) multiplication."]
+ [ Nat n// "lux nat /" "Nat(ural) division."]
+ [ Nat n/% "lux nat %" "Nat(ural) remainder."]
- [ Int i.+ "lux int +" "Int(eger) addition."]
- [ Int i.- "lux int -" "Int(eger) substraction."]
- [ Int i.* "lux int *" "Int(eger) multiplication."]
- [ Int i./ "lux int /" "Int(eger) division."]
- [ Int i.% "lux int %" "Int(eger) remainder."]
-
- [ Deg d.+ "lux deg +" "Deg(ree) addition."]
- [ Deg d.- "lux deg -" "Deg(ree) substraction."]
- [ Deg d.* "lux deg *" "Deg(ree) multiplication."]
- [ Deg d./ "lux deg /" "Deg(ree) division."]
- [ Deg d.% "lux deg %" "Deg(ree) remainder."]
+ [ Int i/+ "lux int +" "Int(eger) addition."]
+ [ Int i/- "lux int -" "Int(eger) substraction."]
+ [ Int i/* "lux int *" "Int(eger) multiplication."]
+ [ Int i// "lux int /" "Int(eger) division."]
+ [ Int i/% "lux int %" "Int(eger) remainder."]
+
+ [ Deg d/+ "lux deg +" "Deg(ree) addition."]
+ [ Deg d/- "lux deg -" "Deg(ree) substraction."]
+ [ Deg d/* "lux deg *" "Deg(ree) multiplication."]
+ [ Deg d// "lux deg /" "Deg(ree) division."]
+ [ Deg d/% "lux deg %" "Deg(ree) remainder."]
- [Frac f.+ "lux frac +" "Frac(tion) addition."]
- [Frac f.- "lux frac -" "Frac(tion) substraction."]
- [Frac f.* "lux frac *" "Frac(tion) multiplication."]
- [Frac f./ "lux frac /" "Frac(tion) division."]
- [Frac f.% "lux frac %" "Frac(tion) remainder."]
+ [Frac f/+ "lux frac +" "Frac(tion) addition."]
+ [Frac f/- "lux frac -" "Frac(tion) substraction."]
+ [Frac f/* "lux frac *" "Frac(tion) multiplication."]
+ [Frac f// "lux frac /" "Frac(tion) division."]
+ [Frac f/% "lux frac %" "Frac(tion) remainder."]
)
(do-template [<type> <name> <op> <doc>]
@@ -2306,8 +2306,8 @@
(-> Nat <type> <type>)
(<op> subject param))]
- [ Deg d.scale "lux deg scale" "Deg(ree) scale."]
- [ Deg d.reciprocal "lux deg reciprocal" "Deg(ree) reciprocal."]
+ [ Deg d/scale "lux deg scale" "Deg(ree) scale."]
+ [ Deg d/reciprocal "lux deg reciprocal" "Deg(ree) reciprocal."]
)
(do-template [<name> <type> <test> <doc>]
@@ -2318,17 +2318,17 @@
left
right))]
- [n.min Nat n.< "Nat(ural) minimum."]
- [n.max Nat n.> "Nat(ural) maximum."]
+ [n/min Nat n/< "Nat(ural) minimum."]
+ [n/max Nat n/> "Nat(ural) maximum."]
- [i.min Int i.< "Int(eger) minimum."]
- [i.max Int i.> "Int(eger) maximum."]
+ [i/min Int i/< "Int(eger) minimum."]
+ [i/max Int i/> "Int(eger) maximum."]
- [d.min Deg d.< "Deg(ree) minimum."]
- [d.max Deg d.> "Deg(ree) maximum."]
+ [d/min Deg d/< "Deg(ree) minimum."]
+ [d/max Deg d/> "Deg(ree) maximum."]
- [f.min Frac f.< "Frac minimum."]
- [f.max Frac f.> "Frac minimum."]
+ [f/min Frac f/< "Frac minimum."]
+ [f/max Frac f/> "Frac minimum."]
)
(def:''' (bool/encode x)
@@ -2356,37 +2356,37 @@
_
(let' [loop ("lux check" (-> Nat Text Text)
(function' recur [input output]
- (if (n.= +0 input)
+ (if (n/= +0 input)
(text/compose "+" output)
- (recur (n./ +10 input)
- (text/compose (|> input (n.% +10) digit-to-text)
+ (recur (n// +10 input)
+ (text/compose (|> input (n/% +10) digit-to-text)
output)))))]
(loop value ""))}))
(def:''' (int/abs value)
#Nil
(-> Int Int)
- (if (i.< 0 value)
- (i.* -1 value)
+ (if (i/< 0 value)
+ (i/* -1 value)
value))
(def:''' (int/encode value)
#Nil
(-> Int Text)
- (if (i.= 0 value)
+ (if (i/= 0 value)
"0"
- (let' [sign (if (i.> 0 value)
+ (let' [sign (if (i/> 0 value)
""
"-")]
(("lux check" (-> Int Text Text)
(function' recur [input output]
- (if (i.= 0 input)
+ (if (i/= 0 input)
(text/compose sign output)
- (recur (i./ 10 input)
- (text/compose (|> input (i.% 10) ("lux coerce" Nat) digit-to-text)
+ (recur (i// 10 input)
+ (text/compose (|> input (i/% 10) ("lux coerce" Nat) digit-to-text)
output)))))
- (|> value (i./ 10) int/abs)
- (|> value (i.% 10) int/abs ("lux coerce" Nat) digit-to-text)))))
+ (|> value (i// 10) int/abs)
+ (|> value (i/% 10) int/abs ("lux coerce" Nat) digit-to-text)))))
(def:''' (frac/encode x)
#Nil
@@ -2396,7 +2396,7 @@
(def:''' (multiple? div n)
#Nil
(-> Nat Nat Bool)
- (|> n (n.% div) (n.= +0)))
+ (|> n (n/% div) (n/= +0)))
(def:''' #export (not x)
(list [(tag$ ["lux" "doc"])
@@ -2724,7 +2724,7 @@
#scope-type-vars scope-type-vars}
(#Right {#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed (n.+ +1 seed) #expected expected
+ #seed (n/+ +1 seed) #expected expected
#cursor cursor
#scope-type-vars scope-type-vars}
(symbol$ ["" ($_ text/compose "__gensym__" prefix (nat/encode seed))]))}))
@@ -2906,7 +2906,7 @@
## Allows the usage of macros within the patterns to provide custom syntax.
(case (: (List Int) (list 1 2 3))
(#Cons x (#Cons y (#Cons z #Nil)))
- (#Some ($_ i.* x y z))
+ (#Some ($_ i/* x y z))
_
#None)")])
@@ -2925,7 +2925,7 @@
## It's a special macro meant to be used with 'case'.
(case (: (List Int) (list 1 2 3))
(^ (list x y z))
- (#Some ($_ i.* x y z))
+ (#Some ($_ i/* x y z))
_
#None)")])
@@ -3392,7 +3392,7 @@
(def: (last-index-of' part part-size since text)
(-> Text Nat Nat Text (Maybe Nat))
- (case ("lux text index" text part (n.+ part-size since))
+ (case ("lux text index" text part (n/+ part-size since))
#;None
(#;Some since)
@@ -3453,7 +3453,7 @@
(clip2 +0 idx input))
(text/split splitter
(default (error! "UNDEFINED")
- (clip1 (n.+ +1 idx) input))))))
+ (clip1 (n/+ +1 idx) input))))))
(def: (nth idx xs)
(All [a]
@@ -3463,9 +3463,9 @@
#None
(#Cons x xs')
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(#Some x)
- (nth (n.- +1 idx) xs')
+ (nth (n/- +1 idx) xs')
)))
(def: (beta-reduce env type)
@@ -4074,8 +4074,8 @@
ups
(#;Some found)
- (if (n.= ups found)
- (count-ups (n.+ +1 ups) input)
+ (if (n/= ups found)
+ (count-ups (n/+ +1 ups) input)
ups)))
(def: (list/drop amount a+)
@@ -4085,7 +4085,7 @@
a+
[_ (#;Cons _ a+')]
- (list/drop (n.- +1 amount) a+')))
+ (list/drop (n/- +1 amount) a+')))
(def: (clean-module relative-root module)
(-> Text Text (Meta Text))
@@ -4095,10 +4095,10 @@
ups
(let [parts (text/split "/" relative-root)]
- (if (n.< (list/size parts) (n.- +1 ups))
+ (if (n/< (list/size parts) (n/- +1 ups))
(let [prefix (|> parts
list/reverse
- (list/drop (n.- +1 ups))
+ (list/drop (n/- +1 ups))
list/reverse
(interpose "/")
text/join)
@@ -4298,7 +4298,7 @@
#;Nil
(#;Cons [var bound] bindings')
- (if (n.= idx var)
+ (if (n/= idx var)
bound
(find-type-var idx bindings'))))
@@ -4470,11 +4470,11 @@
(macro: #export (cond tokens)
{#;doc "## Branching structures with multiple test conditions.
- (cond (n.even? num) \"even\"
- (n.odd? num) \"odd\"
+ (cond (n/even? num) \"even\"
+ (n/odd? num) \"odd\"
## else-branch
\"???\")"}
- (if (n.= +0 (n.% +2 (list/size tokens)))
+ (if (n/= +0 (n/% +2 (list/size tokens)))
(fail "cond requires an even number of arguments.")
(case (list/reverse tokens)
(^ (list& else branches'))
@@ -4492,7 +4492,7 @@
(All [a] (-> Nat (List a) (List [Nat a])))
(case xs
(#Cons x xs')
- (#Cons [idx x] (enumerate' (n.+ +1 idx) xs'))
+ (#Cons [idx x] (enumerate' (n/+ +1 idx) xs'))
#Nil
#Nil))
@@ -4524,7 +4524,7 @@
(#Some members)
(let [pattern (record$ (map (: (-> [Ident [Nat Type]] [Code Code])
(function [[[r-prefix r-name] [r-idx r-type]]]
- [(tag$ [r-prefix r-name]) (if (n.= idx r-idx)
+ [(tag$ [r-prefix r-name]) (if (n/= idx r-idx)
g!output
g!_)]))
(zip2 tags (enumerate members))))]
@@ -4847,7 +4847,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat Code] [Code Code])
(function [[r-slot-name r-idx r-var]]
- [(tag$ r-slot-name) (if (n.= idx r-idx)
+ [(tag$ r-slot-name) (if (n/= idx r-idx)
value
r-var)]))
pattern'))]
@@ -4899,7 +4899,7 @@
(macro: #export (update@ tokens)
{#;doc "## Modifies the value of a record at a given tag, based on some function.
- (update@ #age i.inc person)
+ (update@ #age i/inc person)
## Can also work with multiple levels of nesting:
(update@ [#foo #bar #baz] func my-record)
@@ -4933,7 +4933,7 @@
pattern'))
output (record$ (map (: (-> [Ident Nat Code] [Code Code])
(function [[r-slot-name r-idx r-var]]
- [(tag$ r-slot-name) (if (n.= idx r-idx)
+ [(tag$ r-slot-name) (if (n/= idx r-idx)
(` ((~ fun) (~ r-var)))
r-var)]))
pattern'))]
@@ -5013,7 +5013,7 @@
(do Monad<Maybe>
[bindings' (monad/map Monad<Maybe> get-name bindings)
data' (monad/map Monad<Maybe> tuple->list data)]
- (if (every? (n.= (list/size bindings')) (map list/size data'))
+ (if (every? (n/= (list/size bindings')) (map list/size data'))
(let [apply (: (-> RepEnv (List Code))
(function [env] (map (apply-template env) templates)))]
(|> data'
@@ -5055,12 +5055,12 @@
(^template [<tag>]
[[_ _ column] (<tag> parts)]
- (list/fold n.min column (map find-baseline-column parts)))
+ (list/fold n/min column (map find-baseline-column parts)))
([#Form]
[#Tuple])
[[_ _ column] (#Record pairs)]
- (list/fold n.min column
+ (list/fold n/min column
(list/compose (map (. find-baseline-column first) pairs)
(map (. find-baseline-column second) pairs)))
))
@@ -5098,10 +5098,10 @@
(-> <type> <type>)
(<op> <one> value))]
- [i.inc i.+ 1 Int "[Int] Increment function."]
- [i.dec i.- 1 Int "[Int] Decrement function."]
- [n.inc n.+ +1 Nat "[Nat] Increment function."]
- [n.dec n.- +1 Nat "[Nat] Decrement function."]
+ [i/inc i/+ 1 Int "[Int] Increment function."]
+ [i/dec i/- 1 Int "[Int] Decrement function."]
+ [n/inc n/+ +1 Nat "[Nat] Increment function."]
+ [n/dec n/- +1 Nat "[Nat] Decrement function."]
)
(def: tag/encode
@@ -5121,16 +5121,16 @@
(def: (repeat n x)
(All [a] (-> Int a (List a)))
- (if (i.> 0 n)
- (#;Cons x (repeat (i.+ -1 n) x))
+ (if (i/> 0 n)
+ (#;Cons x (repeat (i/+ -1 n) x))
#;Nil))
(def: (cursor-padding baseline [_ old-line old-column] [_ new-line new-column])
(-> Nat Cursor Cursor Text)
- (if (n.= old-line new-line)
- (text/join (repeat (nat-to-int (n.- old-column new-column)) " "))
- (let [extra-lines (text/join (repeat (nat-to-int (n.- old-line new-line)) "\n"))
- space-padding (text/join (repeat (nat-to-int (n.- baseline new-column)) " "))]
+ (if (n/= old-line new-line)
+ (text/join (repeat (nat-to-int (n/- old-column new-column)) " "))
+ (let [extra-lines (text/join (repeat (nat-to-int (n/- old-line new-line)) "\n"))
+ space-padding (text/join (repeat (nat-to-int (n/- baseline new-column)) " "))]
(text/compose extra-lines space-padding))))
(def: (text/size x)
@@ -5139,11 +5139,11 @@
(def: (update-cursor [file line column] code-text)
(-> Cursor Text Cursor)
- [file line (n.+ column (text/size code-text))])
+ [file line (n/+ column (text/size code-text))])
(def: (delim-update-cursor [file line column])
(-> Cursor Cursor)
- [file line (n.inc column)])
+ [file line (n/inc column)])
(def: rejoin-all-pairs
(-> (List [Code Code]) (List Code))
@@ -5214,7 +5214,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (i.inc count) (f x))
+ (recur (i/inc count) (f x))
x)))"}
(return (list (` [(~ cursor-code)
(#;Text (~ (|> tokens
@@ -5286,7 +5286,7 @@
(loop [count 0
x init]
(if (< 10 count)
- (recur (i.inc count) (f x))
+ (recur (i/inc count) (f x))
x)))}
(case tokens
(^ (list [_ (#Tuple bindings)] body))
@@ -5645,8 +5645,8 @@
(-> <type> Bool)
(not (<even> n)))]
- [Nat n.even? n.odd? n.% n.= +0 +2]
- [Int i.even? i.odd? i.% i.= 0 2])
+ [Nat n/even? n/odd? n/% n/= +0 +2]
+ [Int i/even? i/odd? i/% i/= 0 2])
(def: (get-scope-type-vars state)
(Meta (List Nat))
@@ -5665,9 +5665,9 @@
#;None
(#;Cons x xs')
- (if (n.= +0 idx)
+ (if (n/= +0 idx)
(#;Some x)
- (list-at (n.dec idx) xs'))))
+ (list-at (n/dec idx) xs'))))
(macro: #export ($ tokens)
{#;doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index."
@@ -5699,14 +5699,14 @@
(is value value))
"This one should fail:"
- (is 5 (i.+ 2 3)))}
+ (is 5 (i/+ 2 3)))}
(All [a] (-> a a Bool))
("lux is" reference sample))
(macro: #export (^@ tokens)
{#;doc (doc "Allows you to simultaneously bind and de-structure a value."
(def: (hash (^@ set [Hash<a> _]))
- (list/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc))
+ (list/fold (function [elem acc] (n/+ (:: Hash<a> hash elem) acc))
+0
(to-list set))))}
(case tokens
@@ -5722,7 +5722,7 @@
(macro: #export (^|> tokens)
{#;doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable."
(case input
- (^|> value [n.inc (n.% +10) (n.max +1)])
+ (^|> value [n/inc (n/% +10) (n/max +1)])
(foo value)))}
(case tokens
(^ (list& [_meta (#;Form (list [_ (#;Symbol ["" name])] [_ (#;Tuple steps)]))] body branches))
@@ -5860,7 +5860,7 @@
{#;doc (doc "Define macros in the style of do-template and ^template."
"For simple macros that do not need any fancy features."
(template: (square x)
- (i.* x x)))}
+ (i/* x x)))}
(do Monad<Meta>
[?export-level|tokens (parse-export-level tokens)
#let [[?export-level tokens] ?export-level|tokens]
@@ -5896,7 +5896,7 @@
(macro: #export (char tokens compiler)
(case tokens
(^multi (^ (list [_ (#Text input)]))
- (n.= +1 ("lux text size" input)))
+ (n/= +1 ("lux text size" input)))
(|> ("lux text char" input +0)
(default (undefined))
nat$ list