From f08a9fb208a32ee8f450649095c4f8a0f05931da Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 4 Sep 2017 19:41:59 -0400 Subject: - Re-named "real" numbers to "frac"(tions). --- luxc/src/lux/analyser.clj | 6 +- luxc/src/lux/analyser/base.clj | 2 +- luxc/src/lux/analyser/case.clj | 30 ++-- luxc/src/lux/analyser/parser.clj | 4 +- luxc/src/lux/analyser/proc/common.clj | 88 +++++----- luxc/src/lux/base.clj | 6 +- luxc/src/lux/compiler/cache/ann.clj | 6 +- luxc/src/lux/compiler/js.clj | 4 +- luxc/src/lux/compiler/js/lux.clj | 4 +- luxc/src/lux/compiler/js/proc/common.clj | 82 ++++----- luxc/src/lux/compiler/js/rt.clj | 4 +- luxc/src/lux/compiler/jvm.clj | 4 +- luxc/src/lux/compiler/jvm/case.clj | 2 +- luxc/src/lux/compiler/jvm/lux.clj | 2 +- luxc/src/lux/compiler/jvm/proc/common.clj | 78 ++++----- luxc/src/lux/compiler/jvm/rt.clj | 8 +- luxc/src/lux/lexer.clj | 6 +- luxc/src/lux/optimizer.clj | 18 +- luxc/src/lux/parser.clj | 4 +- luxc/src/lux/type.clj | 6 +- luxc/src/lux/type/host.clj | 2 +- stdlib/source/lux.lux | 92 +++++----- stdlib/source/lux/control/concatenative.lux | 24 +-- stdlib/source/lux/data/color.lux | 232 +++++++++++++------------- stdlib/source/lux/data/format/css.lux | 2 +- stdlib/source/lux/data/format/json.lux | 8 +- stdlib/source/lux/data/format/json/codec.lux | 38 ++--- stdlib/source/lux/data/format/json/reader.lux | 6 +- stdlib/source/lux/data/number.lux | 156 ++++++++--------- stdlib/source/lux/data/number/complex.lux | 200 +++++++++++----------- stdlib/source/lux/data/text/format.lux | 2 +- stdlib/source/lux/host.js.lux | 6 +- stdlib/source/lux/host.jvm.lux | 4 +- stdlib/source/lux/macro.lux | 2 +- stdlib/source/lux/macro/code.lux | 8 +- stdlib/source/lux/macro/poly.lux | 4 +- stdlib/source/lux/macro/poly/eq.lux | 2 +- stdlib/source/lux/macro/syntax.lux | 2 +- stdlib/source/lux/math.lux | 16 +- stdlib/source/lux/math/logic/fuzzy.lux | 18 +- stdlib/source/lux/math/random.lux | 12 +- stdlib/test/test/lux.lux | 10 +- stdlib/test/test/lux/data/color.lux | 54 +++--- stdlib/test/test/lux/data/format/json.lux | 46 ++--- stdlib/test/test/lux/data/number.lux | 34 ++-- stdlib/test/test/lux/data/number/complex.lux | 58 +++---- stdlib/test/test/lux/data/number/ratio.lux | 1 - stdlib/test/test/lux/host.js.lux | 4 +- stdlib/test/test/lux/macro/code.lux | 2 +- stdlib/test/test/lux/macro/poly/eq.lux | 20 +-- stdlib/test/test/lux/macro/syntax.lux | 4 +- stdlib/test/test/lux/math.lux | 40 ++--- stdlib/test/test/lux/math/logic/fuzzy.lux | 22 +-- 53 files changed, 747 insertions(+), 748 deletions(-) diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index 5ea8cf64b..807a7cc68 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -82,9 +82,9 @@ (|do [_ (&type/check exo-type &type/Deg)] (return (&/|list (&&/|meta exo-type cursor (&&/$deg ?value))))) - (&/$Real ?value) - (|do [_ (&type/check exo-type &type/Real)] - (return (&/|list (&&/|meta exo-type cursor (&&/$real ?value))))) + (&/$Frac ?value) + (|do [_ (&type/check exo-type &type/Frac)] + (return (&/|list (&&/|meta exo-type cursor (&&/$frac ?value))))) (&/$Text ?value) (|do [_ (&type/check exo-type &type/Text)] diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index bfe931546..9f44db3af 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -10,7 +10,7 @@ ("nat" 1) ("int" 1) ("deg" 1) - ("real" 1) + ("frac" 1) ("text" 1) ("variant" 3) ("tuple" 1) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index fa9d568d0..a8fdd6f18 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -16,7 +16,7 @@ ("NatTotal" 2) ("IntTotal" 2) ("DegTotal" 2) - ("RealTotal" 2) + ("FracTotal" 2) ("TextTotal" 2) ("TupleTotal" 2) ("VariantTotal" 2)) @@ -28,7 +28,7 @@ ("NatTestAC" 1) ("IntTestAC" 1) ("DegTestAC" 1) - ("RealTestAC" 1) + ("FracTestAC" 1) ("TextTestAC" 1) ("TupleTestAC" 1) ("VariantTestAC" 1)) @@ -289,10 +289,10 @@ =kont kont] (return (&/T [($DegTestAC ?value) =kont]))) - (&/$Real ?value) - (|do [_ (&type/check value-type &type/Real) + (&/$Frac ?value) + (|do [_ (&type/check value-type &type/Frac) =kont kont] - (return (&/T [($RealTestAC ?value) =kont]))) + (return (&/T [($FracTestAC ?value) =kont]))) (&/$Text ?value) (|do [_ (&type/check value-type &type/Text) @@ -418,8 +418,8 @@ [($DegTotal total? ?values) ($NoTestAC)] (return ($DegTotal true ?values)) - [($RealTotal total? ?values) ($NoTestAC)] - (return ($RealTotal true ?values)) + [($FracTotal total? ?values) ($NoTestAC)] + (return ($FracTotal true ?values)) [($TextTotal total? ?values) ($NoTestAC)] (return ($TextTotal true ?values)) @@ -445,8 +445,8 @@ [($DegTotal total? ?values) ($StoreTestAC ?idx)] (return ($DegTotal true ?values)) - [($RealTotal total? ?values) ($StoreTestAC ?idx)] - (return ($RealTotal true ?values)) + [($FracTotal total? ?values) ($StoreTestAC ?idx)] + (return ($FracTotal true ?values)) [($TextTotal total? ?values) ($StoreTestAC ?idx)] (return ($TextTotal true ?values)) @@ -481,11 +481,11 @@ [($DegTotal total? ?values) ($DegTestAC ?value)] (return ($DegTotal total? (&/$Cons ?value ?values))) - [($DefaultTotal total?) ($RealTestAC ?value)] - (return ($RealTotal total? (&/|list ?value))) + [($DefaultTotal total?) ($FracTestAC ?value)] + (return ($FracTotal total? (&/|list ?value))) - [($RealTotal total? ?values) ($RealTestAC ?value)] - (return ($RealTotal total? (&/$Cons ?value ?values))) + [($FracTotal total? ?values) ($FracTestAC ?value)] + (return ($FracTotal total? (&/$Cons ?value ?values))) [($DefaultTotal total?) ($TextTestAC ?value)] (return ($TextTotal total? (&/|list ?value))) @@ -568,8 +568,8 @@ (|do [_ (&type/check value-type &type/Deg)] (return ?total)) - ($RealTotal ?total _) - (|do [_ (&type/check value-type &type/Real)] + ($FracTotal ?total _) + (|do [_ (&type/check value-type &type/Frac)] (return ?total)) ($TextTotal ?total _) diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj index 731b5bace..c2420f21b 100644 --- a/luxc/src/lux/analyser/parser.clj +++ b/luxc/src/lux/analyser/parser.clj @@ -135,11 +135,11 @@ [_ (&lexer/$Int param-value*)] &lexer/lex-int] (return (long param-value*))) - (|do [[_ (&lexer/$Real param-value*)] &lexer/lex-real] + (|do [[_ (&lexer/$Frac param-value*)] &lexer/lex-frac] (return (float param-value*))) (|do [_ (&reader/read-text "d") - [_ (&lexer/$Real param-value*)] &lexer/lex-real] + [_ (&lexer/$Frac param-value*)] &lexer/lex-frac] (return (double param-value*))) (|do [[_ (&lexer/$Text param-value*)] &lexer/lex-text] diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 27af2a08d..d05c68564 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -210,13 +210,13 @@ ^:private analyse-deg-eq ["deg" "="] &type/Deg &type/Bool ^:private analyse-deg-lt ["deg" "<"] &type/Deg &type/Bool - ^:private analyse-real-add ["real" "+"] &type/Real &type/Real - ^:private analyse-real-sub ["real" "-"] &type/Real &type/Real - ^:private analyse-real-mul ["real" "*"] &type/Real &type/Real - ^:private analyse-real-div ["real" "/"] &type/Real &type/Real - ^:private analyse-real-rem ["real" "%"] &type/Real &type/Real - ^:private analyse-real-eq ["real" "="] &type/Real &type/Bool - ^:private analyse-real-lt ["real" "<"] &type/Real &type/Bool + ^:private analyse-frac-add ["frac" "+"] &type/Frac &type/Frac + ^:private analyse-frac-sub ["frac" "-"] &type/Frac &type/Frac + ^:private analyse-frac-mul ["frac" "*"] &type/Frac &type/Frac + ^:private analyse-frac-div ["frac" "/"] &type/Frac &type/Frac + ^:private analyse-frac-rem ["frac" "%"] &type/Frac &type/Frac + ^:private analyse-frac-eq ["frac" "="] &type/Frac &type/Bool + ^:private analyse-frac-lt ["frac" "<"] &type/Frac &type/Bool ) (do-template [ ] @@ -251,7 +251,7 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ) (&/|list =x) (&/|list))))))))) - ^:private analyse-real-encode ["real" "encode"] ^:private analyse-real-decode ["real" "decode"] &type/Real + ^:private analyse-frac-encode ["frac" "encode"] ^:private analyse-frac-decode ["frac" "decode"] &type/Frac ) (do-template [ ] @@ -271,12 +271,12 @@ ^:private analyse-deg-min-value &type/Deg ["deg" "min-value"] ^:private analyse-deg-max-value &type/Deg ["deg" "max-value"] - ^:private analyse-real-smallest-value &type/Real ["real" "smallest-value"] - ^:private analyse-real-min-value &type/Real ["real" "min-value"] - ^:private analyse-real-max-value &type/Real ["real" "max-value"] - ^:private analyse-real-not-a-number &type/Real ["real" "not-a-number"] - ^:private analyse-real-positive-infinity &type/Real ["real" "positive-infinity"] - ^:private analyse-real-negative-infinity &type/Real ["real" "negative-infinity"] + ^:private analyse-frac-smallest-value &type/Frac ["frac" "smallest-value"] + ^:private analyse-frac-min-value &type/Frac ["frac" "min-value"] + ^:private analyse-frac-max-value &type/Frac ["frac" "max-value"] + ^:private analyse-frac-not-a-number &type/Frac ["frac" "not-a-number"] + ^:private analyse-frac-positive-infinity &type/Frac ["frac" "positive-infinity"] + ^:private analyse-frac-negative-infinity &type/Frac ["frac" "negative-infinity"] ) (do-template [ ] @@ -293,11 +293,11 @@ ^:private analyse-nat-to-char &type/Nat &type/Text ["nat" "to-char"] - ^:private analyse-int-to-real &type/Int &type/Real ["int" "to-real"] - ^:private analyse-real-to-int &type/Real &type/Int ["real" "to-int"] + ^:private analyse-int-to-frac &type/Int &type/Frac ["int" "to-frac"] + ^:private analyse-frac-to-int &type/Frac &type/Int ["frac" "to-int"] - ^:private analyse-deg-to-real &type/Deg &type/Real ["deg" "to-real"] - ^:private analyse-real-to-deg &type/Real &type/Deg ["real" "to-deg"] + ^:private analyse-deg-to-frac &type/Deg &type/Frac ["deg" "to-frac"] + ^:private analyse-frac-to-deg &type/Frac &type/Deg ["frac" "to-deg"] ^:private analyse-io-log &type/Text &/$Unit ["io" "log"] ^:private analyse-io-error &type/Text &type/Bottom ["io" "error"] @@ -368,7 +368,7 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Nil) ?values] - _ (&type/check exo-type &type/Real) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list) (&/|list))))))) @@ -380,8 +380,8 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Cons ?input (&/$Nil)) ?values] - =input (&&/analyse-1 analyse &type/Real ?input) - _ (&type/check exo-type &type/Real) + =input (&&/analyse-1 analyse &type/Frac ?input) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list =input) (&/|list))))))) @@ -407,9 +407,9 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Cons ?input (&/$Cons ?param (&/$Nil))) ?values] - =input (&&/analyse-1 analyse &type/Real ?input) - =param (&&/analyse-1 analyse &type/Real ?param) - _ (&type/check exo-type &type/Real) + =input (&&/analyse-1 analyse &type/Frac ?input) + =param (&&/analyse-1 analyse &type/Frac ?param) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list =input =param) (&/|list))))))) @@ -552,7 +552,7 @@ "min-value" (analyse-int-min-value analyse exo-type ?values) "max-value" (analyse-int-max-value analyse exo-type ?values) "to-nat" (analyse-int-to-nat analyse exo-type ?values) - "to-real" (analyse-int-to-real analyse exo-type ?values) + "to-frac" (analyse-int-to-frac analyse exo-type ?values) ) "deg" @@ -566,30 +566,30 @@ "<" (analyse-deg-lt analyse exo-type ?values) "min-value" (analyse-deg-min-value analyse exo-type ?values) "max-value" (analyse-deg-max-value analyse exo-type ?values) - "to-real" (analyse-deg-to-real analyse exo-type ?values) + "to-frac" (analyse-deg-to-frac analyse exo-type ?values) "scale" (analyse-deg-scale analyse exo-type ?values) "reciprocal" (analyse-deg-reciprocal analyse exo-type ?values) ) - "real" + "frac" (case proc - "+" (analyse-real-add analyse exo-type ?values) - "-" (analyse-real-sub analyse exo-type ?values) - "*" (analyse-real-mul analyse exo-type ?values) - "/" (analyse-real-div analyse exo-type ?values) - "%" (analyse-real-rem analyse exo-type ?values) - "=" (analyse-real-eq analyse exo-type ?values) - "<" (analyse-real-lt analyse exo-type ?values) - "encode" (analyse-real-encode analyse exo-type ?values) - "decode" (analyse-real-decode analyse exo-type ?values) - "smallest-value" (analyse-real-smallest-value analyse exo-type ?values) - "min-value" (analyse-real-min-value analyse exo-type ?values) - "max-value" (analyse-real-max-value analyse exo-type ?values) - "not-a-number" (analyse-real-not-a-number analyse exo-type ?values) - "positive-infinity" (analyse-real-positive-infinity analyse exo-type ?values) - "negative-infinity" (analyse-real-negative-infinity analyse exo-type ?values) - "to-deg" (analyse-real-to-deg analyse exo-type ?values) - "to-int" (analyse-real-to-int analyse exo-type ?values) + "+" (analyse-frac-add analyse exo-type ?values) + "-" (analyse-frac-sub analyse exo-type ?values) + "*" (analyse-frac-mul analyse exo-type ?values) + "/" (analyse-frac-div analyse exo-type ?values) + "%" (analyse-frac-rem analyse exo-type ?values) + "=" (analyse-frac-eq analyse exo-type ?values) + "<" (analyse-frac-lt analyse exo-type ?values) + "encode" (analyse-frac-encode analyse exo-type ?values) + "decode" (analyse-frac-decode analyse exo-type ?values) + "smallest-value" (analyse-frac-smallest-value analyse exo-type ?values) + "min-value" (analyse-frac-min-value analyse exo-type ?values) + "max-value" (analyse-frac-max-value analyse exo-type ?values) + "not-a-number" (analyse-frac-not-a-number analyse exo-type ?values) + "positive-infinity" (analyse-frac-positive-infinity analyse exo-type ?values) + "negative-infinity" (analyse-frac-negative-infinity analyse exo-type ?values) + "to-deg" (analyse-frac-to-deg analyse exo-type ?values) + "to-int" (analyse-frac-to-int analyse exo-type ?values) ) "math" diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 8a7378586..172ade295 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -75,7 +75,7 @@ ("Nat" 1) ("Int" 1) ("Deg" 1) - ("Real" 1) + ("Frac" 1) ("Text" 1) ("Symbol" 1) ("Tag" 1) @@ -221,7 +221,7 @@ ("NatA" 1) ("IntA" 1) ("DegA" 1) - ("RealA" 1) + ("FracA" 1) ("TextA" 1) ("IdentA" 1) ("ListA" 1) @@ -1217,7 +1217,7 @@ [_ ($Deg ?value)] (encode-deg ?value) - [_ ($Real ?value)] + [_ ($Frac ?value)] (pr-str ?value) [_ ($Text ?value)] diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj index 35a41f247..6ee941bf8 100644 --- a/luxc/src/lux/compiler/cache/ann.clj +++ b/luxc/src/lux/compiler/cache/ann.clj @@ -40,7 +40,7 @@ (&/$DegA value) (str "D" value stop) - (&/$RealA value) + (&/$FracA value) (str "R" value stop) (&/$TextA value) @@ -84,7 +84,7 @@ ^:private deserialize-nat "N" &/$NatA Long/parseLong ^:private deserialize-int "I" &/$IntA Long/parseLong ^:private deserialize-deg "D" &/$DegA Long/parseLong - ^:private deserialize-real "R" &/$RealA Double/parseDouble + ^:private deserialize-frac "R" &/$FracA Double/parseDouble ^:private deserialize-text "T" &/$TextA identity ) @@ -138,7 +138,7 @@ (deserialize-nat input) (deserialize-int input) (deserialize-deg input) - (deserialize-real input) + (deserialize-frac input) (deserialize-text input) (deserialize-ident input) (deserialize-list input) diff --git a/luxc/src/lux/compiler/js.clj b/luxc/src/lux/compiler/js.clj index b618b7b1b..6eff83688 100644 --- a/luxc/src/lux/compiler/js.clj +++ b/luxc/src/lux/compiler/js.clj @@ -48,8 +48,8 @@ (&o/$deg ?value) (&&lux/compile-deg ?value) - (&o/$real ?value) - (&&lux/compile-real ?value) + (&o/$frac ?value) + (&&lux/compile-frac ?value) (&o/$text ?value) (&&lux/compile-text ?value) diff --git a/luxc/src/lux/compiler/js/lux.clj b/luxc/src/lux/compiler/js/lux.clj index 593055b8b..0be8f1cae 100644 --- a/luxc/src/lux/compiler/js/lux.clj +++ b/luxc/src/lux/compiler/js/lux.clj @@ -42,7 +42,7 @@ compile-deg ) -(defn compile-real [value] +(defn compile-frac [value] (return (str value))) (defn compile-char [value] @@ -189,7 +189,7 @@ (|do [=value (compile-deg _value)] (return (str "if(!" (str "LuxRT$eqI64(" cursor-peek "," =value ")") ") { " pm-fail " }"))) - (&o/$RealPM _value) + (&o/$FracPM _value) (return (str "if(" cursor-peek " !== " _value ") { " pm-fail " }")) (&o/$TextPM _value) diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj index 871f5e15b..a45bc2993 100644 --- a/luxc/src/lux/compiler/js/proc/common.clj +++ b/luxc/src/lux/compiler/js/proc/common.clj @@ -132,13 +132,13 @@ =y (compile ?y)] (return (str "(" =x " " " " =y ")")))) - ^:private compile-real-add "+" - ^:private compile-real-sub "-" - ^:private compile-real-mul "*" - ^:private compile-real-div "/" - ^:private compile-real-rem "%" - ^:private compile-real-eq "===" - ^:private compile-real-lt "<" + ^:private compile-frac-add "+" + ^:private compile-frac-sub "-" + ^:private compile-frac-mul "*" + ^:private compile-frac-div "/" + ^:private compile-frac-rem "%" + ^:private compile-frac-eq "===" + ^:private compile-frac-lt "<" ) (do-template [ ] @@ -148,7 +148,7 @@ (return (str "LuxRT$" "(" =x ")")) )) - ^:private compile-real-decode "decodeReal" + ^:private compile-frac-decode "decodeFrac" ) (do-template [ ] @@ -165,16 +165,16 @@ ^:private compile-deg-min-value &&lux/compile-deg 0 ^:private compile-deg-max-value &&lux/compile-deg -1 - ^:private compile-real-smallest-value &&lux/compile-real Double/MIN_VALUE - ^:private compile-real-min-value &&lux/compile-real (* -1.0 Double/MAX_VALUE) - ^:private compile-real-max-value &&lux/compile-real Double/MAX_VALUE + ^:private compile-frac-smallest-value &&lux/compile-frac Double/MIN_VALUE + ^:private compile-frac-min-value &&lux/compile-frac (* -1.0 Double/MAX_VALUE) + ^:private compile-frac-max-value &&lux/compile-frac Double/MAX_VALUE - ^:private compile-real-not-a-number &&lux/compile-real "NaN" - ^:private compile-real-positive-infinity &&lux/compile-real "Infinity" - ^:private compile-real-negative-infinity &&lux/compile-real "-Infinity" + ^:private compile-frac-not-a-number &&lux/compile-frac "NaN" + ^:private compile-frac-positive-infinity &&lux/compile-frac "Infinity" + ^:private compile-frac-negative-infinity &&lux/compile-frac "-Infinity" ) -(defn ^:private compile-real-encode [compile ?values special-args] +(defn ^:private compile-frac-encode [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "(" =x ")" ".toString()")))) @@ -188,25 +188,25 @@ ^:private compile-int-to-nat ) -(defn ^:private compile-int-to-real [compile ?values special-args] +(defn ^:private compile-int-to-frac [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "LuxRT$toNumberI64(" =x ")")))) -(defn ^:private compile-real-to-int [compile ?values special-args] +(defn ^:private compile-frac-to-int [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "LuxRT$fromNumberI64(" =x ")")))) -(defn ^:private compile-deg-to-real [compile ?values special-args] +(defn ^:private compile-deg-to-frac [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] - (return (str "LuxRT$degToReal(" =x ")")))) + (return (str "LuxRT$degToFrac(" =x ")")))) -(defn ^:private compile-real-to-deg [compile ?values special-args] +(defn ^:private compile-frac-to-deg [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] - (return (str "LuxRT$realToDeg(" =x ")")))) + (return (str "LuxRT$fracToDeg(" =x ")")))) (do-template [ ] (defn [compile ?values special-args] @@ -505,7 +505,7 @@ "max-value" (compile-int-max-value compile ?values special-args) "min-value" (compile-int-min-value compile ?values special-args) "to-nat" (compile-int-to-nat compile ?values special-args) - "to-real" (compile-int-to-real compile ?values special-args) + "to-frac" (compile-int-to-frac compile ?values special-args) ) "deg" @@ -519,30 +519,30 @@ "<" (compile-deg-lt compile ?values special-args) "max-value" (compile-deg-max-value compile ?values special-args) "min-value" (compile-deg-min-value compile ?values special-args) - "to-real" (compile-deg-to-real compile ?values special-args) + "to-frac" (compile-deg-to-frac compile ?values special-args) "scale" (compile-deg-scale compile ?values special-args) "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) - "real" + "frac" (case proc - "+" (compile-real-add compile ?values special-args) - "-" (compile-real-sub compile ?values special-args) - "*" (compile-real-mul compile ?values special-args) - "/" (compile-real-div compile ?values special-args) - "%" (compile-real-rem compile ?values special-args) - "=" (compile-real-eq compile ?values special-args) - "<" (compile-real-lt compile ?values special-args) - "encode" (compile-real-encode compile ?values special-args) - "decode" (compile-real-decode compile ?values special-args) - "smallest-value" (compile-real-smallest-value compile ?values special-args) - "max-value" (compile-real-max-value compile ?values special-args) - "min-value" (compile-real-min-value compile ?values special-args) - "not-a-number" (compile-real-not-a-number compile ?values special-args) - "positive-infinity" (compile-real-positive-infinity compile ?values special-args) - "negative-infinity" (compile-real-negative-infinity compile ?values special-args) - "to-deg" (compile-real-to-deg compile ?values special-args) - "to-int" (compile-real-to-int compile ?values special-args) + "+" (compile-frac-add compile ?values special-args) + "-" (compile-frac-sub compile ?values special-args) + "*" (compile-frac-mul compile ?values special-args) + "/" (compile-frac-div compile ?values special-args) + "%" (compile-frac-rem compile ?values special-args) + "=" (compile-frac-eq compile ?values special-args) + "<" (compile-frac-lt compile ?values special-args) + "encode" (compile-frac-encode compile ?values special-args) + "decode" (compile-frac-decode compile ?values special-args) + "smallest-value" (compile-frac-smallest-value compile ?values special-args) + "max-value" (compile-frac-max-value compile ?values special-args) + "min-value" (compile-frac-min-value compile ?values special-args) + "not-a-number" (compile-frac-not-a-number compile ?values special-args) + "positive-infinity" (compile-frac-positive-infinity compile ?values special-args) + "negative-infinity" (compile-frac-negative-infinity compile ?values special-args) + "to-deg" (compile-frac-to-deg compile ?values special-args) + "to-int" (compile-frac-to-int compile ?values special-args) ) "char" diff --git a/luxc/src/lux/compiler/js/rt.clj b/luxc/src/lux/compiler/js/rt.clj index 838598bbb..04ee6fc69 100644 --- a/luxc/src/lux/compiler/js/rt.clj +++ b/luxc/src/lux/compiler/js/rt.clj @@ -637,13 +637,13 @@ "return LuxRT$shlI64(LuxRT$divI64(l,LuxRT$fromNumberI64(r.H)),32);" "}") "})") - "degToReal" (str "(function LuxRT$degToReal(input) {" + "degToFrac" (str "(function LuxRT$degToFrac(input) {" "var two32 = Math.pow(2,32);" "var high = input.H / two32;" "var low = (input.L / two32) / two32;" "return high+low;" "})") - "realToDeg" (str "(function LuxRT$realToDeg(input) {" + "fracToDeg" (str "(function LuxRT$fracToDeg(input) {" "var two32 = Math.pow(2,32);" "var shifted = (input % 1.0) * two32;" "var low = ((shifted % 1.0) * two32) | 0;" diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj index 5c11c0c6d..e54f92d91 100644 --- a/luxc/src/lux/compiler/jvm.clj +++ b/luxc/src/lux/compiler/jvm.clj @@ -59,8 +59,8 @@ (&o/$deg ?value) (&&lux/compile-deg ?value) - (&o/$real ?value) - (&&lux/compile-real ?value) + (&o/$frac ?value) + (&&lux/compile-frac ?value) (&o/$text ?value) (&&lux/compile-text ?value) diff --git a/luxc/src/lux/compiler/jvm/case.clj b/luxc/src/lux/compiler/jvm/case.clj index c205381e8..38f3ad4fc 100644 --- a/luxc/src/lux/compiler/jvm/case.clj +++ b/luxc/src/lux/compiler/jvm/case.clj @@ -93,7 +93,7 @@ (.visitInsn Opcodes/LCMP) (.visitJumpInsn Opcodes/IFNE $else)) - (&o/$RealPM _value) + (&o/$FracPM _value) (doto writer stack-peek &&/unwrap-double diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/luxc/src/lux/compiler/jvm/lux.clj index 123676d35..99e55c3a0 100644 --- a/luxc/src/lux/compiler/jvm/lux.clj +++ b/luxc/src/lux/compiler/jvm/lux.clj @@ -40,7 +40,7 @@ compile-nat "java/lang/Long" "J" long compile-int "java/lang/Long" "J" long compile-deg "java/lang/Long" "J" long - compile-real "java/lang/Double" "D" double + compile-frac "java/lang/Double" "D" double ) (defn compile-text [?value] diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index 7c44f3434..757f66afd 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -218,11 +218,11 @@ ^:private compile-deg-scale Opcodes/LMUL &&/unwrap-long &&/wrap-long ^:private compile-deg-reciprocal Opcodes/LDIV &&/unwrap-long &&/wrap-long - ^:private compile-real-add Opcodes/DADD &&/unwrap-double &&/wrap-double - ^:private compile-real-sub Opcodes/DSUB &&/unwrap-double &&/wrap-double - ^:private compile-real-mul Opcodes/DMUL &&/unwrap-double &&/wrap-double - ^:private compile-real-div Opcodes/DDIV &&/unwrap-double &&/wrap-double - ^:private compile-real-rem Opcodes/DREM &&/unwrap-double &&/wrap-double + ^:private compile-frac-add Opcodes/DADD &&/unwrap-double &&/wrap-double + ^:private compile-frac-sub Opcodes/DSUB &&/unwrap-double &&/wrap-double + ^:private compile-frac-mul Opcodes/DMUL &&/unwrap-double &&/wrap-double + ^:private compile-frac-div Opcodes/DDIV &&/unwrap-double &&/wrap-double + ^:private compile-frac-rem Opcodes/DREM &&/unwrap-double &&/wrap-double ) (do-template [ ] @@ -270,8 +270,8 @@ ^:private compile-int-eq Opcodes/LCMP 0 &&/unwrap-long ^:private compile-int-lt Opcodes/LCMP -1 &&/unwrap-long - ^:private compile-real-eq Opcodes/DCMPG 0 &&/unwrap-double - ^:private compile-real-lt Opcodes/DCMPG -1 &&/unwrap-double + ^:private compile-frac-eq Opcodes/DCMPG 0 &&/unwrap-double + ^:private compile-frac-lt Opcodes/DCMPG -1 &&/unwrap-double ) (do-template [ ] @@ -343,13 +343,13 @@ ^:private compile-deg-min-value (.visitLdcInsn 0) &&/wrap-long ^:private compile-deg-max-value (.visitLdcInsn -1) &&/wrap-long - ^:private compile-real-smallest-value (.visitLdcInsn Double/MIN_VALUE) &&/wrap-double - ^:private compile-real-min-value (.visitLdcInsn (* -1.0 Double/MAX_VALUE)) &&/wrap-double - ^:private compile-real-max-value (.visitLdcInsn Double/MAX_VALUE) &&/wrap-double + ^:private compile-frac-smallest-value (.visitLdcInsn Double/MIN_VALUE) &&/wrap-double + ^:private compile-frac-min-value (.visitLdcInsn (* -1.0 Double/MAX_VALUE)) &&/wrap-double + ^:private compile-frac-max-value (.visitLdcInsn Double/MAX_VALUE) &&/wrap-double - ^:private compile-real-not-a-number (.visitLdcInsn Double/NaN) &&/wrap-double - ^:private compile-real-positive-infinity (.visitLdcInsn Double/POSITIVE_INFINITY) &&/wrap-double - ^:private compile-real-negative-infinity (.visitLdcInsn Double/NEGATIVE_INFINITY) &&/wrap-double + ^:private compile-frac-not-a-number (.visitLdcInsn Double/NaN) &&/wrap-double + ^:private compile-frac-positive-infinity (.visitLdcInsn Double/POSITIVE_INFINITY) &&/wrap-double + ^:private compile-frac-negative-infinity (.visitLdcInsn Double/NEGATIVE_INFINITY) &&/wrap-double ) (do-template [ ] @@ -362,7 +362,7 @@ (.visitMethodInsn Opcodes/INVOKESTATIC "toString" ))]] (return nil))) - ^:private compile-real-encode "java/lang/Double" "(D)Ljava/lang/String;" &&/unwrap-double + ^:private compile-frac-encode "java/lang/Double" "(D)Ljava/lang/String;" &&/unwrap-double ) @@ -377,7 +377,7 @@ (return nil))) ^:private compile-int-decode "decode_int" - ^:private compile-real-decode "decode_real" + ^:private compile-frac-decode "decode_frac" ) (do-template [ ] @@ -411,8 +411,8 @@ )]] (return nil)))) - ^:private compile-deg-to-real "java.lang.Long" "deg-to-real" "(J)D" &&/unwrap-long &&/wrap-double - ^:private compile-real-to-deg "java.lang.Double" "real-to-deg" "(D)J" &&/unwrap-double &&/wrap-long + ^:private compile-deg-to-frac "java.lang.Long" "deg-to-frac" "(J)D" &&/unwrap-long &&/wrap-double + ^:private compile-frac-to-deg "java.lang.Double" "frac-to-deg" "(D)J" &&/unwrap-double &&/wrap-long ) (defn ^:private compile-nat-to-char [compile ?values special-args] @@ -448,8 +448,8 @@ )]] (return nil))) - ^:private compile-real-to-int &&/unwrap-double Opcodes/D2L &&/wrap-long - ^:private compile-int-to-real &&/unwrap-long Opcodes/L2D &&/wrap-double + ^:private compile-frac-to-int &&/unwrap-double Opcodes/D2L &&/wrap-long + ^:private compile-int-to-frac &&/unwrap-long Opcodes/L2D &&/wrap-double ) (defn ^:private compile-text-eq [compile ?values special-args] @@ -883,7 +883,7 @@ "<" (compile-deg-lt compile ?values special-args) "max-value" (compile-deg-max-value compile ?values special-args) "min-value" (compile-deg-min-value compile ?values special-args) - "to-real" (compile-deg-to-real compile ?values special-args) + "to-frac" (compile-deg-to-frac compile ?values special-args) "scale" (compile-deg-scale compile ?values special-args) "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) @@ -900,28 +900,28 @@ "max-value" (compile-int-max-value compile ?values special-args) "min-value" (compile-int-min-value compile ?values special-args) "to-nat" (compile-int-to-nat compile ?values special-args) - "to-real" (compile-int-to-real compile ?values special-args) + "to-frac" (compile-int-to-frac compile ?values special-args) ) - "real" + "frac" (case proc - "+" (compile-real-add compile ?values special-args) - "-" (compile-real-sub compile ?values special-args) - "*" (compile-real-mul compile ?values special-args) - "/" (compile-real-div compile ?values special-args) - "%" (compile-real-rem compile ?values special-args) - "=" (compile-real-eq compile ?values special-args) - "<" (compile-real-lt compile ?values special-args) - "smallest-value" (compile-real-smallest-value compile ?values special-args) - "max-value" (compile-real-max-value compile ?values special-args) - "min-value" (compile-real-min-value compile ?values special-args) - "not-a-number" (compile-real-not-a-number compile ?values special-args) - "positive-infinity" (compile-real-positive-infinity compile ?values special-args) - "negative-infinity" (compile-real-negative-infinity compile ?values special-args) - "to-int" (compile-real-to-int compile ?values special-args) - "to-deg" (compile-real-to-deg compile ?values special-args) - "encode" (compile-real-encode compile ?values special-args) - "decode" (compile-real-decode compile ?values special-args) + "+" (compile-frac-add compile ?values special-args) + "-" (compile-frac-sub compile ?values special-args) + "*" (compile-frac-mul compile ?values special-args) + "/" (compile-frac-div compile ?values special-args) + "%" (compile-frac-rem compile ?values special-args) + "=" (compile-frac-eq compile ?values special-args) + "<" (compile-frac-lt compile ?values special-args) + "smallest-value" (compile-frac-smallest-value compile ?values special-args) + "max-value" (compile-frac-max-value compile ?values special-args) + "min-value" (compile-frac-min-value compile ?values special-args) + "not-a-number" (compile-frac-not-a-number compile ?values special-args) + "positive-infinity" (compile-frac-positive-infinity compile ?values special-args) + "negative-infinity" (compile-frac-negative-infinity compile ?values special-args) + "to-int" (compile-frac-to-int compile ?values special-args) + "to-deg" (compile-frac-to-deg compile ?values special-args) + "encode" (compile-frac-encode compile ?values special-args) + "decode" (compile-frac-decode compile ?values special-args) ) "math" diff --git a/luxc/src/lux/compiler/jvm/rt.clj b/luxc/src/lux/compiler/jvm/rt.clj index b2670b9ef..83f02af3e 100644 --- a/luxc/src/lux/compiler/jvm/rt.clj +++ b/luxc/src/lux/compiler/jvm/rt.clj @@ -416,7 +416,7 @@ (.visitInsn Opcodes/LRETURN) (.visitMaxs 0 0) (.visitEnd))) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg-to-real" "(J)D" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg-to-frac" "(J)D" nil nil) (.visitCode) ;; Translate high bytes (.visitVarInsn Opcodes/LLOAD 0) high-4b @@ -435,7 +435,7 @@ (.visitInsn Opcodes/DRETURN) (.visitMaxs 0 0) (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "real-to-deg" "(D)J" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac-to-deg" "(D)J" nil nil) (.visitCode) ;; Drop any excess (.visitVarInsn Opcodes/DLOAD 0) @@ -619,7 +619,7 @@ nil)) ^:private compile-LuxRT-int-methods "decode_int" "java/lang/Long" "parseLong" "(Ljava/lang/String;)J" &&/wrap-long - ^:private compile-LuxRT-real-methods "decode_real" "java/lang/Double" "parseDouble" "(Ljava/lang/String;)D" &&/wrap-double + ^:private compile-LuxRT-frac-methods "decode_frac" "java/lang/Double" "parseDouble" "(Ljava/lang/String;)D" &&/wrap-double ) (defn ^:private compile-LuxRT-pm-methods [^ClassWriter =class] @@ -889,7 +889,7 @@ (compile-LuxRT-nat-methods) (compile-LuxRT-int-methods) (compile-LuxRT-deg-methods) - (compile-LuxRT-real-methods) + (compile-LuxRT-frac-methods) (compile-LuxRT-text-methods) (compile-LuxRT-process-methods))]] (&&/save-class! (second (string/split &&/lux-utils-class #"/")) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index dbdeef6a8..65a99de6a 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -13,7 +13,7 @@ ("Nat" 1) ("Int" 1) ("Deg" 1) - ("Real" 1) + ("Frac" 1) ("Text" 1) ("Symbol" 1) ("Tag" 1) @@ -141,7 +141,7 @@ lex-nat $Nat #"^\+(0|[1-9][0-9_]*)" lex-int $Int #"^-?(0|[1-9][0-9_]*)" lex-deg $Deg #"^(\.[0-9_]+)" - lex-real $Real #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" + lex-frac $Frac #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" ) (def ^:private lex-ident @@ -205,7 +205,7 @@ lex-comment lex-bool lex-nat - lex-real + lex-frac lex-deg lex-int lex-text diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj index 107435f92..72dd1e4a5 100644 --- a/luxc/src/lux/optimizer.clj +++ b/luxc/src/lux/optimizer.clj @@ -10,7 +10,7 @@ ("nat" 1) ("int" 1) ("deg" 1) - ("real" 1) + ("frac" 1) ("text" 1) ("variant" 3) ("tuple" 1) @@ -73,8 +73,8 @@ ("IntPM" 1) ;; Compare the CDN with a degree value. ("DegPM" 1) - ;; Compare the CDN with a real value. - ("RealPM" 1) + ;; Compare the CDN with a frac value. + ("FracPM" 1) ;; Compare the CDN with a text value. ("TextPM" 1) ;; Compare the CDN with a variant value. If valid, proceed to test @@ -190,8 +190,8 @@ (&/|list ($DegPM _value) $PopPM) - (&a-case/$RealTestAC _value) - (&/|list ($RealPM _value) + (&a-case/$FracTestAC _value) + (&/|list ($FracPM _value) $PopPM) (&a-case/$TextTestAC _value) @@ -295,9 +295,9 @@ ($DegPM _pre-value) ($AltPM pre post)) - [($RealPM _pre-value) ($RealPM _post-value)] + [($FracPM _pre-value) ($FracPM _post-value)] (if (= _pre-value _post-value) - ($RealPM _pre-value) + ($FracPM _pre-value) ($AltPM pre post)) [($TextPM _pre-value) ($TextPM _post-value)] @@ -1013,8 +1013,8 @@ (&a/$deg value) (&/T [meta ($deg value)]) - (&a/$real value) - (&/T [meta ($real value)]) + (&a/$frac value) + (&/T [meta ($frac value)]) (&a/$text value) (&/T [meta ($text value)]) diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index 7c9076aee..6bc2190a7 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -76,8 +76,8 @@ (&lexer/$Deg ?value) (return (&/|list (&/T [meta (&/$Deg (&/decode-deg ?value))]))) - (&lexer/$Real ?value) - (return (&/|list (&/T [meta (&/$Real (Double/parseDouble ?value))]))) + (&lexer/$Frac ?value) + (return (&/|list (&/T [meta (&/$Frac (Double/parseDouble ?value))]))) (&lexer/$Text ?value) (return (&/|list (&/T [meta (&/$Text ?value)]))) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index e6cc86fff..dd7a49610 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -27,7 +27,7 @@ (def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Host &&host/nat-data-tag &/$Nil))) (def Deg (&/$Named (&/T ["lux" "Deg"]) (&/$Host &&host/deg-data-tag &/$Nil))) (def Int (&/$Named (&/T ["lux" "Int"]) (&/$Host "#Int" &/$Nil))) -(def Real (&/$Named (&/T ["lux" "Real"]) (&/$Host "#Real" &/$Nil))) +(def Frac (&/$Named (&/T ["lux" "Frac"]) (&/$Host "#Frac" &/$Nil))) (def Text (&/$Named (&/T ["lux" "Text"]) (&/$Host "#Text" &/$Nil))) (def Ident (&/$Named (&/T ["lux" "Ident"]) (&/$Product Text Text))) @@ -140,8 +140,8 @@ ;; DegA Deg (&/$Sum - ;; RealA - Real + ;; FracA + Frac (&/$Sum ;; TextA Text diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 7d894b4df..82f14812d 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -255,7 +255,7 @@ (def ^:private lux-jvm-type-combos #{#{"java.lang.Boolean" "#Bool"} #{"java.lang.Long" "#Int"} - #{"java.lang.Double" "#Real"} + #{"java.lang.Double" "#Frac"} #{"java.lang.Character" "#Char"} #{"java.lang.String" "#Text"}}) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 7a49fb2ec..d29e4fca5 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -25,9 +25,9 @@ (+1 [["lux" "doc"] (+5 "Your standard, run-of-the-mill integer numbers.")] (+0))))) -(_lux_def Real - (+12 ["lux" "Real"] - (+0 "#Real" (+0))) +(_lux_def Frac + (+12 ["lux" "Frac"] + (+0 "#Frac" (+0))) (+1 [["lux" "type?"] (+0 true)] (+1 [["lux" "export?"] (+0 true)] (+1 [["lux" "doc"] (+5 "Your standard, run-of-the-mill floating-point numbers.")] @@ -212,7 +212,7 @@ ## (#NatA Nat) ## (#IntA Int) ## (#DegA Deg) -## (#RealA Real) +## (#FracA Frac) ## (#TextA Text) ## (#IdentA Ident) ## (#ListA (List Ann-Value)) @@ -231,8 +231,8 @@ Int (#Sum ## #DegA Deg - (#Sum ## #RealA - Real + (#Sum ## #FracA + Frac (#Sum ## #TextA Text (#Sum ## #IdentA @@ -249,7 +249,7 @@ (#Cons (+5 "NatA") (#Cons (+5 "IntA") (#Cons (+5 "DegA") - (#Cons (+5 "RealA") + (#Cons (+5 "FracA") (#Cons (+5 "TextA") (#Cons (+5 "IdentA") (#Cons (+5 "ListA") @@ -380,7 +380,7 @@ ## (#Nat Nat) ## (#Int Int) ## (#Deg Deg) -## (#Real Real) +## (#Frac Frac) ## (#Text Text) ## (#Symbol Text Text) ## (#Tag Text Text) @@ -404,8 +404,8 @@ Int (#Sum ## "lux;Deg" Deg - (#Sum ## "lux;Real" - Real + (#Sum ## "lux;Frac" + Frac (#Sum ## "lux;Text" Text (#Sum ## "lux;Symbol" @@ -424,7 +424,7 @@ (#Cons (#TextA "Nat") (#Cons (#TextA "Int") (#Cons (#TextA "Deg") - (#Cons (#TextA "Real") + (#Cons (#TextA "Frac") (#Cons (#TextA "Text") (#Cons (#TextA "Symbol") (#Cons (#TextA "Tag") @@ -732,9 +732,9 @@ (_lux_function _ value (_meta (#Deg value)))) #Nil) -(_lux_def real$ - (_lux_: (#Function Real Code) - (_lux_function _ value (_meta (#Real value)))) +(_lux_def frac$ + (_lux_: (#Function Frac Code) + (_lux_function _ value (_meta (#Frac value)))) #Nil) (_lux_def text$ @@ -1778,8 +1778,8 @@ [_ [_ (#Deg value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Deg"]) (deg$ value))))) - [_ [_ (#Real value)]] - (return (wrap-meta (form$ (list (tag$ ["lux" "Real"]) (real$ value))))) + [_ [_ (#Frac value)]] + (return (wrap-meta (form$ (list (tag$ ["lux" "Frac"]) (frac$ value))))) [_ [_ (#Text value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Text"]) (text$ value))))) @@ -2121,16 +2121,16 @@ (_lux_proc [ "="] [subject test])))] [ Nat "nat" n.= n.< n.<= n.> n.>= - "Natural equality." "Natural less-than." "Natural less-than-equal." "Natural greater-than." "Natural greater-than-equal."] + "Nat(ural) equality." "Nat(ural) less-than." "Nat(ural) less-than-equal." "Nat(ural) greater-than." "Nat(ural) greater-than-equal."] [ Int "int" i.= i.< i.<= i.> i.>= - "Integer equality." "Integer less-than." "Integer less-than-equal." "Integer greater-than." "Integer greater-than-equal."] + "Int(eger) equality." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."] [ Deg "deg" d.= d.< d.<= d.> d.>= - "Degree equality." "Degree less-than." "Degree less-than-equal." "Degree greater-than." "Degree greater-than-equal."] + "Deg(ree) equality." "Deg(ree) less-than." "Deg(ree) less-than-equal." "Deg(ree) greater-than." "Deg(ree) greater-than-equal."] - [Real "real" r.= r.< r.<= r.> r.>= - "Real equality." "Real less-than." "Real less-than-equal." "Real greater-than." "Real greater-than-equal."] + [Frac "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."] ) (do-template [ ] @@ -2157,11 +2157,11 @@ [ Deg d./ [ "deg" "/"] "Deg(ree) division."] [ Deg d.% [ "deg" "%"] "Deg(ree) remainder."] - [Real r.+ ["real" "+"] "Real addition."] - [Real r.- ["real" "-"] "Real substraction."] - [Real r.* ["real" "*"] "Real multiplication."] - [Real r./ ["real" "/"] "Real division."] - [Real r.% ["real" "%"] "Real remainder."] + [Frac f.+ ["frac" "+"] "Frac(tion) addition."] + [Frac f.- ["frac" "-"] "Frac(tion) substraction."] + [Frac f.* ["frac" "*"] "Frac(tion) multiplication."] + [Frac f./ ["frac" "/"] "Frac(tion) division."] + [Frac f.% ["frac" "%"] "Frac(tion) remainder."] ) (do-template [ ] @@ -2191,8 +2191,8 @@ [d.min Deg d.< "Deg(ree) minimum."] [d.max Deg d.> "Deg(ree) maximum."] - [r.min Real r.< "Real minimum."] - [r.max Real r.> "Real minimum."] + [f.min Frac f.< "Frac minimum."] + [f.max Frac f.> "Frac minimum."] ) (def:''' (Bool/encode x) @@ -2252,10 +2252,10 @@ (|> value (i./ 10) Int/abs) (|> value (i.% 10) Int/abs (_lux_:! Nat) digit-to-text))))) -(def:''' (Real/encode x) +(def:''' (Frac/encode x) #Nil - (-> Real Text) - (_lux_proc ["real" "encode"] [x])) + (-> Frac Text) + (_lux_proc ["frac" "encode"] [x])) (def:''' (multiple? div n) #Nil @@ -2686,8 +2686,8 @@ [_ (#Deg value)] (_lux_proc ["io" "error"] ["Undefined behavior."]) - [_ (#Real value)] - (Real/encode value) + [_ (#Frac value)] + (Frac/encode value) [_ (#Text value)] ($_ Text/append "\"" value "\"") @@ -2916,8 +2916,8 @@ [_ (#Deg value)] (return (form$ (list (tag$ ["lux" "DegA"]) (deg$ value)))) - [_ (#Real value)] - (return (form$ (list (tag$ ["lux" "RealA"]) (real$ value)))) + [_ (#Frac value)] + (return (form$ (list (tag$ ["lux" "FracA"]) (frac$ value)))) [_ (#Text value)] (return (form$ (list (tag$ ["lux" "TextA"]) (text$ value)))) @@ -4877,8 +4877,8 @@ (-> ) (_lux_proc [n]))] - [real-to-int Real Int ["real" "to-int"]] - [int-to-real Int Real ["int" "to-real"]] + [frac-to-int Frac Int ["frac" "to-int"]] + [int-to-frac Int Frac ["int" "to-frac"]] ) (def: (find-baseline-column ast) @@ -4891,7 +4891,7 @@ [#Nat] [#Int] [#Deg] - [#Real] + [#Frac] [#Text] [#Symbol] [#Tag]) @@ -4958,8 +4958,8 @@ [int-to-nat ["int" "to-nat"] Int Nat] [nat-to-int ["nat" "to-int"] Nat Int] - [real-to-deg ["real" "to-deg"] Real Deg] - [deg-to-real ["deg" "to-real"] Deg Real] + [frac-to-deg ["frac" "to-deg"] Frac Deg] + [deg-to-frac ["deg" "to-frac"] Deg Frac] ) (def: (repeat n x) @@ -5008,7 +5008,7 @@ ([#Bool Bool/encode] [#Nat Nat/encode] [#Int Int/encode] - [#Real Real/encode] + [#Frac Frac/encode] [#Text Text/encode] [#Symbol Ident/encode] [#Tag Tag/encode]) @@ -5208,7 +5208,7 @@ (def: (place-tokens label tokens target) (-> Text (List Code) Code (Maybe (List Code))) (case target - (^or [_ (#Bool _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Deg _)] [_ (#Real _)] [_ (#Text _)] [_ (#Tag _)]) + (^or [_ (#Bool _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Deg _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) (#Some (list target)) [_ (#Symbol [prefix name])] @@ -5257,7 +5257,7 @@ [(bool true) "true" [_ (#;Bool true)]] [(bool false) "false" [_ (#;Bool false)]] [(int 123) "123" [_ (#;Int 123)]] - [(real 123.0) "123.0" [_ (#;Real 123.0)]] + [(frac 123.0) "123.0" [_ (#;Frac 123.0)]] [(text "\n") "\"\\n\"" [_ (#;Text "\n")]] [(tag ["yolo" "lol"]) "#yolo;lol" [_ (#;Tag ["yolo" "lol"])]] [(symbol ["yolo" "lol"]) "yolo;lol" [_ (#;Symbol ["yolo" "lol"])]] @@ -5302,7 +5302,7 @@ ["Nat"] ["Int"] ["Deg"] - ["Real"] + ["Frac"] ["Text"]) (#Named _ type') @@ -5324,7 +5324,7 @@ ["Nat" Nat nat$] ["Int" Int int$] ["Deg" Deg deg$] - ["Real" Real real$] + ["Frac" Frac frac$] ["Text" Text text$]) _ @@ -5362,7 +5362,7 @@ )) (macro: #export (^~ tokens) - {#;doc (doc "Use global defs with simple values, such as text, int, real and bool in place of literals in patterns." + {#;doc (doc "Use global defs with simple values, such as text, int, frac and bool in place of literals in patterns." "The definitions must be properly-qualified (though you may use one of the short-cuts Lux provides)." (def: (empty?' node) (All [K V] (-> (Node K V) Bool)) diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index a0854ffcf..61a6ddbd0 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -2,7 +2,7 @@ n.+ n.- n.* n./ n.% n.= n.< n.<= n.> n.>= i.+ i.- i.* i./ i.% i.= i.< i.<= i.> i.>= d.+ d.- d.* d./ d.% d.= d.< d.<= d.> d.>= - r.+ r.- r.* r./ r.% r.= r.< r.<= r.> r.>=] + f.+ f.- f.* f./ f.% f.= f.< f.<= f.> f.>=] (lux (control ["p" parser "p/" Monad] [monad]) (data [text] @@ -98,7 +98,7 @@ (case command (^or [_ (#;Bool _)] [_ (#;Nat _)] [_ (#;Int _)] - [_ (#;Deg _)] [_ (#;Real _)] + [_ (#;Deg _)] [_ (#;Frac _)] [_ (#;Text _)] [_ (#;Tag _)] (^ [_ (#;Form (list [_ (#;Tag _)]))])) (` (;;push (~ command))) @@ -231,16 +231,16 @@ [Deg Bool d.> ;d.>] [Deg Bool d.>= ;d.>=] - [Real Real r.+ ;r.+] - [Real Real r.- ;r.-] - [Real Real r.* ;r.*] - [Real Real r./ ;r./] - [Real Real r.% ;r.%] - [Real Bool r.= ;r.=] - [Real Bool r.< ;r.<] - [Real Bool r.<= ;r.<=] - [Real Bool r.> ;r.>] - [Real Bool r.>= ;r.>=] + [Frac Frac f.+ ;f.+] + [Frac Frac f.- ;f.-] + [Frac Frac f.* ;f.*] + [Frac Frac f./ ;f./] + [Frac Frac f.% ;f.%] + [Frac Bool f.= ;f.=] + [Frac Bool f.< ;f.<] + [Frac Bool f.<= ;f.<=] + [Frac Bool f.> ;f.>] + [Frac Bool f.>= ;f.>=] ) (def: #export if diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index f4799726f..61ee1249a 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -8,18 +8,18 @@ (def: rgb Nat +256) (def: top Nat (n.dec rgb)) -(def: nat-to-real (-> Nat Real) (|>. nat-to-int int-to-real)) -(def: real-to-nat (-> Real Nat) (|>. real-to-int int-to-nat)) +(def: nat-to-frac (-> Nat Frac) (|>. nat-to-int int-to-frac)) +(def: frac-to-nat (-> Frac Nat) (|>. frac-to-int int-to-nat)) -(def: rgb-factor Real (nat-to-real top)) +(def: rgb-factor Frac (nat-to-frac top)) (def: scale-down - (-> Nat Real) - (|>. nat-to-real (r./ rgb-factor))) + (-> Nat Frac) + (|>. nat-to-frac (f./ rgb-factor))) (def: scale-up - (-> Real Nat) - (|>. (r.* rgb-factor) real-to-nat)) + (-> Frac Nat) + (|>. (f.* rgb-factor) frac-to-nat)) (opaque: #export Color {} {#red Nat @@ -46,115 +46,115 @@ ) (def: #export (to-hsl color) - (-> Color [Real Real Real]) + (-> Color [Frac Frac Frac]) (let [[red green blue] (unpack color) red (scale-down red) green (scale-down green) blue (scale-down blue) - max ($_ r.max red green blue) - min ($_ r.min red green blue) - luminance (|> (r.+ max min) (r./ 2.0))] - (if (r.= max min) + max ($_ f.max red green blue) + min ($_ f.min red green blue) + luminance (|> (f.+ max min) (f./ 2.0))] + (if (f.= max min) ## Achromatic [0.0 0.0 luminance] ## Chromatic - (let [diff (|> max (r.- min)) + (let [diff (|> max (f.- min)) saturation (|> diff - (r./ (if (r.> 0.5 luminance) - (|> 2.0 (r.- max) (r.- min)) - (|> max (r.+ min))))) - hue' (cond (r.= red max) - (|> green (r.- blue) (r./ diff) - (r.+ (if (r.< blue green) 6.0 0.0))) + (f./ (if (f.> 0.5 luminance) + (|> 2.0 (f.- max) (f.- min)) + (|> max (f.+ min))))) + hue' (cond (f.= red max) + (|> green (f.- blue) (f./ diff) + (f.+ (if (f.< blue green) 6.0 0.0))) - (r.= green max) - (|> blue (r.- red) (r./ diff) - (r.+ 2.0)) + (f.= green max) + (|> blue (f.- red) (f./ diff) + (f.+ 2.0)) - ## (r.= blue max) - (|> red (r.- green) (r./ diff) - (r.+ 4.0)))] - [(|> hue' (r./ 6.0)) + ## (f.= blue max) + (|> red (f.- green) (f./ diff) + (f.+ 4.0)))] + [(|> hue' (f./ 6.0)) saturation luminance])))) (def: (hue-to-rgb p q t) - (-> Real Real Real Real) - (let [t (cond (r.< 0.0 t) (r.+ 1.0 t) - (r.> 1.0 t) (r.- 1.0 t) + (-> Frac Frac Frac Frac) + (let [t (cond (f.< 0.0 t) (f.+ 1.0 t) + (f.> 1.0 t) (f.- 1.0 t) ## else t) - f2/3 (r./ 3.0 2.0)] - (cond (r.< (r./ 6.0 1.0) t) - (|> q (r.- p) (r.* 6.0) (r.* t) (r.+ p)) + f2/3 (f./ 3.0 2.0)] + (cond (f.< (f./ 6.0 1.0) t) + (|> q (f.- p) (f.* 6.0) (f.* t) (f.+ p)) - (r.< (r./ 2.0 1.0) t) + (f.< (f./ 2.0 1.0) t) q - (r.< f2/3 t) - (|> q (r.- p) (r.* (|> f2/3 (r.- t))) (r.* 6.0) (r.+ p)) + (f.< f2/3 t) + (|> q (f.- p) (f.* (|> f2/3 (f.- t))) (f.* 6.0) (f.+ p)) ## else p))) (def: #export (from-hsl [hue saturation luminance]) - (-> [Real Real Real] Color) - (if (r.= 0.0 saturation) + (-> [Frac Frac Frac] Color) + (if (f.= 0.0 saturation) ## Achromatic (let [intensity (scale-up luminance)] (color [intensity intensity intensity])) ## Chromatic - (let [q (if (r.< 0.5 luminance) - (|> saturation (r.+ 1.0) (r.* luminance)) - (|> luminance (r.+ saturation) (r.- (r.* saturation luminance)))) - p (|> luminance (r.* 2.0) (r.- q)) - third (|> 1.0 (r./ 3.0))] - (color [(scale-up (|> hue (r.+ third) (hue-to-rgb p q))) + (let [q (if (f.< 0.5 luminance) + (|> saturation (f.+ 1.0) (f.* luminance)) + (|> luminance (f.+ saturation) (f.- (f.* saturation luminance)))) + p (|> luminance (f.* 2.0) (f.- q)) + third (|> 1.0 (f./ 3.0))] + (color [(scale-up (|> hue (f.+ third) (hue-to-rgb p q))) (scale-up (|> hue (hue-to-rgb p q))) - (scale-up (|> hue (r.- third) (hue-to-rgb p q)))])))) + (scale-up (|> hue (f.- third) (hue-to-rgb p q)))])))) (def: #export (to-hsb color) - (-> Color [Real Real Real]) + (-> Color [Frac Frac Frac]) (let [[red green blue] (unpack color) red (scale-down red) green (scale-down green) blue (scale-down blue) - max ($_ r.max red green blue) - min ($_ r.min red green blue) + max ($_ f.max red green blue) + min ($_ f.min red green blue) brightness max - diff (|> max (r.- min)) - saturation (if (r.= 0.0 max) + diff (|> max (f.- min)) + saturation (if (f.= 0.0 max) 0.0 - (|> diff (r./ max)))] - (if (r.= max min) + (|> diff (f./ max)))] + (if (f.= max min) ## Achromatic [0.0 saturation brightness] ## Chromatic - (let [hue (cond (r.= red max) - (|> green (r.- blue) (r./ diff) - (r.+ (if (r.< blue green) 6.0 0.0))) - - (r.= green max) - (|> blue (r.- red) (r./ diff) - (r.+ 2.0)) - - ## (r.= blue max) - (|> red (r.- green) (r./ diff) - (r.+ 4.0)))] - [(|> hue (r./ 6.0)) + (let [hue (cond (f.= red max) + (|> green (f.- blue) (f./ diff) + (f.+ (if (f.< blue green) 6.0 0.0))) + + (f.= green max) + (|> blue (f.- red) (f./ diff) + (f.+ 2.0)) + + ## (f.= blue max) + (|> red (f.- green) (f./ diff) + (f.+ 4.0)))] + [(|> hue (f./ 6.0)) saturation brightness])))) (def: #export (from-hsb [hue saturation brightness]) - (-> [Real Real Real] Color) - (let [hue (|> hue (r.* 6.0)) + (-> [Frac Frac Frac] Color) + (let [hue (|> hue (f.* 6.0)) i (math;floor hue) - f (|> hue (r.- i)) - p (|> 1.0 (r.- saturation) (r.* brightness)) - q (|> 1.0 (r.- (r.* f saturation)) (r.* brightness)) - t (|> 1.0 (r.- (|> 1.0 (r.- f) (r.* saturation))) (r.* brightness)) + f (|> hue (f.- i)) + p (|> 1.0 (f.- saturation) (f.* brightness)) + q (|> 1.0 (f.- (f.* f saturation)) (f.* brightness)) + t (|> 1.0 (f.- (|> 1.0 (f.- f) (f.* saturation))) (f.* brightness)) v brightness - mod (|> i (r.% 6.0) real-to-nat) + mod (|> i (f.% 6.0) frac-to-nat) red (case mod +0 v +1 q +2 p +3 p +4 t +5 v _ (undefined)) green (case mod +0 t +1 v +2 v +3 q +4 p +5 p _ (undefined)) blue (case mod +0 p +1 p +2 t +3 v +4 v +5 q _ (undefined))] @@ -163,51 +163,51 @@ (scale-up blue)]))) (def: #export (to-cmyk color) - (-> Color [Real Real Real Real]) + (-> Color [Frac Frac Frac Frac]) (let [[red green blue] (unpack color) red (scale-down red) green (scale-down green) blue (scale-down blue) - key (|> 1.0 (r.- ($_ r.max red green blue))) - f (if (r.< 1.0 key) - (|> 1.0 (r./ (|> 1.0 (r.- key)))) + key (|> 1.0 (f.- ($_ f.max red green blue))) + f (if (f.< 1.0 key) + (|> 1.0 (f./ (|> 1.0 (f.- key)))) 0.0) - cyan (|> 1.0 (r.- red) (r.- key) (r.* f)) - magenta (|> 1.0 (r.- green) (r.- key) (r.* f)) - yellow (|> 1.0 (r.- blue) (r.- key) (r.* f))] + cyan (|> 1.0 (f.- red) (f.- key) (f.* f)) + magenta (|> 1.0 (f.- green) (f.- key) (f.* f)) + yellow (|> 1.0 (f.- blue) (f.- key) (f.* f))] [cyan magenta yellow key])) (def: #export (from-cmyk [cyan magenta yellow key]) - (-> [Real Real Real Real] Color) - (if (r.= 1.0 key) + (-> [Frac Frac Frac Frac] Color) + (if (f.= 1.0 key) (color [+0 +0 +0]) - (let [red (|> (|> 1.0 (r.- cyan)) - (r.* (|> 1.0 (r.- key)))) - green (|> (|> 1.0 (r.- magenta)) - (r.* (|> 1.0 (r.- key)))) - blue (|> (|> 1.0 (r.- yellow)) - (r.* (|> 1.0 (r.- key))))] + (let [red (|> (|> 1.0 (f.- cyan)) + (f.* (|> 1.0 (f.- key)))) + green (|> (|> 1.0 (f.- magenta)) + (f.* (|> 1.0 (f.- key)))) + blue (|> (|> 1.0 (f.- yellow)) + (f.* (|> 1.0 (f.- key))))] (color [(scale-up red) (scale-up green) (scale-up blue)])))) (def: (normalize ratio) - (-> Real Real) - (cond (r.> 1.0 ratio) - (r.% 1.0 ratio) + (-> Frac Frac) + (cond (f.> 1.0 ratio) + (f.% 1.0 ratio) - (r.< 0.0 ratio) - (|> 1.0 (r.+ (r.% 1.0 ratio))) + (f.< 0.0 ratio) + (|> 1.0 (f.+ (f.% 1.0 ratio))) ## else ratio)) (def: #export (interpolate ratio end start) - (-> Real Color Color Color) + (-> Frac Color Color Color) (let [dS (normalize ratio) - dE (|> 1.0 (r.- dS)) + dE (|> 1.0 (f.- dS)) interpolate' (: (-> Nat Nat Nat) (function [end start] - (real-to-nat (r.+ (r.* dE (nat-to-real end)) - (r.* dS (nat-to-real start)))))) + (frac-to-nat (f.+ (f.* dE (nat-to-frac end)) + (f.* dS (nat-to-frac start)))))) [redS greenS blueS] (unpack start) [redE greenE blueE] (unpack end)] (color [(interpolate' redE redS) @@ -219,7 +219,7 @@ (do-template [ ] [(def: #export ( ratio color) - (-> Real Color Color) + (-> Frac Color Color) (interpolate ratio color))] [darker black] @@ -236,16 +236,16 @@ (do-template [ ] [(def: #export ( ratio color) - (-> Real Color Color) + (-> Frac Color Color) (let [[hue saturation luminance] (to-hsl color)] (from-hsl [hue (|> saturation - (r.* (|> 1.0 ( (normalize ratio)))) - (r.min 1.0)) + (f.* (|> 1.0 ( (normalize ratio)))) + (f.min 1.0)) luminance])))] - [saturate r.+] - [de-saturate r.-] + [saturate f.+] + [de-saturate f.-] ) (def: #export (gray-scale color) @@ -258,12 +258,12 @@ (-> Color [Color Color Color]) (let [[hue saturation luminance] (to-hsl color)] [color - (from-hsl [(|> hue (r.+ <1>) normalize) saturation luminance]) - (from-hsl [(|> hue (r.+ <2>) normalize) saturation luminance])]))] + (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance]) + (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance])]))] - [triad (|> 1.0 (r./ 3.0)) (|> 2.0 (r./ 3.0))] - [clash (|> 1.0 (r./ 4.0)) (|> 3.0 (r./ 4.0))] - [split-complement (|> 1.0 (r./ 5.0)) (|> 3.0 (r./ 5.0))] + [triad (|> 1.0 (f./ 3.0)) (|> 2.0 (f./ 3.0))] + [clash (|> 1.0 (f./ 4.0)) (|> 3.0 (f./ 4.0))] + [split-complement (|> 1.0 (f./ 5.0)) (|> 3.0 (f./ 5.0))] ) (do-template [ <1> <2> <3>] @@ -271,22 +271,22 @@ (-> Color [Color Color Color Color]) (let [[hue saturation luminance] (to-hsl color)] [color - (from-hsl [(|> hue (r.+ <1>) normalize) saturation luminance]) - (from-hsl [(|> hue (r.+ <2>) normalize) saturation luminance]) - (from-hsl [(|> hue (r.+ <3>) normalize) saturation luminance])]))] + (from-hsl [(|> hue (f.+ <1>) normalize) saturation luminance]) + (from-hsl [(|> hue (f.+ <2>) normalize) saturation luminance]) + (from-hsl [(|> hue (f.+ <3>) normalize) saturation luminance])]))] - [square (|> 1.0 (r./ 4.0)) (|> 2.0 (r./ 4.0)) (|> 3.0 (r./ 4.0))] - [tetradic (|> 2.0 (r./ 12.0)) (|> 6.0 (r./ 12.0)) (|> 8.0 (r./ 12.0))] + [square (|> 1.0 (f./ 4.0)) (|> 2.0 (f./ 4.0)) (|> 3.0 (f./ 4.0))] + [tetradic (|> 2.0 (f./ 12.0)) (|> 6.0 (f./ 12.0)) (|> 8.0 (f./ 12.0))] ) (def: #export (analogous results slice color) - (-> Nat Real Color (List Color)) + (-> Nat Frac Color (List Color)) (if (n.= +0 results) (list) (let [[hue saturation luminance] (to-hsl color) slice (normalize slice)] (L/map (function [idx] - (from-hsl [(|> idx nat-to-real (r.* slice) (r.+ hue) normalize) + (from-hsl [(|> idx nat-to-frac (f.* slice) (f.+ hue) normalize) saturation luminance])) (list;n.range +0 (n.dec results)))))) @@ -296,11 +296,11 @@ (if (n.= +0 results) (list) (let [[hue saturation brightness] (to-hsb color) - slice (|> 1.0 (r./ (nat-to-real results)))] + slice (|> 1.0 (f./ (nat-to-frac results)))] (|> (list;n.range +0 (n.dec results)) - (L/map (|>. nat-to-real - (r.* slice) - (r.+ brightness) + (L/map (|>. nat-to-frac + (f.* slice) + (f.+ brightness) normalize [hue saturation] from-hsb)))))) diff --git a/stdlib/source/lux/data/format/css.lux b/stdlib/source/lux/data/format/css.lux index a5adfb928..e4ca7e3cd 100644 --- a/stdlib/source/lux/data/format/css.lux +++ b/stdlib/source/lux/data/format/css.lux @@ -74,7 +74,7 @@ (do-template [ ] [(def: #export ( value) - (-> Real Value) + (-> Frac Value) (format (%r value) ))] [em "em"] diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 379e3b23b..847b5fa0f 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -11,7 +11,7 @@ (data [bool] [text "text/" Eq Monoid] (text ["l" lexer]) - [number "real/" Codec "nat/" Codec] + [number "frac/" Codec "nat/" Codec] maybe ["R" result] [sum] @@ -32,7 +32,7 @@ [Null Unit] [Boolean Bool] - [Number Real] + [Number Frac] [String Text] ) @@ -72,7 +72,7 @@ [_ ( value)] (wrap (list (` (: JSON ( (~ ( value)))))))) ([#;Bool code;bool #Boolean] - [#;Real code;real #Number] + [#;Frac code;frac #Number] [#;Text code;text #String]) [_ (#;Tag ["" "null"])] @@ -190,7 +190,7 @@ [( x') ( y')] (:: = x' y')) ([#Boolean bool;Eq] - [#Number number;Eq] + [#Number number;Eq] [#String text;Eq]) [(#Array xs) (#Array ys)] diff --git a/stdlib/source/lux/data/format/json/codec.lux b/stdlib/source/lux/data/format/json/codec.lux index 8a50757bf..d6d888c0e 100644 --- a/stdlib/source/lux/data/format/json/codec.lux +++ b/stdlib/source/lux/data/format/json/codec.lux @@ -12,7 +12,7 @@ [bit] [text "text/" Eq Monoid] (text ["l" lexer]) - [number "real/" Codec "nat/" Codec] + [number "frac/" Codec "nat/" Codec] maybe ["R" result] [sum] @@ -38,7 +38,7 @@ [(def: (-> Text) )] [show-boolean ..;Boolean (:: bool;Codec encode)] - [show-number ..;Number (:: number;Codec encode)] + [show-number ..;Number (:: number;Codec encode)] [show-string ..;String text;encode]) (def: (show-array show-json elems) @@ -114,7 +114,7 @@ signed?' (l;this? "-") offset (l;many l;decimal)] (wrap ($_ text/append mark (if signed?' "-" "") offset))))] - (case (real/decode ($_ text/append (if signed? "-" "") digits "." decimals exp)) + (case (frac/decode ($_ text/append (if signed? "-" "") digits "." decimals exp)) (#R;Error message) (p;fail message) @@ -185,8 +185,8 @@ L/map) (def: tag - (-> Nat Real) - (|>. nat-to-int int-to-real)) + (-> Nat Frac) + (|>. nat-to-int int-to-frac)) (def: #hidden (rec-encode non-rec) (All [a] (-> (-> (-> a JSON) @@ -202,15 +202,15 @@ (def: (encode input) (let [high (|> input (bit;and high-mask) (bit;unsigned-shift-right +32)) low (bit;and low-mask input)] - (..;array (vector (|> high nat-to-int int-to-real #..;Number) - (|> low nat-to-int int-to-real #..;Number))))) + (..;array (vector (|> high nat-to-int int-to-frac #..;Number) + (|> low nat-to-int int-to-frac #..;Number))))) (def: (decode input) (<| (../reader;run input) (do p;Monad [high ../reader;number low ../reader;number]) - (wrap (n.+ (|> high real-to-int int-to-nat (bit;shift-left +32)) - (|> low real-to-int int-to-nat)))))) + (wrap (n.+ (|> high frac-to-int int-to-nat (bit;shift-left +32)) + (|> low frac-to-int int-to-nat)))))) (struct: #hidden _ (Codec JSON Int) (def: encode (|>. int-to-nat (:: Codec encode))) @@ -229,7 +229,7 @@ [Bool poly;bool ..;boolean] [Nat poly;nat (:: ;;Codec (~' encode))] [Int poly;int (:: ;;Codec (~' encode))] - [Real poly;real ..;number] + [Frac poly;frac ..;number] [Text poly;text ..;string])