aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux246
1 files changed, 125 insertions, 121 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index d4e8efda6..bd65c86da 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -21,7 +21,7 @@
## (type: Any
## (Ex [a] a))
("lux def" Any
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Any"]
(8 #0 (0 #0) (4 #0 1))))
[dummy_location
@@ -35,7 +35,7 @@
## (type: Nothing
## (All [a] a))
("lux def" Nothing
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Nothing"]
(7 #0 (0 #0) (4 #0 1))))
[dummy_location
@@ -67,7 +67,7 @@
#1)
("lux def" Bit
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Bit"]
(0 #0 "#Bit" #Nil)))
[dummy_location
@@ -77,7 +77,7 @@
#1)
("lux def" I64
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "I64"]
(7 #0 (0 #0)
(0 #0 "#I64" (#Cons (4 #0 1) #Nil)))))
@@ -88,7 +88,7 @@
#1)
("lux def" Nat
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Nat"]
(0 #0 "#I64" (#Cons (0 #0 "#Nat" #Nil) #Nil))))
[dummy_location
@@ -100,7 +100,7 @@
#1)
("lux def" Int
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Int"]
(0 #0 "#I64" (#Cons (0 #0 "#Int" #Nil) #Nil))))
[dummy_location
@@ -110,7 +110,7 @@
#1)
("lux def" Rev
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Rev"]
(0 #0 "#I64" (#Cons (0 #0 "#Rev" #Nil) #Nil))))
[dummy_location
@@ -122,7 +122,7 @@
#1)
("lux def" Frac
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Frac"]
(0 #0 "#Frac" #Nil)))
[dummy_location
@@ -132,7 +132,7 @@
#1)
("lux def" Text
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Text"]
(0 #0 "#Text" #Nil)))
[dummy_location
@@ -142,7 +142,7 @@
#1)
("lux def" Name
- ("lux check type"
+ ("lux type check type"
(9 #1 ["lux" "Name"]
(2 #0 Text Text)))
[dummy_location
@@ -212,9 +212,9 @@
Type_Pair
## "lux.Named"
(2 #0 Name Type)))))))))))))}
- ("lux check type" (2 #0 Type Type)))}
- ("lux check type" (9 #0 Type List)))}
- ("lux check type" (9 #0 (4 #0 1) (4 #0 0)))))
+ ("lux type check type" (2 #0 Type Type)))}
+ ("lux type check type" (9 #0 Type List)))}
+ ("lux type check type" (9 #0 (4 #0 1) (4 #0 0)))))
[dummy_location
(9 #1 (#Cons [[dummy_location (7 #0 ["lux" "doc"])]
[dummy_location (5 #0 "This type represents the data-structures that are used to specify types themselves.")]]
@@ -297,10 +297,10 @@
(#Apply (#Product Code Code) List)
))))))))))
)}
- ("lux check type" (#Apply Code List)))}
- ("lux check type" (#Apply (#Apply (#Parameter 1)
- (#Parameter 0))
- (#Parameter 1)))))
+ ("lux type check type" (#Apply Code List)))}
+ ("lux type check type" (#Apply (#Apply (#Parameter 1)
+ (#Parameter 0))
+ (#Parameter 1)))))
[dummy_location
(9 #1 (#Cons [[dummy_location (7 #0 ["lux" "type-args"])]
[dummy_location (9 #0 (#Cons [dummy_location (5 #0 "w")] #Nil))]]
@@ -314,7 +314,7 @@
(#Named ["lux" "Code"]
({w
(#Apply (#Apply w Code') w)}
- ("lux check type" (#Apply Location Ann))))
+ ("lux type check type" (#Apply Location Ann))))
[dummy_location
(#Record (#Cons [[dummy_location (#Tag ["lux" "doc"])]
[dummy_location (#Text "The type of Code nodes for Lux syntax.")]]
@@ -322,88 +322,89 @@
#1)
("lux def" _ann
- ("lux check" (#Function (#Apply (#Apply Location Ann)
- Code')
- Code)
+ ("lux type check"
+ (#Function (#Apply (#Apply Location Ann)
+ Code')
+ Code)
([_ data]
[dummy_location data]))
[dummy_location (#Record #Nil)]
#0)
("lux def" bit$
- ("lux check" (#Function Bit Code)
+ ("lux type check" (#Function Bit Code)
([_ value] (_ann (#Bit value))))
[dummy_location (#Record #Nil)]
#0)
("lux def" nat$
- ("lux check" (#Function Nat Code)
+ ("lux type check" (#Function Nat Code)
([_ value] (_ann (#Nat value))))
[dummy_location (#Record #Nil)]
#0)
("lux def" int$
- ("lux check" (#Function Int Code)
+ ("lux type check" (#Function Int Code)
([_ value] (_ann (#Int value))))
[dummy_location (#Record #Nil)]
#0)
("lux def" rev$
- ("lux check" (#Function Rev Code)
+ ("lux type check" (#Function Rev Code)
([_ value] (_ann (#Rev value))))
[dummy_location (#Record #Nil)]
#0)
("lux def" frac$
- ("lux check" (#Function Frac Code)
+ ("lux type check" (#Function Frac Code)
([_ value] (_ann (#Frac value))))
[dummy_location (#Record #Nil)]
#0)
("lux def" text$
- ("lux check" (#Function Text Code)
+ ("lux type check" (#Function Text Code)
([_ text] (_ann (#Text text))))
[dummy_location (#Record #Nil)]
#0)
("lux def" identifier$
- ("lux check" (#Function Name Code)
+ ("lux type check" (#Function Name Code)
([_ name] (_ann (#Identifier name))))
[dummy_location (#Record #Nil)]
#0)
("lux def" local_identifier$
- ("lux check" (#Function Text Code)
+ ("lux type check" (#Function Text Code)
([_ name] (_ann (#Identifier ["" name]))))
[dummy_location (#Record #Nil)]
#0)
("lux def" tag$
- ("lux check" (#Function Name Code)
+ ("lux type check" (#Function Name Code)
([_ name] (_ann (#Tag name))))
[dummy_location (#Record #Nil)]
#0)
("lux def" local_tag$
- ("lux check" (#Function Text Code)
+ ("lux type check" (#Function Text Code)
([_ name] (_ann (#Tag ["" name]))))
[dummy_location (#Record #Nil)]
#0)
("lux def" form$
- ("lux check" (#Function (#Apply Code List) Code)
+ ("lux type check" (#Function (#Apply Code List) Code)
([_ tokens] (_ann (#Form tokens))))
[dummy_location (#Record #Nil)]
#0)
("lux def" tuple$
- ("lux check" (#Function (#Apply Code List) Code)
+ ("lux type check" (#Function (#Apply Code List) Code)
([_ tokens] (_ann (#Tuple tokens))))
[dummy_location (#Record #Nil)]
#0)
("lux def" record$
- ("lux check" (#Function (#Apply (#Product Code Code) List) Code)
+ ("lux type check" (#Function (#Apply (#Product Code Code) List) Code)
([_ tokens] (_ann (#Record tokens))))
[dummy_location (#Record #Nil)]
#0)
@@ -411,7 +412,7 @@
## (type: Definition
## [Bit Type Code Any])
("lux def" Definition
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Definition"]
(#Product Bit (#Product Type (#Product Code Any)))))
(record$ (#Cons [(tag$ ["lux" "doc"])
@@ -422,7 +423,7 @@
## (type: Alias
## Name)
("lux def" Alias
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Alias"]
Name))
(record$ #Nil)
@@ -493,7 +494,7 @@
#1)
("lux def" Code_List
- ("lux check type"
+ ("lux type check type"
(#Apply Code List))
(record$ #Nil)
#0)
@@ -520,7 +521,7 @@
## (type: Source
## [Location Nat Text])
("lux def" Source
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Source"]
(#Product Location (#Product Nat Text))))
(record$ #Nil)
@@ -693,7 +694,7 @@
## (type: (Meta a)
## (-> Lux (Either Text [Lux a])))
("lux def" Meta
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Meta"]
(#UnivQ #Nil
(#Function Lux
@@ -711,7 +712,7 @@
## (type: Macro'
## (-> (List Code) (Meta (List Code))))
("lux def" Macro'
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Macro'"]
(#Function Code_List (#Apply Code_List Meta))))
(record$ #Nil)
@@ -720,7 +721,7 @@
## (type: Macro
## (primitive "#Macro"))
("lux def" Macro
- ("lux check type"
+ ("lux type check type"
(#Named ["lux" "Macro"]
(#Primitive "#Macro" #Nil)))
(record$ (#Cons [(tag$ ["lux" "doc"])
@@ -730,12 +731,13 @@
## Base functions & macros
("lux def" return
- ("lux check" (#UnivQ #Nil
- (#Function (#Parameter 1)
- (#Function Lux
- (#Apply (#Product Lux
- (#Parameter 1))
- (#Apply Text Either)))))
+ ("lux type check"
+ (#UnivQ #Nil
+ (#Function (#Parameter 1)
+ (#Function Lux
+ (#Apply (#Product Lux
+ (#Parameter 1))
+ (#Apply Text Either)))))
([_ val]
([_ state]
(#Right state val))))
@@ -743,12 +745,13 @@
#0)
("lux def" fail
- ("lux check" (#UnivQ #Nil
- (#Function Text
- (#Function Lux
- (#Apply (#Product Lux
- (#Parameter 1))
- (#Apply Text Either)))))
+ ("lux type check"
+ (#UnivQ #Nil
+ (#Function Text
+ (#Function Lux
+ (#Apply (#Product Lux
+ (#Parameter 1))
+ (#Apply Text Either)))))
([_ msg]
([_ state]
(#Left msg))))
@@ -806,13 +809,13 @@
#0)
("lux def" location_code
- ("lux check" Code
+ ("lux type check" Code
(tuple$ (#Cons (text$ "") (#Cons (nat$ 0) (#Cons (nat$ 0) #Nil)))))
(record$ #Nil)
#0)
("lux def" meta_code
- ("lux check" (#Function Name (#Function Code Code))
+ ("lux type check" (#Function Name (#Function Code Code))
([_ tag]
([_ value]
(tuple$ (#Cons location_code
@@ -822,7 +825,7 @@
#0)
("lux def" flag_meta
- ("lux check" (#Function Text Code)
+ ("lux type check" (#Function Text Code)
([_ tag]
(tuple$ (#Cons [(meta_code ["lux" "Tag"] (tuple$ (#Cons (text$ "lux") (#Cons (text$ tag) #Nil))))
(#Cons [(meta_code ["lux" "Bit"] (bit$ #1))
@@ -831,27 +834,27 @@
#0)
("lux def" doc_meta
- ("lux check" (#Function Text (#Product Code Code))
+ ("lux type check" (#Function Text (#Product Code Code))
(function'' [doc] [(tag$ ["lux" "doc"]) (text$ doc)]))
(record$ #Nil)
#0)
("lux def" as_def
- ("lux check" (#Function Code (#Function Code (#Function Code (#Function Bit Code))))
+ ("lux type check" (#Function Code (#Function Code (#Function Code (#Function Bit Code))))
(function'' [name value annotations exported?]
(form$ (#Cons (text$ "lux def") (#Cons name (#Cons value (#Cons annotations (#Cons (bit$ exported?) #Nil))))))))
(record$ #Nil)
#0)
("lux def" as_checked
- ("lux check" (#Function Code (#Function Code Code))
+ ("lux type check" (#Function Code (#Function Code Code))
(function'' [type value]
- (form$ (#Cons (text$ "lux check") (#Cons type (#Cons value #Nil))))))
+ (form$ (#Cons (text$ "lux type check") (#Cons type (#Cons value #Nil))))))
(record$ #Nil)
#0)
("lux def" as_function
- ("lux check" (#Function Code (#Function (#Apply Code List) (#Function Code Code)))
+ ("lux type check" (#Function Code (#Function (#Apply Code List) (#Function Code Code)))
(function'' [self inputs output]
(form$ (#Cons (identifier$ ["lux" "function''"])
(#Cons self
@@ -861,7 +864,7 @@
#0)
("lux def" as_macro
- ("lux check" (#Function Code Code)
+ ("lux type check" (#Function Code Code)
(function'' [expression]
(form$ (#Cons (text$ "lux macro")
(#Cons expression
@@ -1038,7 +1041,7 @@
[meta (#Tuple (list\map (replace_syntax reps) members))]
[meta (#Record slots)]
- [meta (#Record (list\map ("lux check" (#Function (#Product Code Code) (#Product Code Code))
+ [meta (#Record (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code))
(function'' [slot]
({[k v]
[(replace_syntax reps k) (replace_syntax reps v)]}
@@ -1052,10 +1055,10 @@
(def:'' (n/* param subject)
(#.Cons (doc_meta "Nat(ural) multiplication.") #.Nil)
(#Function Nat (#Function Nat Nat))
- ("lux coerce" Nat
+ ("lux type as" Nat
("lux i64 *"
- ("lux coerce" Int param)
- ("lux coerce" Int subject))))
+ ("lux type as" Int param)
+ ("lux type as" Int subject))))
(def:'' (update_parameters code)
#Nil
@@ -1064,7 +1067,7 @@
(tuple$ (list\map update_parameters members))
[_ (#Record pairs)]
- (record$ (list\map ("lux check" (#Function (#Product Code Code) (#Product Code Code))
+ (record$ (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code))
(function'' [pair]
(let'' [name val] pair
[name (update_parameters val)])))
@@ -1143,7 +1146,7 @@
({(#Cons [_ (#Tuple args)] (#Cons body #Nil))
(parse_quantified_args args
(function'' [names]
- (let'' body' (list\fold ("lux check" (#Function Text (#Function Code Code))
+ (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code))
(function'' [name' body']
(form$ (#Cons (tag$ ["lux" "UnivQ"])
(#Cons (tag$ ["lux" "Nil"])
@@ -1187,7 +1190,7 @@
({(#Cons [_ (#Tuple args)] (#Cons body #Nil))
(parse_quantified_args args
(function'' [names]
- (let'' body' (list\fold ("lux check" (#Function Text (#Function Code Code))
+ (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code))
(function'' [name' body']
(form$ (#Cons (tag$ ["lux" "ExQ"])
(#Cons (tag$ ["lux" "Nil"])
@@ -1215,7 +1218,7 @@
(def:'' (list\reverse list)
#Nil
(All [a] (#Function ($' List a) ($' List a)))
- (list\fold ("lux check" (All [a] (#Function a (#Function ($' List a) ($' List a))))
+ (list\fold ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a))))
(function'' [head tail] (#Cons head tail)))
#Nil
list))
@@ -1229,7 +1232,7 @@
"## This is the type of a function that takes 2 Ints and returns an Int.")))]
#Nil)
({(#Cons output inputs)
- (return (#Cons (list\fold ("lux check" (#Function Code (#Function Code Code))
+ (return (#Cons (list\fold ("lux type check" (#Function Code (#Function Code Code))
(function'' [i o] (form$ (#Cons (tag$ ["lux" "Function"]) (#Cons i (#Cons o #Nil))))))
output
inputs)
@@ -1342,7 +1345,7 @@
(#Cons [meta (#Cons [type (#Cons [body #Nil])])])])])
(return (list (form$ (list (text$ "lux def")
name
- (form$ (list (text$ "lux check")
+ (form$ (list (text$ "lux type check")
type
(form$ (list (identifier$ ["lux" "function'"])
name
@@ -1356,7 +1359,7 @@
(#Cons [[_ (#Tag ["" "export"])] (#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])])
(return (list (form$ (list (text$ "lux def")
name
- (form$ (list (text$ "lux check")
+ (form$ (list (text$ "lux type check")
type
body))
(form$ (#Cons (identifier$ ["lux" "record$"])
@@ -1368,7 +1371,7 @@
(#Cons [meta (#Cons [type (#Cons [body #Nil])])])])
(return (list (form$ (list (text$ "lux def")
name
- (form$ (list (text$ "lux check")
+ (form$ (list (text$ "lux type check")
type
(form$ (list (identifier$ ["lux" "function'"])
name
@@ -1382,7 +1385,7 @@
(#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])
(return (list (form$ (list (text$ "lux def")
name
- (form$ (list (text$ "lux check") type body))
+ (form$ (list (text$ "lux type check") type body))
(form$ (#Cons (identifier$ ["lux" "record$"])
(#Cons meta
#Nil)))
@@ -1404,8 +1407,8 @@
(macro:' (let' tokens)
({(#Cons [[_ (#Tuple bindings)] (#Cons [body #Nil])])
- (return (list (list\fold ("lux check" (-> (& Code Code) Code
- Code)
+ (return (list (list\fold ("lux type check" (-> (& Code Code) Code
+ Code)
(function' [binding body]
({[label value]
(form$ (list (record$ (list [label body])) value))}
@@ -1567,7 +1570,7 @@
({(#Cons monad (#Cons [_ (#Tuple bindings)] (#Cons body #Nil)))
(let' [g!wrap (local_identifier$ "wrap")
g!bind (local_identifier$ " bind ")
- body' (list\fold ("lux check" (-> (& Code Code) Code Code)
+ body' (list\fold ("lux type check" (-> (& Code Code) Code Code)
(function' [binding body']
(let' [[var value] binding]
({[_ (#Tag "" "let")]
@@ -1740,7 +1743,7 @@
(let' [type (form$ (list (tag$ ["lux" "Apply"])
(identifier$ ["lux" "Code"])
(identifier$ ["lux" "List"])))]
- (form$ (list (text$ "lux check") type expression))))
+ (form$ (list (text$ "lux type check") type expression))))
(def:''' (splice replace? untemplate elems)
#Nil
@@ -1837,7 +1840,7 @@
(return (wrap_meta (form$ (list (tag$ ["lux" "Identifier"]) (tuple$ (list (text$ module) (text$ name)))))))
[#1 [_ (#Form (#Cons [[_ (#Identifier ["" "~"])] (#Cons [unquoted #Nil])]))]]
- (return (form$ (list (text$ "lux check")
+ (return (form$ (list (text$ "lux type check")
(identifier$ ["lux" "Code"])
unquoted)))
@@ -1867,7 +1870,7 @@
[_ [_ (#Record fields)]]
(do meta_monad
[=fields (monad\map meta_monad
- ("lux check" (-> (& Code Code) ($' Meta Code))
+ ("lux type check" (-> (& Code Code) ($' Meta Code))
(function' [kv]
(let' [[k v] kv]
(do meta_monad
@@ -1919,7 +1922,7 @@
(do meta_monad
[current_module current_module_name
=template (untemplate #1 current_module template)]
- (wrap (list (form$ (list (text$ "lux check")
+ (wrap (list (form$ (list (text$ "lux type check")
(identifier$ ["lux" "Code"])
=template)))))
@@ -1935,7 +1938,7 @@
({(#Cons template #Nil)
(do meta_monad
[=template (untemplate #1 "" template)]
- (wrap (list (form$ (list (text$ "lux check") (identifier$ ["lux" "Code"]) =template)))))
+ (wrap (list (form$ (list (text$ "lux type check") (identifier$ ["lux" "Code"]) =template)))))
_
(fail "Wrong syntax for `")}
@@ -1949,7 +1952,7 @@
({(#Cons template #Nil)
(do meta_monad
[=template (untemplate #0 "" template)]
- (wrap (list (form$ (list (text$ "lux check") (identifier$ ["lux" "Code"]) =template)))))
+ (wrap (list (form$ (list (text$ "lux type check") (identifier$ ["lux" "Code"]) =template)))))
_
(fail "Wrong syntax for '")}
@@ -1963,7 +1966,7 @@
"## =>" __paragraph
"(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))])
({(#Cons [init apps])
- (return (list (list\fold ("lux check" (-> Code Code Code)
+ (return (list (list\fold ("lux type check" (-> Code Code Code)
(function' [app acc]
({[_ (#Tuple parts)]
(tuple$ (list\compose parts (list acc)))
@@ -1989,7 +1992,7 @@
"## =>" __paragraph
"(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))])
({(#Cons [init apps])
- (return (list (list\fold ("lux check" (-> Code Code Code)
+ (return (list (list\fold ("lux type check" (-> Code Code Code)
(function' [app acc]
({[_ (#Tuple parts)]
(tuple$ (list\compose parts (list acc)))
@@ -2072,7 +2075,7 @@
[meta (#Form (list\map (apply_template env) elems))]
[meta (#Record members)]
- [meta (#Record (list\map ("lux check" (-> (& Code Code) (& Code Code))
+ [meta (#Record (list\map ("lux type check" (-> (& Code Code) (& Code Code))
(function' [kv]
(let' [[slot value] kv]
[(apply_template env slot) (apply_template env value)])))
@@ -2139,7 +2142,7 @@
" " "[dec -1]"))])
({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])])
({[(#Some bindings') (#Some data')]
- (let' [apply ("lux check" (-> RepEnv ($' List Code))
+ (let' [apply ("lux type check" (-> RepEnv ($' List Code))
(function' [env] (list\map (apply_template env) templates)))
num_bindings (list\size bindings')]
(if (every? (function' [size] ("lux i64 =" num_bindings size))
@@ -2162,17 +2165,17 @@
(def:''' (n// param subject)
(list)
(-> Nat Nat Nat)
- (if ("lux i64 <" +0 ("lux coerce" Int param))
+ (if ("lux i64 <" +0 ("lux type as" Int param))
(if (n/< param subject)
0
1)
(let' [quotient (|> subject
("lux i64 right-shift" 1)
- ("lux i64 /" ("lux coerce" Int param))
+ ("lux i64 /" ("lux type as" Int param))
("lux i64 left-shift" 1))
flat ("lux i64 *"
- ("lux coerce" Int param)
- ("lux coerce" Int quotient))
+ ("lux type as" Int param)
+ ("lux type as" Int quotient))
remainder ("lux i64 -" flat subject)]
(if (n/< param remainder)
quotient
@@ -2182,8 +2185,8 @@
(list)
(-> Nat Nat Nat)
(let' [flat ("lux i64 *"
- ("lux coerce" Int param)
- ("lux coerce" Int (n// param subject)))]
+ ("lux type as" Int param)
+ ("lux type as" Int (n// param subject)))]
("lux i64 -" flat subject)))
(def:''' (n/min left right)
@@ -2215,7 +2218,7 @@
"0"
_
- (let' [loop ("lux check" (-> Nat Text Text)
+ (let' [loop ("lux type check" (-> Nat Text Text)
(function' recur [input output]
(if ("lux i64 =" 0 input)
output
@@ -2240,15 +2243,15 @@
(let' [sign (if ("lux i64 <" value +0)
"+"
"-")]
- (("lux check" (-> Int Text Text)
+ (("lux type check" (-> Int Text Text)
(function' recur [input output]
(if ("lux i64 =" +0 input)
(text\compose sign output)
(recur ("lux i64 /" +10 input)
- (text\compose (|> input ("lux i64 %" +10) ("lux coerce" Nat) digit::format)
+ (text\compose (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format)
output)))))
(|> value ("lux i64 /" +10) int\abs)
- (|> value ("lux i64 %" +10) int\abs ("lux coerce" Nat) digit::format)))))
+ (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format)))))
(def:''' (frac\encode x)
#Nil
@@ -2286,7 +2289,7 @@
($' Maybe Macro))
(do maybe_monad
[$module (get module modules)
- gdef (let' [{#module_hash _ #module_aliases _ #definitions bindings #imports _ #tags tags #types types #module_annotations _ #module_state _} ("lux check" Module $module)]
+ gdef (let' [{#module_hash _ #module_aliases _ #definitions bindings #imports _ #tags tags #types types #module_annotations _ #module_state _} ("lux type check" Module $module)]
(get name bindings))]
({(#Left [r_module r_name])
(find_macro' modules current_module r_module r_name)
@@ -2294,12 +2297,12 @@
(#Right [exported? def_type def_meta def_value])
(if (macro_type? def_type)
(if exported?
- (#Some ("lux coerce" Macro def_value))
+ (#Some ("lux type as" Macro def_value))
(if (text\= module current_module)
- (#Some ("lux coerce" Macro def_value))
+ (#Some ("lux type as" Macro def_value))
#None))
#None)}
- ("lux check" Global gdef))))
+ ("lux type check" Global gdef))))
(def:''' (normalize name)
#Nil
@@ -2360,7 +2363,7 @@
[macro_name' (normalize macro_name)
?macro (find_macro macro_name')]
({(#Some macro)
- (("lux coerce" Macro' macro) args)
+ (("lux type as" Macro' macro) args)
#None
(return (list token))}
@@ -2379,7 +2382,7 @@
?macro (find_macro macro_name')]
({(#Some macro)
(do meta_monad
- [expansion (("lux coerce" Macro' macro) args)
+ [expansion (("lux type as" Macro' macro) args)
expansion' (monad\map meta_monad macro_expand expansion)]
(wrap (list\join expansion')))
@@ -2400,7 +2403,7 @@
?macro (find_macro macro_name')]
({(#Some macro)
(do meta_monad
- [expansion (("lux coerce" Macro' macro) args)
+ [expansion (("lux type as" Macro' macro) args)
expansion' (monad\map meta_monad macro_expand_all expansion)]
(wrap (list\join expansion')))
@@ -2459,7 +2462,7 @@
expression
[_ (#Form (#Cons type_fn args))]
- (list\fold ("lux check" (-> Code Code Code)
+ (list\fold ("lux type check" (-> Code Code Code)
(function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn)))))
(walk_type type_fn)
(list\map walk_type args))
@@ -2493,22 +2496,22 @@
"## The type-annotation macro." __paragraph
"(: (List Int) (list +1 +2 +3))"))])
({(#Cons type (#Cons value #Nil))
- (return (list (` ("lux check" (type (~ type)) (~ value)))))
+ (return (list (` ("lux type check" (type (~ type)) (~ value)))))
_
(fail "Wrong syntax for :")}
tokens))
-(macro:' #export (:coerce tokens)
+(macro:' #export (:as tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
"## The type-coercion macro." __paragraph
- "(:coerce Dinosaur (list +1 +2 +3))"))])
+ "(:as Dinosaur (list +1 +2 +3))"))])
({(#Cons type (#Cons value #Nil))
- (return (list (` ("lux coerce" (type (~ type)) (~ value)))))
+ (return (list (` ("lux type as" (type (~ type)) (~ value)))))
_
- (fail "Wrong syntax for :coerce")}
+ (fail "Wrong syntax for :as")}
tokens))
(def:''' (empty? xs)
@@ -2623,7 +2626,7 @@
"''YOLO'')"))])
({(#Cons value actions)
(let' [dummy (local_identifier$ "")]
- (return (list (list\fold ("lux check" (-> Code Code Code)
+ (return (list (list\fold ("lux type check" (-> Code Code Code)
(function' [pre post] (` ({(~ dummy) (~ post)}
(~ pre)))))
value
@@ -3172,7 +3175,7 @@
(: (-> Code (Meta [Text Code]))
(function (_ token)
(case token
- (^ [_ (#Form (list [_ (#Text "lux check")] type [_ (#Identifier ["" name])]))])
+ (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))])
(wrap [name type])
_
@@ -3655,7 +3658,7 @@
_
(` ("lux def" (~ type_name)
- ("lux check type"
+ ("lux type check type"
(~ typeC))
(~ total_meta)
(~ (bit$ exported?))))))))
@@ -3670,7 +3673,7 @@
(template [<name> <to>]
[(def: #export (<name> value)
(-> (I64 Any) <to>)
- (:coerce <to> value))]
+ (:as <to> value))]
[i64 I64]
[nat Nat]
@@ -5070,8 +5073,9 @@
#None (fail "Wrong syntax for loop")))
init_types (monad\map meta_monad find_type inits')
expected get_expected_type]
- (return (list (` (("lux check" (-> (~+ (list\map type_to_code init_types))
- (~ (type_to_code expected)))
+ (return (list (` (("lux type check"
+ (-> (~+ (list\map type_to_code init_types))
+ (~ (type_to_code expected)))
(function ((~ name) (~+ vars))
(~ body)))
(~+ inits))))))
@@ -5238,7 +5242,7 @@
(case (flatten_alias type)
(^template [<name> <type> <wrapper>]
[(#Named ["lux" <name>] _)
- (wrap (<wrapper> (:coerce <type> value)))])
+ (wrap (<wrapper> (:as <type> value)))])
(["Bit" Bit bit$]
["Nat" Nat nat$]
["Int" Int int$]
@@ -5376,7 +5380,7 @@
#None
(case (~ g!temp)
(~+ next_branches))}
- ("lux check" (#.Apply (~ (type_to_code expected)) Maybe)
+ ("lux type check" (#.Apply (~ (type_to_code expected)) Maybe)
(case (~ g!temp)
(~+ (multi_level_case$ g!temp [mlc body]))
@@ -5504,7 +5508,7 @@
(^ (list expr))
(do meta_monad
[type get_expected_type]
- (wrap (list (` ("lux coerce" (~ (type_to_code type)) (~ expr))))))
+ (wrap (list (` ("lux type as" (~ (type_to_code type)) (~ expr))))))
_
(fail (..wrong_syntax_error (name_of ..:assume)))))
@@ -5690,7 +5694,7 @@
(case (..flatten_alias type)
(^or (#Primitive "#Text" #Nil)
(#Named ["lux" "Text"] (#Primitive "#Text" #Nil)))
- (wrap (:coerce ..Text value))
+ (wrap (:as ..Text value))
_
(fail ($_ text\compose