aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/macro.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/macro.lux18
1 files changed, 13 insertions, 5 deletions
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index b05b0682f..e5ac9a87a 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -202,7 +202,6 @@
(flag-set? (name-of <tag>)))]
[export? #.export? "exported"]
- [macro? #.macro? "a macro"]
[type? #.type? "a type"]
[structure? #.struct? "a structure"]
[recursive-type? #.type-rec? "a recursive type"]
@@ -247,13 +246,22 @@
[declared-tags #.tags "Looks up the tags of a tagged (variant or record) type."]
)
+(def: (macro-type? type)
+ (-> Type Bit)
+ (case type
+ (#.Named ["lux" "Macro"] (#.Primitive "#Macro" #.Nil))
+ true
+
+ _
+ false))
+
(def: (find-macro' modules this-module module name)
(-> (List [Text Module]) Text Text Text
(Maybe Macro))
(do maybe.monad
[$module (get module modules)
[def-type def-anns def-value] (: (Maybe Definition) (|> (: Module $module) (get@ #.definitions) (get name)))]
- (if (macro? def-anns)
+ (if (macro-type? def-type)
(#.Some (:coerce Macro def-value))
(case (get-identifier-ann (name-of #.alias) def-anns)
(#.Some [r-module r-name])
@@ -294,7 +302,7 @@
[?macro (find-macro name)]
(case ?macro
(#.Some macro)
- (macro args)
+ ((:coerce Macro' macro) args)
#.None
(:: ..monad wrap (list syntax))))
@@ -313,7 +321,7 @@
(case ?macro
(#.Some macro)
(do ..monad
- [expansion (macro args)
+ [expansion ((:coerce Macro' macro) args)
expansion' (monad.map ..monad expand expansion)]
(wrap (list@join expansion')))
@@ -333,7 +341,7 @@
(case ?macro
(#.Some macro)
(do ..monad
- [expansion (macro args)
+ [expansion ((:coerce Macro' macro) args)
expansion' (monad.map ..monad expand-all expansion)]
(wrap (list@join expansion')))