diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux.lux | 7 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/extension/statement.lux | 24 |
2 files changed, 18 insertions, 13 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 2b99f51f8..549d63112 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -4841,12 +4841,7 @@ (wrap (list))) #let [defs (list;map (: (-> Text Code) (function (_ def) - (` ("lux def" (~ (identifier$ ["" def])) - (~ (identifier$ [module-name def])) - [(~ cursor-code) - (#.Record (#Cons [[(~ cursor-code) (#.Tag ["lux" "alias"])] - [(~ cursor-code) (#.Identifier [(~ (text$ module-name)) (~ (text$ def))])]] - #Nil))])))) + (` ("lux def alias" (~ (identifier$ ["" def])) (~ (identifier$ [module-name def])))))) defs') openings (join-map (: (-> Openings (List Code)) (function (_ [alias structs]) diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux index e36af0de6..e8910a3fb 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux @@ -11,6 +11,7 @@ ["." list ("#;." functor)] ["." dictionary]]] ["." macro + ["." code] ["s" syntax (#+ Syntax)]] [type (#+ :share :by-example) ["." check]]] @@ -145,12 +146,6 @@ _ (///.throw //.invalid-syntax [extension-name])))) -(def: (alias! alias def-name) - (-> Text Name (////analysis.Operation Any)) - (do ///.monad - [definition (//.lift (macro.find-def def-name))] - (module.define alias definition))) - (def: imports (Syntax (List Import)) (|> (s.tuple (p.and s.text s.text)) @@ -187,6 +182,21 @@ _ (///.throw //.invalid-syntax [extension-name])))) +## TODO: Reify aliasing as a feature of the compiler, instead of +## manifesting it implicitly through definition annotations. +(def: (alias-annotations original) + (-> Name Code) + (` {#.alias (~ (code.identifier original))})) + +(def: (define-alias alias original) + (-> Text Name (////analysis.Operation Any)) + (do ///.monad + [[original-type original-annotations original-value] + (//.lift (macro.find-def original))] + (module.define alias [original-type + (alias-annotations original) + original-value]))) + (def: def::alias Handler (function (_ extension-name phase inputsC+) @@ -196,7 +206,7 @@ [_ (//.lift (///.sub [(get@ [#////statement.analysis #////statement.state]) (set@ [#////statement.analysis #////statement.state])] - (alias! alias def-name)))] + (define-alias alias def-name)))] (wrap ////statement.no-requirements)) _ |