aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-31 02:36:42 -0400
committerEduardo Julian2021-07-31 02:36:42 -0400
commitfa320d22d0d7888feddcabe43a2bc9f1e0335032 (patch)
treed003de8e7e1d5fafadde4e02e37efd111c269411 /stdlib/source/library/lux.lux
parent9f039e8a0a09e0278547d697efa018cd3fd68672 (diff)
Yet more renamings.
Diffstat (limited to 'stdlib/source/library/lux.lux')
-rw-r--r--stdlib/source/library/lux.lux141
1 files changed, 73 insertions, 68 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 84d33d03b..6f4d8071d 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -23,7 +23,7 @@
[dummy_location (9 #1 (0 #0))]
#1)
-## (type: Any
+## (type: #export Any
## (Ex [a] a))
("lux def" Any
("lux type check type"
@@ -37,7 +37,7 @@
(0 #0)))]
#1)
-## (type: Nothing
+## (type: #export Nothing
## (All [a] a))
("lux def" Nothing
("lux type check type"
@@ -51,7 +51,7 @@
(0 #0)))]
#1)
-## (type: (List a)
+## (type: #export (List a)
## #End
## (#Item a (List a)))
("lux def type tagged" List
@@ -156,7 +156,7 @@
#End))]
#1)
-## (type: (Maybe a)
+## (type: #export (Maybe a)
## #None
## (#Some a))
("lux def type tagged" Maybe
@@ -175,7 +175,7 @@
["None" "Some"]
#1)
-## (type: #rec Type
+## (type: #export #rec Type
## (#Primitive Text (List Type))
## (#Sum Type Type)
## (#Product Type Type)
@@ -229,7 +229,7 @@
["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"]
#1)
-## (type: Location
+## (type: #export Location
## {#module Text
## #line Nat
## #column Nat})
@@ -243,7 +243,7 @@
["module" "line" "column"]
#1)
-## (type: (Ann m v)
+## (type: #export (Ann m v)
## {#meta m
## #datum v})
("lux def type tagged" Ann
@@ -261,7 +261,7 @@
["meta" "datum"]
#1)
-## (type: (Code' w)
+## (type: #export (Code' w)
## (#Bit Bit)
## (#Nat Nat)
## (#Int Int)
@@ -313,7 +313,7 @@
["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"]
#1)
-## (type: Code
+## (type: #export Code
## (Ann Location (Code' (Ann Location))))
("lux def" Code
(#Named ["library/lux" "Code"]
@@ -414,7 +414,7 @@
[dummy_location (#Record #End)]
#0)
-## (type: Definition
+## (type: #export Definition
## [Bit Type Code Any])
("lux def" Definition
("lux type check type"
@@ -425,7 +425,7 @@
#End))
#1)
-## (type: Alias
+## (type: #export Alias
## Name)
("lux def" Alias
("lux type check type"
@@ -434,7 +434,7 @@
(record$ #End)
#1)
-## (type: Global
+## (type: #export Global
## (#Alias Alias)
## (#Definition Definition))
("lux def type tagged" Global
@@ -447,7 +447,7 @@
["Alias" "Definition"]
#1)
-## (type: (Bindings k v)
+## (type: #export (Bindings k v)
## {#counter Nat
## #mappings (List [k v])})
("lux def type tagged" Bindings
@@ -479,7 +479,7 @@
["Local" "Captured"]
#1)
-## (type: Scope
+## (type: #export Scope
## {#name (List Text)
## #inner Nat
## #locals (Bindings Text [Type Nat])
@@ -504,7 +504,7 @@
(record$ #End)
#0)
-## (type: (Either l r)
+## (type: #export (Either l r)
## (#Left l)
## (#Right r))
("lux def type tagged" Either
@@ -523,7 +523,7 @@
["Left" "Right"]
#1)
-## (type: Source
+## (type: #export Source
## [Location Nat Text])
("lux def" Source
("lux type check type"
@@ -532,7 +532,7 @@
(record$ #End)
#1)
-## (type: Module_State
+## (type: #export Module_State
## #Active
## #Compiled
## #Cached)
@@ -550,7 +550,7 @@
["Active" "Compiled" "Cached"]
#1)
-## (type: Module
+## (type: #export Module
## {#module_hash Nat
## #module_aliases (List [Text Text])
## #definitions (List [Text Global])
@@ -592,7 +592,7 @@
["module_hash" "module_aliases" "definitions" "imports" "tags" "types" "module_annotations" "module_state"]
#1)
-## (type: Type_Context
+## (type: #export Type_Context
## {#ex_counter Nat
## #var_counter Nat
## #var_bindings (List [Nat (Maybe Type)])})
@@ -609,7 +609,7 @@
["ex_counter" "var_counter" "var_bindings"]
#1)
-## (type: Mode
+## (type: #export Mode
## #Build
## #Eval
## #Interpreter)
@@ -627,7 +627,7 @@
["Build" "Eval" "Interpreter"]
#1)
-## (type: Info
+## (type: #export Info
## {#target Text
## #version Text
## #mode Mode})
@@ -647,7 +647,7 @@
["target" "version" "mode"]
#1)
-## (type: Lux
+## (type: #export Lux
## {#info Info
## #source Source
## #location Location
@@ -696,7 +696,7 @@
["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "host"]
#1)
-## (type: (Meta a)
+## (type: #export (Meta a)
## (-> Lux (Either Text [Lux a])))
("lux def" Meta
("lux type check type"
@@ -714,7 +714,7 @@
#End)))
#1)
-## (type: Macro'
+## (type: #export Macro'
## (-> (List Code) (Meta (List Code))))
("lux def" Macro'
("lux type check type"
@@ -723,7 +723,7 @@
(record$ #End)
#1)
-## (type: Macro
+## (type: #export Macro
## (primitive "#Macro"))
("lux def" Macro
("lux type check type"
@@ -993,16 +993,16 @@
(#Item (f x) (list\map f xs'))}
xs))
-(def:'' RepEnv
+(def:'' Replacement_Environment
#End
Type
($' List (#Product Text Code)))
-(def:'' (make_env xs ys)
+(def:'' (replacement_environment xs ys)
#End
- (#Function ($' List Text) (#Function ($' List Code) RepEnv))
+ (#Function ($' List Text) (#Function ($' List Code) Replacement_Environment))
({[(#Item x xs') (#Item y ys')]
- (#Item [x y] (make_env xs' ys'))
+ (#Item [x y] (replacement_environment xs' ys'))
_
#End}
@@ -1013,43 +1013,43 @@
(#Function Text (#Function Text Bit))
("lux text =" reference sample))
-(def:'' (get_rep key env)
+(def:'' (replacement for environment)
#End
- (#Function Text (#Function RepEnv ($' Maybe Code)))
+ (#Function Text (#Function Replacement_Environment ($' Maybe Code)))
({#End
#None
- (#Item [k v] env')
+ (#Item [k v] environment')
({#1
(#Some v)
#0
- (get_rep key env')}
- (text\= k key))}
- env))
+ (replacement for environment')}
+ (text\= k for))}
+ environment))
-(def:'' (replace_syntax reps syntax)
+(def:'' (with_replacements reps syntax)
#End
- (#Function RepEnv (#Function Code Code))
+ (#Function Replacement_Environment (#Function Code Code))
({[_ (#Identifier "" name)]
({(#Some replacement)
replacement
#None
syntax}
- (get_rep name reps))
+ (..replacement name reps))
[meta (#Form parts)]
- [meta (#Form (list\map (replace_syntax reps) parts))]
+ [meta (#Form (list\map (with_replacements reps) parts))]
[meta (#Tuple members)]
- [meta (#Tuple (list\map (replace_syntax reps) members))]
+ [meta (#Tuple (list\map (with_replacements reps) members))]
[meta (#Record slots)]
[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)]}
+ [(with_replacements reps k) (with_replacements reps v)]}
slot)))
slots))]
@@ -1065,24 +1065,24 @@
("lux type as" Int param)
("lux type as" Int subject))))
-(def:'' (update_parameters code)
+(def:'' (nested_quantification code)
#End
(#Function Code Code)
({[_ (#Tuple members)]
- (tuple$ (list\map update_parameters members))
+ (tuple$ (list\map nested_quantification members))
[_ (#Record pairs)]
(record$ (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code))
(function'' [pair]
(let'' [name val] pair
- [name (update_parameters val)])))
+ [name (nested_quantification val)])))
pairs))
[_ (#Form (#Item [_ (#Tag "library/lux" "Parameter")] (#Item [_ (#Nat idx)] #End)))]
(form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ ("lux i64 +" 2 idx)) #End)))
[_ (#Form members)]
- (form$ (list\map update_parameters members))
+ (form$ (list\map nested_quantification members))
_
code}
@@ -1105,7 +1105,7 @@
(failure "Expected identifier.")}
args))
-(def:'' (make_parameter idx)
+(def:'' (type_parameter idx)
#End
(#Function Nat Code)
(form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ idx) #End))))
@@ -1155,8 +1155,9 @@
(function'' [name' body']
(form$ (#Item (tag$ ["library/lux" "UnivQ"])
(#Item (tag$ ["library/lux" "End"])
- (#Item (replace_syntax (#Item [name' (make_parameter 1)] #End)
- (update_parameters body')) #End))))))
+ (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
+ (nested_quantification body'))
+ #End))))))
body
names)
(return (#Item ({[#1 _]
@@ -1166,9 +1167,9 @@
body'
[#0 _]
- (replace_syntax (#Item [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))]
- #End)
- body')}
+ (with_replacements (#Item [self_name (type_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))]
+ #End)
+ body')}
[(text\= "" self_name) names])
#End)))))
@@ -1199,8 +1200,9 @@
(function'' [name' body']
(form$ (#Item (tag$ ["library/lux" "ExQ"])
(#Item (tag$ ["library/lux" "End"])
- (#Item (replace_syntax (#Item [name' (make_parameter 1)] #End)
- (update_parameters body')) #End))))))
+ (#Item (with_replacements (#Item [name' (type_parameter 1)] #End)
+ (nested_quantification body'))
+ #End))))))
body
names)
(return (#Item ({[#1 _]
@@ -1210,9 +1212,9 @@
body'
[#0 _]
- (replace_syntax (#Item [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))]
- #End)
- body')}
+ (with_replacements (#Item [self_name (type_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))]
+ #End)
+ body')}
[(text\= "" self_name) names])
#End)))))
@@ -2069,14 +2071,14 @@
(def:''' (apply_template env template)
#End
- (-> RepEnv Code Code)
+ (-> Replacement_Environment Code Code)
({[_ (#Identifier "" sname)]
({(#Some subst)
subst
_
template}
- (get_rep sname env))
+ (..replacement sname env))
[meta (#Tuple elems)]
[meta (#Tuple (list\map (apply_template env) elems))]
@@ -2152,13 +2154,13 @@
" " "[dec -1]"))])
({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])])
({[(#Some bindings') (#Some data')]
- (let' [apply ("lux type check" (-> RepEnv ($' List Code))
+ (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code))
(function' [env] (list\map (apply_template env) templates)))
num_bindings (list\size bindings')]
(if (every? (function' [size] ("lux i64 =" num_bindings size))
(list\map list\size data'))
(|> data'
- (list\map (compose apply (make_env bindings')))
+ (list\map (compose apply (replacement_environment bindings')))
list\join
return)
(failure "Irregular arguments tuples for template.")))
@@ -2617,8 +2619,9 @@
"## A name has to be given to the whole type, to use it within its body." __paragraph
"(Rec Self [Int (List Self)])"))])
({(#Item [_ (#Identifier "" name)] (#Item body #End))
- (let' [body' (replace_syntax (list [name (` (#.Apply (~ (make_parameter 1)) (~ (make_parameter 0))))])
- (update_parameters body))]
+ (let' [body' (|> body
+ nested_quantification
+ (with_replacements (list [name (` (#.Apply (~ (type_parameter 1)) (~ (type_parameter 0))))])))]
(return (list (` (#.Apply .Nothing (#.UnivQ #.End (~ body')))))))
_
@@ -3639,7 +3642,8 @@
(if (empty? args)
(let [g!param (local_identifier$ "")
prime_name (local_identifier$ name)
- type+ (replace_syntax (list [name (` ((~ prime_name) .Nothing))]) type)]
+ type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))])
+ type)]
(#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+))
.Nothing))))
#None)
@@ -4850,10 +4854,10 @@
(let [num_bindings (list\size bindings')]
(if (every? (|>> ("lux i64 =" num_bindings))
(list\map list\size data'))
- (let [apply (: (-> RepEnv (List Code))
+ (let [apply (: (-> Replacement_Environment (List Code))
(function (_ env) (list\map (apply_template env) templates)))]
(|> data'
- (list\map (compose apply (make_env bindings')))
+ (list\map (compose apply (replacement_environment bindings')))
list\join
in))
#None))))
@@ -5460,13 +5464,13 @@
(#Right state scope_type_vars)
))
-(macro: #export ($ tokens)
+(macro: #export (:parameter tokens)
{#.doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index."
"In the example below, 0 corresponds to the 'a' variable."
(def: #export (of_list list)
(All [a] (-> (List a) (Row a)))
(list\fold add
- (: (Row ($ 0))
+ (: (Row (:parameter 0))
empty)
list)))}
(case tokens
@@ -5678,7 +5682,8 @@
(^ (list (~+ (list\map local_identifier$ args))))
(#.Right [(~ g!compiler)
(list (~+ (list\map (function (_ template)
- (` (`' (~ (replace_syntax rep_env template)))))
+ (` (`' (~ (with_replacements rep_env
+ template)))))
input_templates)))])
(~ g!_)