diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux.lux | 105 |
1 files changed, 23 insertions, 82 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 4f684d34d..05a4ece62 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2179,7 +2179,7 @@ (text$ ($_ "lux text concat" "## By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph "(template [<name> <diff>]" ..new-line - " " "[(def: #export <name> (-> Int Int) (i/+ <diff>))]" __paragraph + " " "[(def: #export <name> (-> Int Int) (+ <diff>))]" __paragraph " " "[inc +1]" ..new-line " " "[dec -1]"))]) ({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])]) @@ -2203,47 +2203,6 @@ (fail "Wrong syntax for template")} tokens)) -(template [<type> - <eq-proc> <lt-proc> <eq-name> <lt-name> <lte-name> <gt-name> <gte-name> - <eq-doc> <<-doc> <<=-doc> <>-doc> <>=-doc>] - [(def:''' #export (<eq-name> reference sample) - (list [(tag$ ["lux" "doc"]) - (text$ <eq-doc>)]) - (-> <type> <type> Bit) - (<eq-proc> reference sample)) - - (def:''' #export (<lt-name> reference sample) - (list [(tag$ ["lux" "doc"]) - (text$ <<-doc>)]) - (-> <type> <type> Bit) - (<lt-proc> reference sample)) - - (def:''' #export (<lte-name> reference sample) - (list [(tag$ ["lux" "doc"]) - (text$ <<=-doc>)]) - (-> <type> <type> Bit) - (if (<lt-proc> reference sample) - #1 - (<eq-proc> reference sample))) - - (def:''' #export (<gt-name> reference sample) - (list [(tag$ ["lux" "doc"]) - (text$ <>-doc>)]) - (-> <type> <type> Bit) - (<lt-proc> sample reference)) - - (def:''' #export (<gte-name> reference sample) - (list [(tag$ ["lux" "doc"]) - (text$ <>=-doc>)]) - (-> <type> <type> Bit) - (if (<lt-proc> sample reference) - #1 - (<eq-proc> reference sample)))] - - [ Int "lux i64 =" "lux i64 <" i/= i/< i/<= i/> i/>= - "Int(eger) equivalence." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."] - ) - (def:''' #export (n// param subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) division.")]) @@ -2283,21 +2242,6 @@ ("lux coerce" Int (n// param subject)))] ("lux i64 -" flat subject))) -(template [<name> <op> <doc>] - [(def:''' #export (<name> param subject) - (list [(tag$ ["lux" "doc"]) - (text$ <doc>)]) - (-> Int Int Int) - (<op> param subject))] - - [i/+ "lux i64 +" "Int(eger) addition."] - [i/- "lux i64 -" "Int(eger) substraction."] - - [i/* "lux i64 *" "Int(eger) multiplication."] - [i// "lux i64 /" "Int(eger) division."] - [i/% "lux i64 %" "Int(eger) remainder."] - ) - (template [<name> <type> <test> <doc>] [(def:''' #export (<name> left right) (list [(tag$ ["lux" "doc"]) @@ -2309,9 +2253,6 @@ [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."] ) (def:''' (bit@encode x) @@ -2349,27 +2290,27 @@ (def:''' (int@abs value) #Nil (-> Int Int) - (if (i/< +0 value) - (i/* -1 value) + (if ("lux i64 <" +0 value) + ("lux i64 *" -1 value) value)) (def:''' (int@encode value) #Nil (-> Int Text) - (if (i/= +0 value) + (if ("lux i64 =" +0 value) "0" - (let' [sign (if (i/> +0 value) + (let' [sign (if ("lux i64 <" value +0) "" "-")] (("lux check" (-> Int Text Text) (function' recur [input output] - (if (i/= +0 input) + (if ("lux i64 =" +0 input) (text@compose sign output) - (recur (i// +10 input) - (text@compose (|> input (i/% +10) ("lux coerce" Nat) digit-to-text) + (recur ("lux i64 /" +10 input) + (text@compose (|> input ("lux i64 %" +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 ("lux i64 /" +10) int@abs) + (|> value ("lux i64 %" +10) int@abs ("lux coerce" Nat) digit-to-text))))) (def:''' (frac@encode x) #Nil @@ -2904,7 +2845,7 @@ "## Allows the usage of macros within the patterns to provide custom syntax." ..new-line "(case (: (List Int) (list +1 +2 +3))" ..new-line " " "(#Cons x (#Cons y (#Cons z #Nil)))" ..new-line - " " "(#Some ($_ i/* x y z))" __paragraph + " " "(#Some ($_ * x y z))" __paragraph " " "_" ..new-line " " "#None)"))]) ({(#Cons value branches) @@ -2923,7 +2864,7 @@ "## It's a special macro meant to be used with 'case'." ..new-line "(case (: (List Int) (list +1 +2 +3))" ..new-line " (^ (list x y z))" ..new-line - " (#Some ($_ i/* x y z))" + " (#Some ($_ * x y z))" __paragraph " _" ..new-line " #None)"))]) @@ -3688,15 +3629,15 @@ "(structure: #export order (Order Int)" ..new-line " (def: &equivalence equivalence)" ..new-line " (def: (< test subject)" ..new-line - " (lux.i/< test subject))" ..new-line + " (< test subject))" ..new-line " (def: (<= test subject)" ..new-line - " (or (lux.i/< test subject)" ..new-line - " (lux.i/= test subject)))" ..new-line + " (or (< test subject)" ..new-line + " (= test subject)))" ..new-line " (def: (> test subject)" ..new-line - " (lux.i/> test subject))" ..new-line + " (> test subject))" ..new-line " (def: (>= test subject)" ..new-line - " (or (lux.i/> test subject)" ..new-line - " (lux.i/= test subject))))"))} + " (or (> test subject)" ..new-line + " (= test subject))))"))} (let [[exported? tokens'] (export^ tokens) ?parts (: (Maybe [Code (List Code) Code Code (List Code)]) (case tokens' @@ -5017,8 +4958,8 @@ (def: (repeat n x) (All [a] (-> Int a (List a))) - (if (i/> +0 n) - (#Cons x (repeat (i/+ -1 n) x)) + (if ("lux i64 <" n +0) + (#Cons x (repeat ("lux i64 +" -1 n) x)) #Nil)) (def: (cursor-padding baseline [_ old-line old-column] [_ new-line new-column]) @@ -5554,7 +5495,7 @@ (not (<even> n)))] [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)) @@ -5607,7 +5548,7 @@ (is? value value)) "This one should fail:" - (is? +5 (i/+ +2 +3)))} + (is? +5 (+ +2 +3)))} (All [a] (-> a a Bit)) ("lux is" reference sample)) @@ -5760,7 +5701,7 @@ {#.doc (doc "Define macros in the style of template and ^template." "For simple macros that do not need any fancy features." (template: (square x) - (i/* x x)))} + (* x x)))} (do meta-monad [#let [[export? tokens] (export^ tokens)] name+args|tokens (parse-complex-declaration tokens) |