aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux.lux')
-rw-r--r--stdlib/source/library/lux.lux628
1 files changed, 314 insertions, 314 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 986378ad7..ffe7daf46 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -1143,7 +1143,7 @@
(#Function Nat Code)
(form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ idx) #End))))
-(def:'' .private (list\fold f init xs)
+(def:'' .private (list\mix f init xs)
#End
... (All [a b] (-> (-> b a a) a (List b) a))
(#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1)
@@ -1156,14 +1156,14 @@
init
(#Item x xs')
- (list\fold f (f x init) xs')}
+ (list\mix f (f x init) xs')}
xs))
(def:'' .private (list\size list)
#End
(#UnivQ #End
(#Function ($' List (#Parameter 1)) Nat))
- (list\fold (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list))
+ (list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list))
(macro:' .public (All tokens)
(#Item [(tag$ ["library/lux" "doc"])
@@ -1184,15 +1184,15 @@
({(#Item [_ (#Tuple args)] (#Item body #End))
(quantified_args_parser args
(function'' [names]
- (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code))
- (function'' [name' body']
- (form$ (#Item (tag$ ["library/lux" "UnivQ"])
- (#Item (tag$ ["library/lux" "End"])
- (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
- (nested_quantification body'))
- #End))))))
- body
- names)
+ (let'' body' (list\mix ("lux type check" (#Function Text (#Function Code Code))
+ (function'' [name' body']
+ (form$ (#Item (tag$ ["library/lux" "UnivQ"])
+ (#Item (tag$ ["library/lux" "End"])
+ (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
+ (nested_quantification body'))
+ #End))))))
+ body
+ names)
(in_meta (#Item ({[#1 _]
body'
@@ -1229,15 +1229,15 @@
({(#Item [_ (#Tuple args)] (#Item body #End))
(quantified_args_parser args
(function'' [names]
- (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code))
- (function'' [name' body']
- (form$ (#Item (tag$ ["library/lux" "ExQ"])
- (#Item (tag$ ["library/lux" "End"])
- (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
- (nested_quantification body'))
- #End))))))
- body
- names)
+ (let'' body' (list\mix ("lux type check" (#Function Text (#Function Code Code))
+ (function'' [name' body']
+ (form$ (#Item (tag$ ["library/lux" "ExQ"])
+ (#Item (tag$ ["library/lux" "End"])
+ (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
+ (nested_quantification body'))
+ #End))))))
+ body
+ names)
(in_meta (#Item ({[#1 _]
body'
@@ -1258,10 +1258,10 @@
(def:'' .private (list\reversed list)
#End
(All [a] (#Function ($' List a) ($' List a)))
- (list\fold ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a))))
- (function'' [head tail] (#Item head tail)))
- #End
- list))
+ (list\mix ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a))))
+ (function'' [head tail] (#Item head tail)))
+ #End
+ list))
(macro:' .public (-> tokens)
(#Item [(tag$ ["library/lux" "doc"])
@@ -1272,10 +1272,10 @@
"... This is the type of a function that takes 2 Ints and returns an Int.")))]
#End)
({(#Item output inputs)
- (in_meta (#Item (list\fold ("lux type check" (#Function Code (#Function Code Code))
- (function'' [i o] (form$ (#Item (tag$ ["library/lux" "Function"]) (#Item i (#Item o #End))))))
- output
- inputs)
+ (in_meta (#Item (list\mix ("lux type check" (#Function Code (#Function Code Code))
+ (function'' [i o] (form$ (#Item (tag$ ["library/lux" "Function"]) (#Item i (#Item o #End))))))
+ output
+ inputs)
#End))
_
@@ -1288,12 +1288,12 @@
("lux text concat" "... List-construction macro." __paragraph)
"(list +1 +2 +3)"))]
#End)
- (in_meta (#Item (list\fold (function'' [head tail]
- (form$ (#Item (tag$ ["library/lux" "Item"])
- (#Item (tuple$ (#Item [head (#Item [tail #End])]))
- #End))))
- (tag$ ["library/lux" "End"])
- (list\reversed xs))
+ (in_meta (#Item (list\mix (function'' [head tail]
+ (form$ (#Item (tag$ ["library/lux" "Item"])
+ (#Item (tuple$ (#Item [head (#Item [tail #End])]))
+ #End))))
+ (tag$ ["library/lux" "End"])
+ (list\reversed xs))
#End)))
(macro:' .public (list& xs)
@@ -1305,11 +1305,11 @@
"(list& +1 +2 +3 (list +4 +5 +6))")))]
#End)
({(#Item last init)
- (in_meta (list (list\fold (function'' [head tail]
- (form$ (list (tag$ ["library/lux" "Item"])
- (tuple$ (list head tail)))))
- last
- init)))
+ (in_meta (list (list\mix (function'' [head tail]
+ (form$ (list (tag$ ["library/lux" "Item"])
+ (tuple$ (list head tail)))))
+ last
+ init)))
_
(failure "Wrong syntax for list&")}
@@ -1329,9 +1329,9 @@
(in_meta (list (identifier$ ["library/lux" "Nothing"])))
(#Item last prevs)
- (in_meta (list (list\fold (function'' [left right] (form$ (list (tag$ ["library/lux" "Sum"]) left right)))
- last
- prevs)))}
+ (in_meta (list (list\mix (function'' [left right] (form$ (list (tag$ ["library/lux" "Sum"]) left right)))
+ last
+ prevs)))}
(list\reversed tokens)))
(macro:' .public (Tuple tokens)
@@ -1348,9 +1348,9 @@
(in_meta (list (identifier$ ["library/lux" "Any"])))
(#Item last prevs)
- (in_meta (list (list\fold (function'' [left right] (form$ (list (tag$ ["library/lux" "Product"]) left right)))
- last
- prevs)))}
+ (in_meta (list (list\mix (function'' [left right] (form$ (list (tag$ ["library/lux" "Product"]) left right)))
+ last
+ prevs)))}
(list\reversed tokens)))
(macro:' .private (function' tokens)
@@ -1367,12 +1367,12 @@
(#Item [harg targs])
(in_meta (list (form$ (list (tuple$ (list (local_identifier$ name)
harg))
- (list\fold (function'' [arg body']
- (form$ (list (tuple$ (list (local_identifier$ "")
- arg))
- body')))
- body
- (list\reversed targs))))))}
+ (list\mix (function'' [arg body']
+ (form$ (list (tuple$ (list (local_identifier$ "")
+ arg))
+ body')))
+ body
+ (list\reversed targs))))))}
args)
_
@@ -1437,14 +1437,14 @@
(macro:' .private (let' tokens)
({(#Item [[_ (#Tuple bindings)] (#Item [body #End])])
- (in_meta (list (list\fold ("lux type check" (-> (Tuple Code Code) Code
- Code)
- (function' [binding body]
- ({[label value]
- (form$ (list (record$ (list [label body])) value))}
- binding)))
- body
- (list\reversed (pairs bindings)))))
+ (in_meta (list (list\mix ("lux type check" (-> (Tuple Code Code) Code
+ Code)
+ (function' [binding body]
+ ({[label value]
+ (form$ (list (record$ (list [label body])) value))}
+ binding)))
+ body
+ (list\reversed (pairs bindings)))))
_
(failure "Wrong syntax for let'")}
@@ -1518,7 +1518,7 @@
#End)
({(#Item op tokens')
({(#Item first nexts)
- (in_meta (list (list\fold (function\flipped (right_associativity op)) first nexts)))
+ (in_meta (list (list\mix (function\flipped (right_associativity op)) first nexts)))
_
(failure "Wrong syntax for _$")}
@@ -1540,7 +1540,7 @@
#End)
({(#Item op tokens')
({(#Item last prevs)
- (in_meta (list (list\fold (right_associativity op) last prevs)))
+ (in_meta (list (list\mix (right_associativity op) last prevs)))
_
(failure "Wrong syntax for $_")}
@@ -1554,7 +1554,7 @@
... (: (All [a] (-> a (m a)))
... in)
... (: (All [a b] (-> (-> a (m b)) (m a) (m b)))
-... bind))
+... then))
("lux def type tagged" Monad
(#Named ["library/lux" "Monad"]
(All [m]
@@ -1563,7 +1563,7 @@
($' m a)
($' m b))))))
(record$ (list))
- ["in" "bind"]
+ ["in" "then"]
#0)
(def:''' .private maybe_monad
@@ -1572,7 +1572,7 @@
{#in
(function' [x] (#Some x))
- #bind
+ #then
(function' [f ma]
({#None #None
(#Some a) (f a)}
@@ -1586,7 +1586,7 @@
(function' [state]
(#Right state x)))
- #bind
+ #then
(function' [f ma]
(function' [state]
({(#Left msg)
@@ -1599,29 +1599,29 @@
(macro:' .private (do tokens)
({(#Item monad (#Item [_ (#Tuple bindings)] (#Item body #End)))
(let' [g!in (local_identifier$ "in")
- g!bind (local_identifier$ " bind ")
- body' (list\fold ("lux type check" (-> (Tuple Code Code) Code Code)
- (function' [binding body']
- (let' [[var value] binding]
- ({[_ (#Identifier [module short])]
- ({""
- (form$ (list g!bind
- (form$ (list (tuple$ (list (local_identifier$ "") var)) body'))
- value))
-
- _
- (form$ (list var value body'))}
- module)
-
-
- _
- (form$ (list g!bind
- (form$ (list (tuple$ (list (local_identifier$ "") var)) body'))
- value))}
- var))))
- body
- (list\reversed (pairs bindings)))]
- (in_meta (list (form$ (list (record$ (list [(record$ (list [(tag$ ["library/lux" "in"]) g!in] [(tag$ ["library/lux" "bind"]) g!bind]))
+ g!then (local_identifier$ " then ")
+ body' (list\mix ("lux type check" (-> (Tuple Code Code) Code Code)
+ (function' [binding body']
+ (let' [[var value] binding]
+ ({[_ (#Identifier [module short])]
+ ({""
+ (form$ (list g!then
+ (form$ (list (tuple$ (list (local_identifier$ "") var)) body'))
+ value))
+
+ _
+ (form$ (list var value body'))}
+ module)
+
+
+ _
+ (form$ (list g!then
+ (form$ (list (tuple$ (list (local_identifier$ "") var)) body'))
+ value))}
+ var))))
+ body
+ (list\reversed (pairs bindings)))]
+ (in_meta (list (form$ (list (record$ (list [(record$ (list [(tag$ ["library/lux" "in"]) g!in] [(tag$ ["library/lux" "then"]) g!then]))
body']))
monad)))))
@@ -1638,7 +1638,7 @@
(-> a ($' m b))
($' List a)
($' m ($' List b))))
- (let' [{#in in #bind _} m]
+ (let' [{#in in #then _} m]
({#End
(in #End)
@@ -1649,7 +1649,7 @@
(in (#Item y ys)))}
xs)))
-(def:''' .private (monad\fold m f y xs)
+(def:''' .private (monad\mix m f y xs)
#End
... (All [m a b]
... (-> (Monad m) (-> a b (m b)) b (List a) (m b)))
@@ -1659,14 +1659,14 @@
b
($' List a)
($' m b)))
- (let' [{#in in #bind _} m]
+ (let' [{#in in #then _} m]
({#End
(in y)
(#Item x xs')
(do m
[y' (f x y)]
- (monad\fold m f y' xs'))}
+ (monad\mix m f y' xs'))}
xs)))
(macro:' .public (if tokens)
@@ -1707,7 +1707,7 @@
(-> Text Text Text)
("lux text concat" x y))
-(def:''' .private (name\encode full_name)
+(def:''' .private (name\encoded full_name)
#End
(-> Name Text)
(let' [[module name] full_name]
@@ -1733,11 +1733,11 @@
constant)
#None
- (#Left ($_ text\compose "Unknown definition: " (name\encode full_name)))}
+ (#Left ($_ text\compose "Unknown definition: " (name\encoded full_name)))}
(plist\value name definitions))
#None
- (#Left ($_ text\compose "Unknown module: " module " @ " (name\encode full_name)))}
+ (#Left ($_ text\compose "Unknown module: " module " @ " (name\encoded full_name)))}
(plist\value module modules))))
(def:''' .private (code_list expression)
@@ -1766,21 +1766,21 @@
(in (code_list (form$ (list (tag$ ["library/lux" "Item"])
(tuple$ (list lastO (tag$ ["library/lux" "End"]))))))))}
lastI)]
- (monad\fold meta_monad
- (function' [leftI rightO]
- ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))]
- (let' [g!in-module (form$ (list (text$ "lux in-module")
- (text$ "library/lux")
- (identifier$ ["library/lux" "list\compose"])))]
- (in (form$ (list g!in-module (code_list spliced) rightO))))
-
- _
- (do meta_monad
- [leftO (untemplated leftI)]
- (in (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list leftO rightO))))))}
- leftI))
- lastO
- inits))}
+ (monad\mix meta_monad
+ (function' [leftI rightO]
+ ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))]
+ (let' [g!in-module (form$ (list (text$ "lux in-module")
+ (text$ "library/lux")
+ (identifier$ ["library/lux" "list\compose"])))]
+ (in (form$ (list g!in-module (code_list spliced) rightO))))
+
+ _
+ (do meta_monad
+ [leftO (untemplated leftI)]
+ (in (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list leftO rightO))))))}
+ leftI))
+ lastO
+ inits))}
(list\reversed elems))
#0
(do meta_monad
@@ -1965,23 +1965,23 @@
(list [(tag$ ["library/lux" "doc"])
(text$ ($_ "lux text concat"
"... Piping macro." __paragraph
- "(|> elems (list\map int\encode) (interposed '' '') (fold text\compose ''''))" __paragraph
+ "(|> elems (list\map int\encoded) (interposed '' '') (mix text\compose ''''))" __paragraph
"... =>" __paragraph
- "(fold text\compose '''' (interposed '' '' (list\map int\encode elems)))"))])
+ "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))])
({(#Item [init apps])
- (in_meta (list (list\fold ("lux type check" (-> Code Code Code)
- (function' [app acc]
- ({[_ (#Tuple parts)]
- (tuple$ (list\compose parts (list acc)))
+ (in_meta (list (list\mix ("lux type check" (-> Code Code Code)
+ (function' [app acc]
+ ({[_ (#Tuple parts)]
+ (tuple$ (list\compose parts (list acc)))
- [_ (#Form parts)]
- (form$ (list\compose parts (list acc)))
+ [_ (#Form parts)]
+ (form$ (list\compose parts (list acc)))
- _
- (` ((~ app) (~ acc)))}
- app)))
- init
- apps)))
+ _
+ (` ((~ app) (~ acc)))}
+ app)))
+ init
+ apps)))
_
(failure "Wrong syntax for |>")}
@@ -1991,23 +1991,23 @@
(list [(tag$ ["library/lux" "doc"])
(text$ ($_ "lux text concat"
"... Reverse piping macro." __paragraph
- "(<| (fold text\compose '''') (interposed '' '') (list\map int\encode) elems)" __paragraph
+ "(<| (mix text\compose '''') (interposed '' '') (list\map int\encoded) elems)" __paragraph
"... =>" __paragraph
- "(fold text\compose '''' (interposed '' '' (list\map int\encode elems)))"))])
+ "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))])
({(#Item [init apps])
- (in_meta (list (list\fold ("lux type check" (-> Code Code Code)
- (function' [app acc]
- ({[_ (#Tuple parts)]
- (tuple$ (list\compose parts (list acc)))
+ (in_meta (list (list\mix ("lux type check" (-> Code Code Code)
+ (function' [app acc]
+ ({[_ (#Tuple parts)]
+ (tuple$ (list\compose parts (list acc)))
- [_ (#Form parts)]
- (form$ (list\compose parts (list acc)))
+ [_ (#Form parts)]
+ (form$ (list\compose parts (list acc)))
- _
- (` ((~ app) (~ acc)))}
- app)))
- init
- apps)))
+ _
+ (` ((~ app) (~ acc)))}
+ app)))
+ init
+ apps)))
_
(failure "Wrong syntax for <|")}
@@ -2092,7 +2092,7 @@
#End
(All [a]
(-> (-> a Bit) ($' List a) Bit))
- (list\fold (function' [_2 _1] (if _1 (p _2) #0)) #1 xs))
+ (list\mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs))
(def:''' .private (high_bits value)
(list)
@@ -2133,7 +2133,7 @@
#End
(All [a]
(-> ($' List ($' List a)) ($' List a)))
- (list\fold list\compose #End (list\reversed xs)))
+ (list\mix list\compose #End (list\reversed xs)))
(macro:' .public (template tokens)
(list [(tag$ ["library/lux" "doc"])
@@ -2199,7 +2199,7 @@
left
right))
-(def:''' .private (bit\encode x)
+(def:''' .private (bit\encoded x)
#End
(-> Bit Text)
(if x "#1" "#0"))
@@ -2214,7 +2214,7 @@
_ ("lux io error" "@digit::format Undefined behavior.")}
digit))
-(def:''' .private (nat\encode value)
+(def:''' .private (nat\encoded value)
#End
(-> Nat Text)
({0
@@ -2238,7 +2238,7 @@
("lux i64 *" -1 value)
value))
-(def:''' .private (int\encode value)
+(def:''' .private (int\encoded value)
#End
(-> Int Text)
(if ("lux i64 =" +0 value)
@@ -2256,7 +2256,7 @@
(|> value ("lux i64 /" +10) int\abs)
(|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format)))))
-(def:''' .private (frac\encode x)
+(def:''' .private (frac\encoded x)
#End
(-> Frac Text)
("lux f64 encode" x))
@@ -2465,10 +2465,10 @@
expression
[_ (#Form (#Item type_fn args))]
- (list\fold ("lux type check" (-> Code Code Code)
- (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn)))))
- (normal_type type_fn)
- (list\map normal_type args))
+ (list\mix ("lux type check" (-> Code Code Code)
+ (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn)))))
+ (normal_type type_fn)
+ (list\map normal_type args))
_
type}
@@ -2601,7 +2601,7 @@
#seed ("lux i64 +" 1 seed) #expected expected
#location location #extensions extensions
#scope_type_vars scope_type_vars #eval _eval}
- (local_identifier$ ($_ text\compose "__gensym__" prefix (nat\encode seed))))}
+ (local_identifier$ ($_ text\compose "__gensym__" prefix (nat\encoded seed))))}
state))
(macro:' .public (Rec tokens)
@@ -2631,11 +2631,11 @@
"''YOLO'')"))])
({(#Item value actions)
(let' [dummy (local_identifier$ "")]
- (in_meta (list (list\fold ("lux type check" (-> Code Code Code)
- (function' [pre post] (` ({(~ dummy) (~ post)}
- (~ pre)))))
- value
- actions))))
+ (in_meta (list (list\mix ("lux type check" (-> Code Code Code)
+ (function' [pre post] (` ({(~ dummy) (~ post)}
+ (~ pre)))))
+ value
+ actions))))
_
(failure "Wrong syntax for exec")}
@@ -2681,29 +2681,29 @@
(failure "Wrong syntax for def'")}
parts)))
-(def:' .private (text\encode original)
+(def:' .private (text\encoded original)
(-> Text Text)
($_ text\compose ..double_quote original ..double_quote))
-(def:' .private (code\encode code)
+(def:' .private (code\encoded code)
(-> Code Text)
({[_ (#Bit value)]
- (bit\encode value)
+ (bit\encoded value)
[_ (#Nat value)]
- (nat\encode value)
+ (nat\encoded value)
[_ (#Int value)]
- (int\encode value)
+ (int\encoded value)
[_ (#Rev value)]
- ("lux io error" "@code\encode Undefined behavior.")
+ ("lux io error" "@code\encoded Undefined behavior.")
[_ (#Frac value)]
- (frac\encode value)
+ (frac\encoded value)
[_ (#Text value)]
- (text\encode value)
+ (text\encoded value)
[_ (#Identifier [module name])]
(if (text\= "" module)
@@ -2717,25 +2717,25 @@
[_ (#Form xs)]
($_ text\compose "(" (|> xs
- (list\map code\encode)
+ (list\map code\encoded)
(list\interposed " ")
list\reversed
- (list\fold text\compose "")) ")")
+ (list\mix text\compose "")) ")")
[_ (#Tuple xs)]
($_ text\compose "[" (|> xs
- (list\map code\encode)
+ (list\map code\encoded)
(list\interposed " ")
list\reversed
- (list\fold text\compose "")) "]")
+ (list\mix text\compose "")) "]")
[_ (#Record kvs)]
($_ text\compose "{" (|> kvs
- (list\map (function' [kv] ({[k v] ($_ text\compose (code\encode k) " " (code\encode v))}
+ (list\map (function' [kv] ({[k v] ($_ text\compose (code\encoded k) " " (code\encoded v))}
kv)))
(list\interposed " ")
list\reversed
- (list\fold text\compose "")) "}")}
+ (list\mix text\compose "")) "}")}
code))
(def:' .private (expander branches)
@@ -2765,10 +2765,10 @@
_
(failure ($_ text\compose "'lux.case' expects an even number of tokens: " (|> branches
- (list\map code\encode)
+ (list\map code\encoded)
(list\interposed " ")
list\reversed
- (list\fold text\compose ""))))}
+ (list\mix text\compose ""))))}
branches))
(macro:' .public (case tokens)
@@ -2865,13 +2865,13 @@
(^ (list [_ (#Tuple bindings)] body))
(if (multiple? 2 (list\size bindings))
(|> bindings pairs list\reversed
- (list\fold (: (-> [Code Code] Code Code)
- (function' [lr body']
- (let' [[l r] lr]
- (if (identifier? l)
- (` ({(~ l) (~ body')} (~ r)))
- (` (case (~ r) (~ l) (~ body')))))))
- body)
+ (list\mix (: (-> [Code Code] Code Code)
+ (function' [lr body']
+ (let' [[l r] lr]
+ (if (identifier? l)
+ (` ({(~ l) (~ body')} (~ r)))
+ (` (case (~ r) (~ l) (~ body')))))))
+ body)
list
in_meta)
(failure "let requires an even number of parts"))
@@ -2906,7 +2906,7 @@
(` ([(~ g!name) (~ g!blank)]
(.case (~ g!blank) (~ arg) (~ body'))))))))]
(in_meta (list (nest (..local_identifier$ g!name) head
- (list\fold (nest g!blank) body (list\reversed tail))))))
+ (list\mix (nest g!blank) body (list\reversed tail))))))
#None
(failure "Wrong syntax for function")))
@@ -2971,13 +2971,13 @@
_
(` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])]
[(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ parameter)
- (` [(~ location_code) (#.Text (~ (text$ (code\encode parameter))))]))
+ (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))]))
parameters))))]]
(~ meta)))))
(def:' .private (with_type_args args)
(-> (List Code) Code)
- (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encode arg)))
+ (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encoded arg)))
args))]}))
(def:' .private (endP tokens)
@@ -3195,7 +3195,7 @@
(-> Code Code Code)
(case addition
[location (#Record pairs)]
- (list\fold with_definition_annotation base pairs)
+ (list\mix with_definition_annotation base pairs)
_
base))
@@ -3295,10 +3295,10 @@
{#.doc <documentation>}
(case (list\reversed tokens)
(^ (list& last init))
- (in_meta (list (list\fold (: (-> Code Code Code)
- (function (_ pre post) (` <form>)))
- last
- init)))
+ (in_meta (list (list\mix (: (-> Code Code Code)
+ (function (_ pre post) (` <form>)))
+ last
+ init)))
_
(failure <message>)))]
@@ -3508,7 +3508,7 @@
(in_meta output)
_
- (failure (text\compose "Unknown tag: " (name\encode [module name]))))))
+ (failure (text\compose "Unknown tag: " (name\encoded [module name]))))))
(def: (record_slots type)
(-> Type (Meta (Maybe [(List Name) (List Type)])))
@@ -3610,10 +3610,10 @@
""
(#Item head tail)
- (list\fold (function (_ right left)
- ($_ text\compose left separator right))
- head
- tail)))
+ (list\mix (function (_ right left)
+ ($_ text\compose left separator right))
+ head
+ tail)))
(def: (remainderP tokens)
(-> (List Code) (Maybe (List Code)))
@@ -4150,7 +4150,7 @@
[current_module current_module_name]
(failure ($_ text\compose
"Wrong syntax for import @ " current_module
- ..\n (code\encode token)))))))
+ ..\n (code\encoded token)))))))
imports)]
(in (list\joined imports'))))
@@ -4181,10 +4181,10 @@
#None
(#Left ($_ text\compose
- "Unknown module: " (text\encode module) ..\n
+ "Unknown module: " (text\encoded module) ..\n
"Current module: " (case current_module
(#Some current_module)
- (text\encode current_module)
+ (text\encoded current_module)
#None
"???") ..\n
@@ -4192,7 +4192,7 @@
(list\map (function (_ [name module])
(text$ name)))
tuple$
- code\encode))))
+ code\encoded))))
))
(def: (only p xs)
@@ -4208,11 +4208,11 @@
(def: (is_member? cases name)
(-> (List Text) Text Bit)
- (let [output (list\fold (function (_ case prev)
- (or prev
- (text\= case name)))
- #0
- cases)]
+ (let [output (list\mix (function (_ case prev)
+ (or prev
+ (text\= case name)))
+ #0
+ cases)]
output))
(def: (on_either f x1 x2)
@@ -4278,12 +4278,12 @@
#scope_type_vars scope_type_vars #eval _eval} state]
(case (plist\value v_module modules)
#None
- (#Left (text\compose "Unknown definition: " (name\encode name)))
+ (#Left (text\compose "Unknown definition: " (name\encoded name)))
(#Some {#definitions definitions #module_hash _ #module_aliases _ #imports _ #tags tags #types types #module_annotations _ #module_state _})
(case (plist\value v_name definitions)
#None
- (#Left (text\compose "Unknown definition: " (name\encode name)))
+ (#Left (text\compose "Unknown definition: " (name\encoded name)))
(#Some definition)
(case definition
@@ -4321,13 +4321,13 @@
(#Right [compiler struct_type])
_
- (#Left ($_ text\compose "Unknown var: " (name\encode full_name)))))
+ (#Left ($_ text\compose "Unknown var: " (name\encoded full_name)))))
(case (definition_type full_name compiler)
(#Some struct_type)
(#Right [compiler struct_type])
_
- (#Left ($_ text\compose "Unknown var: " (name\encode full_name)))))]
+ (#Left ($_ text\compose "Unknown var: " (name\encoded full_name)))))]
(case temp
(#Right [compiler (#Var type_id)])
(let [{#info _ #source _ #current_module _ #modules _
@@ -4360,7 +4360,7 @@
_
(list)))
-(def: (type\encode type)
+(def: (type\encoded type)
(-> Type Text)
(case type
(#Primitive name params)
@@ -4369,41 +4369,41 @@
name
_
- ($_ text\compose "(" name " " (|> params (list\map type\encode) (list\interposed " ") list\reversed (list\fold text\compose "")) ")"))
+ ($_ text\compose "(" name " " (|> params (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")"))
(#Sum _)
- ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encode) (list\interposed " ") list\reversed (list\fold text\compose "")) ")")
+ ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")")
(#Product _)
- ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encode) (list\interposed " ") list\reversed (list\fold text\compose "")) "]")
+ ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) "]")
(#Function _)
- ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encode) (list\interposed " ") list\reversed (list\fold text\compose "")) ")")
+ ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")")
(#Parameter id)
- (nat\encode id)
+ (nat\encoded id)
(#Var id)
- ($_ text\compose "⌈v:" (nat\encode id) "⌋")
+ ($_ text\compose "⌈v:" (nat\encoded id) "⌋")
(#Ex id)
- ($_ text\compose "⟨e:" (nat\encode id) "⟩")
+ ($_ text\compose "⟨e:" (nat\encoded id) "⟩")
(#UnivQ env body)
- ($_ text\compose "(All " (type\encode body) ")")
+ ($_ text\compose "(All " (type\encoded body) ")")
(#ExQ env body)
- ($_ text\compose "(Ex " (type\encode body) ")")
+ ($_ text\compose "(Ex " (type\encoded body) ")")
(#Apply _)
(let [[func args] (flat_application type)]
($_ text\compose
- "(" (type\encode func) " "
- (|> args (list\map type\encode) (list\interposed " ") list\reversed (list\fold text\compose ""))
+ "(" (type\encoded func) " "
+ (|> args (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose ""))
")"))
(#Named name _)
- (name\encode name)
+ (name\encoded name)
))
(macro: .public (^open tokens)
@@ -4425,7 +4425,7 @@
struct_evidence (record_slots init_type)]
(case struct_evidence
#None
- (failure (text\compose "Can only 'open' structs: " (type\encode init_type)))
+ (failure (text\compose "Can only 'open' structs: " (type\encoded init_type)))
(#Some tags&members)
(do meta_monad
@@ -4436,20 +4436,20 @@
tags)
pattern (tuple$ (list\map identifier$ locals))]
(do meta_monad
- [enhanced_target (monad\fold meta_monad
- (function (_ [m_local m_type] enhanced_target)
- (do meta_monad
- [m_implementation (record_slots m_type)]
- (case m_implementation
- (#Some m_tags&members)
- (recur m_local
- m_tags&members
- enhanced_target)
-
- #None
- (in enhanced_target))))
- target
- (zipped/2 locals members))]
+ [enhanced_target (monad\mix meta_monad
+ (function (_ [m_local m_type] enhanced_target)
+ (do meta_monad
+ [m_implementation (record_slots m_type)]
+ (case m_implementation
+ (#Some m_tags&members)
+ (recur m_local
+ m_tags&members
+ enhanced_target)
+
+ #None
+ (in enhanced_target))))
+ target
+ (zipped/2 locals members))]
(in (` ({(~ pattern) (~ enhanced_target)} (~ (identifier$ source)))))))))
name tags&members body)]
(in (list full_body)))))
@@ -4469,12 +4469,12 @@
(failure "cond requires an uneven number of arguments.")
(case (list\reversed tokens)
(^ (list& else branches'))
- (in_meta (list (list\fold (: (-> [Code Code] Code Code)
- (function (_ branch else)
- (let [[right left] branch]
- (` (if (~ left) (~ right) (~ else))))))
- else
- (pairs branches'))))
+ (in_meta (list (list\mix (: (-> [Code Code] Code Code)
+ (function (_ branch else)
+ (let [[right left] branch]
+ (` (if (~ left) (~ right) (~ else))))))
+ else
+ (pairs branches'))))
_
(failure "Wrong syntax for cond"))))
@@ -4526,11 +4526,11 @@
(failure "value@ can only use records.")))
(^ (list [_ (#Tuple slots)] record))
- (in_meta (list (list\fold (: (-> Code Code Code)
- (function (_ slot inner)
- (` (..value@ (~ slot) (~ inner)))))
- record
- slots)))
+ (in_meta (list (list\mix (: (-> Code Code Code)
+ (function (_ slot inner)
+ (` (..value@ (~ slot) (~ inner)))))
+ record
+ slots)))
(^ (list selector))
(do meta_monad
@@ -4601,7 +4601,7 @@
(in_meta (list\joined decls')))
_
- (failure (text\compose "Can only 'open:' structs: " (type\encode struct_type)))))
+ (failure (text\compose "Can only 'open:' structs: " (type\encoded struct_type)))))
_
(do meta_monad
@@ -4617,9 +4617,9 @@
(macro: .public (|>> tokens)
{#.doc (text$ ($_ "lux text concat"
"... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n
- "(|>> (list\map int\encode) (interposed '' '') (fold text\compose ''''))" ..\n
+ "(|>> (list\map int\encoded) (interposed '' '') (mix text\compose ''''))" ..\n
"... =>" ..\n
- "(function (_ <arg>) (fold text\compose '''' (interposed '' '' (list\map int\encode <arg>))))"))}
+ "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))}
(do meta_monad
[g!_ (..identifier "_")
g!arg (..identifier "arg")]
@@ -4628,9 +4628,9 @@
(macro: .public (<<| tokens)
{#.doc (text$ ($_ "lux text concat"
"... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n
- "(<<| (fold text\compose '''') (interposed '' '') (list\map int\encode))" ..\n
+ "(<<| (mix text\compose '''') (interposed '' '') (list\map int\encoded))" ..\n
"... =>" ..\n
- "(function (_ <arg>) (fold text\compose '''' (interposed '' '' (list\map int\encode <arg>))))"))}
+ "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))}
(do meta_monad
[g!_ (..identifier "_")
g!arg (..identifier "arg")]
@@ -4659,9 +4659,9 @@
_
(failure ($_ text\compose "Wrong syntax for refer @ " current_module
..\n (|> options
- (list\map code\encode)
+ (list\map code\encoded)
(list\interposed " ")
- (list\fold text\compose "")))))))
+ (list\mix text\compose "")))))))
(def: (referral_definitions module_name [r_defs r_opens])
(-> Text Refer (Meta (List Code)))
@@ -4792,10 +4792,10 @@
(macro: .public (\ tokens)
{#.doc (text$ ($_ "lux text concat"
"... Allows accessing the value of a implementation's member." ..\n
- "(\ codec encode)"
+ "(\ codec encoded)"
__paragraph
"... Also allows using that value as a function." ..\n
- "(\ codec encode +123)"))}
+ "(\ codec encoded +123)"))}
(case tokens
(^ (list struct [_ (#Identifier member)]))
(in_meta (list (` (let [(^open (~ (text$ ..self_reference))) (~ struct)] (~ (identifier$ member))))))
@@ -4862,17 +4862,17 @@
(function (_ _) (..identifier "temp")))
slots)
.let [pairs (zipped/2 slots bindings)
- update_expr (list\fold (: (-> [Code Code] Code Code)
- (function (_ [s b] v)
- (` (..with@ (~ s) (~ v) (~ b)))))
- value
- (list\reversed pairs))
- [_ accesses'] (list\fold (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))])
- (function (_ [new_slot new_binding] [old_record accesses'])
- [(` (value@ (~ new_slot) (~ new_binding)))
- (#Item (list new_binding old_record) accesses')]))
- [record (: (List (List Code)) #End)]
- pairs)
+ update_expr (list\mix (: (-> [Code Code] Code Code)
+ (function (_ [s b] v)
+ (` (..with@ (~ s) (~ v) (~ b)))))
+ value
+ (list\reversed pairs))
+ [_ accesses'] (list\mix (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))])
+ (function (_ [new_slot new_binding] [old_record accesses'])
+ [(` (value@ (~ new_slot) (~ new_binding)))
+ (#Item (list new_binding old_record) accesses')]))
+ [record (: (List (List Code)) #End)]
+ pairs)
accesses (list\joined (list\reversed accesses'))]]
(in (list (` (let [(~+ accesses)]
(~ update_expr)))))))
@@ -5050,14 +5050,14 @@
(^template [<tag>]
[[[_ _ column] (<tag> parts)]
- (list\fold n/min column (list\map baseline_column parts))])
+ (list\mix n/min column (list\map baseline_column parts))])
([#Form]
[#Tuple])
[[_ _ column] (#Record pairs)]
- (list\fold n/min column
- (list\compose (list\map (|>> product\left baseline_column) pairs)
- (list\map (|>> product\right baseline_column) pairs)))
+ (list\mix n/min column
+ (list\compose (list\map (|>> product\left baseline_column) pairs)
+ (list\map (|>> product\right baseline_column) pairs)))
))
(type: Documentation_Fragment
@@ -5083,9 +5083,9 @@
[-- "lux i64 -" "Decrement function."]
)
-(def: tag\encode
+(def: tag\encoded
(-> Name Text)
- (|>> name\encode (text\compose "#")))
+ (|>> name\encoded (text\compose "#")))
(def: (repeated n x)
(All [a] (-> Int a (List a)))
@@ -5120,27 +5120,27 @@
(def: (example_documentation prev_location baseline example)
(-> Location Nat Code [Location Text])
(case example
- (^template [<tag> <encode>]
+ (^template [<tag> <encoded>]
[[new_location (<tag> value)]
- (let [as_text (<encode> value)]
+ (let [as_text (<encoded> value)]
[(updated_location new_location as_text)
(text\compose (location_padding baseline prev_location new_location)
as_text)])])
- ([#Bit bit\encode]
- [#Nat nat\encode]
- [#Int int\encode]
- [#Frac frac\encode]
- [#Text text\encode]
- [#Identifier name\encode]
- [#Tag tag\encode])
+ ([#Bit bit\encoded]
+ [#Nat nat\encoded]
+ [#Int int\encoded]
+ [#Frac frac\encoded]
+ [#Text text\encoded]
+ [#Identifier name\encoded]
+ [#Tag tag\encoded])
(^template [<tag> <open> <close> <prep>]
[[group_location (<tag> parts)]
- (let [[group_location' parts_text] (list\fold (function (_ part [last_location text_accum])
- (let [[part_location part_text] (example_documentation last_location baseline part)]
- [part_location (text\compose text_accum part_text)]))
- [(revised@ #column ++ group_location) ""]
- (<prep> parts))]
+ (let [[group_location' parts_text] (list\mix (function (_ part [last_location text_accum])
+ (let [[part_location part_text] (example_documentation last_location baseline part)]
+ [part_location (text\compose text_accum part_text)]))
+ [(revised@ #column ++ group_location) ""]
+ (<prep> parts))]
[(revised@ #column ++ group_location')
($_ text\compose (location_padding baseline prev_location group_location)
<open>
@@ -5374,7 +5374,7 @@
(test: "Code operations & implementations"
(with_expansions
[<tests> (template [<expr> <text>]
- [(compare <text> (\ Code/encode encode <expr>))]
+ [(compare <text> (\ codec encoded <expr>))]
[(bit #1) "#1"]
[(int +123) "+123"]
@@ -5448,7 +5448,7 @@
["Text" Text text$])
_
- (failure (text\compose "Cannot anti-quote type: " (name\encode name))))))
+ (failure (text\compose "Cannot anti-quote type: " (name\encoded name))))))
(def: (static_literal token)
(-> Code (Meta Code))
@@ -5542,22 +5542,22 @@
(def: (multi_level_case$ g!_ [[init_pattern levels] body])
(-> Code [Multi_Level_Case Code] (List Code))
- (let [inner_pattern_body (list\fold (function (_ [calculation pattern] success)
- (let [bind? (case pattern
- [_ (#.Identifier _)]
- #1
+ (let [inner_pattern_body (list\mix (function (_ [calculation pattern] success)
+ (let [bind? (case pattern
+ [_ (#.Identifier _)]
+ #1
- _
- #0)]
- (` (case (~ calculation)
- (~ pattern)
- (~ success)
-
- (~+ (if bind?
- (list)
- (list g!_ (` #.None))))))))
- (` (#.Some (~ body)))
- (: (List [Code Code]) (list\reversed levels)))]
+ _
+ #0)]
+ (` (case (~ calculation)
+ (~ pattern)
+ (~ success)
+
+ (~+ (if bind?
+ (list)
+ (list g!_ (` #.None))))))))
+ (` (#.Some (~ body)))
+ (: (List [Code Code]) (list\reversed levels)))]
(list init_pattern inner_pattern_body)))
(macro: .public (^multi tokens)
@@ -5617,7 +5617,7 @@
... 'wrong_syntax_error' for easier maintenance of the error_messages.
(def: wrong_syntax_error
(-> Name Text)
- (|>> name\encode
+ (|>> name\encoded
(text\compose "Wrong syntax for ")))
(macro: .public (name_of tokens)
@@ -5649,10 +5649,10 @@
"In the example below, 0 corresponds to the 'a' variable."
(def: .public (of_list list)
(All [a] (-> (List a) (Row a)))
- (list\fold add
- (: (Row (:parameter 0))
- empty)
- list)))}
+ (list\mix add
+ (: (Row (:parameter 0))
+ empty)
+ list)))}
(case tokens
(^ (list [_ (#Nat idx)]))
(do meta_monad
@@ -5662,7 +5662,7 @@
(in (list (` (#Ex (~ (nat$ var_id))))))
#None
- (failure (text\compose "Indexed-type does not exist: " (nat\encode idx)))))
+ (failure (text\compose "Indexed-type does not exist: " (nat\encoded idx)))))
_
(failure (..wrong_syntax_error (name_of ..$)))))
@@ -5681,9 +5681,9 @@
(macro: .public (^@ tokens)
{#.doc (example "Allows you to simultaneously bind and de-structure a value."
(def: (hash (^@ set [Hash<a> _]))
- (list\fold (function (_ elem acc) (+ (\ Hash<a> hash elem) acc))
- 0
- (to_list set))))}
+ (list\mix (function (_ elem acc) (+ (\ Hash<a> hash elem) acc))
+ 0
+ (to_list set))))}
(case tokens
(^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches))
(let [g!whole (local_identifier$ name)]
@@ -5742,7 +5742,7 @@
(do meta_monad
[location ..location
.let [[module line column] location
- location ($_ "lux text concat" (text\encode module) "," (nat\encode line) "," (nat\encode column))
+ location ($_ "lux text concat" (text\encoded module) "," (nat\encoded line) "," (nat\encoded column))
message ($_ "lux text concat" "Undefined behavior @ " location)]]
(in (list (` (..panic! (~ (text$ message)))))))
@@ -5897,12 +5897,12 @@
_
(failure ($_ text\compose
- "Invalid target platform (must be a value of type Text): " (name\encode identifier)
- " : " (..code\encode (..type_code type))))))
+ "Invalid target platform (must be a value of type Text): " (name\encoded identifier)
+ " : " (..code\encoded (..type_code type))))))
_
(failure ($_ text\compose
- "Invalid target platform syntax: " (..code\encode choice)
+ "Invalid target platform syntax: " (..code\encoded choice)
..\n "Must be either a text literal or an identifier."))))
(def: (target_pick target options default)
@@ -5962,7 +5962,7 @@
[[ann (<tag> parts)]
(do meta_monad
[=parts (monad\map meta_monad embedded_expansions parts)]
- (in [(list\fold list\compose (list) (list\map left =parts))
+ (in [(list\mix list\compose (list) (list\map left =parts))
[ann (<tag> (list\map right =parts))]]))])
([#Form] [#Tuple])
@@ -5977,7 +5977,7 @@
[val_labels val_labelled] =val]]
(in [(list\compose key_labels val_labels) [key_labelled val_labelled]])))
kvs)]
- (in [(list\fold list\compose (list) (list\map left =kvs))
+ (in [(list\mix list\compose (list) (list\map left =kvs))
[ann (#Record (list\map right =kvs))]]))
_
@@ -6124,7 +6124,7 @@
..pairs
(list\map (function (_ [localT valueT])
(list localT (` (..as_is (~ valueT))))))
- (list\fold list\compose (list))))]
+ (list\mix list\compose (list))))]
(~ bodyT)))))
(..failure ":let requires an even number of parts"))