aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/lux.lux61
1 files changed, 35 insertions, 26 deletions
diff --git a/source/lux.lux b/source/lux.lux
index 2a4cc8660..10abcb88a 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -244,10 +244,24 @@
#Nil])])))
(_lux_export LuxVar)
+## (deftype (Module Compiler)
+## (& #aliases (List (, Text Text))
+## #defs (List (, Text (, Bool (DefData' (-> (List Syntax) (StateE Compiler (List Syntax)))))))))
+(_lux_def Module
+ (#AllT [(#Some #Nil) "lux;Module" "Compiler"
+ (#RecordT (#Cons [["lux;aliases" (#AppT [List (#TupleT (#Cons [Text (#Cons [Text #Nil])]))])]
+ (#Cons [["lux;defs" (#AppT [List (#TupleT (#Cons [Text
+ (#Cons [(#TupleT (#Cons [Bool (#Cons [(#AppT [DefData' (#LambdaT [SyntaxList
+ (#AppT [(#AppT [StateE (#BoundT "Compiler")])
+ SyntaxList])])])
+ #Nil])]))
+ #Nil])]))])]
+ #Nil])]))]))
+(_lux_export Module)
+
## (deftype #rec Compiler
## (& #source Reader
-## #modules (List (, Text (List (, Text (, Bool (DefData' (-> (List Syntax) (StateE Compiler (List Syntax)))))))))
-## #module-aliases (List Void)
+## #modules (List (, Text (Module Compiler)))
## #envs (List (Env Text (, LuxVar Type)))
## #types (Bindings Int Type)
## #host HostState))
@@ -255,21 +269,14 @@
(#AppT [(#AllT [(#Some #Nil) "lux;Compiler" ""
(#RecordT (#Cons [["lux;source" Reader]
(#Cons [["lux;modules" (#AppT [List (#TupleT (#Cons [Text
- (#Cons [(#AppT [List (#TupleT (#Cons [Text
- (#Cons [(#TupleT (#Cons [Bool (#Cons [(#AppT [DefData' (#LambdaT [SyntaxList
- (#AppT [(#AppT [StateE (#AppT [(#BoundT "lux;Compiler")
- (#BoundT "")])])
- SyntaxList])])])
- #Nil])]))
- #Nil])]))])
+ (#Cons [(#AppT [Module (#AppT [(#BoundT "lux;Compiler") (#BoundT "")])])
#Nil])]))])]
- (#Cons [["lux;module-aliases" (#AppT [List Void])]
- (#Cons [["lux;envs" (#AppT [List (#AppT [(#AppT [Env Text])
- (#TupleT (#Cons [LuxVar (#Cons [Type #Nil])]))])])]
- (#Cons [["lux;types" (#AppT [(#AppT [Bindings Int]) Type])]
- (#Cons [["lux;host" HostState]
- (#Cons [["lux;seed" Int]
- #Nil])])])])])])]))])
+ (#Cons [["lux;envs" (#AppT [List (#AppT [(#AppT [Env Text])
+ (#TupleT (#Cons [LuxVar (#Cons [Type #Nil])]))])])]
+ (#Cons [["lux;types" (#AppT [(#AppT [Bindings Int]) Type])]
+ (#Cons [["lux;host" HostState]
+ (#Cons [["lux;seed" Int]
+ #Nil])])])])])]))])
Void]))
(_lux_export Compiler)
@@ -1293,7 +1300,7 @@
(def'' #export (get-module-name state)
($' Lux Text)
(_lux_case state
- {#source source #modules modules #module-aliases module-aliases
+ {#source source #modules modules
#envs envs #types types #host host
#seed seed}
(_lux_case (reverse envs)
@@ -1304,12 +1311,13 @@
(#Right [state module-name]))))
(def'' (find-macro' modules current-module module name)
- (-> ($' List (, Text ($' List (, Text (, Bool ($' DefData' (-> ($' List Syntax) ($' StateE Compiler ($' List Syntax)))))))))
+ (-> ($' List (, Text ($' Module Compiler)))
Text Text Text
($' Maybe Macro))
(do Maybe:Monad
- [bindings (get module modules)
- gdef (get name bindings)]
+ [$module (get module modules)
+ gdef (let [{#aliases _ #defs bindings} (_lux_: ($' Module Compiler) $module)]
+ (get name bindings))]
(_lux_case (_lux_: (, Bool ($' DefData' Macro)) gdef)
[exported? (#MacroD macro')]
(if exported?
@@ -1331,7 +1339,7 @@
(let [[module name] ident]
(lambda [state]
(_lux_case state
- {#source source #modules modules #module-aliases module-aliases
+ {#source source #modules modules
#envs envs #types types #host host
#seed seed}
(#Right [state (find-macro' modules current-module module name)]))))))
@@ -1741,10 +1749,10 @@
(def #export (gensym prefix state)
(-> Text (Lux Syntax))
(case state
- {#source source #modules modules #module-aliases module-aliases
+ {#source source #modules modules
#envs envs #types types #host host
#seed seed}
- (#Right [{#source source #modules modules #module-aliases module-aliases
+ (#Right [{#source source #modules modules
#envs envs #types types #host host
#seed (inc seed)}
($symbol ["__gensym__" (int:show seed)])])))
@@ -1950,7 +1958,7 @@
(defmacro #export (lux tokens state)
(case state
- {#source source #modules modules #module-aliases module-aliases
+ {#source source #modules modules
#envs envs #types types #host host
#seed seed}
(case (get "lux" modules)
@@ -1962,7 +1970,8 @@
(if export?
(list name)
(list)))))
- lux)]
+ (let [{#aliases _ #defs defs} lux]
+ defs))]
(#Right [state (: (List Syntax)
(map (: (-> Text Syntax)
(lambda [name]
@@ -2044,7 +2053,7 @@
(#Meta [_ (#SymbolS vname)])
(let [vname' (ident->text vname)]
(case state
- {#source source #modules modules #module-aliases module-aliases
+ {#source source #modules modules
#envs envs #types types #host host
#seed seed}
(let [?struct-type (some (: (-> (Env Text (, LuxVar Type)) (Maybe Type))