aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux471
-rw-r--r--stdlib/source/lux/control/parser/code.lux6
-rw-r--r--stdlib/source/lux/host.jvm.lux2
-rw-r--r--stdlib/source/lux/macro.lux8
-rw-r--r--stdlib/source/lux/macro/syntax.lux5
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/statement.lux13
7 files changed, 271 insertions, 236 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index ed223ac3d..392fede3a 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -20,8 +20,9 @@
## (type: Any
## (Ex [a] a))
("lux def" Any
- (10 ["lux" "Any"]
- (8 (0) (4 1)))
+ ("lux check type"
+ (10 ["lux" "Any"]
+ (8 (0) (4 1))))
[dummy-cursor
(10 (1 [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -34,8 +35,9 @@
## (type: Nothing
## (All [a] a))
("lux def" Nothing
- (10 ["lux" "Nothing"]
- (7 (0) (4 1)))
+ ("lux check type"
+ (10 ["lux" "Nothing"]
+ (7 (0) (4 1))))
[dummy-cursor
(10 (1 [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -49,13 +51,14 @@
## #Nil
## (#Cons a (List a)))
("lux def" List
- (10 ["lux" "List"]
- (7 (0)
- (1 ## "lux.Nil"
- Any
- ## "lux.Cons"
- (2 (4 1)
- (9 (4 1) (4 0))))))
+ ("lux check type"
+ (10 ["lux" "List"]
+ (7 (0)
+ (1 ## "lux.Nil"
+ Any
+ ## "lux.Cons"
+ (2 (4 1)
+ (9 (4 1) (4 0)))))))
[dummy-cursor
(10 (1 [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -68,8 +71,9 @@
(0))))))])
("lux def" Bit
- (10 ["lux" "Bit"]
- (0 "#Bit" #Nil))
+ ("lux check type"
+ (10 ["lux" "Bit"]
+ (0 "#Bit" #Nil)))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -78,9 +82,10 @@
#Nil)))])
("lux def" I64
- (10 ["lux" "I64"]
- (7 (0)
- (0 "#I64" (#Cons (4 1) #Nil))))
+ ("lux check type"
+ (10 ["lux" "I64"]
+ (7 (0)
+ (0 "#I64" (#Cons (4 1) #Nil)))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -89,8 +94,9 @@
#Nil)))])
("lux def" Nat
- (10 ["lux" "Nat"]
- (0 "#I64" (#Cons (0 "#Nat" #Nil) #Nil)))
+ ("lux check type"
+ (10 ["lux" "Nat"]
+ (0 "#I64" (#Cons (0 "#Nat" #Nil) #Nil))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -101,8 +107,9 @@
#Nil)))])
("lux def" Int
- (10 ["lux" "Int"]
- (0 "#I64" (#Cons (0 "#Int" #Nil) #Nil)))
+ ("lux check type"
+ (10 ["lux" "Int"]
+ (0 "#I64" (#Cons (0 "#Int" #Nil) #Nil))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -111,8 +118,9 @@
#Nil)))])
("lux def" Rev
- (10 ["lux" "Rev"]
- (0 "#I64" (#Cons (0 "#Rev" #Nil) #Nil)))
+ ("lux check type"
+ (10 ["lux" "Rev"]
+ (0 "#I64" (#Cons (0 "#Rev" #Nil) #Nil))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -123,8 +131,9 @@
#Nil)))])
("lux def" Frac
- (10 ["lux" "Frac"]
- (0 "#Frac" #Nil))
+ ("lux check type"
+ (10 ["lux" "Frac"]
+ (0 "#Frac" #Nil)))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -133,8 +142,9 @@
#Nil)))])
("lux def" Text
- (10 ["lux" "Text"]
- (0 "#Text" #Nil))
+ ("lux check type"
+ (10 ["lux" "Text"]
+ (0 "#Text" #Nil)))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -143,8 +153,9 @@
#Nil)))])
("lux def" Name
- (10 ["lux" "Name"]
- (2 Text Text))
+ ("lux check type"
+ (10 ["lux" "Name"]
+ (2 Text Text)))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -156,12 +167,13 @@
## #None
## (#Some a))
("lux def" Maybe
- (10 ["lux" "Maybe"]
- (7 #Nil
- (1 ## "lux.None"
- Any
- ## "lux.Some"
- (4 1))))
+ ("lux check type"
+ (10 ["lux" "Maybe"]
+ (7 #Nil
+ (1 ## "lux.None"
+ Any
+ ## "lux.Some"
+ (4 1)))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -187,37 +199,38 @@
## (#Named Name Type)
## )
("lux def" Type
- (10 ["lux" "Type"]
- ({Type
- ({Type-List
- ({Type-Pair
- (9 Nothing
- (7 #Nil
- (1 ## "lux.Primitive"
- (2 Text Type-List)
- (1 ## "lux.Sum"
- Type-Pair
- (1 ## "lux.Product"
+ ("lux check type"
+ (10 ["lux" "Type"]
+ ({Type
+ ({Type-List
+ ({Type-Pair
+ (9 Nothing
+ (7 #Nil
+ (1 ## "lux.Primitive"
+ (2 Text Type-List)
+ (1 ## "lux.Sum"
Type-Pair
- (1 ## "lux.Function"
+ (1 ## "lux.Product"
Type-Pair
- (1 ## "lux.Parameter"
- Nat
- (1 ## "lux.Var"
+ (1 ## "lux.Function"
+ Type-Pair
+ (1 ## "lux.Parameter"
Nat
- (1 ## "lux.Ex"
+ (1 ## "lux.Var"
Nat
- (1 ## "lux.UnivQ"
- (2 Type-List Type)
- (1 ## "lux.ExQ"
+ (1 ## "lux.Ex"
+ Nat
+ (1 ## "lux.UnivQ"
(2 Type-List Type)
- (1 ## "lux.Apply"
- Type-Pair
- ## "lux.Named"
- (2 Name Type)))))))))))))}
- ("lux check type" (2 Type Type)))}
- ("lux check type" (9 Type List)))}
- ("lux check type" (9 (4 1) (4 0)))))
+ (1 ## "lux.ExQ"
+ (2 Type-List Type)
+ (1 ## "lux.Apply"
+ Type-Pair
+ ## "lux.Named"
+ (2 Name Type)))))))))))))}
+ ("lux check type" (2 Type Type)))}
+ ("lux check type" (9 Type List)))}
+ ("lux check type" (9 (4 1) (4 0))))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
@@ -294,38 +307,39 @@
## (#Tuple (List (w (Code' w))))
## (#Record (List [(w (Code' w)) (w (Code' w))])))
("lux def" Code'
- (#Named ["lux" "Code'"]
- ({Code
- ({Code-List
- (#UnivQ #Nil
- (#Sum ## "lux.Bit"
- Bit
- (#Sum ## "lux.Nat"
- Nat
- (#Sum ## "lux.Int"
- Int
- (#Sum ## "lux.Rev"
- Rev
- (#Sum ## "lux.Frac"
- Frac
- (#Sum ## "lux.Text"
- Text
- (#Sum ## "lux.Identifier"
- Name
- (#Sum ## "lux.Tag"
+ ("lux check type"
+ (#Named ["lux" "Code'"]
+ ({Code
+ ({Code-List
+ (#UnivQ #Nil
+ (#Sum ## "lux.Bit"
+ Bit
+ (#Sum ## "lux.Nat"
+ Nat
+ (#Sum ## "lux.Int"
+ Int
+ (#Sum ## "lux.Rev"
+ Rev
+ (#Sum ## "lux.Frac"
+ Frac
+ (#Sum ## "lux.Text"
+ Text
+ (#Sum ## "lux.Identifier"
Name
- (#Sum ## "lux.Form"
- Code-List
- (#Sum ## "lux.Tuple"
+ (#Sum ## "lux.Tag"
+ Name
+ (#Sum ## "lux.Form"
Code-List
- ## "lux.Record"
- (#Apply (#Product Code Code) List)
- ))))))))))
- )}
- ("lux check type" (#Apply Code List)))}
- ("lux check type" (#Apply (#Apply (#Parameter 1)
- (#Parameter 0))
- (#Parameter 1)))))
+ (#Sum ## "lux.Tuple"
+ Code-List
+ ## "lux.Record"
+ (#Apply (#Product Code Code) List)
+ ))))))))))
+ )}
+ ("lux check type" (#Apply Code List)))}
+ ("lux check type" (#Apply (#Apply (#Parameter 1)
+ (#Parameter 0))
+ (#Parameter 1))))))
[dummy-cursor
(10 (#Cons [[dummy-cursor (7 ["lux" "tags"])]
[dummy-cursor (9 (#Cons [dummy-cursor (5 "Bit")]
@@ -443,8 +457,9 @@
## (type: Definition
## [Type Code Any])
("lux def" Definition
- (#Named ["lux" "Definition"]
- (#Product Type (#Product Code Any)))
+ ("lux check type"
+ (#Named ["lux" "Definition"]
+ (#Product Type (#Product Code Any))))
(record$ (#Cons [(tag$ ["lux" "doc"])
(text$ "Represents all the data associated with a definition: its type, its annotations, and its value.")]
default-def-meta-exported)))
@@ -453,15 +468,16 @@
## {#counter Nat
## #mappings (List [k v])})
("lux def" Bindings
- (#Named ["lux" "Bindings"]
- (#UnivQ #Nil
- (#UnivQ #Nil
- (#Product ## "lux.counter"
- Nat
- ## "lux.mappings"
- (#Apply (#Product (#Parameter 3)
- (#Parameter 1))
- List)))))
+ ("lux check type"
+ (#Named ["lux" "Bindings"]
+ (#UnivQ #Nil
+ (#UnivQ #Nil
+ (#Product ## "lux.counter"
+ Nat
+ ## "lux.mappings"
+ (#Apply (#Product (#Parameter 3)
+ (#Parameter 1))
+ List))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "counter") (#Cons (text$ "mappings") #Nil)))]
(#Cons [(tag$ ["lux" "type-args"])
@@ -472,11 +488,12 @@
## (#Local Nat)
## (#Captured Nat))
("lux def" Ref
- (#Named ["lux" "Ref"]
- (#Sum ## Local
- Nat
- ## Captured
- Nat))
+ ("lux check type"
+ (#Named ["lux" "Ref"]
+ (#Sum ## Local
+ Nat
+ ## Captured
+ Nat)))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Local") (#Cons (text$ "Captured") #Nil)))]
default-def-meta-exported)))
@@ -487,34 +504,37 @@
## #locals (Bindings Text [Type Nat])
## #captured (Bindings Text [Type Ref])})
("lux def" Scope
- (#Named ["lux" "Scope"]
- (#Product ## name
- (#Apply Text List)
- (#Product ## inner
- Nat
- (#Product ## locals
- (#Apply (#Product Type Nat) (#Apply Text Bindings))
- ## captured
- (#Apply (#Product Type Ref) (#Apply Text Bindings))))))
+ ("lux check type"
+ (#Named ["lux" "Scope"]
+ (#Product ## name
+ (#Apply Text List)
+ (#Product ## inner
+ Nat
+ (#Product ## locals
+ (#Apply (#Product Type Nat) (#Apply Text Bindings))
+ ## captured
+ (#Apply (#Product Type Ref) (#Apply Text Bindings)))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "name") (#Cons (text$ "inner") (#Cons (text$ "locals") (#Cons (text$ "captured") #Nil)))))]
default-def-meta-exported)))
("lux def" Code-List
- (#Apply Code List)
+ ("lux check type"
+ (#Apply Code List))
(record$ #Nil))
## (type: (Either l r)
## (#Left l)
## (#Right r))
("lux def" Either
- (#Named ["lux" "Either"]
- (#UnivQ #Nil
- (#UnivQ #Nil
- (#Sum ## "lux.Left"
- (#Parameter 3)
- ## "lux.Right"
- (#Parameter 1)))))
+ ("lux check type"
+ (#Named ["lux" "Either"]
+ (#UnivQ #Nil
+ (#UnivQ #Nil
+ (#Sum ## "lux.Left"
+ (#Parameter 3)
+ ## "lux.Right"
+ (#Parameter 1))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Left") (#Cons (text$ "Right") #Nil)))]
(#Cons [(tag$ ["lux" "type-args"])
@@ -526,8 +546,9 @@
## (type: Source
## [Cursor Nat Text])
("lux def" Source
- (#Named ["lux" "Source"]
- (#Product Cursor (#Product Nat Text)))
+ ("lux check type"
+ (#Named ["lux" "Source"]
+ (#Product Cursor (#Product Nat Text))))
(record$ default-def-meta-exported))
## (type: Module-State
@@ -535,15 +556,16 @@
## #Compiled
## #Cached)
("lux def" Module-State
- (#Named ["lux" "Module-State"]
- (#Sum
- ## #Active
- Any
+ ("lux check type"
+ (#Named ["lux" "Module-State"]
(#Sum
- ## #Compiled
+ ## #Active
Any
- ## #Cached
- Any)))
+ (#Sum
+ ## #Compiled
+ Any
+ ## #Cached
+ Any))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Active") (#Cons (text$ "Compiled") (#Cons (text$ "Cached") #Nil))))]
default-def-meta-exported)))
@@ -558,32 +580,33 @@
## #module-annotations (Maybe Code)
## #module-state Module-State})
("lux def" Module
- (#Named ["lux" "Module"]
- (#Product ## "lux.module-hash"
- Nat
- (#Product ## "lux.module-aliases"
- (#Apply (#Product Text Text) List)
- (#Product ## "lux.definitions"
- (#Apply (#Product Text Definition) List)
- (#Product ## "lux.imports"
- (#Apply Text List)
- (#Product ## "lux.tags"
- (#Apply (#Product Text
- (#Product Nat
- (#Product (#Apply Name List)
- (#Product Bit
- Type))))
- List)
- (#Product ## "lux.types"
+ ("lux check type"
+ (#Named ["lux" "Module"]
+ (#Product ## "lux.module-hash"
+ Nat
+ (#Product ## "lux.module-aliases"
+ (#Apply (#Product Text Text) List)
+ (#Product ## "lux.definitions"
+ (#Apply (#Product Text Definition) List)
+ (#Product ## "lux.imports"
+ (#Apply Text List)
+ (#Product ## "lux.tags"
(#Apply (#Product Text
- (#Product (#Apply Name List)
- (#Product Bit
- Type)))
+ (#Product Nat
+ (#Product (#Apply Name List)
+ (#Product Bit
+ Type))))
List)
- (#Product ## "lux.module-annotations"
- (#Apply Code Maybe)
- Module-State))
- ))))))
+ (#Product ## "lux.types"
+ (#Apply (#Product Text
+ (#Product (#Apply Name List)
+ (#Product Bit
+ Type)))
+ List)
+ (#Product ## "lux.module-annotations"
+ (#Apply Code Maybe)
+ Module-State))
+ )))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "module-hash")
(#Cons (text$ "module-aliases")
@@ -603,14 +626,15 @@
## #var-counter Nat
## #var-bindings (List [Nat (Maybe Type)])})
("lux def" Type-Context
- (#Named ["lux" "Type-Context"]
- (#Product ## ex-counter
- Nat
- (#Product ## var-counter
+ ("lux check type"
+ (#Named ["lux" "Type-Context"]
+ (#Product ## ex-counter
Nat
- ## var-bindings
- (#Apply (#Product Nat (#Apply Type Maybe))
- List))))
+ (#Product ## var-counter
+ Nat
+ ## var-bindings
+ (#Apply (#Product Nat (#Apply Type Maybe))
+ List)))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "ex-counter")
(#Cons (text$ "var-counter")
@@ -623,13 +647,14 @@
## #Eval
## #Interpreter)
("lux def" Mode
- (#Named ["lux" "Mode"]
- (#Sum ## Build
- Any
- (#Sum ## Eval
+ ("lux check type"
+ (#Named ["lux" "Mode"]
+ (#Sum ## Build
Any
- ## Interpreter
- Any)))
+ (#Sum ## Eval
+ Any
+ ## Interpreter
+ Any))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Build")
(#Cons (text$ "Eval")
@@ -644,15 +669,16 @@
## #version Text
## #mode Mode})
("lux def" Info
- (#Named ["lux" "Info"]
- (#Product
- ## target
- Text
+ ("lux check type"
+ (#Named ["lux" "Info"]
(#Product
- ## version
+ ## target
Text
- ## mode
- Mode)))
+ (#Product
+ ## version
+ Text
+ ## mode
+ Mode))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "target")
(#Cons (text$ "version")
@@ -676,31 +702,32 @@
## #extensions Any
## #host Any})
("lux def" Lux
- (#Named ["lux" "Lux"]
- (#Product ## "lux.info"
- Info
- (#Product ## "lux.source"
- Source
- (#Product ## "lux.cursor"
- Cursor
- (#Product ## "lux.current-module"
- (#Apply Text Maybe)
- (#Product ## "lux.modules"
- (#Apply (#Product Text Module) List)
- (#Product ## "lux.scopes"
- (#Apply Scope List)
- (#Product ## "lux.type-context"
- Type-Context
- (#Product ## "lux.expected"
- (#Apply Type Maybe)
- (#Product ## "lux.seed"
- Nat
- (#Product ## scope-type-vars
- (#Apply Nat List)
- (#Product ## extensions
- Any
- ## "lux.host"
- Any))))))))))))
+ ("lux check type"
+ (#Named ["lux" "Lux"]
+ (#Product ## "lux.info"
+ Info
+ (#Product ## "lux.source"
+ Source
+ (#Product ## "lux.cursor"
+ Cursor
+ (#Product ## "lux.current-module"
+ (#Apply Text Maybe)
+ (#Product ## "lux.modules"
+ (#Apply (#Product Text Module) List)
+ (#Product ## "lux.scopes"
+ (#Apply Scope List)
+ (#Product ## "lux.type-context"
+ Type-Context
+ (#Product ## "lux.expected"
+ (#Apply Type Maybe)
+ (#Product ## "lux.seed"
+ Nat
+ (#Product ## scope-type-vars
+ (#Apply Nat List)
+ (#Product ## extensions
+ Any
+ ## "lux.host"
+ Any)))))))))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "info")
(#Cons (text$ "source")
@@ -726,11 +753,12 @@
## (type: (Meta a)
## (-> Lux (Either Text [Lux a])))
("lux def" Meta
- (#Named ["lux" "Meta"]
- (#UnivQ #Nil
- (#Function Lux
- (#Apply (#Product Lux (#Parameter 1))
- (#Apply Text Either)))))
+ ("lux check type"
+ (#Named ["lux" "Meta"]
+ (#UnivQ #Nil
+ (#Function Lux
+ (#Apply (#Product Lux (#Parameter 1))
+ (#Apply Text Either))))))
(record$ (#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
("lux text concat" "Computations that can have access to the state of the compiler." __paragraph)
@@ -742,15 +770,17 @@
## (type: Macro'
## (-> (List Code) (Meta (List Code))))
("lux def" Macro'
- (#Named ["lux" "Macro'"]
- (#Function Code-List (#Apply Code-List Meta)))
+ ("lux check type"
+ (#Named ["lux" "Macro'"]
+ (#Function Code-List (#Apply Code-List Meta))))
(record$ default-def-meta-exported))
## (type: Macro
## (primitive "#Macro"))
("lux def" Macro
- (#Named ["lux" "Macro"]
- (#Primitive "#Macro" #Nil))
+ ("lux check type"
+ (#Named ["lux" "Macro"]
+ (#Primitive "#Macro" #Nil)))
(record$ (#Cons [(tag$ ["lux" "doc"])
(text$ "Functions that run at compile-time and allow you to transform and extend the language in powerful ways.")]
default-def-meta-exported)))
@@ -3980,9 +4010,10 @@
type-meta
meta))
Type
- (#.Named [(~ (text$ module-name))
- (~ (text$ name))]
- (type (~ type'')))))))
+ ("lux check type"
+ (#.Named [(~ (text$ module-name))
+ (~ (text$ name))]
+ (type (~ type''))))))))
#None
(fail "Wrong syntax for type:"))))
@@ -4872,18 +4903,18 @@
[(list) tokens]))]
current-module current-module-name
imports (parse-imports #0 current-module "" _imports)
- #let [=imports (list@map (: (-> Importation Code)
- (function (_ [m-name m-alias =refer])
- (` [(~ (text$ m-name)) (~ (text$ (default "" m-alias)))])))
- imports)
+ #let [=imports (|> imports
+ (list@map (: (-> Importation Code)
+ (function (_ [m-name m-alias =refer])
+ (` [(~ (text$ m-name)) (~ (text$ (default "" m-alias)))]))))
+ tuple$)
=refers (list@map (: (-> Importation Code)
(function (_ [m-name m-alias =refer])
(refer-to-code m-name m-alias =refer)))
imports)
- =meta (process-def-meta (list& [(` #.imports) (` [(~+ =imports)])]
- _meta))
=module (` ("lux def module" [(~ cursor-code)
- (#.Record (~ =meta))]))]]
+ (#.Record (~ (process-def-meta _meta)))]
+ (~ =imports)))]]
(wrap (#Cons =module =refers))))
(macro: #export (:: tokens)
diff --git a/stdlib/source/lux/control/parser/code.lux b/stdlib/source/lux/control/parser/code.lux
index 1e1287467..25009b447 100644
--- a/stdlib/source/lux/control/parser/code.lux
+++ b/stdlib/source/lux/control/parser/code.lux
@@ -166,8 +166,8 @@
(#error.Success [input value])
)))
-(def: #export (run inputs syntax)
- (All [a] (-> (List Code) (Parser a) (Error a)))
+(def: #export (run syntax inputs)
+ (All [a] (-> (Parser a) (List Code) (Error a)))
(case (syntax inputs)
(#error.Failure error)
(#error.Failure error)
@@ -187,5 +187,5 @@
(All [a] (-> (List Code) (Parser a) (Parser a)))
(function (_ real)
(do error.monad
- [value (run inputs syntax)]
+ [value (run syntax inputs)]
(wrap [real value]))))
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index 3b3d31341..1113868e8 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -452,7 +452,7 @@
(def: (parser->replacer p ast)
(-> (Parser Code) (-> Code Code))
- (case (p.run (list ast) p)
+ (case (p.run p (list ast))
(#.Right [#.Nil ast'])
ast'
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 0b0c59623..4277745f9 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -651,7 +651,13 @@
(fail ($_ text@compose "Cannot access tag: " (name@encode tag) " from module " this-module-name)))
_
- (fail ($_ text@compose "Unknown tag: " (name@encode tag))))))
+ (fail ($_ text@compose
+ "Unknown tag: " (name@encode tag) text.new-line
+ " Known tags: " (|> =module
+ (get@ #.tags)
+ (list@map (|>> product.left [module] name@encode (text.prefix text.new-line)))
+ (text.join-with ""))
+ )))))
(def: #export (tag-lists module)
{#.doc "All the tag-lists defined in a module, with their associated types."}
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index 52966ea0d..ede922cbc 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -93,13 +93,14 @@
(#.Left (~ g!error))
(#.Left ((~! text.join-with) ": " (list (~ error-msg) (~ g!error))))}
- ((~! </>.run) (~ g!tokens)
+ ((~! </>.run)
(: ((~! </>.Parser) (Meta (List Code)))
((~! do) (~! <>.monad)
[(~+ (join-pairs vars+parsers))]
((~' wrap) ((~! do) (~! //.monad)
[]
- (~ body)))))))))))))
+ (~ body)))))
+ (~ g!tokens)))))))))
_
(//.fail (//.wrong-syntax-error (name-of ..syntax:))))))
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
index e14a528b2..fadb92667 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
@@ -82,7 +82,7 @@
(-> Text Phase s (Operation Analysis))]
Handler))
(function (_ extension-name analyse args)
- (case (s.run args syntax)
+ (case (s.run syntax args)
(#error.Success inputs)
(handler extension-name analyse inputs)
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
index 7deb93696..99a8d1fe6 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
@@ -168,19 +168,16 @@
Handler
(function (_ extension-name phase inputsC+)
(case inputsC+
- (^ (list annotationsC))
+ (^ (list annotationsC importsC))
(do ///.monad
- [[_ annotationsT annotationsV] (evaluate! Code annotationsC)
- #let [annotationsV (:coerce Code annotationsV)]
- imports (case (s.run (list (|> annotationsV
- (macro.get-ann (name-of #.imports))
- (maybe.default (' []))))
- ..imports)
+ [imports (case (s.run ..imports (list importsC))
(#error.Success imports)
(wrap imports)
(#error.Failure error)
- (///.throw //.invalid-syntax [extension-name %code (list annotationsV)]))
+ (///.throw //.invalid-syntax [extension-name %code (list annotationsC importsC)]))
+ [_ annotationsT annotationsV] (evaluate! Code annotationsC)
+ #let [annotationsV (:coerce Code annotationsV)]
_ (////statement.lift-analysis
(do @
[_ (monad.map @ (function (_ [module alias])