diff options
Diffstat (limited to '')
54 files changed, 702 insertions, 703 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index c93e834db..e31e96e7c 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -759,10 +759,10 @@ Caveat emptor: Avoid fiddling with it, unless you know what you're doing.")] default-def-meta-exported)))) -## (type: (Lux a) +## (type: (Meta a) ## (-> Compiler (Either Text [Compiler a]))) -(_lux_def Lux - (#Named ["lux" "Lux"] +(_lux_def Meta + (#Named ["lux" "Meta"] (#UnivQ #Nil (#Function Compiler (#Apply (#Product Compiler (#Bound +1)) @@ -776,10 +776,10 @@ default-def-meta-exported)))) ## (type: Macro -## (-> (List Code) (Lux (List Code)))) +## (-> (List Code) (Meta (List Code)))) (_lux_def Macro (#Named ["lux" "Macro"] - (#Function Code-List (#Apply Code-List Lux))) + (#Function Code-List (#Apply Code-List Meta))) (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))) @@ -1164,10 +1164,10 @@ (def:'' (parse-quantified-args args next) #;Nil - ## (-> (List Code) (-> (List Text) (Lux (List Code))) (Lux (List Code))) + ## (-> (List Code) (-> (List Text) (Meta (List Code))) (Meta (List Code))) (#Function ($' List Code) - (#Function (#Function ($' List Text) (#Apply ($' List Code) Lux)) - (#Apply ($' List Code) Lux) + (#Function (#Function ($' List Text) (#Apply ($' List Code) Meta)) + (#Apply ($' List Code) Meta) )) (_lux_case args #Nil @@ -1646,9 +1646,9 @@ #None #None (#Some a) (f a)))}) -(def:''' Monad<Lux> +(def:''' Monad<Meta> #Nil - ($' Monad Lux) + ($' Monad Meta) {#wrap (function' [x] (function' [state] @@ -1805,7 +1805,7 @@ (def:''' (resolve-global-symbol ident state) #Nil - (-> Ident ($' Lux Ident)) + (-> Ident ($' Meta Ident)) (let' [[module name] ident {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -1830,22 +1830,22 @@ (def:''' (splice replace? untemplate tag elems) #Nil - (-> Bool (-> Code ($' Lux Code)) Code ($' List Code) ($' Lux Code)) + (-> Bool (-> Code ($' Meta Code)) Code ($' List Code) ($' Meta Code)) (_lux_case replace? true (_lux_case (any? spliced? elems) true - (do Monad<Lux> - [elems' (_lux_: ($' Lux ($' List Code)) - (mapM Monad<Lux> - (_lux_: (-> Code ($' Lux Code)) + (do Monad<Meta> + [elems' (_lux_: ($' Meta ($' List Code)) + (mapM Monad<Meta> + (_lux_: (-> Code ($' Meta Code)) (function' [elem] (_lux_case elem [_ (#Form (#Cons [[_ (#Symbol ["" "~@"])] (#Cons [spliced #Nil])]))] (wrap spliced) _ - (do Monad<Lux> + (do Monad<Meta> [=elem (untemplate elem)] (wrap (form$ (list (symbol$ ["" "_lux_:"]) (form$ (list (tag$ ["lux" "Apply"]) (tuple$ (list (symbol$ ["lux" "Code"]) (symbol$ ["lux" "List"]))))) @@ -1857,17 +1857,17 @@ elems'))))))) false - (do Monad<Lux> - [=elems (mapM Monad<Lux> untemplate elems)] + (do Monad<Meta> + [=elems (mapM Monad<Meta> untemplate elems)] (wrap (wrap-meta (form$ (list tag (untemplate-list =elems))))))) false - (do Monad<Lux> - [=elems (mapM Monad<Lux> untemplate elems)] + (do Monad<Meta> + [=elems (mapM Monad<Meta> untemplate elems)] (wrap (wrap-meta (form$ (list tag (untemplate-list =elems)))))))) (def:''' (untemplate replace? subst token) #Nil - (-> Bool Text Code ($' Lux Code)) + (-> Bool Text Code ($' Meta Code)) (_lux_case [replace? token] [_ [_ (#Bool value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Bool"]) (bool$ value))))) @@ -1900,7 +1900,7 @@ (return (wrap-meta (form$ (list (tag$ ["lux" "Tag"]) (tuple$ (list (text$ module') (text$ name)))))))) [true [_ (#Symbol [module name])]] - (do Monad<Lux> + (do Monad<Meta> [real-name (_lux_case module "" (if (text/= "" subst) @@ -1925,18 +1925,18 @@ (untemplate false subst keep-quoted) [_ [meta (#Form elems)]] - (do Monad<Lux> + (do Monad<Meta> [output (splice replace? (untemplate replace? subst) (tag$ ["lux" "Form"]) elems) #let [[_ form'] output]] (return [meta form'])) [_ [_ (#Record fields)]] - (do Monad<Lux> - [=fields (mapM Monad<Lux> - (_lux_: (-> (& Code Code) ($' Lux Code)) + (do Monad<Meta> + [=fields (mapM Monad<Meta> + (_lux_: (-> (& Code Code) ($' Meta Code)) (function' [kv] (let' [[k v] kv] - (do Monad<Lux> + (do Monad<Meta> [=k (untemplate replace? subst k) =v (untemplate replace? subst v)] (wrap (tuple$ (list =k =v))))))) @@ -1962,7 +1962,7 @@ (def:'' (current-module-name state) #Nil - ($' Lux Text) + ($' Meta Text) (_lux_case state {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -1985,7 +1985,7 @@ (~ body))))")]) (_lux_case tokens (#Cons template #Nil) - (do Monad<Lux> + (do Monad<Meta> [current-module current-module-name =template (untemplate true current-module template)] (wrap (list (form$ (list (symbol$ ["" "_lux_:"]) (symbol$ ["lux" "Code"]) =template))))) @@ -2001,7 +2001,7 @@ (~ body))))")]) (_lux_case tokens (#Cons template #Nil) - (do Monad<Lux> + (do Monad<Meta> [=template (untemplate true "" template)] (wrap (list (form$ (list (symbol$ ["" "_lux_:"]) (symbol$ ["lux" "Code"]) =template))))) @@ -2014,7 +2014,7 @@ (' \"YOLO\")")]) (_lux_case tokens (#Cons template #Nil) - (do Monad<Lux> + (do Monad<Meta> [=template (untemplate false "" template)] (wrap (list (form$ (list (symbol$ ["" "_lux_:"]) (symbol$ ["lux" "Code"]) =template))))) @@ -2416,10 +2416,10 @@ (def:''' (normalize ident) #Nil - (-> Ident ($' Lux Ident)) + (-> Ident ($' Meta Ident)) (_lux_case ident ["" name] - (do Monad<Lux> + (do Monad<Meta> [module-name current-module-name] (wrap [module-name name])) @@ -2428,8 +2428,8 @@ (def:''' (find-macro ident) #Nil - (-> Ident ($' Lux ($' Maybe Macro))) - (do Monad<Lux> + (-> Ident ($' Meta ($' Maybe Macro))) + (do Monad<Meta> [current-module current-module-name] (let' [[module name] ident] (function' [state] @@ -2443,8 +2443,8 @@ (def:''' (macro? ident) #Nil - (-> Ident ($' Lux Bool)) - (do Monad<Lux> + (-> Ident ($' Meta Bool)) + (do Monad<Meta> [ident (normalize ident) output (find-macro ident)] (wrap (_lux_case output @@ -2473,10 +2473,10 @@ (def:''' (macro-expand-once token) #Nil - (-> Code ($' Lux ($' List Code))) + (-> Code ($' Meta ($' List Code))) (_lux_case token [_ (#Form (#Cons [_ (#Symbol macro-name)] args))] - (do Monad<Lux> + (do Monad<Meta> [macro-name' (normalize macro-name) ?macro (find-macro macro-name')] (_lux_case ?macro @@ -2491,17 +2491,17 @@ (def:''' (macro-expand token) #Nil - (-> Code ($' Lux ($' List Code))) + (-> Code ($' Meta ($' List Code))) (_lux_case token [_ (#Form (#Cons [_ (#Symbol macro-name)] args))] - (do Monad<Lux> + (do Monad<Meta> [macro-name' (normalize macro-name) ?macro (find-macro macro-name')] (_lux_case ?macro (#Some macro) - (do Monad<Lux> + (do Monad<Meta> [expansion (macro args) - expansion' (mapM Monad<Lux> macro-expand expansion)] + expansion' (mapM Monad<Meta> macro-expand expansion)] (wrap (list/join expansion'))) #None @@ -2512,40 +2512,40 @@ (def:''' (macro-expand-all syntax) #Nil - (-> Code ($' Lux ($' List Code))) + (-> Code ($' Meta ($' List Code))) (_lux_case syntax [_ (#Form (#Cons [_ (#Symbol macro-name)] args))] - (do Monad<Lux> + (do Monad<Meta> [macro-name' (normalize macro-name) ?macro (find-macro macro-name')] (_lux_case ?macro (#Some macro) - (do Monad<Lux> + (do Monad<Meta> [expansion (macro args) - expansion' (mapM Monad<Lux> macro-expand-all expansion)] + expansion' (mapM Monad<Meta> macro-expand-all expansion)] (wrap (list/join expansion'))) #None - (do Monad<Lux> - [args' (mapM Monad<Lux> macro-expand-all args)] + (do Monad<Meta> + [args' (mapM Monad<Meta> macro-expand-all args)] (wrap (list (form$ (#Cons (symbol$ macro-name) (list/join args')))))))) [_ (#Form members)] - (do Monad<Lux> - [members' (mapM Monad<Lux> macro-expand-all members)] + (do Monad<Meta> + [members' (mapM Monad<Meta> macro-expand-all members)] (wrap (list (form$ (list/join members'))))) [_ (#Tuple members)] - (do Monad<Lux> - [members' (mapM Monad<Lux> macro-expand-all members)] + (do Monad<Meta> + [members' (mapM Monad<Meta> macro-expand-all members)] (wrap (list (tuple$ (list/join members'))))) [_ (#Record pairs)] - (do Monad<Lux> - [pairs' (mapM Monad<Lux> + (do Monad<Meta> + [pairs' (mapM Monad<Meta> (function' [kv] (let' [[key val] kv] - (do Monad<Lux> + (do Monad<Meta> [val' (macro-expand-all val)] (_lux_case val' (#;Cons val'' #;Nil) @@ -2584,7 +2584,7 @@ (type (All [a] (Maybe (List a))))")]) (_lux_case tokens (#Cons type #Nil) - (do Monad<Lux> + (do Monad<Meta> [type+ (macro-expand-all type)] (_lux_case type+ (#Cons type' #Nil) @@ -2636,12 +2636,12 @@ (def:''' (unfold-type-def type-codes) #Nil - (-> ($' List Code) ($' Lux (& Code ($' Maybe ($' List Text))))) + (-> ($' List Code) ($' Meta (& Code ($' Maybe ($' List Text))))) (_lux_case type-codes (#Cons [_ (#Record pairs)] #;Nil) - (do Monad<Lux> - [members (mapM Monad<Lux> - (: (-> [Code Code] (Lux [Text Code])) + (do Monad<Meta> + [members (mapM Monad<Meta> + (: (-> [Code Code] (Meta [Text Code])) (function' [pair] (_lux_case pair [[_ (#Tag "" member-name)] member-type] @@ -2665,9 +2665,9 @@ (return [type #None])) (#Cons case cases) - (do Monad<Lux> - [members (mapM Monad<Lux> - (: (-> Code (Lux [Text Code])) + (do Monad<Meta> + [members (mapM Monad<Meta> + (: (-> Code (Meta [Text Code])) (function' [case] (_lux_case case [_ (#Tag "" member-name)] @@ -2690,7 +2690,7 @@ (def:''' (gensym prefix state) #Nil - (-> Text ($' Lux Code)) + (-> Text ($' Meta Code)) (_lux_case state {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -2843,30 +2843,30 @@ )) (def:' (expander branches) - (-> (List Code) (Lux (List Code))) + (-> (List Code) (Meta (List Code))) (_lux_case branches (#;Cons [_ (#Form (#Cons [_ (#Symbol macro-name)] macro-args))] (#;Cons body branches')) - (do Monad<Lux> + (do Monad<Meta> [??? (macro? macro-name)] (if ??? - (do Monad<Lux> + (do Monad<Meta> [init-expansion (macro-expand-once (form$ (list& (symbol$ macro-name) (form$ macro-args) body branches')))] (expander init-expansion)) - (do Monad<Lux> + (do Monad<Meta> [sub-expansion (expander branches')] (wrap (list& (form$ (list& (symbol$ macro-name) macro-args)) body sub-expansion))))) (#;Cons pattern (#;Cons body branches')) - (do Monad<Lux> + (do Monad<Meta> [sub-expansion (expander branches')] (wrap (list& pattern body sub-expansion))) #;Nil - (do Monad<Lux> [] (wrap (list))) + (do Monad<Meta> [] (wrap (list))) _ (fail ($_ text/compose "\"lux;case\" expects an even number of tokens: " (|> branches @@ -2887,7 +2887,7 @@ #None)")]) (_lux_case tokens (#Cons value branches) - (do Monad<Lux> + (do Monad<Meta> [expansion (expander branches)] (wrap (list (` (;_lux_case (~ value) (~@ expansion)))))) @@ -2906,7 +2906,7 @@ #None)")]) (case tokens (#Cons [_ (#Form (#Cons pattern #Nil))] (#Cons body branches)) - (do Monad<Lux> + (do Monad<Meta> [pattern+ (macro-expand-all pattern)] (case pattern+ (#Cons pattern' #Nil) @@ -3297,12 +3297,12 @@ #None))] (case ?parts (#Some name args meta sigs) - (do Monad<Lux> + (do Monad<Meta> [name+ (normalize name) - sigs' (mapM Monad<Lux> macro-expand sigs) - members (: (Lux (List [Text Code])) - (mapM Monad<Lux> - (: (-> Code (Lux [Text Code])) + sigs' (mapM Monad<Meta> macro-expand sigs) + members (: (Meta (List [Text Code])) + (mapM Monad<Meta> + (: (-> Code (Meta [Text Code])) (function [token] (case token (^ [_ (#Form (list [_ (#Symbol _ "_lux_:")] type [_ (#Symbol ["" name])]))]) @@ -3554,7 +3554,7 @@ (#Some (list type)))) (def: (find-module name) - (-> Text (Lux Module)) + (-> Text (Meta Module)) (function [state] (let [{#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -3568,14 +3568,14 @@ (#Left ($_ text/compose "Unknown module: " name)))))) (def: get-current-module - (Lux Module) - (do Monad<Lux> + (Meta Module) + (do Monad<Meta> [module-name current-module-name] (find-module module-name))) (def: (resolve-tag [module name]) - (-> Ident (Lux [Nat (List Ident) Bool Type])) - (do Monad<Lux> + (-> Ident (Meta [Nat (List Ident) Bool Type])) + (do Monad<Meta> [=module (find-module module) #let [{#module-hash _ #module-aliases _ #defs bindings #imports _ #tags tags-table #types types #module-annotations _ #module-state _} =module]] (case (get name tags-table) @@ -3586,7 +3586,7 @@ (fail (text/compose "Unknown tag: " (ident/encode [module name])))))) (def: (resolve-type-tags type) - (-> Type (Lux (Maybe [(List Ident) (List Type)]))) + (-> Type (Meta (Maybe [(List Ident) (List Type)]))) (case type (#Apply arg func) (resolve-type-tags func) @@ -3598,7 +3598,7 @@ (resolve-type-tags body) (#Named [module name] unnamed) - (do Monad<Lux> + (do Monad<Meta> [=module (find-module module) #let [{#module-hash _ #module-aliases _ #defs bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} =module]] (case (get name types) @@ -3617,7 +3617,7 @@ (return #None))) (def: get-expected-type - (Lux Type) + (Meta Type) (function [state] (let [{#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -3632,11 +3632,11 @@ (macro: #export (struct tokens) {#;doc "Not meant to be used directly. Prefer \"struct:\"."} - (do Monad<Lux> - [tokens' (mapM Monad<Lux> macro-expand tokens) + (do Monad<Meta> + [tokens' (mapM Monad<Meta> macro-expand tokens) struct-type get-expected-type tags+type (resolve-type-tags struct-type) - tags (: (Lux (List Ident)) + tags (: (Meta (List Ident)) (case tags+type (#Some [tags _]) (return tags) @@ -3646,8 +3646,8 @@ #let [tag-mappings (: (List [Text Code]) (map (function [tag] [(second tag) (tag$ tag)]) tags))] - members (mapM Monad<Lux> - (: (-> Code (Lux [Code Code])) + members (mapM Monad<Meta> + (: (-> Code (Meta [Code Code])) (function [token] (case token (^ [_ (#Form (list [_ (#Symbol _ "_lux_def")] [_ (#Symbol "" tag-name)] value meta))]) @@ -3804,7 +3804,7 @@ #None))] (case parts (#Some name args meta type-codes) - (do Monad<Lux> + (do Monad<Meta> [type+tags?? (unfold-type-def type-codes) module-name current-module-name] (let [type-name (symbol$ ["" name]) @@ -3870,9 +3870,9 @@ #import-refer Refer}) (def: (extract-defs defs) - (-> (List Code) (Lux (List Text))) - (mapM Monad<Lux> - (: (-> Code (Lux Text)) + (-> (List Code) (Meta (List Text))) + (mapM Monad<Meta> + (: (-> Code (Meta Text)) (function [def] (case def [_ (#Symbol ["" name])] @@ -3883,7 +3883,7 @@ defs)) (def: (parse-alias tokens) - (-> (List Code) (Lux [(Maybe Text) (List Code)])) + (-> (List Code) (Meta [(Maybe Text) (List Code)])) (case tokens (^ (list& [_ (#Tag "" "as")] [_ (#Symbol "" alias)] tokens')) (return [(#Some alias) tokens']) @@ -3892,7 +3892,7 @@ (return [#None tokens]))) (def: (parse-referrals tokens) - (-> (List Code) (Lux [Referrals (List Code)])) + (-> (List Code) (Meta [Referrals (List Code)])) (case tokens (^ (list& [_ (#Tag ["" "refer"])] referral tokens')) (case referral @@ -3900,12 +3900,12 @@ (return [#All tokens']) (^ [_ (#Form (list& [_ (#Tag ["" "only"])] defs))]) - (do Monad<Lux> + (do Monad<Meta> [defs' (extract-defs defs)] (return [(#Only defs') tokens'])) (^ [_ (#Form (list& [_ (#Tag ["" "exclude"])] defs))]) - (do Monad<Lux> + (do Monad<Meta> [defs' (extract-defs defs)] (return [(#Exclude defs') tokens'])) @@ -3934,17 +3934,17 @@ [(reverse ys') xs'])) (def: (parse-short-referrals tokens) - (-> (List Code) (Lux [Referrals (List Code)])) + (-> (List Code) (Meta [Referrals (List Code)])) (case tokens (^ (list& [_ (#Tag "" "+")] tokens')) (let [[defs tokens'] (split-with symbol? tokens')] - (do Monad<Lux> + (do Monad<Meta> [defs' (extract-defs defs)] (return [(#Only defs') tokens']))) (^ (list& [_ (#Tag "" "-")] tokens')) (let [[defs tokens'] (split-with symbol? tokens')] - (do Monad<Lux> + (do Monad<Meta> [defs' (extract-defs defs)] (return [(#Exclude defs') tokens']))) @@ -3955,7 +3955,7 @@ (return [#Nothing tokens]))) (def: (extract-symbol syntax) - (-> Code (Lux Ident)) + (-> Code (Meta Ident)) (case syntax [_ (#Symbol ident)] (return ident) @@ -3964,7 +3964,7 @@ (fail "Not a symbol."))) (def: (parse-openings tokens) - (-> (List Code) (Lux [(List Openings) (List Code)])) + (-> (List Code) (Meta [(List Openings) (List Code)])) (case tokens (^ (list& [_ (#Tag "" "open")] [_ (#Form parts)] tokens')) (if (|> parts @@ -4002,7 +4002,7 @@ (return [(list) tokens]))) (def: (parse-short-openings parts) - (-> (List Code) (Lux [(List Openings) (List Code)])) + (-> (List Code) (Meta [(List Openings) (List Code)])) (if (|> parts (map (: (-> Code Bool) (function [part] @@ -4052,8 +4052,8 @@ (_lux_proc ["text" "replace-all"] [template pattern value])) (def: (clean-module module) - (-> Text (Lux Text)) - (do Monad<Lux> + (-> Text (Meta Text)) + (do Monad<Meta> [current-module current-module-name] (case (split-module module) (^ (list& "." parts)) @@ -4074,20 +4074,20 @@ )) (def: (parse-imports imports) - (-> (List Code) (Lux (List Importation))) - (do Monad<Lux> - [imports' (mapM Monad<Lux> - (: (-> Code (Lux (List Importation))) + (-> (List Code) (Meta (List Importation))) + (do Monad<Meta> + [imports' (mapM Monad<Meta> + (: (-> Code (Meta (List Importation))) (function [token] (case token [_ (#Symbol "" m-name)] - (do Monad<Lux> + (do Monad<Meta> [m-name (clean-module m-name)] (wrap (list [m-name #None {#refer-defs #All #refer-open (list)}]))) (^ [_ (#Form (list& [_ (#Symbol "" m-name)] extra))]) - (do Monad<Lux> + (do Monad<Meta> [m-name (clean-module m-name) alias+extra (parse-alias extra) #let [[alias extra] alias+extra] @@ -4106,7 +4106,7 @@ sub-imports)))) (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Symbol "" m-name)] extra))]) - (do Monad<Lux> + (do Monad<Meta> [m-name (clean-module m-name) referral+extra (parse-short-referrals extra) #let [[referral extra] referral+extra] @@ -4118,7 +4118,7 @@ #refer-open openings}}))) (^ [_ (#Tuple (list& [_ (#Symbol "" raw-m-name)] extra))]) - (do Monad<Lux> + (do Monad<Meta> [m-name (clean-module raw-m-name) referral+extra (parse-short-referrals extra) #let [[referral extra] referral+extra] @@ -4130,14 +4130,14 @@ #refer-open openings}}))) _ - (do Monad<Lux> + (do Monad<Meta> [current-module current-module-name] (fail (text/compose "Wrong syntax for import @ " current-module)))))) imports)] (wrap (list/join imports')))) (def: (exported-defs module state) - (-> Text (Lux (List Text))) + (-> Text (Meta (List Text))) (let [modules (case state {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -4234,7 +4234,7 @@ (#Some def-type))))) (def: (find-def-value name state) - (-> Ident (Lux [Type Top])) + (-> Ident (Meta [Type Top])) (let [[v-prefix v-name] name {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -4253,8 +4253,8 @@ (#Right [state [def-type def-value]]))))) (def: (find-type ident) - (-> Ident (Lux Type)) - (do Monad<Lux> + (-> Ident (Meta Type)) + (do Monad<Meta> [#let [[module name] ident] current-module current-module-name] (function [state] @@ -4361,7 +4361,7 @@ (macro: #hidden (^open' tokens) (case tokens (^ (list [_ (#Symbol name)] [_ (#Text prefix)] body)) - (do Monad<Lux> + (do Monad<Meta> [init-type (find-type name) struct-evidence (resolve-type-tags init-type)] (case struct-evidence @@ -4369,17 +4369,17 @@ (fail (text/compose "Can only \"open\" structs: " (Type/show init-type))) (#;Some tags&members) - (do Monad<Lux> - [full-body ((: (-> Ident [(List Ident) (List Type)] Code (Lux Code)) + (do Monad<Meta> + [full-body ((: (-> Ident [(List Ident) (List Type)] Code (Meta Code)) (function recur [source [tags members] target] (let [pattern (record$ (map (function [[t-module t-name]] [(tag$ [t-module t-name]) (symbol$ ["" (text/compose prefix t-name)])]) tags))] - (do Monad<Lux> - [enhanced-target (foldM Monad<Lux> + (do Monad<Meta> + [enhanced-target (foldM Monad<Meta> (function [[[_ m-name] m-type] enhanced-target] - (do Monad<Lux> + (do Monad<Meta> [m-structure (resolve-type-tags m-type)] (case m-structure (#;Some m-tags&members) @@ -4406,7 +4406,7 @@ (range' <= succ from to))"} (case tokens (^ (list& [_ (#Form (list [_ (#Text prefix)]))] body branches)) - (do Monad<Lux> + (do Monad<Meta> [g!temp (gensym "temp")] (return (list& g!temp (` (^open' (~ g!temp) (~ (text$ prefix)) (~ body))) branches))) @@ -4462,7 +4462,7 @@ (getter my-record))"} (case tokens (^ (list [_ (#Tag slot')] record)) - (do Monad<Lux> + (do Monad<Meta> [slot (normalize slot') output (resolve-tag slot) #let [[idx tags exported? type] output] @@ -4489,7 +4489,7 @@ slots))) (^ (list selector)) - (do Monad<Lux> + (do Monad<Meta> [g!record (gensym "record")] (wrap (list (` (function [(~ g!record)] (;;get@ (~ selector) (~ g!record))))))) @@ -4497,15 +4497,15 @@ (fail "Wrong syntax for get@"))) (def: (open-field prefix [module name] source type) - (-> Text Ident Code Type (Lux (List Code))) - (do Monad<Lux> + (-> Text Ident Code Type (Meta (List Code))) + (do Monad<Meta> [output (resolve-type-tags type) #let [source+ (` (get@ (~ (tag$ [module name])) (~ source)))]] (case output (#Some [tags members]) - (do Monad<Lux> - [decls' (mapM Monad<Lux> - (: (-> [Ident Type] (Lux (List Code))) + (do Monad<Meta> + [decls' (mapM Monad<Meta> + (: (-> [Ident Type] (Meta (List Code))) (function [[sname stype]] (open-field prefix sname source+ stype))) (zip2 tags members))] (return (list/join decls'))) @@ -4525,7 +4525,7 @@ ..."} (case tokens (^ (list& [_ (#Symbol struct-name)] tokens')) - (do Monad<Lux> + (do Monad<Meta> [@module current-module-name #let [prefix (case tokens' (^ (list [_ (#Text prefix)])) @@ -4538,9 +4538,9 @@ #let [source (symbol$ struct-name)]] (case output (#Some [tags members]) - (do Monad<Lux> - [decls' (mapM Monad<Lux> (: (-> [Ident Type] (Lux (List Code))) - (function [[sname stype]] (open-field prefix sname source stype))) + (do Monad<Meta> + [decls' (mapM Monad<Meta> (: (-> [Ident Type] (Meta (List Code))) + (function [[sname stype]] (open-field prefix sname source stype))) (zip2 tags members))] (return (list/join decls'))) @@ -4558,7 +4558,7 @@ (fold text/compose \"\" (interpose \" \" (map int/encode <arg>))))"} - (do Monad<Lux> + (do Monad<Meta> [g!arg (gensym "arg")] (return (list (` (function [(~ g!arg)] (|> (~ g!arg) (~@ tokens)))))))) @@ -4570,29 +4570,29 @@ (fold text/compose \"\" (interpose \" \" (map int/encode <arg>))))"} - (do Monad<Lux> + (do Monad<Meta> [g!arg (gensym "arg")] (return (list (` (function [(~ g!arg)] (<| (~@ tokens) (~ g!arg)))))))) (def: (imported-by? import-name module-name) - (-> Text Text (Lux Bool)) - (do Monad<Lux> + (-> Text Text (Meta Bool)) + (do Monad<Meta> [module (find-module module-name) #let [{#module-hash _ #module-aliases _ #defs _ #imports imports #tags _ #types _ #module-annotations _ #module-state _} module]] (wrap (is-member? imports import-name)))) (def: (read-refer module-name options) - (-> Text (List Code) (Lux Refer)) - (do Monad<Lux> + (-> Text (List Code) (Meta Refer)) + (do Monad<Meta> [referral+options (parse-referrals options) #let [[referral options] referral+options] openings+options (parse-openings options) #let [[openings options] openings+options] current-module current-module-name - #let [test-referrals (: (-> Text (List Text) (List Text) (Lux (List Unit))) + #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit))) (function [module-name all-defs referred-defs] - (mapM Monad<Lux> - (: (-> Text (Lux Unit)) + (mapM Monad<Meta> + (: (-> Text (Meta Unit)) (function [_def] (if (is-member? all-defs _def) (return []) @@ -4611,13 +4611,13 @@ (fold text/compose ""))))))) (def: (write-refer module-name [r-defs r-opens]) - (-> Text Refer (Lux (List Code))) - (do Monad<Lux> + (-> Text Refer (Meta (List Code))) + (do Monad<Meta> [current-module current-module-name - #let [test-referrals (: (-> Text (List Text) (List Text) (Lux (List Unit))) + #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit))) (function [module-name all-defs referred-defs] - (mapM Monad<Lux> - (: (-> Text (Lux Unit)) + (mapM Monad<Meta> + (: (-> Text (Meta Unit)) (function [_def] (if (is-member? all-defs _def) (return []) @@ -4628,13 +4628,13 @@ (exported-defs module-name) (#Only +defs) - (do Monad<Lux> + (do Monad<Meta> [*defs (exported-defs module-name) _ (test-referrals module-name *defs +defs)] (wrap +defs)) (#Exclude -defs) - (do Monad<Lux> + (do Monad<Meta> [*defs (exported-defs module-name) _ (test-referrals module-name *defs -defs)] (wrap (filter (|>. (is-member? -defs) not) *defs))) @@ -4661,7 +4661,7 @@ (macro: #hidden (refer tokens) (case tokens (^ (list& [_ (#Text module-name)] options)) - (do Monad<Lux> + (do Monad<Meta> [=refer (read-refer module-name options)] (write-refer module-name =refer)) @@ -4719,7 +4719,7 @@ meta (macro code)) (.. [type \"\" Eq<Type>]))"} - (do Monad<Lux> + (do Monad<Meta> [#let [[_meta _imports] (: [(List [Code Code]) (List Code)] (case tokens (^ (list& [_ (#Record _meta)] _imports)) @@ -4774,17 +4774,17 @@ (setter value my-record))"} (case tokens (^ (list [_ (#Tag slot')] value record)) - (do Monad<Lux> + (do Monad<Meta> [slot (normalize slot') output (resolve-tag slot) #let [[idx tags exported? type] output]] (case (resolve-struct-type type) (#Some members) - (do Monad<Lux> - [pattern' (mapM Monad<Lux> - (: (-> [Ident [Nat Type]] (Lux [Ident Nat Code])) + (do Monad<Meta> + [pattern' (mapM Monad<Meta> + (: (-> [Ident [Nat Type]] (Meta [Ident Nat Code])) (function [[r-slot-name [r-idx r-type]]] - (do Monad<Lux> + (do Monad<Meta> [g!slot (gensym "")] (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] @@ -4809,9 +4809,9 @@ (fail "Wrong syntax for set@") _ - (do Monad<Lux> - [bindings (mapM Monad<Lux> - (: (-> Code (Lux Code)) + (do Monad<Meta> + [bindings (mapM Monad<Meta> + (: (-> Code (Meta Code)) (function [_] (gensym "temp"))) slots) #let [pairs (zip2 slots bindings) @@ -4831,12 +4831,12 @@ (~ update-expr))))))) (^ (list selector value)) - (do Monad<Lux> + (do Monad<Meta> [g!record (gensym "record")] (wrap (list (` (function [(~ g!record)] (;;set@ (~ selector) (~ value) (~ g!record))))))) (^ (list selector)) - (do Monad<Lux> + (do Monad<Meta> [g!value (gensym "value") g!record (gensym "record")] (wrap (list (` (function [(~ g!value) (~ g!record)] (;;set@ (~ selector) (~ g!value) (~ g!record))))))) @@ -4860,17 +4860,17 @@ (updater func my-record))"} (case tokens (^ (list [_ (#Tag slot')] fun record)) - (do Monad<Lux> + (do Monad<Meta> [slot (normalize slot') output (resolve-tag slot) #let [[idx tags exported? type] output]] (case (resolve-struct-type type) (#Some members) - (do Monad<Lux> - [pattern' (mapM Monad<Lux> - (: (-> [Ident [Nat Type]] (Lux [Ident Nat Code])) + (do Monad<Meta> + [pattern' (mapM Monad<Meta> + (: (-> [Ident [Nat Type]] (Meta [Ident Nat Code])) (function [[r-slot-name [r-idx r-type]]] - (do Monad<Lux> + (do Monad<Meta> [g!slot (gensym "")] (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] @@ -4895,7 +4895,7 @@ (fail "Wrong syntax for update@") _ - (do Monad<Lux> + (do Monad<Meta> [g!record (gensym "record") g!temp (gensym "temp")] (wrap (list (` (let [(~ g!record) (~ record) @@ -4903,12 +4903,12 @@ (set@ [(~@ slots)] ((~ fun) (~ g!temp)) (~ g!record)))))))) (^ (list selector fun)) - (do Monad<Lux> + (do Monad<Meta> [g!record (gensym "record")] (wrap (list (` (function [(~ g!record)] (;;update@ (~ selector) (~ fun) (~ g!record))))))) (^ (list selector)) - (do Monad<Lux> + (do Monad<Meta> [g!fun (gensym "fun") g!record (gensym "record")] (wrap (list (` (function [(~ g!fun) (~ g!record)] (;;update@ (~ selector) (~ g!fun) (~ g!record))))))) @@ -5246,21 +5246,21 @@ vars (map first pairs) inits (map second pairs)] (if (every? symbol? inits) - (do Monad<Lux> - [inits' (: (Lux (List Ident)) + (do Monad<Meta> + [inits' (: (Meta (List Ident)) (case (mapM Monad<Maybe> get-ident inits) (#Some inits') (return inits') #None (fail "Wrong syntax for loop"))) - init-types (mapM Monad<Lux> find-type inits') + init-types (mapM Monad<Meta> find-type inits') expected get-expected-type] (return (list (` ((;_lux_: (-> (~@ (map type-to-code init-types)) (~ (type-to-code expected))) (function (~ (symbol$ ["" "recur"])) [(~@ vars)] (~ body))) (~@ inits)))))) - (do Monad<Lux> - [aliases (mapM Monad<Lux> - (: (-> Code (Lux Code)) + (do Monad<Meta> + [aliases (mapM Monad<Meta> + (: (-> Code (Meta Code)) (function [_] (gensym ""))) inits)] (return (list (` (let [(~@ (interleave aliases inits))] @@ -5277,8 +5277,8 @@ (f foo bar baz)))} (case tokens (^ (list& [_ (#Form (list [_ (#Tuple (list& hslot' tslots'))]))] body branches)) - (do Monad<Lux> - [slots (: (Lux [Ident (List Ident)]) + (do Monad<Meta> + [slots (: (Meta [Ident (List Ident)]) (case (: (Maybe [Ident (List Ident)]) (do Monad<Maybe> [hslot (get-tag hslot') @@ -5291,7 +5291,7 @@ (fail "Wrong syntax for ^slots"))) #let [[hslot tslots] slots] hslot (normalize hslot) - tslots (mapM Monad<Lux> normalize tslots) + tslots (mapM Monad<Meta> normalize tslots) output (resolve-tag hslot) g!_ (gensym "_") #let [[idx tags exported? type] output @@ -5377,7 +5377,7 @@ (^ (list& [_ (#Tuple bindings)] bodies)) (case bindings (^ (list& [_ (#Symbol ["" var-name])] macro-expr bindings')) - (do Monad<Lux> + (do Monad<Meta> [expansion (macro-expand-once macro-expr)] (case (place-tokens var-name expansion (` (;with-expansions [(~@ bindings')] @@ -5417,8 +5417,8 @@ type)) (def: (anti-quote-def name) - (-> Ident (Lux Code)) - (do Monad<Lux> + (-> Ident (Meta Code)) + (do Monad<Meta> [type+value (find-def-value name) #let [[type value] type+value]] (case (flatten-alias type) @@ -5436,34 +5436,34 @@ (fail (text/compose "Cannot anti-quote type: " (ident/encode name)))))) (def: (anti-quote token) - (-> Code (Lux Code)) + (-> Code (Meta Code)) (case token [_ (#Symbol [def-prefix def-name])] (if (text/= "" def-prefix) - (:: Monad<Lux> return token) + (:: Monad<Meta> return token) (anti-quote-def [def-prefix def-name])) (^template [<tag>] [meta (<tag> parts)] - (do Monad<Lux> - [=parts (mapM Monad<Lux> anti-quote parts)] + (do Monad<Meta> + [=parts (mapM Monad<Meta> anti-quote parts)] (wrap [meta (<tag> =parts)]))) ([#Form] [#Tuple]) [meta (#Record pairs)] - (do Monad<Lux> - [=pairs (mapM Monad<Lux> - (: (-> [Code Code] (Lux [Code Code])) + (do Monad<Meta> + [=pairs (mapM Monad<Meta> + (: (-> [Code Code] (Meta [Code Code])) (function [[slot value]] - (do Monad<Lux> + (do Monad<Meta> [=value (anti-quote value)] (wrap [slot =value])))) pairs)] (wrap [meta (#Record =pairs)])) _ - (:: Monad<Lux> return token) + (:: Monad<Meta> return token) )) (macro: #export (^~ tokens) @@ -5479,12 +5479,12 @@ false)))} (case tokens (^ (list& [_ (#Form (list pattern))] body branches)) - (do Monad<Lux> + (do Monad<Meta> [module-name current-module-name pattern+ (macro-expand-all pattern)] (case pattern+ (^ (list pattern')) - (do Monad<Lux> + (do Monad<Meta> [pattern'' (anti-quote pattern')] (wrap (list& pattern'' body branches))) @@ -5498,7 +5498,7 @@ [Code (List [Code Code])]) (def: (case-level^ level) - (-> Code (Lux [Code Code])) + (-> Code (Meta [Code Code])) (case level (^ [_ (#;Tuple (list expr binding))]) (return [expr binding]) @@ -5508,14 +5508,14 @@ )) (def: (multi-level-case^ levels) - (-> (List Code) (Lux Multi-Level-Case)) + (-> (List Code) (Meta Multi-Level-Case)) (case levels #;Nil (fail "Multi-level patterns cannot be empty.") (#;Cons init extras) - (do Monad<Lux> - [extras' (mapM Monad<Lux> case-level^ extras)] + (do Monad<Meta> + [extras' (mapM Monad<Meta> case-level^ extras)] (wrap [init extras'])))) (def: (multi-level-case$ g!_ [[init-pattern levels] body]) @@ -5552,7 +5552,7 @@ (#;Left (format "Static part " (%t static) " does not match URI: " uri))))} (case tokens (^ (list& [_meta (#;Form levels)] body next-branches)) - (do Monad<Lux> + (do Monad<Meta> [mlc (multi-level-case^ levels) expected get-expected-type g!temp (gensym "temp")] @@ -5601,7 +5601,7 @@ [Int i.even? i.odd? i.% i.= 0 2]) (def: (get-scope-type-vars state) - (Lux (List Nat)) + (Meta (List Nat)) (case state {#info info #source source #modules modules #scopes scopes #type-context types #host host @@ -5632,7 +5632,7 @@ list)))} (case tokens (^ (list [_ (#Nat idx)])) - (do Monad<Lux> + (do Monad<Meta> [stvs get-scope-type-vars] (case (list-at idx (reverse stvs)) (#;Some var-id) @@ -5692,7 +5692,7 @@ (: Dinosaur (:!! (list 1 2 3))))} (case tokens (^ (list expr)) - (do Monad<Lux> + (do Monad<Meta> [type get-expected-type] (wrap (list (` (;_lux_:! (~ (type-to-code type)) (~ expr)))))) @@ -5721,7 +5721,7 @@ Int)} (case tokens (^ (list [_ (#;Symbol var-name)])) - (do Monad<Lux> + (do Monad<Meta> [var-type (find-type var-name)] (wrap (list (type-to-code var-type)))) @@ -5733,16 +5733,16 @@ #Hidden) (def: (parse-export-level tokens) - (-> (List Code) (Lux [(Maybe Export-Level') (List Code)])) + (-> (List Code) (Meta [(Maybe Export-Level') (List Code)])) (case tokens (^ (list& [_ (#Tag ["" "export"])] tokens')) - (:: Monad<Lux> wrap [(#;Some #Export) tokens']) + (:: Monad<Meta> wrap [(#;Some #Export) tokens']) (^ (list& [_ (#Tag ["" "hidden"])] tokens')) - (:: Monad<Lux> wrap [(#;Some #Hidden) tokens']) + (:: Monad<Meta> wrap [(#;Some #Hidden) tokens']) _ - (:: Monad<Lux> wrap [#;None tokens]) + (:: Monad<Meta> wrap [#;None tokens]) )) (def: (gen-export-level ?export-level) @@ -5759,11 +5759,11 @@ )) (def: (parse-complex-declaration tokens) - (-> (List Code) (Lux [[Text (List Text)] (List Code)])) + (-> (List Code) (Meta [[Text (List Text)] (List Code)])) (case tokens (^ (list& [_ (#Form (list& [_ (#Symbol ["" name])] args'))] tokens')) - (do Monad<Lux> - [args (mapM Monad<Lux> + (do Monad<Meta> + [args (mapM Monad<Meta> (function [arg'] (case arg' [_ (#Symbol ["" arg-name])] @@ -5779,33 +5779,33 @@ )) (def: (parse-any tokens) - (-> (List Code) (Lux [Code (List Code)])) + (-> (List Code) (Meta [Code (List Code)])) (case tokens (^ (list& token tokens')) - (:: Monad<Lux> wrap [token tokens']) + (:: Monad<Meta> wrap [token tokens']) _ (fail "Could not parse anything.") )) (def: (parse-end tokens) - (-> (List Code) (Lux Unit)) + (-> (List Code) (Meta Unit)) (case tokens (^ (list)) - (:: Monad<Lux> wrap []) + (:: Monad<Meta> wrap []) _ (fail "Expected input Codes to be empty.") )) (def: (parse-anns tokens) - (-> (List Code) (Lux [Code (List Code)])) + (-> (List Code) (Meta [Code (List Code)])) (case tokens (^ (list& [_ (#Record _anns)] tokens')) - (:: Monad<Lux> wrap [(record$ _anns) tokens']) + (:: Monad<Meta> wrap [(record$ _anns) tokens']) _ - (:: Monad<Lux> wrap [(' {}) tokens]) + (:: Monad<Meta> wrap [(' {}) tokens]) )) (macro: #export (template: tokens) @@ -5813,7 +5813,7 @@ "For simple macros that do not need any fancy features." (template: (square x) (i.* x x)))} - (do Monad<Lux> + (do Monad<Meta> [?export-level|tokens (parse-export-level tokens) #let [[?export-level tokens] ?export-level|tokens] name+args|tokens (parse-complex-declaration tokens) diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index ef8b05e41..8f44d3df9 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -8,9 +8,9 @@ ["E" error] [sum]) [io] - [macro #+ with-gensyms Functor<Lux> Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta #+ with-gensyms] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) ## [Types] (type: #export (CLI a) diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index b42a54a33..c09cde8bc 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -7,14 +7,14 @@ (data text/format (coll [list "L/" Monoid<List> Monad<List> Fold<List>]) [product]) - [macro #+ with-gensyms Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax: Syntax] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))) - [type] - (type opaque)) + [meta #+ with-gensyms Monad<Meta>] + (meta [code] + ["s" syntax #+ syntax: Syntax] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer])) + [type] + (type opaque))) (.. ["A" atom] ["P" promise "P/" Monad<Promise>] ["T" task] @@ -150,16 +150,16 @@ (code;tag name)]))) (def: #hidden (<resolve> name) - (-> Ident (Lux Ident)) - (do Monad<Lux> - [name (macro;normalize name) - [_ annotations _] (macro;find-def name)] - (case (macro;get-tag-ann (ident-for <tag>) annotations) + (-> Ident (Meta Ident)) + (do Monad<Meta> + [name (meta;normalize name) + [_ annotations _] (meta;find-def name)] + (case (meta;get-tag-ann (ident-for <tag>) annotations) (#;Some actor-name) (wrap actor-name) _ - (macro;fail (format "Definition is not " <desc> ".")))))] + (meta;fail (format "Definition is not " <desc> ".")))))] [with-actor resolve-actor #;;actor "an actor"] [with-message resolve-message #;;message "a message"] @@ -224,7 +224,7 @@ (wrap output)))))} (with-gensyms [g!message g!self g!state g!init g!error g!return g!output] (do @ - [module macro;current-module-name + [module meta;current-module-name #let [g!type (code;local-symbol (state-name _name)) g!behavior (code;local-symbol (behavior-name _name)) g!actor (code;local-symbol _name) diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index d59b96563..57789d708 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -8,8 +8,8 @@ [io #- run] (data (coll [list "L/" Monoid<List>]) text/format) - [macro] - (macro ["s" syntax #+ syntax: Syntax])) + [meta] + (meta ["s" syntax #+ syntax: Syntax])) (.. ["&" promise])) ## [Types] diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index 1e6bb72e9..b41a20e41 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -9,8 +9,8 @@ ["A" applicative] ["M" monad #+ do Monad] ["p" parser]) - [macro] - (macro ["s" syntax #+ syntax: Syntax]) + [meta] + (meta ["s" syntax #+ syntax: Syntax]) (concurrency [atom #+ Atom atom]) )) diff --git a/stdlib/source/lux/concurrency/space.lux b/stdlib/source/lux/concurrency/space.lux index 8fe9fa583..df0ec47a9 100644 --- a/stdlib/source/lux/concurrency/space.lux +++ b/stdlib/source/lux/concurrency/space.lux @@ -9,12 +9,12 @@ (data [product] (coll [list "L/" Functor<List> Fold<List>])) [io #- run] - [macro #+ with-gensyms] - (macro [code] - ["s" syntax #+ syntax:] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))))) + [meta #+ with-gensyms] + (meta [code] + ["s" syntax #+ syntax:] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer]))))) (with-expansions [<Event> [e (A;Actor Top) (Space e)] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index 7886dda36..d1762ee01 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -12,9 +12,9 @@ maybe [number "Nat/" Codec<Text,Nat>] text/format) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]) (concurrency [atom #+ Atom atom] ["P" promise] [frp]) diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux index 374acee46..fbc3cbf1e 100644 --- a/stdlib/source/lux/concurrency/task.lux +++ b/stdlib/source/lux/concurrency/task.lux @@ -6,8 +6,8 @@ monad ["ex" exception #+ Exception]) (concurrency ["P" promise]) - [macro] - (macro ["s" syntax #+ syntax: Syntax]) + [meta] + (meta ["s" syntax #+ syntax: Syntax]) )) (type: #export (Task a) diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index 1459a41ab..549ac19b0 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -9,12 +9,12 @@ text/format [maybe "m/" Monad<Maybe>] (coll [list "L/" Fold<List> Functor<List>])) - [macro #+ with-gensyms Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax:] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))))) + [meta #+ with-gensyms Monad<Meta>] + (meta [code] + ["s" syntax #+ syntax:] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer]))))) ## [Syntax] (type: Alias [Text Code]) @@ -49,16 +49,16 @@ tops)) (def: (singleton expander) - (-> (Lux (List Code)) (Lux Code)) - (monad;do Monad<Lux> + (-> (Meta (List Code)) (Meta Code)) + (monad;do Monad<Meta> [expansion expander] (case expansion (#;Cons singleton #;Nil) (wrap singleton) _ - (macro;fail (format "Cannot expand to more than a single AST/Code node:\n" - (|> expansion (L/map %code) (text;join-with " "))))))) + (meta;fail (format "Cannot expand to more than a single AST/Code node:\n" + (|> expansion (L/map %code) (text;join-with " "))))))) (syntax: #export (=> [aliases aliases^] [inputs stack^] @@ -72,16 +72,16 @@ (|> outputs (get@ #bottom) (m/map (|>. code;nat (~) #;Bound (`))))] [(#;Some bottomI) (#;Some bottomO)] (monad;do @ - [inputC (singleton (macro;expand-all (stack-fold (get@ #top inputs) bottomI))) - outputC (singleton (macro;expand-all (stack-fold (get@ #top outputs) bottomO)))] + [inputC (singleton (meta;expand-all (stack-fold (get@ #top inputs) bottomI))) + outputC (singleton (meta;expand-all (stack-fold (get@ #top outputs) bottomO)))] (wrap (list (` (-> (~ (de-alias inputC)) (~ (de-alias outputC))))))) [?bottomI ?bottomO] (with-gensyms [g!stack] (monad;do @ - [inputC (singleton (macro;expand-all (stack-fold (get@ #top inputs) (maybe;default g!stack ?bottomI)))) - outputC (singleton (macro;expand-all (stack-fold (get@ #top outputs) (maybe;default g!stack ?bottomO))))] + [inputC (singleton (meta;expand-all (stack-fold (get@ #top inputs) (maybe;default g!stack ?bottomI)))) + outputC (singleton (meta;expand-all (stack-fold (get@ #top outputs) (maybe;default g!stack ?bottomO))))] (wrap (list (` (All [(~ g!stack)] (-> (~ (de-alias inputC)) (~ (de-alias outputC)))))))))))) @@ -124,7 +124,7 @@ (syntax: #export (apply [arity (|> s;nat (p;filter (;n.> +0)))]) (with-gensyms [g!func g!stack g!output] (monad;do @ - [g!inputs (|> (macro;gensym "input") (list;repeat arity) (monad;seq @))] + [g!inputs (|> (meta;gensym "input") (list;repeat arity) (monad;seq @))] (wrap (list (` (: (All [(~@ g!inputs) (~ g!output)] (-> (-> (~@ g!inputs) (~ g!output)) (=> [(~@ g!inputs)] [(~ g!output)]))) diff --git a/stdlib/source/lux/control/cont.lux b/stdlib/source/lux/control/cont.lux index 81f62eccb..0db72d0fc 100644 --- a/stdlib/source/lux/control/cont.lux +++ b/stdlib/source/lux/control/cont.lux @@ -4,9 +4,9 @@ ["A" applicative] monad) function - [macro #+ with-gensyms] - (macro [code] - [syntax #+ syntax:]))) + [meta #+ with-gensyms] + (meta [code] + [syntax #+ syntax:]))) (type: #export (Cont i o) {#;doc "Continuations."} diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux index ef46bcb19..5ff6309ec 100644 --- a/stdlib/source/lux/control/contract.lux +++ b/stdlib/source/lux/control/contract.lux @@ -2,9 +2,9 @@ lux (lux (control monad) (data text/format) - [macro #+ Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax:]))) + [meta] + (meta [code] + ["s" syntax #+ syntax:]))) (def: #export (assert! message test) (-> Text Bool []) @@ -30,7 +30,7 @@ (post i.even? (i.+ 2 2)))} (do @ - [g!output (macro;gensym "")] + [g!output (meta;gensym "")] (wrap (list (` (let [(~ g!output) (~ expr)] (exec (assert! (~ (code;text (format "Post-condition failed: " (%code test)))) ((~ test) (~ g!output))) diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index b8be7b70d..abc729129 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -4,12 +4,12 @@ (data ["E" error] [maybe] [text "text/" Monoid<Text>]) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer]))))) ## [Types] (type: #export Exception @@ -71,7 +71,7 @@ "It moslty just serves as a way to tag error messages for later catching." (exception: #export Some-Exception))} (do @ - [current-module macro;current-module-name + [current-module meta;current-module-name #let [descriptor ($_ text/compose "{" current-module ";" name "}" "\n") g!message (code;symbol ["" "message"])]] (wrap (list (` (def: (~@ (csw;export _ex-lev)) ((~ (code;symbol ["" name])) (~ g!message)) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index 543c4c769..937935684 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -3,9 +3,9 @@ (lux (control ["M" monad #+ do Monad] ["p" parser]) (data (coll [list #+ Monad<List> "L/" Fold<List> Monad<List>])) - [macro #+ with-gensyms Monad<Lux>] - (macro ["s" syntax #+ syntax: Syntax] - [code]) + [meta #+ with-gensyms] + (meta ["s" syntax #+ syntax: Syntax] + [code]) )) ## [Syntax] @@ -108,7 +108,7 @@ (~> [int-to-nat %n log!]) (i.* 10)))} (do @ - [g!temp (macro;gensym "")] + [g!temp (meta;gensym "")] (wrap (list (` (let [(~ g!temp) (~ prev)] (exec (|> (~ g!temp) (~@ body)) (~ g!temp)))))))) @@ -122,7 +122,7 @@ [Int/encode])) "Will become: [50 2 \"5\"]")} (do @ - [g!temp (macro;gensym "")] + [g!temp (meta;gensym "")] (wrap (list (` (let [(~ g!temp) (~ prev)] [(~@ (L/map (function [body] (` (|> (~ g!temp) (~@ body)))) paths))])))))) diff --git a/stdlib/source/lux/data/coll/ordered/dict.lux b/stdlib/source/lux/data/coll/ordered/dict.lux index 677a24190..21cd20eb8 100644 --- a/stdlib/source/lux/data/coll/ordered/dict.lux +++ b/stdlib/source/lux/data/coll/ordered/dict.lux @@ -6,9 +6,9 @@ (data (coll [list "L/" Monad<List> Monoid<List> Fold<List>]) ["p" product] [maybe]) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) (def: error-message Text "Invariant violation") diff --git a/stdlib/source/lux/data/coll/ordered/set.lux b/stdlib/source/lux/data/coll/ordered/set.lux index 376624033..90026feab 100644 --- a/stdlib/source/lux/data/coll/ordered/set.lux +++ b/stdlib/source/lux/data/coll/ordered/set.lux @@ -7,9 +7,9 @@ (ordered ["d" dict])) ["p" product] ["M" maybe #+ Functor<Maybe>]) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) (type: #export (Set a) (d;Dict a a)) diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux index f85558c5e..c76735d3c 100644 --- a/stdlib/source/lux/data/coll/sequence.lux +++ b/stdlib/source/lux/data/coll/sequence.lux @@ -12,9 +12,9 @@ [array "array/" Functor<Array> Fold<Array>]) [bit] [product]) - [macro #+ with-gensyms] - (macro [code] - ["s" syntax #+ syntax: Syntax]) + [meta #+ with-gensyms] + (meta [code] + ["s" syntax #+ syntax: Syntax]) )) ## [Utils] diff --git a/stdlib/source/lux/data/coll/stream.lux b/stdlib/source/lux/data/coll/stream.lux index 43ed0087c..61e3b3e6c 100644 --- a/stdlib/source/lux/data/coll/stream.lux +++ b/stdlib/source/lux/data/coll/stream.lux @@ -5,8 +5,8 @@ comonad [cont #+ pending Cont] ["p" parser]) - [macro #+ with-gensyms] - (macro ["s" syntax #+ syntax: Syntax]) + [meta #+ with-gensyms] + (meta ["s" syntax #+ syntax: Syntax]) (data (coll [list "List/" Monad<List>]) bool))) diff --git a/stdlib/source/lux/data/coll/tree/rose.lux b/stdlib/source/lux/data/coll/tree/rose.lux index 546982dba..b07f1ed84 100644 --- a/stdlib/source/lux/data/coll/tree/rose.lux +++ b/stdlib/source/lux/data/coll/tree/rose.lux @@ -6,9 +6,9 @@ ["p" parser] fold) (data (coll [list "L/" Monad<List> Fold<List>])) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) ## [Types] (type: #export (Tree a) diff --git a/stdlib/source/lux/data/coll/tree/zipper.lux b/stdlib/source/lux/data/coll/tree/zipper.lux index c8f9a9059..ddab9d121 100644 --- a/stdlib/source/lux/data/coll/tree/zipper.lux +++ b/stdlib/source/lux/data/coll/tree/zipper.lux @@ -6,9 +6,9 @@ (tree [rose #+ Tree "T/" Functor<Tree>]) [stack #+ Stack]) [maybe "M/" Monad<Maybe>]) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) ## Adapted from the clojure.zip namespace in the Clojure standard library. diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 61ee1249a..490e31094 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -3,7 +3,7 @@ (lux (control [eq]) (data (coll [list "L/" Functor<List>])) [math] - (type opaque))) + (meta (type opaque)))) (def: rgb Nat +256) (def: top Nat (n.dec rgb)) diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index e00783c0b..899cd652a 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -17,11 +17,11 @@ (coll [list "list/" Fold<List> Monad<List>] [sequence #+ Sequence sequence "sequence/" Monad<Sequence>] [dict #+ Dict])) - [macro #+ Monad<Lux> with-gensyms] - (macro ["s" syntax #+ syntax:] - [code] - [poly #+ poly:]) - [type] + [meta #+ Monad<Meta> with-gensyms] + (meta ["s" syntax #+ syntax:] + [code] + [poly #+ poly:] + [type]) )) (do-template [<name> <type>] @@ -61,7 +61,7 @@ (json ["this" "is" "an" "array"]) (json {"this" "is" "an" "object"}))} - (let [(^open) Monad<Lux> + (let [(^open) Monad<Meta> wrapper (function [x] (` (;;json (~ x))))] (case token (^template [<ast-tag> <ctor> <json-tag>] @@ -78,7 +78,7 @@ (wrap (list (` (: JSON (#Array (sequence (~@ (list/map wrapper members)))))))) [_ (#;Record pairs)] - (do Monad<Lux> + (do Monad<Meta> [pairs' (monad;map @ (function [[slot value]] (case slot @@ -86,7 +86,7 @@ (wrap (` [(~ (code;text key-name)) (~ (wrapper value))])) _ - (macro;fail "Wrong syntax for JSON object."))) + (meta;fail "Wrong syntax for JSON object."))) pairs)] (wrap (list (` (: JSON (#Object (dict;from-list text;Hash<Text> (list (~@ pairs'))))))))) diff --git a/stdlib/source/lux/data/lazy.lux b/stdlib/source/lux/data/lazy.lux index e344c6a0a..0b0bf8a1d 100644 --- a/stdlib/source/lux/data/lazy.lux +++ b/stdlib/source/lux/data/lazy.lux @@ -5,9 +5,9 @@ ["A" applicative] monad) (concurrency ["a" atom]) - [macro] - (macro ["s" syntax #+ syntax:]) - (type opaque))) + [meta] + (meta ["s" syntax #+ syntax:] + (type opaque)))) (opaque: #export (Lazy a) (-> [] a) @@ -31,7 +31,7 @@ (syntax: #export (freeze expr) (do @ - [g!_ (macro;gensym "_")] + [g!_ (meta;gensym "_")] (wrap (list (` (freeze' (function [(~ g!_)] (~ expr)))))))) (struct: #export _ (F;Functor Lazy) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index e1fbccb36..ffe40e20e 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -12,9 +12,9 @@ ["E" error] [maybe] (coll [list "L/" Monad<List>])) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) ## Based on org.apache.commons.math4.complex.Complex ## https://github.com/apache/commons-math/blob/master/src/main/java/org/apache/commons/math4/complex/Complex.java @@ -30,7 +30,7 @@ (complex real))} (wrap (list (` {#;;real (~ real) #;;imaginary (~ (maybe;default (' 0.0) - ?imaginary))})))) + ?imaginary))})))) (def: #export i Complex (complex 0.0 1.0)) diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index 8db271d7d..d14e5e1f1 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -13,9 +13,9 @@ ["E" error] [product] [maybe]) - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax]))) (type: #export Ratio {#numerator Nat @@ -157,4 +157,4 @@ (ratio numerator))} (wrap (list (` (normalize {#;;numerator (~ numerator) #;;denominator (~ (maybe;default (' +1) - ?denominator))}))))) + ?denominator))}))))) diff --git a/stdlib/source/lux/data/store.lux b/stdlib/source/lux/data/store.lux index ef92b68c4..f798078dd 100644 --- a/stdlib/source/lux/data/store.lux +++ b/stdlib/source/lux/data/store.lux @@ -2,7 +2,7 @@ lux (lux (control ["F" functor] comonad) - (type auto))) + (meta (type auto)))) (type: #export (Store s a) {#cursor s diff --git a/stdlib/source/lux/data/tainted.lux b/stdlib/source/lux/data/tainted.lux index ffe128022..ad91ea8ab 100644 --- a/stdlib/source/lux/data/tainted.lux +++ b/stdlib/source/lux/data/tainted.lux @@ -1,7 +1,7 @@ (;module: lux (lux (data [product]) - (type opaque))) + (meta (type opaque)))) (opaque: #export (Tainted a) a diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux index f0b9d0e6f..323ce1efb 100644 --- a/stdlib/source/lux/data/text/format.lux +++ b/stdlib/source/lux/data/text/format.lux @@ -12,10 +12,10 @@ (time [instant] [duration] [date]) - [type] - [macro] - (macro [code] - ["s" syntax #+ syntax: Syntax]))) + [meta] + (meta [code] + ["s" syntax #+ syntax: Syntax] + [type]))) ## [Syntax] (def: #hidden _compose_ @@ -23,7 +23,7 @@ (:: text;Monoid<Text> compose)) (syntax: #export (format [fragments (p;many s;any)]) - {#;doc (doc "Text interpolation as a macro." + {#;doc (doc "Text interpolation." (format "Static part " (%t static) " does not match URI: " uri))} (wrap (list (` ($_ _compose_ (~@ fragments)))))) diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index 3803414e4..7ad4a0954 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -7,7 +7,7 @@ [maybe] ["E" error] (coll [list])) - (macro [code]))) + (meta [code]))) (type: Offset Nat) diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index a425224cb..bcefa4331 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -10,9 +10,9 @@ ["E" error] [maybe] (coll [list "L/" Fold<List> Monad<List>])) - [macro #- run] - (macro [code] - ["s" syntax #+ syntax:]))) + [meta #- run] + (meta [code] + ["s" syntax #+ syntax:]))) ## [Utils] (def: regex-char^ @@ -458,13 +458,13 @@ (regex "a(.)(.)|b(.)(.)") )} (do @ - [current-module macro;current-module-name] + [current-module meta;current-module-name] (case (|> (regex^ current-module) (p;before l;end) (l;run pattern)) (#E;Error error) - (macro;fail (format "Error while parsing regular-expression:\n" - error)) + (meta;fail (format "Error while parsing regular-expression:\n" + error)) (#E;Success regex) (wrap (list regex)) @@ -485,10 +485,10 @@ _ do-something-else))} (do @ - [g!temp (macro;gensym "temp")] + [g!temp (meta;gensym "temp")] (wrap (list& (` (^multi (~ g!temp) [(l;run (~ g!temp) (regex (~ (code;text pattern)))) (#E;Success (~ (maybe;default g!temp - bindings)))])) + bindings)))])) body branches)))) diff --git a/stdlib/source/lux/data/trace.lux b/stdlib/source/lux/data/trace.lux index ffae2164f..acb059dc0 100644 --- a/stdlib/source/lux/data/trace.lux +++ b/stdlib/source/lux/data/trace.lux @@ -2,8 +2,7 @@ lux (lux (control ["m" monoid] ["F" functor] - comonad) - [macro])) + comonad))) (type: #export (Trace t a) {#monoid (m;Monoid t) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index 5f334fb46..4abafbdf3 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -3,9 +3,9 @@ (lux (control monad ["p" parser]) (data (coll [list #* "L/" Fold<List>])) - [macro #+ with-gensyms] - (macro [code] - ["s" syntax #+ syntax: Syntax]) + [meta #+ with-gensyms] + (meta [code] + ["s" syntax #+ syntax: Syntax]) )) (do-template [<name> <type>] diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index c4ee39c4b..319615411 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -11,10 +11,10 @@ [text "text/" Eq<Text> Monoid<Text>] text/format [bool "bool/" Codec<Text,Bool>]) - [macro #+ with-gensyms Functor<Lux> Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax: Syntax]) - [type] + [meta #+ with-gensyms Functor<Meta> Monad<Meta>] + (meta [code] + ["s" syntax #+ syntax: Syntax] + [type]) )) (do-template [<name> <op> <from> <to>] @@ -352,21 +352,21 @@ (def: (class-imports compiler) (-> Compiler ClassImports) - (case (macro;run compiler - (: (Lux ClassImports) - (do Monad<Lux> - [current-module macro;current-module-name - defs (macro;defs current-module)] - (wrap (list/fold (: (-> [Text Def] ClassImports ClassImports) - (function [[short-name [_ meta _]] imports] - (case (macro;get-text-ann (ident-for #;;jvm-class) meta) - (#;Some full-class-name) - (add-import [short-name full-class-name] imports) - - _ - imports))) - empty-imports - defs))))) + (case (meta;run compiler + (: (Meta ClassImports) + (do Monad<Meta> + [current-module meta;current-module-name + defs (meta;defs current-module)] + (wrap (list/fold (: (-> [Text Def] ClassImports ClassImports) + (function [[short-name [_ meta _]] imports] + (case (meta;get-text-ann (ident-for #;;jvm-class) meta) + (#;Some full-class-name) + (add-import [short-name full-class-name] imports) + + _ + imports))) + empty-imports + defs))))) (#;Left _) (list) (#;Right imports) imports)) @@ -1304,8 +1304,8 @@ "(.new! []) for calling the class's constructor." "(.resolve! container [value]) for calling the \"resolve\" method." )} - (do Monad<Lux> - [current-module macro;current-module-name + (do Monad<Meta> + [current-module meta;current-module-name #let [fully-qualified-class-name (format (text;replace-all "/" "." current-module) "." full-class-name) field-parsers (list/map (field->parser fully-qualified-class-name) fields) method-parsers (list/map (method->parser (product;right class-decl) fully-qualified-class-name) methods) @@ -1435,7 +1435,7 @@ #;None (do @ - [g!obj (macro;gensym "obj")] + [g!obj (meta;gensym "obj")] (wrap (list (` (: (-> (host (~' java.lang.Object)) Bool) (function [(~ g!obj)] (;_lux_proc ["jvm" (~ (code;text (format "instanceof" ":" (simple-class$ (list) class))))] [(~ g!obj)]))))))) @@ -1500,13 +1500,13 @@ class-tvars)) (def: (member-def-arg-bindings type-params class member) - (-> (List TypeParam) ClassDecl ImportMemberDecl (Lux [(List Code) (List Code) (List Text) (List Code)])) + (-> (List TypeParam) ClassDecl ImportMemberDecl (Meta [(List Code) (List Code) (List Text) (List Code)])) (case member (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) (let [(^slots [#import-member-tvars #import-member-args]) commons] - (do Monad<Lux> + (do Monad<Meta> [arg-inputs (monad;map @ - (: (-> [Bool GenericType] (Lux [Code Code])) + (: (-> [Bool GenericType] (Meta [Code Code])) (function [[maybe? _]] (with-gensyms [arg-name] (wrap [arg-name (if maybe? @@ -1528,19 +1528,19 @@ (wrap [arg-function-inputs arg-method-inputs arg-classes arg-types]))) _ - (:: Monad<Lux> wrap [(list) (list) (list) (list)]))) + (:: Monad<Meta> wrap [(list) (list) (list) (list)]))) (def: (member-def-return mode type-params class member) - (-> Primitive-Mode (List TypeParam) ClassDecl ImportMemberDecl (Lux Code)) + (-> Primitive-Mode (List TypeParam) ClassDecl ImportMemberDecl (Meta Code)) (case member (#ConstructorDecl _) - (:: Monad<Lux> wrap (class-decl-type$ class)) + (:: Monad<Meta> wrap (class-decl-type$ class)) (#MethodDecl [_ method]) - (:: Monad<Lux> wrap (class->type mode type-params (get@ #import-method-return method))) + (:: Monad<Meta> wrap (class->type mode type-params (get@ #import-method-return method))) _ - (macro;fail "Only methods have return values."))) + (meta;fail "Only methods have return values."))) (def: (decorate-return-maybe member [return-type return-term]) (-> ImportMemberDecl [Code Code] [Code Code]) @@ -1668,14 +1668,14 @@ _ input))) (def: (member-def-interop type-params kind class [arg-function-inputs arg-method-inputs arg-classes arg-types] member method-prefix) - (-> (List TypeParam) ClassKind ClassDecl [(List Code) (List Code) (List Text) (List Code)] ImportMemberDecl Text (Lux (List Code))) + (-> (List TypeParam) ClassKind ClassDecl [(List Code) (List Code) (List Text) (List Code)] ImportMemberDecl Text (Meta (List Code))) (let [[full-name class-tvars] class all-params (|> (member-type-vars class-tvars member) (list;filter free-type-param?) (list/map type-param->type-arg))] (case member (#EnumDecl enum-members) - (do Monad<Lux> + (do Monad<Meta> [#let [enum-type (: Code (case class-tvars #;Nil @@ -1695,7 +1695,7 @@ (wrap (list/map getter-interop enum-members))) (#ConstructorDecl [commons _]) - (do Monad<Lux> + (do Monad<Meta> [return-type (member-def-return (get@ #import-member-mode commons) type-params class member) #let [def-name (code;symbol ["" (format method-prefix member-separator (get@ #import-member-alias commons))]) def-params (list (code;tuple arg-function-inputs)) @@ -1755,7 +1755,7 @@ (~ jvm-interop))))))) (#FieldAccessDecl fad) - (do Monad<Lux> + (do Monad<Meta> [#let [(^open) fad base-gtype (class->type import-field-mode type-params import-field-type) g!class (class-decl-type$ class) @@ -1817,12 +1817,12 @@ ))) (def: (member-import$ type-params long-name? kind class member) - (-> (List TypeParam) Bool ClassKind ClassDecl ImportMemberDecl (Lux (List Code))) + (-> (List TypeParam) Bool ClassKind ClassDecl ImportMemberDecl (Meta (List Code))) (let [[full-name _] class method-prefix (if long-name? full-name (short-class-name full-name))] - (do Monad<Lux> + (do Monad<Meta> [=args (member-def-arg-bindings type-params class member)] (member-def-interop type-params kind class =args member method-prefix)))) @@ -1835,15 +1835,15 @@ (try (_lux_proc ["jvm" "invokestatic:java.lang.Class:forName:java.lang.String"] [class-name]))) (def: (class-kind [class-name _]) - (-> ClassDecl (Lux ClassKind)) + (-> ClassDecl (Meta ClassKind)) (case (load-class class-name) (#;Right class) - (:: Monad<Lux> wrap (if (interface? class) - #Interface - #Class)) + (:: Monad<Meta> wrap (if (interface? class) + #Interface + #Class)) (#;Left _) - (macro;fail (format "Unknown class: " class-name)))) + (meta;fail (format "Unknown class: " class-name)))) (syntax: #export (import [#let [imports (class-imports *compiler*)]] [long-name? (s;this? (' #long))] @@ -1898,7 +1898,7 @@ (java.util.List.size [] my-list) Character$UnicodeScript.LATIN )} - (do Monad<Lux> + (do Monad<Meta> [kind (class-kind class-decl) =members (monad;map @ (member-import$ (product;right class-decl) long-name? kind class-decl) members)] (wrap (list& (class-import$ long-name? class-decl) (list/join =members))))) @@ -1930,15 +1930,15 @@ (wrap (list (` (;_lux_proc ["jvm" "arraylength"] [(~ array)]))))) (def: (type->class-name type) - (-> Type (Lux Text)) + (-> Type (Meta Text)) (case type (#;Host name params) - (:: Monad<Lux> wrap name) + (:: Monad<Meta> wrap name) (#;Apply A F) (case (type;apply (list A) F) #;None - (macro;fail (format "Cannot apply type: " (type;to-text F) " to " (type;to-text A))) + (meta;fail (format "Cannot apply type: " (type;to-text F) " to " (type;to-text A))) (#;Some type') (type->class-name type')) @@ -1947,10 +1947,10 @@ (type->class-name type') #;Unit - (:: Monad<Lux> wrap "java.lang.Object") + (:: Monad<Meta> wrap "java.lang.Object") (^or #;Void (#;Var _) (#;Ex _) (#;Bound _) (#;Sum _) (#;Product _) (#;Function _) (#;UnivQ _) (#;ExQ _)) - (macro;fail (format "Cannot convert to JvmType: " (type;to-text type))) + (meta;fail (format "Cannot convert to JvmType: " (type;to-text type))) )) (syntax: #export (array-read idx array) @@ -1958,8 +1958,8 @@ (array-read +10 my-array))} (case array [_ (#;Symbol array-name)] - (do Monad<Lux> - [array-type (macro;find-type array-name) + (do Monad<Meta> + [array-type (meta;find-type array-name) array-jvm-type (type->class-name array-type)] (case array-jvm-type (^template [<type> <array-op>] @@ -1987,8 +1987,8 @@ (array-write +10 my-object my-array))} (case array [_ (#;Symbol array-name)] - (do Monad<Lux> - [array-type (macro;find-type array-name) + (do Monad<Meta> + [array-type (meta;find-type array-name) array-jvm-type (type->class-name array-type)] (case array-jvm-type (^template [<type> <array-op>] @@ -2045,7 +2045,7 @@ (wrap (list (` (;_lux_proc ["jvm" "load-class"] [(~ (code;text (simple-class$ (list) type)))]))))) (def: get-compiler - (Lux Compiler) + (Meta Compiler) (function [compiler] (#;Right [compiler compiler]))) @@ -2065,15 +2065,15 @@ (resolve-class "String") => "java.lang.String")} - (-> Text (Lux Text)) - (do Monad<Lux> + (-> Text (Meta Text)) + (do Monad<Meta> [*compiler* get-compiler] (case (fully-qualify-class-name+ (class-imports *compiler*) class) (#;Some fqcn) (wrap fqcn) #;None - (macro;fail (text/compose "Unknown class: " class))))) + (meta;fail (text/compose "Unknown class: " class))))) (syntax: #export (type [#let [imports (class-imports *compiler*)]] [type (generic-type^ imports (list))]) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index c2933ba85..89f2e0a56 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -4,9 +4,9 @@ ["p" parser "p/" Functor<Parser>]) (data (coll [list "L/" Fold<List>]) [product]) - [macro] - (macro ["s" syntax #+ syntax: Syntax] - [code]))) + [meta] + (meta ["s" syntax #+ syntax: Syntax] + [code]))) ## [Values] (do-template [<name> <value>] diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/meta.lux index 4fb0b08a4..0d5ac7c0f 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/meta.lux @@ -1,7 +1,6 @@ (;module: {#;doc "Functions for extracting information from the state of the compiler."} lux - (lux (macro [code]) - (control ["F" functor] + (lux (control ["F" functor] ["A" applicative] ["M" monad #+ do Monad]) (data [number] @@ -10,12 +9,13 @@ [maybe] ["E" error] [text "text/" Monoid<Text> Eq<Text>] - (coll [list "list/" Monoid<List> Monad<List>])))) + (coll [list "list/" Monoid<List> Monad<List>]))) + (. [code])) -## (type: (Lux a) +## (type: (Meta a) ## (-> Compiler (E;Error [Compiler a]))) -(struct: #export _ (F;Functor Lux) +(struct: #export _ (F;Functor Meta) (def: (map f fa) (function [state] (case (fa state) @@ -25,8 +25,8 @@ (#E;Success [state' a]) (#E;Success [state' (f a)]))))) -(struct: #export _ (A;Applicative Lux) - (def: functor Functor<Lux>) +(struct: #export _ (A;Applicative Meta) + (def: functor Functor<Meta>) (def: (wrap x) (function [state] @@ -46,8 +46,8 @@ (#E;Error msg) (#E;Error msg))))) -(struct: #export _ (Monad Lux) - (def: applicative Applicative<Lux>) +(struct: #export _ (Monad Meta) + (def: applicative Applicative<Meta>) (def: (join mma) (function [state] @@ -71,11 +71,11 @@ (get k plist')))) (def: #export (run' compiler action) - (All [a] (-> Compiler (Lux a) (E;Error [Compiler a]))) + (All [a] (-> Compiler (Meta a) (E;Error [Compiler a]))) (action compiler)) (def: #export (run compiler action) - (All [a] (-> Compiler (Lux a) (E;Error a))) + (All [a] (-> Compiler (Meta a) (E;Error a))) (case (action compiler) (#E;Error error) (#E;Error error) @@ -85,7 +85,7 @@ (def: #export (either left right) {#;doc "Pick whichever computation succeeds."} - (All [a] (-> (Lux a) (Lux a) (Lux a))) + (All [a] (-> (Meta a) (Meta a) (Meta a))) (function [compiler] (case (left compiler) (#E;Error error) @@ -96,7 +96,7 @@ (def: #export (assert message test) {#;doc "Fails with the given message if the test is false."} - (-> Text Bool (Lux Unit)) + (-> Text Bool (Meta Unit)) (function [compiler] (if test (#E;Success [compiler []]) @@ -105,12 +105,12 @@ (def: #export (fail msg) {#;doc "Fails with the given message."} (All [a] - (-> Text (Lux a))) + (-> Text (Meta a))) (function [_] (#E;Error msg))) (def: #export (find-module name) - (-> Text (Lux Module)) + (-> Text (Meta Module)) (function [state] (case (get name (get@ #;modules state)) (#;Some module) @@ -120,7 +120,7 @@ (#E;Error ($_ text/compose "Unknown module: " name))))) (def: #export current-module-name - (Lux Text) + (Meta Text) (function [state] (case (list;last (get@ #;scopes state)) (#;Some scope) @@ -136,8 +136,8 @@ ))) (def: #export current-module - (Lux Module) - (do Monad<Lux> + (Meta Module) + (do Monad<Meta> [this-module-name current-module-name] (find-module this-module-name))) @@ -255,11 +255,11 @@ #;None)))) (def: #export (find-macro ident) - (-> Ident (Lux (Maybe Macro))) - (do Monad<Lux> + (-> Ident (Meta (Maybe Macro))) + (do Monad<Meta> [this-module current-module-name] (let [[module name] ident] - (: (Lux (Maybe Macro)) + (: (Meta (Maybe Macro)) (function [state] (#E;Success [state (find-macro' (get@ #;modules state) this-module module name)])))))) @@ -267,24 +267,24 @@ {#;doc "If given an identifier without a module prefix, gives it the current module's name as prefix. Otherwise, returns the identifier as-is."} - (-> Ident (Lux Ident)) + (-> Ident (Meta Ident)) (case ident ["" name] - (do Monad<Lux> + (do Monad<Meta> [module-name current-module-name] (wrap [module-name name])) _ - (:: Monad<Lux> wrap ident))) + (:: Monad<Meta> wrap ident))) (def: #export (expand-once syntax) {#;doc "Given code that requires applying a macro, does it once and returns the result. Otherwise, returns the code as-is."} - (-> Code (Lux (List Code))) + (-> Code (Meta (List Code))) (case syntax [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))] - (do Monad<Lux> + (do Monad<Meta> [name' (normalize name) ?macro (find-macro name')] (case ?macro @@ -292,82 +292,82 @@ (macro args) #;None - (:: Monad<Lux> wrap (list syntax)))) + (:: Monad<Meta> wrap (list syntax)))) _ - (:: Monad<Lux> wrap (list syntax)))) + (:: Monad<Meta> wrap (list syntax)))) (def: #export (expand syntax) {#;doc "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left. Otherwise, returns the code as-is."} - (-> Code (Lux (List Code))) + (-> Code (Meta (List Code))) (case syntax [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))] - (do Monad<Lux> + (do Monad<Meta> [name' (normalize name) ?macro (find-macro name')] (case ?macro (#;Some macro) - (do Monad<Lux> + (do Monad<Meta> [expansion (macro args) - expansion' (M;map Monad<Lux> expand expansion)] + expansion' (M;map Monad<Meta> expand expansion)] (wrap (list/join expansion'))) #;None - (:: Monad<Lux> wrap (list syntax)))) + (:: Monad<Meta> wrap (list syntax)))) _ - (:: Monad<Lux> wrap (list syntax)))) + (:: Monad<Meta> wrap (list syntax)))) (def: #export (expand-all syntax) {#;doc "Expands all macro-calls everywhere recursively, until only primitive/base code remains."} - (-> Code (Lux (List Code))) + (-> Code (Meta (List Code))) (case syntax [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))] - (do Monad<Lux> + (do Monad<Meta> [name' (normalize name) ?macro (find-macro name')] (case ?macro (#;Some macro) - (do Monad<Lux> + (do Monad<Meta> [expansion (macro args) - expansion' (M;map Monad<Lux> expand-all expansion)] + expansion' (M;map Monad<Meta> expand-all expansion)] (wrap (list/join expansion'))) #;None - (do Monad<Lux> - [parts' (M;map Monad<Lux> expand-all (list& (code;symbol name) args))] + (do Monad<Meta> + [parts' (M;map Monad<Meta> expand-all (list& (code;symbol name) args))] (wrap (list (code;form (list/join parts'))))))) [_ (#;Form (#;Cons [harg targs]))] - (do Monad<Lux> + (do Monad<Meta> [harg+ (expand-all harg) - targs+ (M;map Monad<Lux> expand-all targs)] + targs+ (M;map Monad<Meta> expand-all targs)] (wrap (list (code;form (list/compose harg+ (list/join (: (List (List Code)) targs+))))))) [_ (#;Tuple members)] - (do Monad<Lux> - [members' (M;map Monad<Lux> expand-all members)] + (do Monad<Meta> + [members' (M;map Monad<Meta> expand-all members)] (wrap (list (code;tuple (list/join members'))))) _ - (:: Monad<Lux> wrap (list syntax)))) + (:: Monad<Meta> wrap (list syntax)))) (def: #export (gensym prefix) {#;doc "Generates a unique identifier as an Code node (ready to be used in code templates). A prefix can be given (or just be empty text \"\") to better identify the code for debugging purposes."} - (-> Text (Lux Code)) + (-> Text (Meta Code)) (function [state] (#E;Success [(update@ #;seed n.inc state) (code;symbol ["" ($_ text/compose "__gensym__" prefix (:: number;Codec<Text,Nat> encode (get@ #;seed state)))])]))) (def: (get-local-symbol ast) - (-> Code (Lux Text)) + (-> Code (Meta Text)) (case ast [_ (#;Symbol [_ name])] - (:: Monad<Lux> wrap name) + (:: Monad<Meta> wrap name) _ (fail (text/compose "Code is not a local symbol: " (code;to-text ast))))) @@ -384,12 +384,12 @@ )))} (case tokens (^ (list [_ (#;Tuple symbols)] body)) - (do Monad<Lux> + (do Monad<Meta> [symbol-names (M;map @ get-local-symbol symbols) #let [symbol-defs (list/join (list/map (: (-> Text (List Code)) (function [name] (list (code;symbol ["" name]) (` (gensym (~ (code;text name))))))) symbol-names))]] - (wrap (list (` (do Monad<Lux> + (wrap (list (` (do Monad<Meta> [(~@ symbol-defs)] (~ body)))))) @@ -398,8 +398,8 @@ (def: #export (expand-1 token) {#;doc "Works just like expand, except that it ensures that the output is a single Code token."} - (-> Code (Lux Code)) - (do Monad<Lux> + (-> Code (Meta Code)) + (do Monad<Meta> [token+ (expand token)] (case token+ (^ (list token')) @@ -409,7 +409,7 @@ (fail "Macro expanded to more than 1 element.")))) (def: #export (module-exists? module) - (-> Text (Lux Bool)) + (-> Text (Meta Bool)) (function [state] (#E;Success [state (case (get module (get@ #;modules state)) (#;Some _) @@ -427,7 +427,7 @@ (def: #export (find-var-type name) {#;doc "Looks-up the type of a local variable somewhere in the environment."} - (-> Text (Lux Type)) + (-> Text (Meta Type)) (function [state] (let [test (: (-> [Text [Type Top]] Bool) (|>. product;left (text/= name)))] @@ -452,7 +452,7 @@ (def: #export (find-def name) {#;doc "Looks-up a definition's whole data in the available modules (including the current one)."} - (-> Ident (Lux Def)) + (-> Ident (Meta Def)) (function [state] (case (: (Maybe Def) (do maybe;Monad<Maybe> @@ -467,15 +467,15 @@ (def: #export (find-def-type name) {#;doc "Looks-up a definition's type in the available modules (including the current one)."} - (-> Ident (Lux Type)) - (do Monad<Lux> + (-> Ident (Meta Type)) + (do Monad<Meta> [[def-type def-data def-value] (find-def name)] (wrap def-type))) (def: #export (find-type name) {#;doc "Looks-up the type of either a local variable or a definition."} - (-> Ident (Lux Type)) - (do Monad<Lux> + (-> Ident (Meta Type)) + (do Monad<Meta> [#let [[_ _name] name]] (either (find-var-type _name) (do @ @@ -484,14 +484,14 @@ (def: #export (find-type-def name) {#;doc "Finds the value of a type definition (such as Int, Top or Compiler)."} - (-> Ident (Lux Type)) - (do Monad<Lux> + (-> Ident (Meta Type)) + (do Monad<Meta> [[def-type def-data def-value] (find-def name)] (wrap (:! Type def-value)))) (def: #export (defs module-name) {#;doc "The entire list of definitions in a module (including the unexported/private ones)."} - (-> Text (Lux (List [Text Def]))) + (-> Text (Meta (List [Text Def]))) (function [state] (case (get module-name (get@ #;modules state)) #;None (#E;Error ($_ text/compose "Unknown module: " module-name)) @@ -500,8 +500,8 @@ (def: #export (exports module-name) {#;doc "All the exported definitions in a module."} - (-> Text (Lux (List [Text Def]))) - (do Monad<Lux> + (-> Text (Meta (List [Text Def]))) + (do Monad<Meta> [defs (defs module-name)] (wrap (list;filter (function [[name [def-type def-anns def-value]]] (and (export? def-anns) @@ -510,7 +510,7 @@ (def: #export modules {#;doc "All the available modules (including the current one)."} - (Lux (List [Text Module])) + (Meta (List [Text Module])) (function [state] (|> state (get@ #;modules) @@ -519,8 +519,8 @@ (def: #export (tags-of type-name) {#;doc "All the tags associated with a type definition."} - (-> Ident (Lux (List Ident))) - (do Monad<Lux> + (-> Ident (Meta (List Ident))) + (do Monad<Meta> [#let [[module name] type-name] module (find-module module)] (case (get name (get@ #;types module)) @@ -532,13 +532,13 @@ (def: #export cursor {#;doc "The cursor of the current expression being analyzed."} - (Lux Cursor) + (Meta Cursor) (function [state] (#E;Success [state (get@ #;cursor state)]))) (def: #export expected-type {#;doc "The expected type of the current expression being analyzed."} - (Lux Type) + (Meta Type) (function [state] (case (get@ #;expected state) (#;Some type) @@ -549,15 +549,15 @@ (def: #export (imported-modules module-name) {#;doc "All the modules imported by a specified module."} - (-> Text (Lux (List Text))) - (do Monad<Lux> + (-> Text (Meta (List Text))) + (do Monad<Meta> [(^slots [#;imports]) (find-module module-name)] (wrap imports))) (def: #export (resolve-tag tag) {#;doc "Given a tag, finds out what is its index, its related tag-list and it's associated type."} - (-> Ident (Lux [Nat (List Ident) Type])) - (do Monad<Lux> + (-> Ident (Meta [Nat (List Ident) Type])) + (do Monad<Meta> [#let [[module name] tag] =module (find-module module) this-module-name current-module-name] @@ -573,8 +573,8 @@ (def: #export (tag-lists module) {#;doc "All the tag-lists defined in a module, with their associated types."} - (-> Text (Lux (List [(List Ident) Type]))) - (do Monad<Lux> + (-> Text (Meta (List [(List Ident) Type]))) + (do Monad<Meta> [=module (find-module module) this-module-name current-module-name] (wrap (|> (get@ #;types =module) @@ -586,7 +586,7 @@ (def: #export locals {#;doc "All the local variables currently in scope, separated in different scopes."} - (Lux (List (List [Text Type]))) + (Meta (List (List [Text Type]))) (function [state] (case (list;inits (get@ #;scopes state)) #;None @@ -601,8 +601,8 @@ (def: #export (un-alias def-name) {#;doc "Given an aliased definition's name, returns the original definition being referenced."} - (-> Ident (Lux Ident)) - (do Monad<Lux> + (-> Ident (Meta Ident)) + (do Monad<Meta> [def-name (normalize def-name) [_ def-anns _] (find-def def-name)] (case (get-symbol-ann (ident-for #;alias) def-anns) @@ -614,12 +614,12 @@ (def: #export get-compiler {#;doc "Obtains the current state of the compiler."} - (Lux Compiler) + (Meta Compiler) (function [compiler] (#E;Success [compiler compiler]))) (def: #export type-context - (Lux Type-Context) + (Meta Type-Context) (function [compiler] (#E;Success [compiler (get@ #;type-context compiler)]))) @@ -635,14 +635,14 @@ (case tokens (^ (list [_ (#;Tag ["" "omit"])] token)) - (do Monad<Lux> + (do Monad<Meta> [output (<func> token) #let [_ (list/map (. log! code;to-text) output)]] (wrap (list))) (^ (list token)) - (do Monad<Lux> + (do Monad<Meta> [output (<func> token) #let [_ (list/map (. log! code;to-text) output)]] diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/meta/code.lux index 0f5465f2b..d41dbe240 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/meta/code.lux @@ -22,7 +22,7 @@ ## (#;Record (List [(w (Code' w)) (w (Code' w))]))) ## (type: Code -## (Meta Cursor (Code' (Meta Cursor)))) +## (Ann Cursor (Code' (Ann Cursor)))) ## [Utils] (def: _cursor Cursor ["" +0 +0]) diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/meta/poly.lux index fc6c7120f..04ac1fd82 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/meta/poly.lux @@ -13,14 +13,14 @@ [maybe] [ident "ident/" Eq<Ident> Codec<Text,Ident>] ["E" error]) - [macro #+ with-gensyms] - (macro [code] - ["s" syntax #+ syntax: Syntax] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))) - [type] - (type [check]) + [meta #+ with-gensyms] + (meta [code] + ["s" syntax #+ syntax: Syntax] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer])) + [type] + (type [check])) )) (type: #export Env (Dict Nat [Type Code])) @@ -343,8 +343,8 @@ (with-gensyms [g!type g!output] (let [g!name (code;symbol ["" name])] (wrap (;list (` (syntax: (~@ (csw;export export)) ((~ g!name) [(~ g!type) s;symbol]) - (do macro;Monad<Lux> - [(~ g!type) (macro;find-type-def (~ g!type))] + (do meta;Monad<Meta> + [(~ g!type) (meta;find-type-def (~ g!type))] (case (|> (~ body) (;function [(~ g!name)]) p;rec @@ -352,7 +352,7 @@ (;;run (~ g!type)) (: (;Either ;Text ;Code))) (#;Left (~ g!output)) - (macro;fail (~ g!output)) + (meta;fail (~ g!output)) (#;Right (~ g!output)) ((~' wrap) (;list (~ g!output)))))))))))) @@ -372,7 +372,7 @@ [[poly-func poly-args] (s;form (p;seq s;symbol (p;many s;symbol)))] [?custom-impl (p;maybe s;any)]) (do @ - [poly-args (monad;map @ macro;normalize poly-args) + [poly-args (monad;map @ meta;normalize poly-args) name (case ?name (#;Some name) (wrap name) diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/meta/poly/eq.lux index 4c376d742..86a373a4c 100644 --- a/stdlib/source/lux/macro/poly/eq.lux +++ b/stdlib/source/lux/meta/poly/eq.lux @@ -19,13 +19,13 @@ (time ["du" duration] ["da" date] ["i" instant]) - [macro #+ Monad<Lux> with-gensyms] - (macro [code] - [syntax #+ syntax: Syntax] - (syntax [common]) - [poly #+ poly:]) - [type] - (type [unit]) + [meta] + (meta [code] + [syntax #+ syntax: Syntax] + (syntax [common]) + [poly #+ poly:] + [type] + (type [unit])) )) ## [Derivers] diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/meta/poly/functor.lux index 139cc5f7e..7dc20edaf 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/meta/poly/functor.lux @@ -7,12 +7,12 @@ text/format (coll [list "L/" Monad<List> Monoid<List>]) [product]) - [macro #+ Monad<Lux> with-gensyms] - (macro [code] - [syntax #+ syntax: Syntax] - (syntax [common]) - [poly #+ poly:]) - [type] + [meta] + (meta [code] + [syntax #+ syntax: Syntax] + (syntax [common]) + [poly #+ poly:] + [type]) )) (poly: #export Functor<?> diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/meta/poly/json.lux index ab0dab936..0569d03d5 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/meta/poly/json.lux @@ -20,12 +20,12 @@ (time ["i" instant] ["du" duration] ["da" date]) - [macro #+ Monad<Lux> with-gensyms] - (macro ["s" syntax #+ syntax:] - [code] - [poly #+ poly:]) - [type] - (type [unit]) + [meta #+ with-gensyms] + (meta ["s" syntax #+ syntax:] + [code] + [poly #+ poly:] + [type] + (type [unit])) )) (def: #hidden _map_ diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/meta/syntax.lux index a31eb8c6e..c92db5191 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/meta/syntax.lux @@ -1,6 +1,6 @@ (;module: lux - (lux [macro #+ with-gensyms] + (lux [meta #+ with-gensyms] (control [monad #+ do Monad] [eq #+ Eq] ["p" parser]) @@ -171,9 +171,9 @@ (def: #export (on compiler action) {#;doc "Run a Lux operation as if it was a Syntax parser."} - (All [a] (-> Compiler (Lux a) (Syntax a))) + (All [a] (-> Compiler (Meta a) (Syntax a))) (function [input] - (case (macro;run compiler action) + (case (meta;run compiler action) (#E;Error error) (#E;Error error) @@ -208,7 +208,7 @@ (macro: #export (syntax: tokens) {#;doc (doc "A more advanced way to define macros than macro:." "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." - "The macro body is also (implicitly) run in the Monad<Lux>, to save some typing." + "The macro body is also (implicitly) run in the Monad<Meta>, to save some typing." "Also, the compiler state can be accessed through the *compiler* binding." (syntax: #export (object [#let [imports (class-imports *compiler*)]] [#let [class-vars (list)]] @@ -247,9 +247,9 @@ (case ?parts (#;Some [name args meta body]) (with-gensyms [g!tokens g!body g!msg] - (do macro;Monad<Lux> + (do meta;Monad<Meta> [vars+parsers (monad;map @ - (: (-> Code (Lux [Code Code])) + (: (-> Code (Meta [Code Code])) (function [arg] (case arg (^ [_ (#;Tuple (list var parser))]) @@ -259,7 +259,7 @@ (wrap [(code;symbol var-name) (` any)]) _ - (macro;fail "Syntax pattern expects tuples or symbols.")))) + (meta;fail "Syntax pattern expects tuples or symbols.")))) args) #let [g!state (code;symbol ["" "*compiler*"]) g!end (code;symbol ["" ""]) @@ -277,11 +277,11 @@ (~ meta) (function [(~ g!state)] (;_lux_case (;;_run_ (~ g!tokens) - (: (Syntax (Lux (List Code))) + (: (Syntax (Meta (List Code))) (do ;;_Monad<Parser>_ [(~@ (join-pairs vars+parsers)) (~ g!end) ;;end!] - ((~' wrap) (do macro;Monad<Lux> + ((~' wrap) (do meta;Monad<Meta> [] (~ body)))))) (#E;Success [(~ g!tokens) (~ g!body)]) @@ -291,4 +291,4 @@ (#E;Error (text.join-with ": " (list (~ error-msg) (~ g!msg)))))))))))) _ - (macro;fail "Wrong syntax for syntax:")))) + (meta;fail "Wrong syntax for syntax:")))) diff --git a/stdlib/source/lux/macro/syntax/common.lux b/stdlib/source/lux/meta/syntax/common.lux index 72e52a4ab..72e52a4ab 100644 --- a/stdlib/source/lux/macro/syntax/common.lux +++ b/stdlib/source/lux/meta/syntax/common.lux diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/meta/syntax/common/reader.lux index aa5743f76..579cf0273 100644 --- a/stdlib/source/lux/macro/syntax/common/reader.lux +++ b/stdlib/source/lux/meta/syntax/common/reader.lux @@ -6,8 +6,8 @@ [ident "ident/" Eq<Ident>] [product] [maybe]) - [macro] - (macro ["s" syntax #+ syntax: Syntax])) + [meta] + (meta ["s" syntax #+ syntax: Syntax])) [.. #*]) ## Exports @@ -109,7 +109,7 @@ (do p;Monad<Parser> [definition-raw s;any me-definition-raw (s;on compiler - (macro;expand-all definition-raw))] + (meta;expand-all definition-raw))] (s;local me-definition-raw (s;form (do @ [_ (s;this (' lux;_lux_def)) diff --git a/stdlib/source/lux/macro/syntax/common/writer.lux b/stdlib/source/lux/meta/syntax/common/writer.lux index 72e4a11eb..c7eaf6f00 100644 --- a/stdlib/source/lux/macro/syntax/common/writer.lux +++ b/stdlib/source/lux/meta/syntax/common/writer.lux @@ -2,7 +2,7 @@ lux (lux (data (coll [list "L/" Functor<List>]) [product]) - (macro [code])) + (meta [code])) [.. #*]) ## Exports diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/meta/type.lux index 117d77043..ad51b0c58 100644 --- a/stdlib/source/lux/type.lux +++ b/stdlib/source/lux/meta/type.lux @@ -7,7 +7,7 @@ [number "Nat/" Codec<Text,Nat>] [maybe] (coll [list #+ "List/" Monad<List> Monoid<List> Fold<List>])) - (macro [code]) + (meta [code]) )) ## [Utils] diff --git a/stdlib/source/lux/type/auto.lux b/stdlib/source/lux/meta/type/auto.lux index 67d1455a1..0162d7a04 100644 --- a/stdlib/source/lux/type/auto.lux +++ b/stdlib/source/lux/meta/type/auto.lux @@ -11,15 +11,15 @@ [bool] [product] [maybe]) - [macro #+ Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax: Syntax]) - [type] - (type ["tc" check #+ Check Monad<Check>]) + [meta #+ Monad<Meta>] + (meta [code] + ["s" syntax #+ syntax: Syntax] + [type] + (type ["tc" check #+ Check Monad<Check>])) )) (def: (find-type-var id env) - (-> Nat Type-Context (Lux Type)) + (-> Nat Type-Context (Meta Type)) (case (list;find (|>. product;left (n.= id)) (get@ #;var-bindings env)) (#;Some [_ (#;Some type)]) @@ -28,20 +28,20 @@ (find-type-var id' env) _ - (:: Monad<Lux> wrap type)) + (:: Monad<Meta> wrap type)) (#;Some [_ #;None]) - (macro;fail (format "Unbound type-var " (%n id))) + (meta;fail (format "Unbound type-var " (%n id))) #;None - (macro;fail (format "Unknown type-var " (%n id))) + (meta;fail (format "Unknown type-var " (%n id))) )) (def: (resolve-type var-name) - (-> Ident (Lux Type)) - (do Monad<Lux> - [raw-type (macro;find-type var-name) - compiler macro;get-compiler] + (-> Ident (Meta Type)) + (do Monad<Meta> + [raw-type (meta;find-type var-name) + compiler meta;get-compiler] (case raw-type (#;Var id) (find-type-var id (get@ #;type-context compiler)) @@ -74,52 +74,52 @@ (tc;fail (format "Cannot find member type " (%n idx) " for " (%type sig-type)))))) (def: (find-member-name member) - (-> Ident (Lux Ident)) + (-> Ident (Meta Ident)) (case member ["" simple-name] - (macro;either (do Monad<Lux> - [member (macro;normalize member) - _ (macro;resolve-tag member)] - (wrap member)) - (do Monad<Lux> - [this-module-name macro;current-module-name - imp-mods (macro;imported-modules this-module-name) - tag-lists (M;map @ macro;tag-lists imp-mods) - #let [tag-lists (|> tag-lists List/join (List/map product;left) List/join) - candidates (list;filter (. (Text/= simple-name) product;right) - tag-lists)]] - (case candidates - #;Nil - (macro;fail (format "Unknown tag: " (%ident member))) - - (#;Cons winner #;Nil) - (wrap winner) - - _ - (macro;fail (format "Too many candidate tags: " (%list %ident candidates)))))) + (meta;either (do Monad<Meta> + [member (meta;normalize member) + _ (meta;resolve-tag member)] + (wrap member)) + (do Monad<Meta> + [this-module-name meta;current-module-name + imp-mods (meta;imported-modules this-module-name) + tag-lists (M;map @ meta;tag-lists imp-mods) + #let [tag-lists (|> tag-lists List/join (List/map product;left) List/join) + candidates (list;filter (. (Text/= simple-name) product;right) + tag-lists)]] + (case candidates + #;Nil + (meta;fail (format "Unknown tag: " (%ident member))) + + (#;Cons winner #;Nil) + (wrap winner) + + _ + (meta;fail (format "Too many candidate tags: " (%list %ident candidates)))))) _ - (:: Monad<Lux> wrap member))) + (:: Monad<Meta> wrap member))) (def: (resolve-member member) - (-> Ident (Lux [Nat Type])) - (do Monad<Lux> + (-> Ident (Meta [Nat Type])) + (do Monad<Meta> [member (find-member-name member) - [idx tag-list sig-type] (macro;resolve-tag member)] + [idx tag-list sig-type] (meta;resolve-tag member)] (wrap [idx sig-type]))) (def: (prepare-defs this-module-name defs) (-> Text (List [Text Def]) (List [Ident Type])) (|> defs (list;filter (function [[name [def-type def-anns def-value]]] - (macro;struct? def-anns))) + (meta;struct? def-anns))) (List/map (function [[name [def-type def-anns def-value]]] [[this-module-name name] def-type])))) (def: local-env - (Lux (List [Ident Type])) - (do Monad<Lux> - [local-batches macro;locals + (Meta (List [Ident Type])) + (do Monad<Meta> + [local-batches meta;locals #let [total-locals (List/fold (function [[name type] table] (dict;put~ name type table)) (: (dict;Dict Text Type) @@ -130,20 +130,20 @@ (List/map (function [[name type]] [["" name] type])))))) (def: local-structs - (Lux (List [Ident Type])) - (do Monad<Lux> - [this-module-name macro;current-module-name - defs (macro;defs this-module-name)] + (Meta (List [Ident Type])) + (do Monad<Meta> + [this-module-name meta;current-module-name + defs (meta;defs this-module-name)] (wrap (prepare-defs this-module-name defs)))) (def: import-structs - (Lux (List [Ident Type])) - (do Monad<Lux> - [this-module-name macro;current-module-name - imp-mods (macro;imported-modules this-module-name) + (Meta (List [Ident Type])) + (do Monad<Meta> + [this-module-name meta;current-module-name + imp-mods (meta;imported-modules this-module-name) export-batches (M;map @ (function [imp-mod] (do @ - [exports (macro;exports imp-mod)] + [exports (meta;exports imp-mod)] (wrap (prepare-defs imp-mod exports)))) imp-mods)] (wrap (List/join export-batches)))) @@ -198,9 +198,9 @@ (def: (test-provision provision context dep alts) (-> (-> Compiler Type-Context Type (Check Instance)) Type-Context Type (List [Ident Type]) - (Lux (List Instance))) - (do Monad<Lux> - [compiler macro;get-compiler] + (Meta (List Instance))) + (do Monad<Meta> + [compiler meta;get-compiler] (case (|> alts (List/map (function [[alt-name alt-type]] (case (tc;run context @@ -218,18 +218,18 @@ (list [alt-name =deps])))) List/join) #;Nil - (macro;fail (format "No candidates for provisioning: " (%type dep))) + (meta;fail (format "No candidates for provisioning: " (%type dep))) found (wrap found)))) (def: (provision compiler context dep) (-> Compiler Type-Context Type (Check Instance)) - (case (macro;run compiler - ($_ macro;either - (do Monad<Lux> [alts local-env] (test-provision provision context dep alts)) - (do Monad<Lux> [alts local-structs] (test-provision provision context dep alts)) - (do Monad<Lux> [alts import-structs] (test-provision provision context dep alts)))) + (case (meta;run compiler + ($_ meta;either + (do Monad<Meta> [alts local-env] (test-provision provision context dep alts)) + (do Monad<Meta> [alts local-structs] (test-provision provision context dep alts)) + (do Monad<Meta> [alts import-structs] (test-provision provision context dep alts)))) (#;Left error) (tc;fail error) @@ -246,10 +246,10 @@ )) (def: (test-alternatives sig-type member-idx input-types output-type alts) - (-> Type Nat (List Type) Type (List [Ident Type]) (Lux (List Instance))) - (do Monad<Lux> - [compiler macro;get-compiler - context macro;type-context] + (-> Type Nat (List Type) Type (List [Ident Type]) (Meta (List Instance))) + (do Monad<Meta> + [compiler meta;get-compiler + context meta;type-context] (case (|> alts (List/map (function [[alt-name alt-type]] (case (tc;run context @@ -269,18 +269,18 @@ (list [alt-name =deps])))) List/join) #;Nil - (macro;fail (format "No alternatives for " (%type (type;function input-types output-type)))) + (meta;fail (format "No alternatives for " (%type (type;function input-types output-type)))) found (wrap found)))) (def: (find-alternatives sig-type member-idx input-types output-type) - (-> Type Nat (List Type) Type (Lux (List Instance))) + (-> Type Nat (List Type) Type (Meta (List Instance))) (let [test (test-alternatives sig-type member-idx input-types output-type)] - ($_ macro;either - (do Monad<Lux> [alts local-env] (test alts)) - (do Monad<Lux> [alts local-structs] (test alts)) - (do Monad<Lux> [alts import-structs] (test alts))))) + ($_ meta;either + (do Monad<Meta> [alts local-env] (test alts)) + (do Monad<Meta> [alts local-structs] (test alts)) + (do Monad<Meta> [alts import-structs] (test alts))))) (def: (var? input) (-> Code Bool) @@ -305,8 +305,8 @@ (` ((~ (code;symbol constructor)) (~@ (List/map instance$ dependencies)))))) (syntax: #export (::: [member s;symbol] - [args (p;alt (p;seq (p;some s;symbol) s;end!) - (p;seq (p;some s;any) s;end!))]) + [args (p;alt (p;seq (p;some s;symbol) s;end!) + (p;seq (p;some s;any) s;end!))]) {#;doc (doc "Automatic structure selection (for type-class style polymorphism)." "This feature layers type-class style polymorphism on top of Lux's signatures and structures." "When calling a polymorphic function, or using a polymorphic constant," @@ -324,8 +324,8 @@ (::: eq;= x y) "(List Nat) equality" (::: = - (list;n.range +1 +10) - (list;n.range +1 +10)) + (list;n.range +1 +10) + (list;n.range +1 +10)) "(Functor List) map" (::: map n.inc (list;n.range +0 +9)) "Caveat emptor: You need to make sure to import the module of any structure you want to use." @@ -335,11 +335,11 @@ (do @ [[member-idx sig-type] (resolve-member member) input-types (M;map @ resolve-type args) - output-type macro;expected-type + output-type meta;expected-type chosen-ones (find-alternatives sig-type member-idx input-types output-type)] (case chosen-ones #;Nil - (macro;fail (format "No structure option could be found for member: " (%ident member))) + (meta;fail (format "No structure option could be found for member: " (%ident member))) (#;Cons chosen #;Nil) (wrap (list (` (:: (~ (instance$ chosen)) @@ -347,16 +347,16 @@ (~@ (List/map code;symbol args)))))) _ - (macro;fail (format "Too many options available: " - (|> chosen-ones - (List/map (. %ident product;left)) - (text;join-with ", ")) - " --- for type: " (%type sig-type))))) + (meta;fail (format "Too many options available: " + (|> chosen-ones + (List/map (. %ident product;left)) + (text;join-with ", ")) + " --- for type: " (%type sig-type))))) (#;Right [args _]) (do @ [labels (M;seq @ (list;repeat (list;size args) - (macro;gensym ""))) + (meta;gensym ""))) #let [retry (` (let [(~@ (|> (list;zip2 labels args) (List/map join-pair) List/join))] (;;::: (~ (code;symbol member)) (~@ labels))))]] (wrap (list retry))) diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/meta/type/check.lux index f51ba5a15..3b7c95cc4 100644 --- a/stdlib/source/lux/type/check.lux +++ b/stdlib/source/lux/meta/type/check.lux @@ -11,7 +11,7 @@ [product] (coll [list]) ["E" error]) - [type "type/" Eq<Type>] + (meta [type "type/" Eq<Type>]) )) (type: #export Assumptions (List [[Type Type] Bool])) diff --git a/stdlib/source/lux/type/object.lux b/stdlib/source/lux/meta/type/object.lux index 02306554b..dd2552eab 100644 --- a/stdlib/source/lux/type/object.lux +++ b/stdlib/source/lux/meta/type/object.lux @@ -9,13 +9,13 @@ [ident #+ "Ident/" Eq<Ident>] (coll [list "L/" Functor<List> Fold<List> Monoid<List>] [set #+ Set])) - [macro #+ Monad<Lux> "Lux/" Monad<Lux>] - (macro [code] - ["s" syntax #+ syntax:] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))) - [type])) + [meta #+ Monad<Meta> "Meta/" Monad<Meta>] + (meta [code] + ["s" syntax #+ syntax:] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer])) + [type]))) ## [Common] (type: Declaration @@ -141,12 +141,12 @@ (do-template [<name> <name-tag> <parent-tag> <desc>] [(def: (<name> name) - (-> Ident (Lux [Ident (List Ident)])) - (do Monad<Lux> - [name (macro;normalize name) - [_ annotations _] (macro;find-def name)] - (case [(macro;get-tag-ann (ident-for <name-tag>) annotations) - (macro;get-tag-ann (ident-for <parent-tag>) annotations)] + (-> Ident (Meta [Ident (List Ident)])) + (do Monad<Meta> + [name (meta;normalize name) + [_ annotations _] (meta;find-def name)] + (case [(meta;get-tag-ann (ident-for <name-tag>) annotations) + (meta;get-tag-ann (ident-for <parent-tag>) annotations)] [(#;Some real-name) (#;Some parent)] (if (Ident/= no-parent parent) (wrap [real-name (list)]) @@ -155,14 +155,14 @@ (wrap [real-name (#;Cons parent ancestors)]))) _ - (macro;fail (format "Wrong format for " <desc> " lineage.")))))] + (meta;fail (format "Wrong format for " <desc> " lineage.")))))] [interfaceN #;;interface-name #;;interface-parent "interface"] [classN #;;class-name #;;class-parent "class"] ) (def: (extract newT) - (-> Type (Lux [Nat (List Type)])) + (-> Type (Meta [Nat (List Type)])) (loop [depth +0 currentT newT] (case currentT @@ -171,10 +171,10 @@ (#;Function inputT outputT) (let [[stateT+ objectT] (type;flatten-function currentT)] - (Lux/wrap [depth stateT+])) + (Meta/wrap [depth stateT+])) _ - (macro;fail (format "Cannot extract inheritance from type: " (type;to-text newT)))))) + (meta;fail (format "Cannot extract inheritance from type: " (type;to-text newT)))))) (def: (specialize mappings typeC) (-> (List Code) Code Code) @@ -310,30 +310,30 @@ ## [Macros] (def: (type-to-code type) - (-> Type (Lux Code)) + (-> Type (Meta Code)) (case type (#;Host name params) - (do Monad<Lux> + (do Monad<Meta> [paramsC+ (M;map @ type-to-code params)] (wrap (` (;host (~ (code;symbol ["" name])) (~@ paramsC+))))) #;Void - (Lux/wrap (` (;|))) + (Meta/wrap (` (;|))) #;Unit - (Lux/wrap (` (;&))) + (Meta/wrap (` (;&))) (^template [<tag> <macro> <flatten>] (<tag> _) - (do Monad<Lux> + (do Monad<Meta> [partsC+ (M;map @ type-to-code (<flatten> type))] (wrap (` (<macro> (~@ partsC+)))))) ([#;Sum ;| type;flatten-variant] [#;Product ;& type;flatten-tuple]) (#;Function input output) - (do Monad<Lux> + (do Monad<Meta> [#let [[insT+ outT] (type;flatten-function type)] insC+ (M;map @ type-to-code insT+) outC (type-to-code outT)] @@ -341,23 +341,23 @@ (^template [<tag>] (<tag> idx) - (Lux/wrap (` (<tag> (~ (code;nat idx)))))) + (Meta/wrap (` (<tag> (~ (code;nat idx)))))) ([#;Bound] [#;Var] [#;Ex]) (#;Apply param fun) - (do Monad<Lux> + (do Monad<Meta> [#let [[funcT argsT+] (type;flatten-application type)] funcC (type-to-code funcT) argsC+ (M;map @ type-to-code argsT+)] (wrap (` ((~ funcC) (~@ argsC+))))) (#;Named name unnamedT) - (Lux/wrap (code;symbol name)) + (Meta/wrap (code;symbol name)) _ - (macro;fail (format "Cannot convert type to code: " (type;to-text type))))) + (meta;fail (format "Cannot convert type to code: " (type;to-text type))))) (syntax: #export (interface: [export csr;export] [(^@ decl [interface parameters]) declarationS] @@ -365,10 +365,10 @@ [alias aliasS] [annotations (p;default cs;empty-annotations csr;annotations)] [methods (p;many (method (var-set parameters)))]) - (macro;with-gensyms [g!self-class g!child g!ext] + (meta;with-gensyms [g!self-class g!child g!ext] (do @ - [module macro;current-module-name - [parent ancestors mappings] (: (Lux [Ident (List Ident) (List Code)]) + [module meta;current-module-name + [parent ancestors mappings] (: (Meta [Ident (List Ident) (List Code)]) (case ?extends #;None (wrap [no-parent (list) (list)]) @@ -433,11 +433,11 @@ [super (p;maybe inheritance)] state-type [impls (p;many s;any)]) - (macro;with-gensyms [g!init g!extension] + (meta;with-gensyms [g!init g!extension] (do @ - [module macro;current-module-name + [module meta;current-module-name [interface _] (interfaceN interface) - [parent ancestors parent-mappings] (: (Lux [Ident (List Ident) (List Code)]) + [parent ancestors parent-mappings] (: (Meta [Ident (List Ident) (List Code)]) (case super (#;Some [super-class super-mappings]) (do @ @@ -446,11 +446,11 @@ #;None (wrap [no-parent (list) (list)]))) - g!inheritance (: (Lux (List Code)) + g!inheritance (: (Meta (List Code)) (if (no-parent? parent) (wrap (list)) (do @ - [newT (macro;find-def-type (product;both id newN parent)) + [newT (meta;find-def-type (product;both id newN parent)) [depth rawT+] (extract newT) codeT+ (M;map @ type-to-code rawT+)] (wrap (L/map (specialize parent-mappings) codeT+))))) @@ -466,7 +466,7 @@ g!parent-structs (if (no-parent? parent) (list) (L/map (|>. (product;both id structN) code;symbol) (list& parent ancestors)))] - g!parent-inits (M;map @ (function [_] (macro;gensym "parent-init")) + g!parent-inits (M;map @ (function [_] (meta;gensym "parent-init")) g!parent-structs) #let [g!full-init (L/fold (function [[parent-struct parent-state] child] (` [(~ parent-struct) (~ parent-state) (~ child)])) diff --git a/stdlib/source/lux/type/opaque.lux b/stdlib/source/lux/meta/type/opaque.lux index 00a27333a..460ae22c4 100644 --- a/stdlib/source/lux/type/opaque.lux +++ b/stdlib/source/lux/meta/type/opaque.lux @@ -6,12 +6,12 @@ (data [text "text/" Eq<Text> Monoid<Text>] ["E" error] (coll [list "list/" Functor<List> Monoid<List>])) - [macro] - (macro [code] - ["s" syntax #+ syntax:] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))))) + [meta] + (meta [code] + ["s" syntax #+ syntax:] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer]))))) (def: (get k plist) (All [a] @@ -59,9 +59,9 @@ (let [[module kind] (ident-for #;;Representation)]))) (def: (install-casts' this-module-name name type-vars) - (-> Text Text (List Text) (Lux Unit)) - (do macro;Monad<Lux> - [this-module (macro;find-module this-module-name) + (-> Text Text (List Text) (Meta Unit)) + (do meta;Monad<Meta> + [this-module (meta;find-module this-module-name) #let [type-varsC (list/map code;local-symbol type-vars) opaque-declaration (` ((~ (code;local-symbol name)) (~@ type-varsC))) representation-declaration (` ((~ (code;local-symbol (representation-name name))) (~@ type-varsC))) @@ -77,7 +77,7 @@ (~ value))))) _ - (macro;fail ($_ text/compose "Wrong syntax for " down-cast))))]))) + (meta;fail ($_ text/compose "Wrong syntax for " down-cast))))]))) (update@ #;defs (put up-cast (: Def [Macro macro-anns (function [tokens] @@ -89,15 +89,15 @@ (~ value))))) _ - (macro;fail ($_ text/compose "Wrong syntax for " up-cast))))]))))]] + (meta;fail ($_ text/compose "Wrong syntax for " up-cast))))]))))]] (function [compiler] (#E;Success [(update@ #;modules (put this-module-name this-module) compiler) []])))) (def: (un-install-casts' this-module-name) - (-> Text (Lux Unit)) - (do macro;Monad<Lux> - [this-module (macro;find-module this-module-name) + (-> Text (Meta Unit)) + (do meta;Monad<Meta> + [this-module (meta;find-module this-module-name) #let [this-module (|> this-module (update@ #;defs (remove down-cast)) (update@ #;defs (remove up-cast)))]] @@ -108,9 +108,9 @@ (syntax: #hidden (install-casts [name s;local-symbol] [type-vars (s;tuple (p;some s;local-symbol))]) (do @ - [this-module-name macro;current-module-name - ?down-cast (macro;find-macro [this-module-name down-cast]) - ?up-cast (macro;find-macro [this-module-name up-cast])] + [this-module-name meta;current-module-name + ?down-cast (meta;find-macro [this-module-name down-cast]) + ?up-cast (meta;find-macro [this-module-name up-cast])] (case [?down-cast ?up-cast] [#;None #;None] (do @ @@ -118,16 +118,16 @@ (wrap (list))) _ - (macro;fail ($_ text/compose - "Cannot temporarily define casting functions (" - down-cast " & " up-cast - ") because definitions like that already exist."))))) + (meta;fail ($_ text/compose + "Cannot temporarily define casting functions (" + down-cast " & " up-cast + ") because definitions like that already exist."))))) (syntax: #hidden (un-install-casts) - (do macro;Monad<Lux> - [this-module-name macro;current-module-name - ?down-cast (macro;find-macro [this-module-name down-cast]) - ?up-cast (macro;find-macro [this-module-name up-cast])] + (do meta;Monad<Meta> + [this-module-name meta;current-module-name + ?down-cast (meta;find-macro [this-module-name down-cast]) + ?up-cast (meta;find-macro [this-module-name up-cast])] (case [?down-cast ?up-cast] [(#;Some _) (#;Some _)] (do @ @@ -135,10 +135,10 @@ (wrap (list))) _ - (macro;fail ($_ text/compose - "Cannot un-define casting functions (" - down-cast " & " up-cast - ") because they do not exist."))))) + (meta;fail ($_ text/compose + "Cannot un-define casting functions (" + down-cast " & " up-cast + ") because they do not exist."))))) (def: declaration (s;Syntax [Text (List Text)]) diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/meta/type/unit.lux index 84fee2dbb..9382a0506 100644 --- a/stdlib/source/lux/type/unit.lux +++ b/stdlib/source/lux/meta/type/unit.lux @@ -7,12 +7,12 @@ [enum #+ Enum]) (data text/format (number ["r" ratio])) - [macro] - (macro [code] - ["s" syntax #+ syntax:] - (syntax ["cs" common] - (common ["csr" reader] - ["csw" writer]))))) + [meta] + (meta [code] + ["s" syntax #+ syntax:] + (syntax ["cs" common] + (common ["csr" reader] + ["csw" writer]))))) (type: #export (Qty unit) [Int unit]) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index e25f685cf..f4c55d69b 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -1,8 +1,8 @@ (;module: {#;doc "Tools for unit & property-based/generative testing."} lux - (lux [macro #+ Monad<Lux> with-gensyms] - (macro ["s" syntax #+ syntax: Syntax] - [code]) + (lux [meta #+ Monad<Meta> with-gensyms] + (meta ["s" syntax #+ syntax: Syntax] + [code]) (control ["M" monad #+ do Monad] ["p" parser]) (concurrency [promise #+ Promise Monad<Promise>]) @@ -253,12 +253,12 @@ (io (~ body))))))))) (def: (exported-tests module-name) - (-> Text (Lux (List [Text Text Text]))) - (do Monad<Lux> - [defs (macro;exports module-name)] + (-> Text (Meta (List [Text Text Text]))) + (do Monad<Meta> + [defs (meta;exports module-name)] (wrap (|> defs (L/map (function [[def-name [_ def-anns _]]] - (case (macro;get-text-ann (ident-for #;;test) def-anns) + (case (meta;get-text-ann (ident-for #;;test) def-anns) (#;Some description) [true module-name def-name description] @@ -275,9 +275,9 @@ (run))} (with-gensyms [g!successes g!failures g!total-successes g!total-failures] (do @ - [current-module macro;current-module-name - modules (macro;imported-modules current-module) - tests (: (Lux (List [Text Text Text])) + [current-module meta;current-module-name + modules (meta;imported-modules current-module) + tests (: (Meta (List [Text Text Text])) (|> (#;Cons current-module modules) list;reverse (M;map @ exported-tests) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index 35911a6cc..e063a30ce 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -9,7 +9,7 @@ [text "text/" Monoid<Text>] (text ["l" lexer]) ["E" error]) - (type opaque))) + (meta (type opaque)))) (opaque: #export Duration {#;doc "Durations have a resolution of milliseconds."} diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index d04b7c845..0dea95584 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -14,7 +14,7 @@ [maybe] (coll [list "L/" Fold<List> Functor<List>] [sequence #+ Sequence sequence "sequence/" Functor<Sequence> Fold<Sequence>])) - (type opaque)) + (meta (type opaque))) (.. [duration "duration/" Order<Duration>] [date])) diff --git a/stdlib/source/lux/world/net/tcp.jvm.lux b/stdlib/source/lux/world/net/tcp.jvm.lux index e8832b67e..81aec7dc2 100644 --- a/stdlib/source/lux/world/net/tcp.jvm.lux +++ b/stdlib/source/lux/world/net/tcp.jvm.lux @@ -5,7 +5,7 @@ ["T" task] [frp]) (data ["E" error]) - (type opaque) + (meta (type opaque)) (world [blob #+ Blob]) [io] [host]) diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux index 29be4a920..4bbc28729 100644 --- a/stdlib/source/lux/world/net/udp.jvm.lux +++ b/stdlib/source/lux/world/net/udp.jvm.lux @@ -8,7 +8,7 @@ (data ["E" error] [maybe] (coll [array])) - (type opaque) + (meta (type opaque)) (world [blob #+ Blob]) [io] [host]) |