aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux.lux92
-rw-r--r--stdlib/source/lux/control/concatenative.lux24
-rw-r--r--stdlib/source/lux/data/color.lux232
-rw-r--r--stdlib/source/lux/data/format/css.lux2
-rw-r--r--stdlib/source/lux/data/format/json.lux8
-rw-r--r--stdlib/source/lux/data/format/json/codec.lux38
-rw-r--r--stdlib/source/lux/data/format/json/reader.lux6
-rw-r--r--stdlib/source/lux/data/number.lux156
-rw-r--r--stdlib/source/lux/data/number/complex.lux200
-rw-r--r--stdlib/source/lux/data/text/format.lux2
-rw-r--r--stdlib/source/lux/host.js.lux6
-rw-r--r--stdlib/source/lux/host.jvm.lux4
-rw-r--r--stdlib/source/lux/macro.lux2
-rw-r--r--stdlib/source/lux/macro/code.lux8
-rw-r--r--stdlib/source/lux/macro/poly.lux4
-rw-r--r--stdlib/source/lux/macro/poly/eq.lux2
-rw-r--r--stdlib/source/lux/macro/syntax.lux2
-rw-r--r--stdlib/source/lux/math.lux16
-rw-r--r--stdlib/source/lux/math/logic/fuzzy.lux18
-rw-r--r--stdlib/source/lux/math/random.lux12
20 files changed, 417 insertions, 417 deletions
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 [<category> "="] [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 [<type> <name> <op> <doc>]
@@ -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 [<type> <name> <op> <doc>]
@@ -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 @@
(-> <from> <to>)
(_lux_proc <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<Parser>]
[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 [<name> <target>]
[(def: #export (<name> ratio color)
- (-> Real Color Color)
+ (-> Frac Color Color)
(interpolate ratio <target> color))]
[darker black]
@@ -236,16 +236,16 @@
(do-template [<name> <op>]
[(def: #export (<name> ratio color)
- (-> Real Color Color)
+ (-> Frac Color Color)
(let [[hue saturation luminance] (to-hsl color)]
(from-hsl [hue
(|> saturation
- (r.* (|> 1.0 (<op> (normalize ratio))))
- (r.min 1.0))
+ (f.* (|> 1.0 (<op> (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 [<name> <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 [<name> <suffix>]
[(def: #export (<name> value)
- (-> Real Value)
+ (-> Frac Value)
(format (%r value) <suffix>))]
[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<Text> Monoid<Text>]
(text ["l" lexer])
- [number "real/" Codec<Text,Real> "nat/" Codec<Text,Nat>]
+ [number "frac/" Codec<Text,Frac> "nat/" Codec<Text,Nat>]
maybe
["R" result]
[sum]
@@ -32,7 +32,7 @@
[Null Unit]
[Boolean Bool]
- [Number Real]
+ [Number Frac]
[String Text]
)
@@ -72,7 +72,7 @@
[_ (<ast-tag> value)]
(wrap (list (` (: JSON (<json-tag> (~ (<ctor> value))))))))
([#;Bool code;bool #Boolean]
- [#;Real code;real #Number]
+ [#;Frac code;frac #Number]
[#;Text code;text #String])
[_ (#;Tag ["" "null"])]
@@ -190,7 +190,7 @@
[(<tag> x') (<tag> y')]
(:: <struct> = x' y'))
([#Boolean bool;Eq<Bool>]
- [#Number number;Eq<Real>]
+ [#Number number;Eq<Frac>]
[#String text;Eq<Text>])
[(#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<Text> Monoid<Text>]
(text ["l" lexer])
- [number "real/" Codec<Text,Real> "nat/" Codec<Text,Nat>]
+ [number "frac/" Codec<Text,Frac> "nat/" Codec<Text,Nat>]
maybe
["R" result]
[sum]
@@ -38,7 +38,7 @@
[(def: <name> (-> <type> Text) <codec>)]
[show-boolean ..;Boolean (:: bool;Codec<Text,Bool> encode)]
- [show-number ..;Number (:: number;Codec<Text,Real> encode)]
+ [show-number ..;Number (:: number;Codec<Text,Frac> 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<Parser>
[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<JSON,Nat> encode)))
@@ -229,7 +229,7 @@
[Bool poly;bool ..;boolean]
[Nat poly;nat (:: ;;Codec<JSON,Nat> (~' encode))]
[Int poly;int (:: ;;Codec<JSON,Int> (~' encode))]
- [Real poly;real ..;number]
+ [Frac poly;frac ..;number]
[Text poly;text ..;string])
<time> (do-template [<type> <codec>]
[(do @
@@ -284,7 +284,7 @@
(case (~ g!input)
(~@ (L/join (L/map (function [[tag g!encode]]
(list (` ((~ (code;nat tag)) (~ g!input)))
- (` (..;json [(~ (code;real (;;tag tag)))
+ (` (..;json [(~ (code;frac (;;tag tag)))
((~ g!encode) (~ g!input))]))))
(list;enumerate members))))))))))
(do @
@@ -336,7 +336,7 @@
[Bool poly;bool ../reader;boolean]
[Nat poly;nat (p;codec ;;Codec<JSON,Nat> ../reader;any)]
[Int poly;int (p;codec ;;Codec<JSON,Int> ../reader;any)]
- [Real poly;real ../reader;number]
+ [Frac poly;frac ../reader;number]
[Text poly;text ../reader;string])
<time> (do-template [<type> <codec>]
[(do @
@@ -381,7 +381,7 @@
($_ p;alt
(~@ (L/map (function [[tag memberC]]
(` (|> (~ memberC)
- (p;after (../reader;number! (~ (code;real (;;tag tag)))))
+ (p;after (../reader;number! (~ (code;frac (;;tag tag)))))
../reader;array)))
(list;enumerate members))))))))
(do @
@@ -418,18 +418,18 @@
(type: Variant
(#Case0 Bool)
(#Case1 Text)
- (#Case2 Real))
+ (#Case2 Frac))
(type: Record
{#unit Unit
#bool Bool
- #real Real
+ #frac Frac
#text Text
- #maybe (Maybe Real)
- #list (List Real)
+ #maybe (Maybe Frac)
+ #list (List Frac)
#variant Variant
- #tuple [Bool Real Text]
- #dict (Dict Text Real)})
+ #tuple [Bool Frac Text]
+ #dict (Dict Text Frac)})
(derived: (Codec<JSON,?> Record)))}
(with-gensyms [g!inputs]
diff --git a/stdlib/source/lux/data/format/json/reader.lux b/stdlib/source/lux/data/format/json/reader.lux
index 83713bcf3..1b26d746d 100644
--- a/stdlib/source/lux/data/format/json/reader.lux
+++ b/stdlib/source/lux/data/format/json/reader.lux
@@ -8,7 +8,7 @@
["p" parser "p/" Monad<Parser>])
(data [bool]
[text "text/" Monoid<Text>]
- [number "real/" Codec<Text,Real> "nat/" Codec<Text,Nat>]
+ [number "frac/" Codec<Text,Frac> "nat/" Codec<Text,Nat>]
["R" result]
(coll [list]
[vector]
@@ -63,7 +63,7 @@
[null Unit #..;Null "null"]
[boolean Bool #..;Boolean "boolean"]
- [number Real #..;Number "number"]
+ [number Frac #..;Number "number"]
[string Text #..;String "string"]
)
@@ -96,7 +96,7 @@
(fail ($_ text/append "JSON value is not a " <desc> ".")))))]
[boolean? boolean! Bool bool;Eq<Bool> (:: bool;Codec<Text,Bool> encode) #..;Boolean "boolean" id]
- [number? number! Real number;Eq<Real> (:: number;Codec<Text,Real> encode) #..;Number "number" id]
+ [number? number! Frac number;Eq<Frac> (:: number;Codec<Text,Frac> encode) #..;Number "number" id]
[string? string! Text text;Eq<Text> text;encode #..;String "string" id]
)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 783e9bc55..713ee943f 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -19,7 +19,7 @@
[ Nat n.=]
[ Int i.=]
[ Deg d.=]
- [Real r.=]
+ [Frac f.=]
)
(do-template [<type> <eq> <lt> <lte> <gt> <gte>]
@@ -33,7 +33,7 @@
[ Nat Eq<Nat> n.< n.<= n.> n.>=]
[ Int Eq<Int> i.< i.<= i.> i.>=]
[Deg Eq<Deg> d.< d.<= d.> d.>=]
- [Real Eq<Real> r.< r.<= r.> r.>=]
+ [Frac Eq<Frac> f.< f.<= f.> f.>=]
)
(struct: #export _ (Number Nat)
@@ -70,7 +70,7 @@
)]
[ Int Order<Int> i.+ i.- i.* i./ i.% i.= i.< 0 1 -1]
- [Real Order<Real> r.+ r.- r.* r./ r.% r.= r.< 0.0 1.0 -1.0]
+ [Frac Order<Frac> f.+ f.- f.* f./ f.% f.= f.< 0.0 1.0 -1.0]
)
(struct: #export _ (Number Deg)
@@ -93,7 +93,7 @@
[Nat Order<Nat> n.inc n.dec]
[Int Order<Int> i.inc i.dec]
- [Real Order<Real> (r.+ (_lux_proc [ "real" "smallest-value"] [])) (r.- (_lux_proc [ "real" "smallest-value"] []))]
+ [Frac Order<Frac> (f.+ (_lux_proc [ "frac" "smallest-value"] [])) (f.- (_lux_proc [ "frac" "smallest-value"] []))]
[Deg Order<Deg> (d.+ (_lux_proc [ "deg" "min-value"] [])) (d.- (_lux_proc [ "deg" "min-value"] []))]
)
@@ -105,7 +105,7 @@
[ Nat Enum<Nat> (_lux_proc [ "nat" "max-value"] []) (_lux_proc [ "nat" "min-value"] [])]
[ Int Enum<Int> (_lux_proc [ "int" "max-value"] []) (_lux_proc [ "int" "min-value"] [])]
- [Real Enum<Real> (_lux_proc ["real" "max-value"] []) (_lux_proc ["real" "min-value"] [])]
+ [Frac Enum<Frac> (_lux_proc ["frac" "max-value"] []) (_lux_proc ["frac" "min-value"] [])]
[ Deg Enum<Deg> (_lux_proc [ "deg" "max-value"] []) (_lux_proc [ "deg" "min-value"] [])]
)
@@ -122,10 +122,10 @@
[ Mul@Monoid<Int> Int 1 i.*]
[ Max@Monoid<Int> Int (:: Interval<Int> bottom) i.max]
[ Min@Monoid<Int> Int (:: Interval<Int> top) i.min]
- [Add@Monoid<Real> Real 0.0 r.+]
- [Mul@Monoid<Real> Real 1.0 r.*]
- [Max@Monoid<Real> Real (:: Interval<Real> bottom) r.max]
- [Min@Monoid<Real> Real (:: Interval<Real> top) r.min]
+ [Add@Monoid<Frac> Frac 0.0 f.+]
+ [Mul@Monoid<Frac> Frac 1.0 f.*]
+ [Max@Monoid<Frac> Frac (:: Interval<Frac> bottom) f.max]
+ [Min@Monoid<Frac> Frac (:: Interval<Frac> top) f.min]
[ Add@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.+]
[ Mul@Monoid<Deg> Deg (:: Interval<Deg> top) d.*]
[ Max@Monoid<Deg> Deg (:: Interval<Deg> bottom) d.max]
@@ -135,8 +135,8 @@
(do-template [<name> <const> <doc>]
[(def: #export <name>
{#;doc <doc>}
- Real
- (_lux_proc ["real" <const>] []))]
+ Frac
+ (_lux_proc ["frac" <const>] []))]
[not-a-number "not-a-number" "Not-a-number."]
[positive-infinity "positive-infinity" "Positive infinity."]
@@ -144,15 +144,15 @@
)
(def: #export (not-a-number? number)
- {#;doc "Tests whether a real is actually not-a-number."}
- (-> Real Bool)
- (not (r.= number number)))
+ {#;doc "Tests whether a frac is actually not-a-number."}
+ (-> Frac Bool)
+ (not (f.= number number)))
-(def: #export (real? value)
- (-> Real Bool)
+(def: #export (frac? value)
+ (-> Frac Bool)
(not (or (not-a-number? value)
- (r.= positive-infinity value)
- (r.= negative-infinity value))))
+ (f.= positive-infinity value)
+ (f.= negative-infinity value))))
(do-template [<type> <encoder> <decoder> <error>]
[(struct: #export _ (Codec Text <type>)
@@ -167,7 +167,7 @@
#;None
(#R;Error <error>))))]
- [Real ["real" "encode"] ["real" "decode"] "Could not decode Real"]
+ [Frac ["frac" "encode"] ["frac" "decode"] "Could not decode Frac"]
)
## [Values & Syntax]
@@ -302,21 +302,21 @@
)
(do-template [<struct> <int> <base> <char-set> <error>]
- [(struct: #export <struct> (Codec Text Real)
+ [(struct: #export <struct> (Codec Text Frac)
(def: (encode value)
- (let [whole (real-to-int value)
+ (let [whole (frac-to-int value)
whole-part (:: <int> encode whole)
- decimal (:: Number<Real> abs (r.% 1.0 value))
- decimal-part (if (r.= 0.0 decimal)
+ decimal (:: Number<Frac> abs (f.% 1.0 value))
+ decimal-part (if (f.= 0.0 decimal)
".0"
(loop [dec-left decimal
output ""]
- (if (r.= 0.0 dec-left)
+ (if (f.= 0.0 dec-left)
(_lux_proc ["text" "append"] ["." output])
- (let [shifted (r.* <base> dec-left)
- digit (|> shifted (r.% <base>) real-to-int int-to-nat
+ (let [shifted (f.* <base> dec-left)
+ digit (|> shifted (f.% <base>) frac-to-int int-to-nat
(get-char <char-set>) assume)]
- (recur (r.% 1.0 shifted)
+ (recur (f.% 1.0 shifted)
(_lux_proc ["text" "append"] [output digit]))))))]
(_lux_proc ["text" "append"] [whole-part decimal-part])))
@@ -337,16 +337,16 @@
(if (n.= +0 muls-left)
output
(recur (n.dec muls-left)
- (r.* <base> output))))
- adjusted-decimal (|> decimal int-to-real (r./ div-power))
+ (f.* <base> output))))
+ adjusted-decimal (|> decimal int-to-frac (f./ div-power))
dec-deg (case (:: Hex@Codec<Text,Deg> decode (_lux_proc ["text" "append"] ["." decimal-part]))
(#R;Success dec-deg)
dec-deg
(#R;Error error)
(error! error))]
- (#R;Success (r.+ (int-to-real whole)
- (r.* sign adjusted-decimal))))
+ (#R;Success (f.+ (int-to-frac whole)
+ (f.* sign adjusted-decimal))))
_
(#R;Error (_lux_proc ["text" "append"] [<error> repr]))))
@@ -354,7 +354,7 @@
_
(#R;Error (_lux_proc ["text" "append"] [<error> repr])))))]
- [Binary@Codec<Text,Real> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "]
+ [Binary@Codec<Text,Frac> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "]
)
(def: (segment-digits chunk-size digits)
@@ -493,13 +493,13 @@
)
(do-template [<struct> <error> <from> <to>]
- [(struct: #export <struct> (Codec Text Real)
+ [(struct: #export <struct> (Codec Text Frac)
(def: (encode value)
- (let [sign (:: Number<Real> signum value)
- raw-bin (:: Binary@Codec<Text,Real> encode value)
+ (let [sign (:: Number<Frac> signum value)
+ raw-bin (:: Binary@Codec<Text,Frac> encode value)
dot-idx (assume (_lux_proc ["text" "index"] [raw-bin "." +0]))
whole-part (assume (_lux_proc ["text" "clip"] [raw-bin
- (if (r.= -1.0 sign) +1 +0)
+ (if (f.= -1.0 sign) +1 +0)
dot-idx]))
decimal-part (assume (_lux_proc ["text" "clip"] [raw-bin (n.inc dot-idx) (_lux_proc ["text" "size"] [raw-bin])]))
hex-output (|> (<from> false decimal-part)
@@ -507,7 +507,7 @@
(_lux_proc ["text" "append"])
[(<from> true whole-part)]
(_lux_proc ["text" "append"])
- [(if (r.= -1.0 sign) "-" "")]
+ [(if (f.= -1.0 sign) "-" "")]
(_lux_proc ["text" "append"]))]
hex-output))
@@ -520,16 +520,16 @@
1.0)]
(case (_lux_proc ["text" "index"] [repr "." +0])
(#;Some split-index)
- (let [whole-part (assume (_lux_proc ["text" "clip"] [repr (if (r.= -1.0 sign) +1 +0) split-index]))
+ (let [whole-part (assume (_lux_proc ["text" "clip"] [repr (if (f.= -1.0 sign) +1 +0) split-index]))
decimal-part (assume (_lux_proc ["text" "clip"] [repr (n.inc split-index) (_lux_proc ["text" "size"] [repr])]))
as-binary (|> (<to> decimal-part)
["."]
(_lux_proc ["text" "append"])
[(<to> whole-part)]
(_lux_proc ["text" "append"])
- [(if (r.= -1.0 sign) "-" "")]
+ [(if (f.= -1.0 sign) "-" "")]
(_lux_proc ["text" "append"]))]
- (case (:: Binary@Codec<Text,Real> decode as-binary)
+ (case (:: Binary@Codec<Text,Frac> decode as-binary)
(#R;Error _)
(#R;Error (_lux_proc ["text" "append"] [<error> repr]))
@@ -539,11 +539,11 @@
_
(#R;Error (_lux_proc ["text" "append"] [<error> repr]))))))]
- [Octal@Codec<Text,Real> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary]
- [Hex@Codec<Text,Real> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary]
+ [Octal@Codec<Text,Frac> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary]
+ [Hex@Codec<Text,Frac> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary]
)
-(do-template [<macro> <nat> <int> <deg> <real> <error> <doc>]
+(do-template [<macro> <nat> <int> <deg> <frac> <error> <doc>]
[(macro: #export (<macro> tokens state)
{#;doc <doc>}
(case tokens
@@ -561,8 +561,8 @@
(#R;Success [state (list [meta (#;Deg value)])])
(^multi (#R;Error _)
- [(:: <real> decode repr) (#R;Success value)])
- (#R;Success [state (list [meta (#;Real value)])])
+ [(:: <frac> decode repr) (#R;Success value)])
+ (#R;Success [state (list [meta (#;Frac value)])])
_
(#R;Error <error>))
@@ -570,17 +570,17 @@
_
(#R;Error <error>)))]
- [bin Binary@Codec<Text,Nat> Binary@Codec<Text,Int> Binary@Codec<Text,Deg> Binary@Codec<Text,Real>
+ [bin Binary@Codec<Text,Nat> Binary@Codec<Text,Int> Binary@Codec<Text,Deg> Binary@Codec<Text,Frac>
"Invalid binary syntax."
- (doc "Given syntax for a binary number, generates a Nat, an Int, a Deg or a Real."
+ (doc "Given syntax for a binary number, generates a Nat, an Int, a Deg or a Frac."
(bin "11001001"))]
- [oct Octal@Codec<Text,Nat> Octal@Codec<Text,Int> Octal@Codec<Text,Deg> Octal@Codec<Text,Real>
+ [oct Octal@Codec<Text,Nat> Octal@Codec<Text,Int> Octal@Codec<Text,Deg> Octal@Codec<Text,Frac>
"Invalid octal syntax."
- (doc "Given syntax for a octal number, generates a Nat, an Int, a Deg or a Real."
+ (doc "Given syntax for a octal number, generates a Nat, an Int, a Deg or a Frac."
(oct "615243"))]
- [hex Hex@Codec<Text,Nat> Hex@Codec<Text,Int> Hex@Codec<Text,Deg> Hex@Codec<Text,Real>
+ [hex Hex@Codec<Text,Nat> Hex@Codec<Text,Int> Hex@Codec<Text,Deg> Hex@Codec<Text,Frac>
"Invalid hexadecimal syntax."
- (doc "Given syntax for a hexadecimal number, generates a Nat, an Int, a Deg or a Real."
+ (doc "Given syntax for a hexadecimal number, generates a Nat, an Int, a Deg or a Frac."
(hex "deadBEEF"))]
)
@@ -771,8 +771,8 @@
))
(def: (log2 input)
- (-> Real Real)
- (r./ (_lux_proc ["math" "log"] [2.0])
+ (-> Frac Frac)
+ (f./ (_lux_proc ["math" "log"] [2.0])
(_lux_proc ["math" "log"] [input])))
(def: double-bias Nat +1023)
@@ -780,38 +780,38 @@
(def: mantissa-size Nat +52)
(def: exponent-size Nat +11)
-(def: #export (real-to-bits input)
- (-> Real Nat)
+(def: #export (frac-to-bits input)
+ (-> Frac Nat)
(cond (not-a-number? input)
(hex "+7FF7FFFFFFFFFFFF")
- (r.= positive-infinity input)
+ (f.= positive-infinity input)
(hex "+7FF0000000000000")
- (r.= negative-infinity input)
+ (f.= negative-infinity input)
(hex "+FFF0000000000000")
- (r.= 0.0 input)
- (let [reciprocal (r./ input 1.0)]
- (if (r.= positive-infinity reciprocal)
+ (f.= 0.0 input)
+ (let [reciprocal (f./ input 1.0)]
+ (if (f.= positive-infinity reciprocal)
## Positive zero
(hex "+0000000000000000")
## Negative zero
(hex "+8000000000000000")))
## else
- (let [sign (:: Number<Real> signum input)
- input (:: Number<Real> abs input)
+ (let [sign (:: Number<Frac> signum input)
+ input (:: Number<Frac> abs input)
exponent (_lux_proc ["math" "floor"] [(log2 input)])
exponent-mask (|> +1 (bit;shift-left exponent-size) n.dec)
mantissa (|> input
## Normalize
- (r./ (_lux_proc ["math" "pow"] [2.0 exponent]))
+ (f./ (_lux_proc ["math" "pow"] [2.0 exponent]))
## Make it int-equivalent
- (r.* (_lux_proc ["math" "pow"] [2.0 52.0])))
- sign-bit (if (r.= -1.0 sign) +1 +0)
- exponent-bits (|> exponent real-to-int int-to-nat (n.+ double-bias) (bit;and exponent-mask))
- mantissa-bits (|> mantissa real-to-int int-to-nat)]
+ (f.* (_lux_proc ["math" "pow"] [2.0 52.0])))
+ sign-bit (if (f.= -1.0 sign) +1 +0)
+ exponent-bits (|> exponent frac-to-int int-to-nat (n.+ double-bias) (bit;and exponent-mask))
+ mantissa-bits (|> mantissa frac-to-int int-to-nat)]
($_ bit;or
(bit;shift-left +63 sign-bit)
(bit;shift-left mantissa-size exponent-bits)
@@ -829,8 +829,8 @@
[sign sign-mask +1 (n.+ exponent-size mantissa-size)]
)
-(def: #export (bits-to-real input)
- (-> Nat Real)
+(def: #export (bits-to-frac input)
+ (-> Nat Frac)
(let [S (sign input)
E (exponent input)
M (mantissa input)]
@@ -844,20 +844,20 @@
(and (n.= +0 E) (n.= +0 M))
(if (n.= +0 S)
0.0
- (r.* -1.0 0.0))
+ (f.* -1.0 0.0))
## else
(let [normalized (|> M (bit;set mantissa-size)
- nat-to-int int-to-real
- (r./ (_lux_proc ["math" "pow"] [2.0 52.0])))
+ nat-to-int int-to-frac
+ (f./ (_lux_proc ["math" "pow"] [2.0 52.0])))
power (|> E (n.- double-bias)
- nat-to-int int-to-real
+ nat-to-int int-to-frac
[2.0] (_lux_proc ["math" "pow"]))
- shifted (r.* power
+ shifted (f.* power
normalized)]
(if (n.= +0 S)
shifted
- (r.* -1.0 shifted))))))
+ (f.* -1.0 shifted))))))
## [Hash]
(struct: #export _ (Hash Nat)
@@ -868,10 +868,10 @@
(def: eq Eq<Int>)
(def: hash int-to-nat))
-(struct: #export _ (Hash Real)
- (def: eq Eq<Real>)
+(struct: #export _ (Hash Frac)
+ (def: eq Eq<Frac>)
- (def: hash real-to-bits))
+ (def: hash frac-to-bits))
(struct: #export _ (Hash Deg)
(def: eq Eq<Deg>)
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index a3a2fe217..3b8fb7f00 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -6,7 +6,7 @@
codec
["M" monad #+ do Monad]
["p" parser])
- (data [number "r/" Number<Real> Codec<Text,Real>]
+ (data [number "f/" Number<Frac> Codec<Text,Frac>]
[text "text/" Monoid<Text>]
text/format
["R" result]
@@ -20,8 +20,8 @@
## https://github.com/apache/commons-math/blob/master/src/main/java/org/apache/commons/math4/complex/Complex.java
(type: #export Complex
- {#real Real
- #imaginary Real})
+ {#real Frac
+ #imaginary Frac})
(syntax: #export (complex real [?imaginary (p;opt s;any)])
{#;doc (doc "Complex literals."
@@ -44,9 +44,9 @@
(def: #export (c.= param input)
(-> Complex Complex Bool)
- (and (r.= (get@ #real param)
+ (and (f.= (get@ #real param)
(get@ #real input))
- (r.= (get@ #imaginary param)
+ (f.= (get@ #imaginary param)
(get@ #imaginary input))))
(do-template [<name> <op>]
@@ -57,8 +57,8 @@
#imaginary (<op> (get@ #imaginary param)
(get@ #imaginary input))})]
- [c.+ r.+]
- [c.- r.-]
+ [c.+ f.+]
+ [c.- f.-]
)
(struct: #export _ (Eq Complex)
@@ -66,55 +66,55 @@
(def: #export c.negate
(-> Complex Complex)
- (|>. (update@ #real r/negate)
- (update@ #imaginary r/negate)))
+ (|>. (update@ #real f/negate)
+ (update@ #imaginary f/negate)))
(def: #export c.signum
(-> Complex Complex)
- (|>. (update@ #real r/signum)
- (update@ #imaginary r/signum)))
+ (|>. (update@ #real f/signum)
+ (update@ #imaginary f/signum)))
(def: #export conjugate
(-> Complex Complex)
- (update@ #imaginary r/negate))
+ (update@ #imaginary f/negate))
(def: #export (c.*' param input)
- (-> Real Complex Complex)
- {#real (r.* param
+ (-> Frac Complex Complex)
+ {#real (f.* param
(get@ #real input))
- #imaginary (r.* param
+ #imaginary (f.* param
(get@ #imaginary input))})
(def: #export (c.* param input)
(-> Complex Complex Complex)
- {#real (r.- (r.* (get@ #imaginary param)
+ {#real (f.- (f.* (get@ #imaginary param)
(get@ #imaginary input))
- (r.* (get@ #real param)
+ (f.* (get@ #real param)
(get@ #real input)))
- #imaginary (r.+ (r.* (get@ #real param)
+ #imaginary (f.+ (f.* (get@ #real param)
(get@ #imaginary input))
- (r.* (get@ #imaginary param)
+ (f.* (get@ #imaginary param)
(get@ #real input)))})
(def: #export (c./ param input)
(-> Complex Complex Complex)
(let [(^slots [#real #imaginary]) param]
- (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))}))))
+ (if (f.< (f/abs imaginary)
+ (f/abs real))
+ (let [quot (f./ imaginary real)
+ denom (|> real (f.* quot) (f.+ imaginary))]
+ {#real (|> (get@ #real input) (f.* quot) (f.+ (get@ #imaginary input)) (f./ denom))
+ #imaginary (|> (get@ #imaginary input) (f.* quot) (f.- (get@ #real input)) (f./ denom))})
+ (let [quot (f./ real imaginary)
+ denom (|> imaginary (f.* quot) (f.+ real))]
+ {#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom))
+ #imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))}))))
(def: #export (c./' param subject)
- (-> Real Complex Complex)
+ (-> Frac Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (r./ param real)
- #imaginary (r./ param imaginary)}))
+ {#real (f./ param real)
+ #imaginary (f./ param imaginary)}))
(def: #export (c.% param input)
(-> Complex Complex Complex)
@@ -128,68 +128,68 @@
(def: #export (cos subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (r.* (math;cosh imaginary)
+ {#real (f.* (math;cosh imaginary)
(math;cos real))
- #imaginary (r.* (math;sinh imaginary)
- (r/negate (math;sin real)))}))
+ #imaginary (f.* (math;sinh imaginary)
+ (f/negate (math;sin real)))}))
(def: #export (cosh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (r.* (math;cos imaginary)
+ {#real (f.* (math;cos imaginary)
(math;cosh real))
- #imaginary (r.* (math;sin imaginary)
+ #imaginary (f.* (math;sin imaginary)
(math;sinh real))}))
(def: #export (sin subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (r.* (math;cosh imaginary)
+ {#real (f.* (math;cosh imaginary)
(math;sin real))
- #imaginary (r.* (math;sinh imaginary)
+ #imaginary (f.* (math;sinh imaginary)
(math;cos real))}))
(def: #export (sinh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- {#real (r.* (math;cos imaginary)
+ {#real (f.* (math;cos imaginary)
(math;sinh real))
- #imaginary (r.* (math;sin imaginary)
+ #imaginary (f.* (math;sin imaginary)
(math;cosh real))}))
(def: #export (tan subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- 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))}))
+ r2 (f.* 2.0 real)
+ i2 (f.* 2.0 imaginary)
+ d (f.+ (math;cos r2) (math;cosh i2))]
+ {#real (f./ d (math;sin r2))
+ #imaginary (f./ d (math;sinh i2))}))
(def: #export (tanh subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
- 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))}))
+ r2 (f.* 2.0 real)
+ i2 (f.* 2.0 imaginary)
+ d (f.+ (math;cosh r2) (math;cos i2))]
+ {#real (f./ d (math;sinh r2))
+ #imaginary (f./ d (math;sin i2))}))
(def: #export (c.abs subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject]
- (complex (if (r.< (r/abs imaginary)
- (r/abs real))
- (if (r.= 0.0 imaginary)
- (r/abs real)
- (let [q (r./ imaginary real)]
- (r.* (math;root2 (r.+ 1.0 (r.* q q)))
- (r/abs imaginary))))
- (if (r.= 0.0 real)
- (r/abs imaginary)
- (let [q (r./ real imaginary)]
- (r.* (math;root2 (r.+ 1.0 (r.* q q)))
- (r/abs real))))
+ (complex (if (f.< (f/abs imaginary)
+ (f/abs real))
+ (if (f.= 0.0 imaginary)
+ (f/abs real)
+ (let [q (f./ imaginary real)]
+ (f.* (math;root2 (f.+ 1.0 (f.* q q)))
+ (f/abs imaginary))))
+ (if (f.= 0.0 real)
+ (f/abs imaginary)
+ (let [q (f./ real imaginary)]
+ (f.* (math;root2 (f.+ 1.0 (f.* q q)))
+ (f/abs real))))
))))
(struct: #export _ (Number Complex)
@@ -200,20 +200,20 @@
(def: % c.%)
(def: (negate x)
(|> x
- (update@ #real r/negate)
- (update@ #imaginary r/negate)))
+ (update@ #real f/negate)
+ (update@ #imaginary f/negate)))
(def: abs c.abs)
(def: (signum x)
(|> x
- (update@ #real r/signum)
- (update@ #imaginary r/signum))))
+ (update@ #real f/signum)
+ (update@ #imaginary f/signum))))
(def: #export (exp subject)
(-> Complex Complex)
(let [(^slots [#real #imaginary]) subject
r-exp (math;exp real)]
- {#real (r.* r-exp (math;cos imaginary))
- #imaginary (r.* r-exp (math;sin imaginary))}))
+ {#real (f.* r-exp (math;cos imaginary))
+ #imaginary (f.* r-exp (math;sin imaginary))}))
(def: #export (log subject)
(-> Complex Complex)
@@ -227,23 +227,23 @@
(|> input log (<op> param) exp))]
[pow Complex c.*]
- [pow' Real c.*']
+ [pow' Frac c.*']
)
(def: (copy-sign sign magnitude)
- (-> Real Real Real)
- (r.* (r/signum sign) magnitude))
+ (-> Frac Frac Frac)
+ (f.* (f/signum sign) magnitude))
(def: #export (root2 (^@ input (^slots [#real #imaginary])))
(-> Complex Complex)
- (let [t (|> input c.abs (get@ #real) (r.+ (r/abs real)) (r./ 2.0) math;root2)]
- (if (r.>= 0.0 real)
+ (let [t (|> input c.abs (get@ #real) (f.+ (f/abs real)) (f./ 2.0) math;root2)]
+ (if (f.>= 0.0 real)
{#real t
- #imaginary (r./ (r.* 2.0 t)
+ #imaginary (f./ (f.* 2.0 t)
imaginary)}
- {#real (r./ (r.* 2.0 t)
- (r/abs imaginary))
- #imaginary (r.* t (copy-sign imaginary 1.0))})))
+ {#real (f./ (f.* 2.0 t)
+ (f/abs imaginary))
+ #imaginary (f.* t (copy-sign imaginary 1.0))})))
(def: #export (root2-1z input)
(-> Complex Complex)
@@ -251,18 +251,18 @@
(def: #export (reciprocal (^slots [#real #imaginary]))
(-> Complex Complex)
- (if (r.< (r/abs imaginary)
- (r/abs real))
- (let [q (r./ imaginary real)
- scale (r./ (|> real (r.* q) (r.+ imaginary))
+ (if (f.< (f/abs imaginary)
+ (f/abs real))
+ (let [q (f./ imaginary real)
+ scale (f./ (|> real (f.* q) (f.+ imaginary))
1.0)]
- {#real (r.* q scale)
- #imaginary (r/negate scale)})
- (let [q (r./ real imaginary)
- scale (r./ (|> imaginary (r.* q) (r.+ real))
+ {#real (f.* q scale)
+ #imaginary (f/negate scale)})
+ (let [q (f./ real imaginary)
+ scale (f./ (|> imaginary (f.* q) (f.+ real))
1.0)]
{#real scale
- #imaginary (|> scale r/negate (r.* q))})))
+ #imaginary (|> scale f/negate (f.* q))})))
(def: #export (acos input)
(-> Complex Complex)
@@ -288,32 +288,32 @@
(c.* (c./ (complex 2.0) i))))
(def: #export (argument (^slots [#real #imaginary]))
- (-> Complex Real)
+ (-> Complex Frac)
(math;atan2 real imaginary))
(def: #export (nth-roots nth input)
(-> Nat Complex (List Complex))
(if (n.= +0 nth)
(list)
- (let [r-nth (|> nth nat-to-int int-to-real)
- nth-root-of-abs (|> input c.abs (get@ #real) (math;pow (r./ r-nth 1.0)))
- nth-phi (|> input argument (r./ r-nth))
- slice (|> math;pi (r.* 2.0) (r./ r-nth))]
+ (let [r-nth (|> nth nat-to-int int-to-frac)
+ nth-root-of-abs (|> input c.abs (get@ #real) (math;pow (f./ r-nth 1.0)))
+ nth-phi (|> input argument (f./ r-nth))
+ slice (|> math;pi (f.* 2.0) (f./ r-nth))]
(|> (list;n.range +0 (n.dec nth))
(L/map (function [nth']
- (let [inner (|> nth' nat-to-int int-to-real
- (r.* slice)
- (r.+ nth-phi))
- real (r.* nth-root-of-abs
+ (let [inner (|> nth' nat-to-int int-to-frac
+ (f.* slice)
+ (f.+ nth-phi))
+ real (f.* nth-root-of-abs
(math;cos inner))
- imaginary (r.* nth-root-of-abs
+ imaginary (f.* nth-root-of-abs
(math;sin inner))]
{#real real
#imaginary imaginary})))))))
(struct: #export _ (Codec Text Complex)
(def: (encode (^slots [#real #imaginary]))
- ($_ text/append "(" (r/encode real) ", " (r/encode imaginary) ")"))
+ ($_ text/append "(" (f/encode real) ", " (f/encode imaginary) ")"))
(def: (decode input)
(case (do maybe;Monad<Maybe>
@@ -324,8 +324,8 @@
(#;Some [r' i'])
(do R;Monad<Result>
- [r (r/decode (text;trim r'))
- i (r/decode (text;trim i'))]
+ [r (f/decode (text;trim r'))
+ i (f/decode (text;trim i'))]
(wrap {#real r
#imaginary i}))
)))
diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux
index 37e5e7cb6..db33bdc05 100644
--- a/stdlib/source/lux/data/text/format.lux
+++ b/stdlib/source/lux/data/text/format.lux
@@ -42,7 +42,7 @@
[%n Nat (:: number;Codec<Text,Nat> encode)]
[%i Int (:: number;Codec<Text,Int> encode)]
[%d Deg (:: number;Codec<Text,Deg> encode)]
- [%r Real (:: number;Codec<Text,Real> encode)]
+ [%r Frac (:: number;Codec<Text,Frac> encode)]
[%t Text text;encode]
[%ident Ident (:: ident;Codec<Text,Ident> encode)]
[%code Code code;to-text]
diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux
index 2a6aa45f4..258de1b8d 100644
--- a/stdlib/source/lux/host.js.lux
+++ b/stdlib/source/lux/host.js.lux
@@ -21,7 +21,7 @@
[(type: #export <name> <type>)]
[String Text]
- [Number Real]
+ [Number Frac]
[Boolean Bool]
)
@@ -39,7 +39,7 @@
(syntax: #export (get field-name type object)
{#;doc (doc "A way to get fields from objects."
(get "ceil" (ref "Math"))
- (get "ceil" (-> Real Real) (ref "Math")))}
+ (get "ceil" (-> Frac Frac) (ref "Math")))}
(wrap (list (` (:! (~ type)
(;_lux_proc ["js" "get-field"] [(~ object) (~ field-name)]))))))
@@ -55,7 +55,7 @@
(syntax: #export (ref [name s;text] [type (p;opt s;any)])
{#;doc (doc "A way to refer to JavaScript variables."
(ref "document")
- (ref "Math.ceil" (-> Real Real)))}
+ (ref "Math.ceil" (-> Frac Frac)))}
(wrap (list (` (:! (~ (default (' ;;Object) type))
(;_lux_proc ["js" "ref"] [(~ (code;text name))]))))))
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index a735a8570..42a076b8f 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -276,8 +276,8 @@
["short" ;Int]
["int" ;Int]
["long" ;Int]
- ["float" ;Real]
- ["double" ;Real]
+ ["float" ;Frac]
+ ["double" ;Frac]
["void" ;Unit])
_
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 88e2b4d91..a7a5d22cd 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -167,7 +167,7 @@
[get-bool-ann #;BoolA Bool]
[get-int-ann #;IntA Int]
- [get-real-ann #;RealA Real]
+ [get-frac-ann #;FracA Frac]
[get-text-ann #;TextA Text]
[get-ident-ann #;IdentA Ident]
[get-list-ann #;ListA (List Ann-Value)]
diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux
index 2755ae6f5..a171d74d5 100644
--- a/stdlib/source/lux/macro/code.lux
+++ b/stdlib/source/lux/macro/code.lux
@@ -13,7 +13,7 @@
## (#;Bool Bool)
## (#;Nat Nat)
## (#;Int Int)
-## (#;Real Real)
+## (#;Frac Frac)
## (#;Text Text)
## (#;Symbol Text Text)
## (#;Tag Text Text)
@@ -37,7 +37,7 @@
[nat Nat #;Nat]
[int Int #;Int]
[deg Deg #;Deg]
- [real Real #;Real]
+ [frac Frac #;Frac]
[text Text #;Text]
[symbol Ident #;Symbol]
[tag Ident #;Tag]
@@ -66,7 +66,7 @@
[#;Nat Eq<Nat>]
[#;Int Eq<Int>]
[#;Deg Eq<Deg>]
- [#;Real Eq<Real>]
+ [#;Frac Eq<Frac>]
[#;Text Eq<Text>]
[#;Symbol Eq<Ident>]
[#;Tag Eq<Ident>])
@@ -102,7 +102,7 @@
[#;Nat Codec<Text,Nat>]
[#;Int Codec<Text,Int>]
[#;Deg Codec<Text,Deg>]
- [#;Real Codec<Text,Real>]
+ [#;Frac Codec<Text,Frac>]
[#;Symbol Codec<Text,Ident>])
[_ (#;Text value)]
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index 995cc023a..bc8d5d375 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -131,7 +131,7 @@
[nat "Nat" (#;Host "#Nat" #;Nil)]
[int "Int" (#;Host "#Int" #;Nil)]
[deg "Deg" (#;Host "#Deg" #;Nil)]
- [real "Real" (#;Host "#Real" #;Nil)]
+ [frac "Frac" (#;Host "#Frac" #;Nil)]
[text "Text" (#;Host "#Text" #;Nil)]
)
@@ -146,7 +146,7 @@
nat
int
deg
- real
+ frac
text))
(#R;Error error)
(p;fail error)
diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux
index b4d1a5231..45013ebb8 100644
--- a/stdlib/source/lux/macro/poly/eq.lux
+++ b/stdlib/source/lux/macro/poly/eq.lux
@@ -43,7 +43,7 @@
[poly;nat number;Eq<Nat>]
[poly;int number;Eq<Int>]
[poly;deg number;Eq<Deg>]
- [poly;real number;Eq<Real>]
+ [poly;frac number;Eq<Frac>]
[poly;text text;Eq<Text>])
<time> (do-template [<type> <eq>]
[(do @
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index f56c84e1b..4a05041f6 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -58,7 +58,7 @@
[ nat Nat #;Nat number;Eq<Nat> "nat"]
[ int Int #;Int number;Eq<Int> "int"]
[ deg Deg #;Deg number;Eq<Deg> "deg"]
- [ real Real #;Real number;Eq<Real> "real"]
+ [ frac Frac #;Frac number;Eq<Frac> "frac"]
[ text Text #;Text text;Eq<Text> "text"]
[symbol Ident #;Symbol ident;Eq<Ident> "symbol"]
[ tag Ident #;Tag ident;Eq<Ident> "tag"]
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index e5e06bd16..73c37d598 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -11,7 +11,7 @@
## [Values]
(do-template [<name> <value>]
[(def: #export <name>
- Real
+ Frac
(_lux_proc ["math" <value>] []))]
[e "e"]
@@ -20,12 +20,12 @@
(def: #export tau
{#;doc "The same as 2*PI."}
- Real
+ Frac
6.28318530717958647692)
(do-template [<name> <method>]
[(def: #export (<name> input)
- (-> Real Real)
+ (-> Frac Frac)
(_lux_proc ["math" <method>] [input]))]
[cos "cos"]
@@ -53,7 +53,7 @@
(do-template [<name> <method>]
[(def: #export (<name> param subject)
- (-> Real Real Real)
+ (-> Frac Frac Frac)
(_lux_proc ["math" <method>] [subject param]))]
[atan2 "atan2"]
@@ -61,7 +61,7 @@
)
(def: #export (log' base input)
- (r./ (log base)
+ (f./ (log base)
(log input)))
(def: #export (factorial n)
@@ -73,8 +73,8 @@
(recur (n.* n acc) (n.dec n)))))
(def: #export (hypotenuse catA catB)
- (-> Real Real Real)
- (root2 (r.+ (pow 2.0 catA)
+ (-> Frac Frac Frac)
+ (root2 (f.+ (pow 2.0 catA)
(pow 2.0 catB))))
(def: #export (gcd a b)
@@ -109,7 +109,7 @@
(p/map code;nat s;nat)
(p/map code;int s;int)
(p/map code;deg s;deg)
- (p/map code;real s;real)
+ (p/map code;frac s;frac)
(p/map code;text s;text)
(p/map code;symbol s;symbol)
(p/map code;tag s;tag))
diff --git a/stdlib/source/lux/math/logic/fuzzy.lux b/stdlib/source/lux/math/logic/fuzzy.lux
index c3677649b..84e217d6b 100644
--- a/stdlib/source/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/lux/math/logic/fuzzy.lux
@@ -82,7 +82,7 @@
(<descending> from to)))]
[d.ascending d.descending d.gradient Deg d.< d.> d.<= d.>= d.- d./ id]
- [r.ascending r.descending r.gradient Real r.< r.> r.<= r.>= r.- r./ real-to-deg]
+ [f.ascending f.descending f.gradient Frac f.< f.> f.<= f.>= f.- f./ frac-to-deg]
)
(do-template [<triangle> <trapezoid> <type> <ascending> <descending> <lt>]
@@ -107,22 +107,22 @@
(undefined)))]
[d.triangle d.trapezoid Deg d.ascending d.descending d.<]
- [r.triangle r.trapezoid Real r.ascending r.descending r.<]
+ [f.triangle f.trapezoid Frac f.ascending f.descending f.<]
)
(def: #export (gaussian deviation center)
- (-> Real Real (Fuzzy Real))
+ (-> Frac Frac (Fuzzy Frac))
(function [elem]
- (let [scale (|> deviation (math;pow 2.0) (r.* 2.0))
+ (let [scale (|> deviation (math;pow 2.0) (f.* 2.0))
membership (|> elem
- (r.- center)
+ (f.- center)
(math;pow 2.0)
- (r.* -1.0)
- (r./ scale)
+ (f.* -1.0)
+ (f./ scale)
math;exp)]
- (if (r.= 1.0 membership)
+ (if (f.= 1.0 membership)
&;~true
- (real-to-deg membership)))))
+ (frac-to-deg membership)))))
(def: #export (cut treshold set)
(All [a] (-> Deg (Fuzzy a) (Fuzzy a)))
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index 376dd9192..7a0c2963d 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -84,20 +84,20 @@
(let [[prng output] (prng [])]
[prng (bit;unsigned-shift-right (n.- n +64) output)])))
-(def: #export real
- (Random Real)
+(def: #export frac
+ (Random Frac)
(do Monad<Random>
[left (bits +26)
right (bits +27)]
(wrap (|> right
(n.+ (bit;shift-left +27 left))
nat-to-int
- int-to-real
- (r./ (|> +1 (bit;shift-left +53) nat-to-int int-to-real))))))
+ int-to-frac
+ (f./ (|> +1 (bit;shift-left +53) nat-to-int int-to-frac))))))
(def: #export deg
(Random Deg)
- (:: Monad<Random> map real-to-deg real))
+ (:: Monad<Random> map frac-to-deg frac))
(def: #export (text' char-gen size)
(-> (Random Nat) Nat (Random Text))
@@ -121,7 +121,7 @@
(wrap (<ctor> left right))))]
[ratio r;Ratio r;ratio nat]
- [complex c;Complex c;complex real]
+ [complex c;Complex c;complex frac]
)
(def: #export (seq left right)