From 190b512a822fefbb9c66271feb189cc6ccebaf85 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 15 Nov 2017 23:22:30 -0400 Subject: - Re-named "lux/meta" to to "lux/macro". --- new-luxc/source/luxc/io.jvm.lux | 2 +- new-luxc/source/luxc/lang.lux | 18 +- new-luxc/source/luxc/lang/analysis.lux | 2 +- new-luxc/source/luxc/lang/analysis/case.lux | 38 +- .../source/luxc/lang/analysis/case/coverage.lux | 14 +- new-luxc/source/luxc/lang/analysis/common.lux | 4 +- new-luxc/source/luxc/lang/analysis/expression.lux | 12 +- new-luxc/source/luxc/lang/analysis/function.lux | 10 +- new-luxc/source/luxc/lang/analysis/inference.lux | 40 +- new-luxc/source/luxc/lang/analysis/primitive.lux | 8 +- .../source/luxc/lang/analysis/procedure/common.lux | 24 +- .../luxc/lang/analysis/procedure/host.jvm.lux | 144 ++--- new-luxc/source/luxc/lang/analysis/reference.lux | 14 +- new-luxc/source/luxc/lang/analysis/structure.lux | 46 +- new-luxc/source/luxc/lang/analysis/type.lux | 6 +- new-luxc/source/luxc/lang/eval.lux | 4 +- new-luxc/source/luxc/lang/host.jvm.lux | 2 +- new-luxc/source/luxc/lang/host/jvm.lux | 6 +- new-luxc/source/luxc/lang/host/jvm/inst.lux | 6 +- new-luxc/source/luxc/lang/host/macro.lux | 4 +- new-luxc/source/luxc/lang/module.lux | 18 +- new-luxc/source/luxc/lang/scope.lux | 6 +- new-luxc/source/luxc/lang/synthesis/case.lux | 2 +- new-luxc/source/luxc/lang/synthesis/expression.lux | 4 +- new-luxc/source/luxc/lang/synthesis/loop.lux | 4 +- new-luxc/source/luxc/lang/translation.lux | 50 +- new-luxc/source/luxc/lang/translation/case.jvm.lux | 142 ++--- new-luxc/source/luxc/lang/translation/eval.jvm.lux | 6 +- .../luxc/lang/translation/expression.jvm.lux | 4 +- .../source/luxc/lang/translation/function.jvm.lux | 10 +- new-luxc/source/luxc/lang/translation/loop.jvm.lux | 6 +- .../source/luxc/lang/translation/primitive.jvm.lux | 12 +- .../luxc/lang/translation/procedure/common.jvm.lux | 14 +- .../luxc/lang/translation/procedure/host.jvm.lux | 40 +- .../source/luxc/lang/translation/reference.jvm.lux | 8 +- .../source/luxc/lang/translation/runtime.jvm.lux | 8 +- .../source/luxc/lang/translation/statement.jvm.lux | 12 +- .../source/luxc/lang/translation/structure.jvm.lux | 6 +- new-luxc/test/test/luxc/lang/analysis/case.lux | 4 +- new-luxc/test/test/luxc/lang/analysis/common.lux | 6 +- new-luxc/test/test/luxc/lang/analysis/function.lux | 18 +- .../test/test/luxc/lang/analysis/primitive.lux | 8 +- .../test/luxc/lang/analysis/procedure/common.lux | 18 +- .../test/luxc/lang/analysis/procedure/host.jvm.lux | 6 +- .../test/test/luxc/lang/analysis/reference.lux | 6 +- .../test/test/luxc/lang/analysis/structure.lux | 54 +- new-luxc/test/test/luxc/lang/analysis/type.lux | 8 +- .../test/test/luxc/lang/synthesis/case/special.lux | 2 +- new-luxc/test/test/luxc/lang/synthesis/common.lux | 2 +- .../test/test/luxc/lang/synthesis/function.lux | 2 +- new-luxc/test/test/luxc/lang/synthesis/loop.lux | 2 +- .../test/test/luxc/lang/synthesis/primitive.lux | 2 +- new-luxc/test/test/luxc/lang/translation/case.lux | 15 +- .../test/test/luxc/lang/translation/function.lux | 16 +- .../test/test/luxc/lang/translation/primitive.lux | 12 +- .../luxc/lang/translation/procedure/common.jvm.lux | 72 +-- .../luxc/lang/translation/procedure/host.jvm.lux | 104 ++-- .../test/test/luxc/lang/translation/reference.lux | 12 +- .../test/test/luxc/lang/translation/structure.lux | 12 +- stdlib/source/lux/cli.lux | 6 +- stdlib/source/lux/concurrency/actor.lux | 22 +- stdlib/source/lux/concurrency/frp.lux | 4 +- stdlib/source/lux/concurrency/promise.lux | 4 +- stdlib/source/lux/concurrency/space.lux | 12 +- stdlib/source/lux/concurrency/stm.lux | 6 +- stdlib/source/lux/concurrency/task.lux | 4 +- stdlib/source/lux/control/concatenative.lux | 26 +- stdlib/source/lux/control/cont.lux | 6 +- stdlib/source/lux/control/contract.lux | 8 +- stdlib/source/lux/control/exception.lux | 14 +- stdlib/source/lux/control/pipe.lux | 10 +- stdlib/source/lux/data/coll/ordered/dict.lux | 6 +- stdlib/source/lux/data/coll/ordered/set.lux | 6 +- stdlib/source/lux/data/coll/sequence.lux | 6 +- stdlib/source/lux/data/coll/stream.lux | 4 +- stdlib/source/lux/data/coll/tree/rose.lux | 6 +- stdlib/source/lux/data/coll/tree/zipper.lux | 6 +- stdlib/source/lux/data/format/json.lux | 10 +- stdlib/source/lux/data/lazy.lux | 6 +- stdlib/source/lux/data/number/complex.lux | 6 +- stdlib/source/lux/data/number/ratio.lux | 6 +- stdlib/source/lux/data/text/format.lux | 6 +- stdlib/source/lux/data/text/lexer.lux | 2 +- stdlib/source/lux/data/text/regex.lux | 14 +- stdlib/source/lux/host.js.lux | 6 +- stdlib/source/lux/host.jvm.lux | 54 +- stdlib/source/lux/lang/type.lux | 2 +- stdlib/source/lux/macro.lux | 653 +++++++++++++++++++++ stdlib/source/lux/macro/code.lux | 143 +++++ stdlib/source/lux/macro/poly.lux | 448 ++++++++++++++ stdlib/source/lux/macro/poly/eq.lux | 147 +++++ stdlib/source/lux/macro/poly/functor.lux | 95 +++ stdlib/source/lux/macro/poly/json.lux | 312 ++++++++++ stdlib/source/lux/macro/syntax.lux | 297 ++++++++++ stdlib/source/lux/macro/syntax/common.lux | 27 + stdlib/source/lux/macro/syntax/common/reader.lux | 150 +++++ stdlib/source/lux/macro/syntax/common/writer.lux | 24 + stdlib/source/lux/math.lux | 6 +- stdlib/source/lux/meta.lux | 653 --------------------- stdlib/source/lux/meta/code.lux | 143 ----- stdlib/source/lux/meta/poly.lux | 448 -------------- stdlib/source/lux/meta/poly/eq.lux | 147 ----- stdlib/source/lux/meta/poly/functor.lux | 95 --- stdlib/source/lux/meta/poly/json.lux | 312 ---------- stdlib/source/lux/meta/syntax.lux | 297 ---------- stdlib/source/lux/meta/syntax/common.lux | 27 - stdlib/source/lux/meta/syntax/common/reader.lux | 150 ----- stdlib/source/lux/meta/syntax/common/writer.lux | 24 - stdlib/source/lux/test.lux | 14 +- stdlib/source/lux/type/implicit.lux | 108 ++-- stdlib/source/lux/type/object.lux | 48 +- stdlib/source/lux/type/opaque.lux | 54 +- stdlib/source/lux/type/unit.lux | 12 +- stdlib/test/test/lux.lux | 4 +- stdlib/test/test/lux/control/parser.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 46 +- stdlib/test/test/lux/data/text/regex.lux | 6 +- stdlib/test/test/lux/lang/syntax.lux | 2 +- stdlib/test/test/lux/macro/code.lux | 32 + stdlib/test/test/lux/macro/poly/eq.lux | 72 +++ stdlib/test/test/lux/macro/poly/functor.lux | 30 + stdlib/test/test/lux/macro/syntax.lux | 153 +++++ stdlib/test/test/lux/meta/code.lux | 32 - stdlib/test/test/lux/meta/poly/eq.lux | 72 --- stdlib/test/test/lux/meta/poly/functor.lux | 30 - stdlib/test/test/lux/meta/syntax.lux | 153 ----- stdlib/test/tests.lux | 10 +- 127 files changed, 3444 insertions(+), 3443 deletions(-) create mode 100644 stdlib/source/lux/macro.lux create mode 100644 stdlib/source/lux/macro/code.lux create mode 100644 stdlib/source/lux/macro/poly.lux create mode 100644 stdlib/source/lux/macro/poly/eq.lux create mode 100644 stdlib/source/lux/macro/poly/functor.lux create mode 100644 stdlib/source/lux/macro/poly/json.lux create mode 100644 stdlib/source/lux/macro/syntax.lux create mode 100644 stdlib/source/lux/macro/syntax/common.lux create mode 100644 stdlib/source/lux/macro/syntax/common/reader.lux create mode 100644 stdlib/source/lux/macro/syntax/common/writer.lux delete mode 100644 stdlib/source/lux/meta.lux delete mode 100644 stdlib/source/lux/meta/code.lux delete mode 100644 stdlib/source/lux/meta/poly.lux delete mode 100644 stdlib/source/lux/meta/poly/eq.lux delete mode 100644 stdlib/source/lux/meta/poly/functor.lux delete mode 100644 stdlib/source/lux/meta/poly/json.lux delete mode 100644 stdlib/source/lux/meta/syntax.lux delete mode 100644 stdlib/source/lux/meta/syntax/common.lux delete mode 100644 stdlib/source/lux/meta/syntax/common/reader.lux delete mode 100644 stdlib/source/lux/meta/syntax/common/writer.lux create mode 100644 stdlib/test/test/lux/macro/code.lux create mode 100644 stdlib/test/test/lux/macro/poly/eq.lux create mode 100644 stdlib/test/test/lux/macro/poly/functor.lux create mode 100644 stdlib/test/test/lux/macro/syntax.lux delete mode 100644 stdlib/test/test/lux/meta/code.lux delete mode 100644 stdlib/test/test/lux/meta/poly/eq.lux delete mode 100644 stdlib/test/test/lux/meta/poly/functor.lux delete mode 100644 stdlib/test/test/lux/meta/syntax.lux diff --git a/new-luxc/source/luxc/io.jvm.lux b/new-luxc/source/luxc/io.jvm.lux index a4049de3a..79a4ecfc5 100644 --- a/new-luxc/source/luxc/io.jvm.lux +++ b/new-luxc/source/luxc/io.jvm.lux @@ -8,7 +8,7 @@ (data ["e" error] [text "text/" Eq] text/format) - [meta] + [macro] [host] (world [file #+ File] [blob #+ Blob]))) diff --git a/new-luxc/source/luxc/lang.lux b/new-luxc/source/luxc/lang.lux index 45a8b1860..4aa47754a 100644 --- a/new-luxc/source/luxc/lang.lux +++ b/new-luxc/source/luxc/lang.lux @@ -8,8 +8,8 @@ [text "text/" Eq] text/format (coll [list])) - [meta] - (meta ["s" syntax #+ syntax:]) + [macro] + (macro ["s" syntax #+ syntax:]) (lang (type ["tc" check]))) (luxc (lang ["la" analysis]))) @@ -23,13 +23,13 @@ (def: #export (fail message) (All [a] (-> Text (Meta a))) - (do meta;Monad - [[file line col] meta;cursor + (do macro;Monad + [[file line col] macro;cursor #let [location (format file "," (|> line nat-to-int %i) "," (|> col nat-to-int %i))]] - (meta;fail (format message "\n\n" - "@ " location)))) + (macro;fail (format message "\n\n" + "@ " location)))) (def: #export (throw exception message) (All [a] (-> ex;Exception Text (Meta a))) @@ -37,7 +37,7 @@ (syntax: #export (assert exception message test) (wrap (list (` (if (~ test) - (:: meta;Monad (~' wrap) []) + (:: macro;Monad (~' wrap) []) (;;throw (~ exception) (~ message))))))) (def: #export (with-type expected action) @@ -77,8 +77,8 @@ (def: #export (infer actualT) (-> Type (Meta Unit)) - (do meta;Monad - [expectedT meta;expected-type] + (do macro;Monad + [expectedT macro;expected-type] (with-type-env (tc;check expectedT actualT)))) diff --git a/new-luxc/source/luxc/lang/analysis.lux b/new-luxc/source/luxc/lang/analysis.lux index 03e4c867f..f6163feb1 100644 --- a/new-luxc/source/luxc/lang/analysis.lux +++ b/new-luxc/source/luxc/lang/analysis.lux @@ -2,7 +2,7 @@ lux (lux [function] (data (coll [list "list/" Fold])) - (meta [code])) + (macro [code])) (luxc (lang [";L" variable #+ Variable]))) (type: #export Pattern Code) diff --git a/new-luxc/source/luxc/lang/analysis/case.lux b/new-luxc/source/luxc/lang/analysis/case.lux index 69a975b52..5d4c592aa 100644 --- a/new-luxc/source/luxc/lang/analysis/case.lux +++ b/new-luxc/source/luxc/lang/analysis/case.lux @@ -11,8 +11,8 @@ [text] text/format (coll [list "list/" Fold Monoid Functor])) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type] (type ["tc" check]))) (luxc ["&" lang] @@ -46,7 +46,7 @@ (-> Type (Meta Type)) (case caseT (#;Var id) - (do meta;Monad + (do macro;Monad [?caseT' (&;with-type-env (tc;read id))] (case ?caseT' @@ -60,7 +60,7 @@ (simplify-case-type unnamedT) (^or (#;UnivQ _) (#;ExQ _)) - (do meta;Monad + (do macro;Monad [[ex-id exT] (&;with-type-env tc;existential)] (simplify-case-type (maybe;assume (type;apply (list exT) caseT)))) @@ -68,7 +68,7 @@ (#;Apply inputT funcT) (case funcT (#;Var funcT-id) - (do meta;Monad + (do macro;Monad [funcT' (&;with-type-env (do tc;Monad [?funct' (tc;read funcT-id)] @@ -83,13 +83,13 @@ _ (case (type;apply (list inputT) funcT) (#;Some outputT) - (:: meta;Monad wrap outputT) + (:: macro;Monad wrap outputT) #;None (&;throw Cannot-Simplify-Type-For-Pattern-Matching (%type caseT)))) _ - (:: meta;Monad wrap caseT))) + (:: macro;Monad wrap caseT))) ## This function handles several concerns at once, but it must be that ## way because those concerns are interleaved when doing @@ -112,7 +112,7 @@ (case pattern [cursor (#;Symbol ["" name])] (&;with-cursor cursor - (do meta;Monad + (do macro;Monad [outputA (&scope;with-local [name inputT] next) idx &scope;next-local] @@ -125,7 +125,7 @@ (^template [ ] [cursor ( test)] (&;with-cursor cursor - (do meta;Monad + (do macro;Monad [_ (&;with-type-env (tc;check inputT )) outputA next] @@ -139,7 +139,7 @@ (^ [cursor (#;Tuple (list))]) (&;with-cursor cursor - (do meta;Monad + (do macro;Monad [_ (&;with-type-env (tc;check inputT Unit)) outputA next] @@ -150,7 +150,7 @@ [cursor (#;Tuple sub-patterns)] (&;with-cursor cursor - (do meta;Monad + (do macro;Monad [inputT' (simplify-case-type inputT)] (case inputT' (#;Product _) @@ -191,7 +191,7 @@ ))) [cursor (#;Record record)] - (do meta;Monad + (do macro;Monad [record (structureA;normalize record) [members recordT] (structureA;order record) _ (&;with-type-env @@ -204,7 +204,7 @@ (^ [cursor (#;Form (list& [_ (#;Nat idx)] values))]) (&;with-cursor cursor - (do meta;Monad + (do macro;Monad [inputT' (simplify-case-type inputT)] (case inputT' (#;Sum _) @@ -216,14 +216,14 @@ (n.< num-cases idx)) (if (and (n.> num-cases size-sum) (n.= (n.dec num-cases) idx)) - (do meta;Monad + (do macro;Monad [[testP nextA] (analyse-pattern #;None (type;variant (list;drop (n.dec num-cases) flat-sum)) (` [(~@ values)]) next)] (wrap [(` ("lux case variant" (~ (code;nat idx)) (~ (code;nat num-cases)) (~ testP))) nextA])) - (do meta;Monad + (do macro;Monad [[testP nextA] (analyse-pattern #;None case-type (` [(~@ values)]) next)] (wrap [(` ("lux case variant" (~ (code;nat idx)) (~ (code;nat num-cases)) (~ testP))) nextA]))) @@ -238,9 +238,9 @@ (^ [cursor (#;Form (list& [_ (#;Tag tag)] values))]) (&;with-cursor cursor - (do meta;Monad - [tag (meta;normalize tag) - [idx group variantT] (meta;resolve-tag tag) + (do macro;Monad + [tag (macro;normalize tag) + [idx group variantT] (macro;resolve-tag tag) _ (&;with-type-env (tc;check inputT variantT))] (analyse-pattern (#;Some (list;size group)) inputT (` ((~ (code;nat idx)) (~@ values))) next))) @@ -256,7 +256,7 @@ (&;throw Cannot-Have-Empty-Branches "") (#;Cons [patternH bodyH] branchesT) - (do meta;Monad + (do macro;Monad [[inputT inputA] (commonA;with-unknown-type (analyse inputC)) outputH (analyse-pattern #;None inputT patternH (analyse bodyH)) diff --git a/new-luxc/source/luxc/lang/analysis/case/coverage.lux b/new-luxc/source/luxc/lang/analysis/case/coverage.lux index c41cfb2a4..283e21d02 100644 --- a/new-luxc/source/luxc/lang/analysis/case/coverage.lux +++ b/new-luxc/source/luxc/lang/analysis/case/coverage.lux @@ -9,7 +9,7 @@ text/format (coll [list "list/" Fold] [dict #+ Dict])) - [meta "meta/" Monad]) + [macro "macro/" Monad]) (luxc ["&" lang] (lang ["la" analysis]))) @@ -52,7 +52,7 @@ ## Unit [] amounts to exhaustive coverage because there is only one ## possible value, so matching against it covers all cases. (^or (^code ("lux case bind" (~ _))) (^code ("lux case tuple" []))) - (meta/wrap #Exhaustive) + (macro/wrap #Exhaustive) (^code ("lux case tuple" [(~ singleton)])) (determine singleton) @@ -61,13 +61,13 @@ ## are too many possibilities as far as values go. (^or [_ (#;Nat _)] [_ (#;Int _)] [_ (#;Deg _)] [_ (#;Frac _)] [_ (#;Text _)]) - (meta/wrap #Partial) + (macro/wrap #Partial) ## Bools are the exception, since there is only "true" and ## "false", which means it is possible for boolean ## pattern-matching to become exhaustive if complementary parts meet. [_ (#;Bool value)] - (meta/wrap (#Bool value)) + (macro/wrap (#Bool value)) ## Tuple patterns can be exhaustive if there is exhaustiveness for all of ## their sub-patterns. @@ -75,10 +75,10 @@ (loop [subs subs] (case subs #;Nil - (meta/wrap #Exhaustive) + (macro/wrap #Exhaustive) (#;Cons sub subs') - (do meta;Monad + (do macro;Monad [pre (determine sub) post (recur subs')] (if (exhaustive? post) @@ -88,7 +88,7 @@ ## Variant patterns can be shown to be exhaustive if all the possible ## cases are handled exhaustively. (^code ("lux case variant" (~ [_ (#;Nat tag-id)]) (~ [_ (#;Nat num-tags)]) (~ sub))) - (do meta;Monad + (do macro;Monad [=sub (determine sub)] (wrap (#Variant num-tags (|> (dict;new number;Hash) diff --git a/new-luxc/source/luxc/lang/analysis/common.lux b/new-luxc/source/luxc/lang/analysis/common.lux index b67e8e268..c1a2a4f5b 100644 --- a/new-luxc/source/luxc/lang/analysis/common.lux +++ b/new-luxc/source/luxc/lang/analysis/common.lux @@ -4,7 +4,7 @@ ["ex" exception #+ exception:]) (data text/format [product]) - [meta] + [macro] (lang [type] (type ["tc" check]))) (luxc ["&" lang] @@ -12,7 +12,7 @@ (def: #export (with-unknown-type action) (All [a] (-> (Meta a) (Meta [Type a]))) - (do meta;Monad + (do macro;Monad [[_ varT] (&;with-type-env tc;var) analysis (&;with-type varT action) diff --git a/new-luxc/source/luxc/lang/analysis/expression.lux b/new-luxc/source/luxc/lang/analysis/expression.lux index 98addd197..5157848ec 100644 --- a/new-luxc/source/luxc/lang/analysis/expression.lux +++ b/new-luxc/source/luxc/lang/analysis/expression.lux @@ -5,7 +5,7 @@ (data ["e" error] [product] text/format) - [meta] + [macro] (lang [type] (type ["tc" check])) [host]) @@ -30,8 +30,8 @@ (-> &;Eval &;Analyser) (: (-> Code (Meta la;Analysis)) (function analyse [ast] - (do meta;Monad - [expectedT meta;expected-type] + (do macro;Monad + [expectedT macro;expected-type] (let [[cursor ast'] ast] ## The cursor must be set in the compiler for the sake ## of having useful error messages. @@ -82,14 +82,14 @@ (structureA;analyse-tagged-sum analyse tag (' [])) (^ (#;Form (list& func args))) - (do meta;Monad + (do macro;Monad [[funcT =func] (commonA;with-unknown-type (analyse func))] (case =func [_ (#;Symbol def-name)] (do @ - [[def-type def-anns def-value] (meta;find-def def-name)] - (if (meta;macro? def-anns) + [[def-type def-anns def-value] (macro;find-def def-name)] + (if (macro;macro? def-anns) (do @ [expansion (function [compiler] (case (macroH;expand (:! Macro def-value) args compiler) diff --git a/new-luxc/source/luxc/lang/analysis/function.lux b/new-luxc/source/luxc/lang/analysis/function.lux index 7f2787e6f..a2aa95c08 100644 --- a/new-luxc/source/luxc/lang/analysis/function.lux +++ b/new-luxc/source/luxc/lang/analysis/function.lux @@ -6,8 +6,8 @@ [text] text/format (coll [list "list/" Fold Monoid Monad])) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type] (type ["tc" check]))) (luxc ["&" lang] @@ -23,8 +23,8 @@ ## [Analysers] (def: #export (analyse-function analyse func-name arg-name body) (-> &;Analyser Text Text Code (Meta Analysis)) - (do meta;Monad - [functionT meta;expected-type] + (do macro;Monad + [functionT macro;expected-type] (loop [expectedT functionT] (&;with-stacked-errors (function [_] (Invalid-Function-Type (%type expectedT))) @@ -94,6 +94,6 @@ (list/map (function [[idx argC]] (format "\n " (%n idx) " " (%code argC)))) (text;join-with ""))))) - (do meta;Monad + (do macro;Monad [[applyT argsA] (&inference;general analyse funcT args)] (wrap (la;apply argsA funcA))))) diff --git a/new-luxc/source/luxc/lang/analysis/inference.lux b/new-luxc/source/luxc/lang/analysis/inference.lux index 910d5093a..c6f0323f7 100644 --- a/new-luxc/source/luxc/lang/analysis/inference.lux +++ b/new-luxc/source/luxc/lang/analysis/inference.lux @@ -6,7 +6,7 @@ [text] text/format (coll [list "list/" Functor])) - [meta "meta/" Monad] + [macro "macro/" Monad] (lang [type] (type ["tc" check]))) (luxc ["&" lang] @@ -71,7 +71,7 @@ (-> &;Analyser Type (List Code) (Meta [Type (List Analysis)])) (case args #;Nil - (do meta;Monad + (do macro;Monad [_ (&;infer inferT)] (wrap [inferT (list)])) @@ -81,12 +81,12 @@ (general analyse unnamedT args) (#;UnivQ _) - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] (general analyse (maybe;assume (type;apply (list varT) inferT)) args)) (#;ExQ _) - (do meta;Monad + (do macro;Monad [[ex-id exT] (&;with-type-env tc;existential)] (general analyse (maybe;assume (type;apply (list exT) inferT)) args)) @@ -107,7 +107,7 @@ ## avoided in Lux code, since the inference algorithm can piece ## things together more easily. (#;Function inputT outputT) - (do meta;Monad + (do macro;Monad [[outputT' args'A] (general analyse outputT args') argA (&;with-stacked-errors (function [_] (Cannot-Infer-Argument @@ -118,7 +118,7 @@ (wrap [outputT' (list& argA args'A)])) (#;Var infer-id) - (do meta;Monad + (do macro;Monad [?inferT' (&;with-type-env (tc;read infer-id))] (case ?inferT' (#;Some inferT') @@ -140,14 +140,14 @@ (^template [] ( env bodyT) - (do meta;Monad + (do macro;Monad [bodyT+ (record bodyT)] (wrap ( env bodyT+)))) ([#;UnivQ] [#;ExQ]) (#;Product _) - (meta/wrap (type;function (type;flatten-tuple type) type)) + (macro/wrap (type;function (type;flatten-tuple type) type)) _ (&;throw Not-A-Record-Type (%type type)))) @@ -159,13 +159,13 @@ currentT type] (case currentT (#;Named name unnamedT) - (do meta;Monad + (do macro;Monad [unnamedT+ (recur depth unnamedT)] (wrap unnamedT+)) (^template [] ( env bodyT) - (do meta;Monad + (do macro;Monad [bodyT+ (recur (n.inc depth) bodyT)] (wrap ( env bodyT+)))) ([#;UnivQ] @@ -180,11 +180,11 @@ (n.< boundary tag))) (case (list;nth tag cases) (#;Some caseT) - (meta/wrap (if (n.= +0 depth) - (type;function (list caseT) currentT) - (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] - (type;function (list (replace! caseT)) - (replace! currentT))))) + (macro/wrap (if (n.= +0 depth) + (type;function (list caseT) currentT) + (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] + (type;function (list (replace! caseT)) + (replace! currentT))))) #;None (&common;variant-out-of-bounds-error type expected-size tag)) @@ -196,11 +196,11 @@ (n.= boundary tag) (let [caseT (type;variant (list;drop boundary cases))] - (meta/wrap (if (n.= +0 depth) - (type;function (list caseT) currentT) - (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] - (type;function (list (replace! caseT)) - (replace! currentT)))))) + (macro/wrap (if (n.= +0 depth) + (type;function (list caseT) currentT) + (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] + (type;function (list (replace! caseT)) + (replace! currentT)))))) ## else (&common;variant-out-of-bounds-error type expected-size tag))) diff --git a/new-luxc/source/luxc/lang/analysis/primitive.lux b/new-luxc/source/luxc/lang/analysis/primitive.lux index 2a0fbfbe5..9124ca271 100644 --- a/new-luxc/source/luxc/lang/analysis/primitive.lux +++ b/new-luxc/source/luxc/lang/analysis/primitive.lux @@ -1,8 +1,8 @@ (;module: lux (lux (control monad) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang (type ["tc" check]))) (luxc ["&" lang] (lang ["la" analysis #+ Analysis]))) @@ -11,7 +11,7 @@ (do-template [ ] [(def: #export ( value) (-> (Meta Analysis)) - (do meta;Monad + (do macro;Monad [_ (&;infer )] (wrap ( value))))] @@ -25,6 +25,6 @@ (def: #export analyse-unit (Meta Analysis) - (do meta;Monad + (do macro;Monad [_ (&;infer Unit)] (wrap (` [])))) diff --git a/new-luxc/source/luxc/lang/analysis/procedure/common.lux b/new-luxc/source/luxc/lang/analysis/procedure/common.lux index a394c554c..747e9f61d 100644 --- a/new-luxc/source/luxc/lang/analysis/procedure/common.lux +++ b/new-luxc/source/luxc/lang/analysis/procedure/common.lux @@ -8,8 +8,8 @@ (coll [list "list/" Functor] [array] [dict #+ Dict])) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang (type ["tc" check])) [io]) (luxc ["&" lang] @@ -52,7 +52,7 @@ (function [analyse eval args] (let [num-actual (list;size args)] (if (n.= num-expected num-actual) - (do meta;Monad + (do macro;Monad [_ (&;infer outputT) argsA (monad;map @ (function [[argT argC]] @@ -83,7 +83,7 @@ (def: (lux-is proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((binary varT varT Bool proc) analyse eval args)))) @@ -95,7 +95,7 @@ (function [analyse eval args] (case args (^ (list opC)) - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Either Text varT))) opA (&;with-type (type (io;IO varT)) @@ -146,7 +146,7 @@ (function [analyse eval args] (case args (^ (list valueC)) - (do meta;Monad + (do macro;Monad [_ (&;infer (type Type)) valueA (&;with-type Type (analyse valueC))] @@ -278,7 +278,7 @@ (def: (array-get proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((binary Nat (type (Array varT)) varT proc) analyse eval args)))) @@ -286,7 +286,7 @@ (def: (array-put proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((trinary Nat varT (type (Array varT)) (type (Array varT)) proc) analyse eval args)))) @@ -294,7 +294,7 @@ (def: (array-remove proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((binary Nat (type (Array varT)) (type (Array varT)) proc) analyse eval args)))) @@ -339,7 +339,7 @@ (function [analyse eval args] (case args (^ (list initC)) - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Atom varT))) initA (&;with-type varT @@ -352,7 +352,7 @@ (def: (atom-read proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((unary (type (Atom varT)) varT proc) analyse eval args)))) @@ -360,7 +360,7 @@ (def: (atom-compare-and-swap proc) (-> Text Proc) (function [analyse eval args] - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var)] ((trinary varT varT (type (Atom varT)) Bool proc) analyse eval args)))) diff --git a/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux index 827f3213d..fad31eca0 100644 --- a/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux +++ b/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux @@ -14,9 +14,9 @@ (coll [list "list/" Fold Functor Monoid] [array] [dict #+ Dict])) - [meta "meta/" Monad] - (meta [code] - ["s" syntax]) + [macro "macro/" Monad] + (macro [code] + ["s" syntax]) (lang [type] (type ["tc" check])) [host]) @@ -194,7 +194,7 @@ (function [analyse eval args] (case args (^ (list arrayC)) - (do meta;Monad + (do macro;Monad [_ (&;infer Nat) [var-id varT] (&;with-type-env tc;var) arrayA (&;with-type (type (Array varT)) @@ -209,10 +209,10 @@ (function [analyse eval args] (case args (^ (list lengthC)) - (do meta;Monad + (do macro;Monad [lengthA (&;with-type Nat (analyse lengthC)) - expectedT meta;expected-type + expectedT macro;expected-type [level elem-class] (: (Meta [Nat Text]) (loop [analysisT expectedT level +0] @@ -245,13 +245,13 @@ (-> Type (Meta Text)) (case objectT (#;Primitive name _) - (meta/wrap name) + (macro/wrap name) (#;Named name unnamed) (check-jvm unnamed) (#;Var id) - (meta/wrap "java.lang.Object") + (macro/wrap "java.lang.Object") (^template [] ( env unquantified) @@ -272,11 +272,11 @@ (def: (check-object objectT) (-> Type (Meta Text)) - (do meta;Monad + (do macro;Monad [name (check-jvm objectT)] (if (dict;contains? name boxes) (&;throw Primitives-Are-Not-Objects name) - (meta/wrap name)))) + (macro/wrap name)))) (def: (box-array-element-type elemT) (-> Type (Meta [Type Text])) @@ -284,13 +284,13 @@ (#;Primitive name #;Nil) (let [boxed-name (|> (dict;get name boxes) (maybe;default name))] - (meta/wrap [(#;Primitive boxed-name #;Nil) - boxed-name])) + (macro/wrap [(#;Primitive boxed-name #;Nil) + boxed-name])) (#;Primitive name _) (if (dict;contains? name boxes) (&;throw Primitives-Cannot-Have-Type-Parameters name) - (meta/wrap [elemT name])) + (macro/wrap [elemT name])) _ (&;throw Invalid-Type-For-Array-Element (%type elemT)))) @@ -300,7 +300,7 @@ (function [analyse eval args] (case args (^ (list arrayC idxC)) - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var) _ (&;infer varT) arrayA (&;with-type (type (Array varT)) @@ -320,7 +320,7 @@ (function [analyse eval args] (case args (^ (list arrayC idxC valueC)) - (do meta;Monad + (do macro;Monad [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Array varT))) arrayA (&;with-type (type (Array varT)) @@ -352,8 +352,8 @@ (function [analyse eval args] (case args (^ (list)) - (do meta;Monad - [expectedT meta;expected-type + (do macro;Monad + [expectedT macro;expected-type _ (check-object expectedT)] (wrap (la;procedure proc (list)))) @@ -365,7 +365,7 @@ (function [analyse eval args] (case args (^ (list objectC)) - (do meta;Monad + (do macro;Monad [_ (&;infer Bool) [objectT objectA] (&common;with-unknown-type (analyse objectC)) @@ -380,7 +380,7 @@ (function [analyse eval args] (case args (^ (list monitorC exprC)) - (do meta;Monad + (do macro;Monad [[monitorT monitorA] (&common;with-unknown-type (analyse monitorC)) _ (check-object monitorT) @@ -454,7 +454,7 @@ (def: (load-class name) (-> Text (Meta (Class Object))) - (do meta;Monad + (do macro;Monad [class-loader &host;class-loader] (case (Class.forName [name false class-loader]) (#e;Success [class]) @@ -465,7 +465,7 @@ (def: (sub-class? super sub) (-> Text Text (Meta Bool)) - (do meta;Monad + (do macro;Monad [super (load-class super) sub (load-class sub)] (wrap (Class.isAssignableFrom [sub] super)))) @@ -475,7 +475,7 @@ (function [analyse eval args] (case args (^ (list exceptionC)) - (do meta;Monad + (do macro;Monad [_ (&;infer Bottom) [exceptionT exceptionA] (&common;with-unknown-type (analyse exceptionC)) @@ -497,7 +497,7 @@ (^ (list classC)) (case classC [_ (#;Text class)] - (do meta;Monad + (do macro;Monad [_ (&;infer (#;Primitive "java.lang.Class" (list (#;Primitive class (list))))) _ (load-class class)] (wrap (la;procedure proc (list (code;text class))))) @@ -515,7 +515,7 @@ (^ (list classC objectC)) (case classC [_ (#;Text class)] - (do meta;Monad + (do macro;Monad [_ (&;infer Bool) [objectT objectA] (&common;with-unknown-type (analyse objectC)) @@ -550,7 +550,7 @@ (def: (java-type-to-class type) (-> java.lang.reflect.Type (Meta Text)) (cond (host;instance? Class type) - (meta/wrap (Class.getName [] (:! Class type))) + (macro/wrap (Class.getName [] (:! Class type))) (host;instance? ParameterizedType type) (java-type-to-class (ParameterizedType.getRawType [] (:! ParameterizedType type))) @@ -569,7 +569,7 @@ (let [var-name (TypeVariable.getName [] (:! TypeVariable java-type))] (case (dict;get var-name mappings) (#;Some var-type) - (meta/wrap var-type) + (macro/wrap var-type) #;None (&;throw Unknown-Type-Var var-name))) @@ -582,37 +582,37 @@ (java-type-to-lux-type mappings bound) _ - (meta/wrap Top))) + (macro/wrap Top))) (host;instance? Class java-type) (let [java-type (:! (Class Object) java-type) class-name (Class.getName [] java-type)] - (meta/wrap (case (array;size (Class.getTypeParameters [] java-type)) - +0 - (#;Primitive class-name (list)) - - arity - (|> (list;n.range +0 (n.dec arity)) - list;reverse - (list/map (|>. (n.* +2) n.inc #;Bound)) - (#;Primitive class-name) - (type;univ-q arity))))) + (macro/wrap (case (array;size (Class.getTypeParameters [] java-type)) + +0 + (#;Primitive class-name (list)) + + arity + (|> (list;n.range +0 (n.dec arity)) + list;reverse + (list/map (|>. (n.* +2) n.inc #;Bound)) + (#;Primitive class-name) + (type;univ-q arity))))) (host;instance? ParameterizedType java-type) (let [java-type (:! ParameterizedType java-type) raw (ParameterizedType.getRawType [] java-type)] (if (host;instance? Class raw) - (do meta;Monad + (do macro;Monad [paramsT (|> java-type (ParameterizedType.getActualTypeArguments []) array;to-list (monad;map @ (java-type-to-lux-type mappings)))] - (meta/wrap (#;Primitive (Class.getName [] (:! (Class Object) raw)) - paramsT))) + (macro/wrap (#;Primitive (Class.getName [] (:! (Class Object) raw)) + paramsT))) (&;throw JVM-Type-Is-Not-Class (type-descriptor raw)))) (host;instance? GenericArrayType java-type) - (do meta;Monad + (do macro;Monad [innerT (|> (:! GenericArrayType java-type) (GenericArrayType.getGenericComponentType []) (java-type-to-lux-type mappings))] @@ -652,9 +652,9 @@ " Type: " (%type type))) ## else - (meta/wrap (|> params - (list;zip2 (list/map (TypeVariable.getName []) class-params)) - (dict;from-list text;Hash))) + (macro/wrap (|> params + (list;zip2 (list/map (TypeVariable.getName []) class-params)) + (dict;from-list text;Hash))) )) _ @@ -662,7 +662,7 @@ (def: (cast direction to from) (-> Direction Type Type (Meta [Text Type])) - (do meta;Monad + (do macro;Monad [to-name (check-jvm to) from-name (check-jvm from)] (cond (dict;contains? to-name boxes) @@ -712,8 +712,8 @@ (def: (infer-out outputT) (-> Type (Meta [Text Type])) - (do meta;Monad - [expectedT meta;expected-type + (do macro;Monad + [expectedT macro;expected-type [unboxed castT] (cast #Out expectedT outputT) _ (&;with-type-env (tc;check expectedT castT))] @@ -721,7 +721,7 @@ (def: (find-field class-name field-name) (-> Text Text (Meta [(Class Object) Field])) - (do meta;Monad + (do macro;Monad [class (load-class class-name)] (case (Class.getDeclaredField [field-name] class) (#e;Success field) @@ -738,7 +738,7 @@ (def: (static-field class-name field-name) (-> Text Text (Meta [Type Bool])) - (do meta;Monad + (do macro;Monad [[class fieldJ] (find-field class-name field-name) #let [modifiers (Field.getModifiers [] fieldJ)]] (if (Modifier.isStatic [modifiers]) @@ -750,7 +750,7 @@ (def: (virtual-field class-name field-name objectT) (-> Text Text Type (Meta [Type Bool])) - (do meta;Monad + (do macro;Monad [[class fieldJ] (find-field class-name field-name) #let [modifiers (Field.getModifiers [] fieldJ)]] (if (not (Modifier.isStatic [modifiers])) @@ -783,7 +783,7 @@ (def: (analyse-object class analyse sourceC) (-> Text &;Analyser Code (Meta [Type la;Analysis])) - (do meta;Monad + (do macro;Monad [target-class (load-class class) targetT (java-type-to-lux-type fresh-mappings (:! java.lang.reflect.Type @@ -797,7 +797,7 @@ (def: (analyse-input analyse targetT sourceC) (-> &;Analyser Type Code (Meta [Type Text la;Analysis])) - (do meta;Monad + (do macro;Monad [[sourceT sourceA] (&common;with-unknown-type (analyse sourceC)) [unboxed castT] (cast #In targetT sourceT)] @@ -810,7 +810,7 @@ (^ (list classC fieldC)) (case [classC fieldC] [[_ (#;Text class)] [_ (#;Text field)]] - (do meta;Monad + (do macro;Monad [[fieldT final?] (static-field class field) [unboxed castT] (infer-out fieldT)] (wrap (la;procedure proc (list (code;text class) (code;text field) @@ -829,7 +829,7 @@ (^ (list classC fieldC valueC)) (case [classC fieldC] [[_ (#;Text class)] [_ (#;Text field)]] - (do meta;Monad + (do macro;Monad [_ (&;infer Unit) [fieldT final?] (static-field class field) _ (&;assert Cannot-Set-Final-Field (format class "#" field) @@ -853,7 +853,7 @@ (^ (list classC fieldC objectC)) (case [classC fieldC] [[_ (#;Text class)] [_ (#;Text field)]] - (do meta;Monad + (do macro;Monad [[objectT objectA] (analyse-object class analyse objectC) [fieldT final?] (virtual-field class field objectT) [unboxed castT] (infer-out fieldT)] @@ -873,7 +873,7 @@ (^ (list classC fieldC valueC objectC)) (case [classC fieldC] [[_ (#;Text class)] [_ (#;Text field)]] - (do meta;Monad + (do macro;Monad [[objectT objectA] (analyse-object class analyse objectC) _ (&;infer objectT) [fieldT final?] (virtual-field class field objectT) @@ -891,17 +891,17 @@ (def: (java-type-to-parameter type) (-> java.lang.reflect.Type (Meta Text)) (cond (host;instance? Class type) - (meta/wrap (Class.getName [] (:! Class type))) + (macro/wrap (Class.getName [] (:! Class type))) (host;instance? ParameterizedType type) (java-type-to-parameter (ParameterizedType.getRawType [] (:! ParameterizedType type))) (or (host;instance? TypeVariable type) (host;instance? WildcardType type)) - (meta/wrap "java.lang.Object") + (macro/wrap "java.lang.Object") (host;instance? GenericArrayType type) - (do meta;Monad + (do macro;Monad [componentP (java-type-to-parameter (GenericArrayType.getGenericComponentType [] (:! GenericArrayType type)))] (wrap (format componentP "[]"))) @@ -917,7 +917,7 @@ (def: (check-method class method-name method-type arg-classes method) (-> (Class Object) Text Method-Type (List Text) Method (Meta Bool)) - (do meta;Monad + (do macro;Monad [parameters (|> (Method.getGenericParameterTypes [] method) array;to-list (monad;map @ java-type-to-parameter)) @@ -946,7 +946,7 @@ (def: (check-constructor class arg-classes constructor) (-> (Class Object) (List Text) (Constructor Object) (Meta Bool)) - (do meta;Monad + (do macro;Monad [parameters (|> (Constructor.getGenericParameterTypes [] constructor) array;to-list (monad;map @ java-type-to-parameter))] @@ -997,7 +997,7 @@ list;reverse (list;zip2 all-tvars) (dict;from-list text;Hash))))] - (do meta;Monad + (do macro;Monad [inputsT (|> (Method.getGenericParameterTypes [] method) array;to-list (monad;map @ (java-type-to-lux-type mappings))) @@ -1018,7 +1018,7 @@ (def: (methods class-name method-name method-type arg-classes) (-> Text Text Method-Type (List Text) (Meta [Type (List Type)])) - (do meta;Monad + (do macro;Monad [class (load-class class-name) candidates (|> class (Class.getDeclaredMethods []) @@ -1059,7 +1059,7 @@ list;reverse (list;zip2 all-tvars) (dict;from-list text;Hash))))] - (do meta;Monad + (do macro;Monad [inputsT (|> (Constructor.getGenericParameterTypes [] constructor) array;to-list (monad;map @ (java-type-to-lux-type mappings))) @@ -1074,7 +1074,7 @@ (def: (constructor-methods class-name arg-classes) (-> Text (List Text) (Meta [Type (List Type)])) - (do meta;Monad + (do macro;Monad [class (load-class class-name) candidates (|> class (Class.getConstructors []) @@ -1103,10 +1103,10 @@ (def: (sub-type-analyser analyse) (-> &;Analyser &;Analyser) (function [argC] - (do meta;Monad + (do macro;Monad [[argT argA] (&common;with-unknown-type (analyse argC)) - expectedT meta;expected-type + expectedT macro;expected-type [unboxed castT] (cast #In expectedT argT)] (wrap argA)))) @@ -1116,7 +1116,7 @@ (case (: (e;Error [Text Text (List [Text Code])]) (s;run args ($_ p;seq s;text s;text (p;some (s;tuple (p;seq s;text s;any)))))) (#e;Success [class method argsTC]) - (do meta;Monad + (do macro;Monad [#let [argsT (list/map product;left argsTC)] [methodT exceptionsT] (methods class method #Static argsT) [outputT argsA] (inferenceA;general (sub-type-analyser analyse) methodT (list/map product;right argsTC)) @@ -1133,7 +1133,7 @@ (case (: (e;Error [Text Text Code (List [Text Code])]) (s;run args ($_ p;seq s;text s;text s;any (p;some (s;tuple (p;seq s;text s;any)))))) (#e;Success [class method objectC argsTC]) - (do meta;Monad + (do macro;Monad [#let [argsT (list/map product;left argsTC)] [methodT exceptionsT] (methods class method #Virtual argsT) [outputT allA] (inferenceA;general (sub-type-analyser analyse) methodT (list& objectC (list/map product;right argsTC))) @@ -1156,7 +1156,7 @@ (case (: (e;Error [(List Code) [Text Text Code (List [Text Code]) Unit]]) (p;run args ($_ p;seq s;text s;text s;any (p;some (s;tuple (p;seq s;text s;any))) s;end!))) (#e;Success [_ [class method objectC argsTC _]]) - (do meta;Monad + (do macro;Monad [#let [argsT (list/map product;left argsTC)] [methodT exceptionsT] (methods class method #Special argsT) [outputT argsA] (inferenceA;general (sub-type-analyser analyse) methodT (list& objectC (list/map product;right argsTC))) @@ -1173,7 +1173,7 @@ (case (: (e;Error [Text Text Code (List [Text Code])]) (s;run args ($_ p;seq s;text s;text s;any (p;some (s;tuple (p;seq s;text s;any)))))) (#e;Success [class-name method objectC argsTC]) - (do meta;Monad + (do macro;Monad [#let [argsT (list/map product;left argsTC)] class (load-class class-name) _ (&;assert Non-Interface class-name @@ -1194,7 +1194,7 @@ (case (: (e;Error [Text (List [Text Code])]) (s;run args ($_ p;seq s;text (p;some (s;tuple (p;seq s;text s;any)))))) (#e;Success [class argsTC]) - (do meta;Monad + (do macro;Monad [#let [argsT (list/map product;left argsTC)] [methodT exceptionsT] (constructor-methods class argsT) [outputT argsA] (inferenceA;general (sub-type-analyser analyse) methodT (list/map product;right argsTC)) diff --git a/new-luxc/source/luxc/lang/analysis/reference.lux b/new-luxc/source/luxc/lang/analysis/reference.lux index c3ff3456b..25b33881c 100644 --- a/new-luxc/source/luxc/lang/analysis/reference.lux +++ b/new-luxc/source/luxc/lang/analysis/reference.lux @@ -1,8 +1,8 @@ (;module: lux (lux (control monad) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang (type ["tc" check]))) (luxc ["&" lang] (lang ["&;" scope] @@ -12,14 +12,14 @@ ## [Analysers] (def: (analyse-definition def-name) (-> Ident (Meta Analysis)) - (do meta;Monad - [actualT (meta;find-def-type def-name) + (do macro;Monad + [actualT (macro;find-def-type def-name) _ (&;infer actualT)] (wrap (code;symbol def-name)))) (def: (analyse-variable var-name) (-> Text (Meta (Maybe Analysis))) - (do meta;Monad + (do macro;Monad [?var (&scope;find var-name)] (case ?var (#;Some [actualT ref]) @@ -34,7 +34,7 @@ (-> Ident (Meta Analysis)) (case reference ["" simple-name] - (do meta;Monad + (do macro;Monad [?var (analyse-variable simple-name)] (case ?var (#;Some varA) @@ -42,7 +42,7 @@ #;None (do @ - [this-module meta;current-module-name] + [this-module macro;current-module-name] (analyse-definition [this-module simple-name])))) _ diff --git a/new-luxc/source/luxc/lang/analysis/structure.lux b/new-luxc/source/luxc/lang/analysis/structure.lux index 70744ba5b..2292d93cf 100644 --- a/new-luxc/source/luxc/lang/analysis/structure.lux +++ b/new-luxc/source/luxc/lang/analysis/structure.lux @@ -9,8 +9,8 @@ (coll [list "list/" Functor] [dict #+ Dict]) text/format) - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type] (type ["tc" check]))) (luxc ["&" lang] @@ -32,8 +32,8 @@ (def: #export (analyse-sum analyse tag valueC) (-> &;Analyser Nat Code (Meta la;Analysis)) - (do meta;Monad - [expectedT meta;expected-type] + (do macro;Monad + [expectedT macro;expected-type] (&;with-stacked-errors (function [_] (Not-Variant-Type (format " Type: " (%type expectedT) "\n" "Value: " (%code valueC) "\n" @@ -115,8 +115,8 @@ (def: (analyse-typed-product analyse membersC+) (-> &;Analyser (List Code) (Meta la;Analysis)) - (do meta;Monad - [expectedT meta;expected-type] + (do macro;Monad + [expectedT macro;expected-type] (loop [expectedT expectedT membersC+ membersC+] (case [expectedT membersC+] @@ -154,7 +154,7 @@ ## and what was analysed. [tailT tailC] (do @ - [g!tail (meta;gensym "tail")] + [g!tail (macro;gensym "tail")] (&;with-type tailT (analyse (` ("lux case" [(~@ tailC)] (~ g!tail) @@ -163,8 +163,8 @@ (def: #export (analyse-product analyse membersC) (-> &;Analyser (List Code) (Meta la;Analysis)) - (do meta;Monad - [expectedT meta;expected-type] + (do macro;Monad + [expectedT macro;expected-type] (&;with-stacked-errors (function [_] (Not-Tuple-Type (format " Type: " (%type expectedT) "\n" "Value: " (%code (` [(~@ membersC)]))))) @@ -234,10 +234,10 @@ (def: #export (analyse-tagged-sum analyse tag valueC) (-> &;Analyser Ident Code (Meta la;Analysis)) - (do meta;Monad - [tag (meta;normalize tag) - [idx group variantT] (meta;resolve-tag tag) - expectedT meta;expected-type] + (do macro;Monad + [tag (macro;normalize tag) + [idx group variantT] (macro;resolve-tag tag) + expectedT macro;expected-type] (case expectedT (#;Var _) (do @ @@ -256,12 +256,12 @@ ## canonical form (with their corresponding module identified). (def: #export (normalize record) (-> (List [Code Code]) (Meta (List [Ident Code]))) - (monad;map meta;Monad + (monad;map macro;Monad (function [[key val]] (case key [_ (#;Tag key)] - (do meta;Monad - [key (meta;normalize key)] + (do macro;Monad + [key (macro;normalize key)] (wrap [key val])) _ @@ -277,12 +277,12 @@ (case record ## empty-record = empty-tuple = unit = [] #;Nil - (:: meta;Monad wrap [(list) Unit]) + (:: macro;Monad wrap [(list) Unit]) (#;Cons [head-k head-v] _) - (do meta;Monad - [head-k (meta;normalize head-k) - [_ tag-set recordT] (meta;resolve-tag head-k) + (do macro;Monad + [head-k (macro;normalize head-k) + [_ tag-set recordT] (macro;resolve-tag head-k) #let [size-record (list;size record) size-ts (list;size tag-set)] _ (if (n.= size-ts size-record) @@ -296,7 +296,7 @@ idx->val (monad;fold @ (function [[key val] idx->val] (do @ - [key (meta;normalize key)] + [key (macro;normalize key)] (case (dict;get key tag->idx) #;None (&;throw Tag-Does-Not-Belong-To-Record @@ -321,10 +321,10 @@ (def: #export (analyse-record analyse members) (-> &;Analyser (List [Code Code]) (Meta la;Analysis)) - (do meta;Monad + (do macro;Monad [members (normalize members) [membersC recordT] (order members) - expectedT meta;expected-type] + expectedT macro;expected-type] (case expectedT (#;Var _) (do @ diff --git a/new-luxc/source/luxc/lang/analysis/type.lux b/new-luxc/source/luxc/lang/analysis/type.lux index c91fdab38..f85608e19 100644 --- a/new-luxc/source/luxc/lang/analysis/type.lux +++ b/new-luxc/source/luxc/lang/analysis/type.lux @@ -1,7 +1,7 @@ (;module: lux (lux (control monad) - [meta] + [macro] (lang (type ["tc" check]))) (luxc ["&" lang] (lang ["la" analysis #+ Analysis]))) @@ -11,7 +11,7 @@ ## computing Lux type values. (def: #export (analyse-check analyse eval type value) (-> &;Analyser &;Eval Code Code (Meta Analysis)) - (do meta;Monad + (do macro;Monad [actualT (eval Type type) #let [actualT (:! Type actualT)] _ (&;infer actualT)] @@ -20,7 +20,7 @@ (def: #export (analyse-coerce analyse eval type value) (-> &;Analyser &;Eval Code Code (Meta Analysis)) - (do meta;Monad + (do macro;Monad [actualT (eval Type type) _ (&;infer (:! Type actualT))] (&;with-type Top diff --git a/new-luxc/source/luxc/lang/eval.lux b/new-luxc/source/luxc/lang/eval.lux index 265320dbe..e691ec7a1 100644 --- a/new-luxc/source/luxc/lang/eval.lux +++ b/new-luxc/source/luxc/lang/eval.lux @@ -1,7 +1,7 @@ (;module: lux (lux (control [monad #+ do]) - [meta]) + [macro]) (luxc ["&" lang] (lang (analysis [";A" expression]) (synthesis [";S" expression]) @@ -10,7 +10,7 @@ (def: #export (eval type exprC) &;Eval - (do meta;Monad + (do macro;Monad [exprA (&;with-type type (expressionA;analyser eval exprC)) #let [exprS (expressionS;synthesize exprA)] diff --git a/new-luxc/source/luxc/lang/host.jvm.lux b/new-luxc/source/luxc/lang/host.jvm.lux index ae1d29387..726bb5bbc 100644 --- a/new-luxc/source/luxc/lang/host.jvm.lux +++ b/new-luxc/source/luxc/lang/host.jvm.lux @@ -9,7 +9,7 @@ text/format (coll [dict] [array])) - [meta #+ Monad] + [macro #+ Monad] [host #+ do-to object] [io]) (luxc ["&" lang] diff --git a/new-luxc/source/luxc/lang/host/jvm.lux b/new-luxc/source/luxc/lang/host/jvm.lux index 24d4a9ea9..f96b3e646 100644 --- a/new-luxc/source/luxc/lang/host/jvm.lux +++ b/new-luxc/source/luxc/lang/host/jvm.lux @@ -3,9 +3,9 @@ (lux (control monad ["p" parser]) (data (coll [list "list/" Functor])) - [meta] - (meta [code] - ["s" syntax #+ syntax:]) + [macro] + (macro [code] + ["s" syntax #+ syntax:]) [host])) ## [Host] diff --git a/new-luxc/source/luxc/lang/host/jvm/inst.lux b/new-luxc/source/luxc/lang/host/jvm/inst.lux index 37ab75020..dc2909b69 100644 --- a/new-luxc/source/luxc/lang/host/jvm/inst.lux +++ b/new-luxc/source/luxc/lang/host/jvm/inst.lux @@ -7,9 +7,9 @@ text/format (coll [list "L/" Functor])) [host #+ do-to] - [meta] - (meta [code] - ["s" syntax #+ syntax:])) + [macro] + (macro [code] + ["s" syntax #+ syntax:])) ["$" ..] (.. ["$t" type])) diff --git a/new-luxc/source/luxc/lang/host/macro.lux b/new-luxc/source/luxc/lang/host/macro.lux index 01f8c3bdb..d557b6750 100644 --- a/new-luxc/source/luxc/lang/host/macro.lux +++ b/new-luxc/source/luxc/lang/host/macro.lux @@ -2,7 +2,7 @@ lux (lux (control [monad #+ do]) (data ["e" error]) - [meta] + [macro] [host]) (luxc (lang (translation [";T" common]))) [..]) @@ -22,7 +22,7 @@ (host;array-write +1 _object-class))) (def: #export (expand macro inputs) (-> Macro (List Code) (Meta (List Code))) - (do meta;Monad + (do macro;Monad [class (commonT;load-class ..;function-class)] (function [compiler] (do e;Monad diff --git a/new-luxc/source/luxc/lang/module.lux b/new-luxc/source/luxc/lang/module.lux index fba337cc3..2b855d927 100644 --- a/new-luxc/source/luxc/lang/module.lux +++ b/new-luxc/source/luxc/lang/module.lux @@ -6,8 +6,8 @@ text/format ["e" error] (coll [list "list/" Fold Functor])) - [meta] - (meta [code])) + [macro] + (macro [code])) (luxc ["&" lang] (lang ["&;" scope]))) @@ -61,11 +61,11 @@ (def: #export (with-module hash name action) (All [a] (-> Nat Text (Meta a) (Meta [Module a]))) - (do meta;Monad + (do macro;Monad [_ (create hash name) output (&;with-current-module name (&scope;with-scope name action)) - module (meta;find-module name)] + module (macro;find-module name)] (wrap [module output]))) (do-template [ ] @@ -114,7 +114,7 @@ (#e;Success [compiler (get@ module)]) #;None - (meta;run compiler (&;throw Unknown-Module module-name))) + (macro;run compiler (&;throw Unknown-Module module-name))) ))] [tags-by-module #;tags (List [Text [Nat (List Ident) Bool Type]])] @@ -124,7 +124,7 @@ (def: (ensure-undeclared-tags module-name tags) (-> Text (List Text) (Meta Unit)) - (do meta;Monad + (do macro;Monad [bindings (tags-by-module module-name) _ (monad;map @ (function [tag] @@ -140,8 +140,8 @@ (def: #export (declare-tags tags exported? type) (-> (List Text) Bool Type (Meta Unit)) - (do meta;Monad - [current-module meta;current-module-name + (do macro;Monad + [current-module macro;current-module-name [type-module type-name] (case type (#;Named type-ident _) (wrap type-ident) @@ -170,4 +170,4 @@ compiler) []])) #;None - (meta;run compiler (&;throw Unknown-Module current-module)))))) + (macro;run compiler (&;throw Unknown-Module current-module)))))) diff --git a/new-luxc/source/luxc/lang/scope.lux b/new-luxc/source/luxc/lang/scope.lux index 435b8ef61..8bc61e722 100644 --- a/new-luxc/source/luxc/lang/scope.lux +++ b/new-luxc/source/luxc/lang/scope.lux @@ -7,7 +7,7 @@ [product] ["e" error] (coll [list "list/" Functor Fold Monoid])) - [meta]) + [macro]) (luxc ["&" lang] (lang [";L" variable #+ Variable]))) @@ -102,8 +102,8 @@ (|>. (update@ #;counter n.inc) (update@ #;mappings (&;pl-put name [type new-var-id])))) head)] - (case (meta;run' (set@ #;scopes (#;Cons new-head tail) compiler) - action) + (case (macro;run' (set@ #;scopes (#;Cons new-head tail) compiler) + action) (#e;Success [compiler' output]) (case (get@ #;scopes compiler') (#;Cons head' tail') diff --git a/new-luxc/source/luxc/lang/synthesis/case.lux b/new-luxc/source/luxc/lang/synthesis/case.lux index 2fd6e19bb..dfe05e1bf 100644 --- a/new-luxc/source/luxc/lang/synthesis/case.lux +++ b/new-luxc/source/luxc/lang/synthesis/case.lux @@ -5,7 +5,7 @@ text/format [number] (coll [list "list/" Fold Monoid])) - (meta [code "code/" Eq])) + (macro [code "code/" Eq])) (luxc (lang [";L" variable #+ Variable] ["la" analysis] ["ls" synthesis] diff --git a/new-luxc/source/luxc/lang/synthesis/expression.lux b/new-luxc/source/luxc/lang/synthesis/expression.lux index 4571a8875..b9f5d56cc 100644 --- a/new-luxc/source/luxc/lang/synthesis/expression.lux +++ b/new-luxc/source/luxc/lang/synthesis/expression.lux @@ -8,8 +8,8 @@ text/format (coll [list "list/" Functor Fold Monoid] [dict #+ Dict])) - (meta [code] - ["s" syntax])) + (macro [code] + ["s" syntax])) (luxc (lang ["la" analysis] ["ls" synthesis] (synthesis [";S" case] diff --git a/new-luxc/source/luxc/lang/synthesis/loop.lux b/new-luxc/source/luxc/lang/synthesis/loop.lux index 0070fcd5d..86c37a3f0 100644 --- a/new-luxc/source/luxc/lang/synthesis/loop.lux +++ b/new-luxc/source/luxc/lang/synthesis/loop.lux @@ -4,8 +4,8 @@ ["p" parser]) (data [maybe] (coll [list "list/" Functor])) - (meta [code] - [syntax])) + (macro [code] + [syntax])) (luxc (lang ["ls" synthesis] [";L" variable #+ Variable Register]))) diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux index 1e631205d..9b59e5341 100644 --- a/new-luxc/source/luxc/lang/translation.lux +++ b/new-luxc/source/luxc/lang/translation.lux @@ -7,7 +7,7 @@ [text "text/" Hash] text/format (coll [dict])) - [meta] + [macro] (lang [syntax] (type ["tc" check])) [host] @@ -39,7 +39,7 @@ (def: (process-annotations annsC) (-> Code (Meta [$;Inst Code])) - (do meta;Monad + (do macro;Monad [[_ annsA] (&;with-scope (&;with-type Code (analyse annsC))) @@ -53,10 +53,10 @@ (^code ("lux def" (~ [_ (#;Symbol ["" def-name])]) (~ valueC) (~ annsC))) (hostL;with-context def-name (&;with-fresh-type-env - (do meta;Monad + (do macro;Monad [[annsI annsV] (process-annotations annsC) [_ valueT valueA] (&;with-scope - (if (meta;type? (:! Code annsV)) + (if (macro;type? (:! Code annsV)) (do @ [valueA (&;with-type Type (analyse valueC))] @@ -71,7 +71,7 @@ (wrap [])))) (^code ("lux program" (~ [_ (#;Symbol ["" program-args])]) (~ programC))) - (do meta;Monad + (do macro;Monad [[_ programA] (&;with-scope (&;with-type (type (io;IO Unit)) (analyse programC))) @@ -79,15 +79,15 @@ (statementT;translate-program program-args programI)) (^code ("lux module" (~ annsC))) - (do meta;Monad + (do macro;Monad [[annsI annsV] (process-annotations annsC)] (&;fail (%code annsV))) (^code ((~ [_ (#;Symbol macro-name)]) (~@ args))) - (do meta;Monad - [macro-name (meta;normalize macro-name) - [def-type def-anns def-value] (meta;find-def macro-name)] - (if (meta;macro? def-anns) + (do macro;Monad + [macro-name (macro;normalize macro-name) + [def-type def-anns def-value] (macro;find-def macro-name)] + (if (macro;macro? def-anns) (do @ [expansion (function [compiler] (case (macroH;expand (:! Macro def-value) args compiler) @@ -119,7 +119,7 @@ (def: (with-active-compilation [module-name file-name source-code] action) (All [a] (-> [Text Text Text] (Meta a) (Meta a))) - (do meta;Monad + (do macro;Monad [#let [init-cursor [file-name +1 +0]] output (&;with-source-code [init-cursor +0 source-code] action) @@ -143,20 +143,20 @@ [_ (&io;prepare-module target-dir module-name) [file-name file-content] (&io;read-module source-dirs module-name) #let [module-hash (text/hash file-content)]] - (case (meta;run' compiler - (do meta;Monad - [[_ artifacts _] (moduleL;with-module module-hash module-name - (commonT;with-artifacts - (with-active-compilation [module-name - file-name - file-content] - (exhaust - (do @ - [code (parse module-name) - #let [[cursor _] code]] - (&;with-cursor cursor - (translate code)))))))] - (wrap artifacts))) + (case (macro;run' compiler + (do macro;Monad + [[_ artifacts _] (moduleL;with-module module-hash module-name + (commonT;with-artifacts + (with-active-compilation [module-name + file-name + file-content] + (exhaust + (do @ + [code (parse module-name) + #let [[cursor _] code]] + (&;with-cursor cursor + (translate code)))))))] + (wrap artifacts))) (#e;Success [compiler artifacts]) (do @ [_ (monad;map @ (function [[class-name class-bytecode]] diff --git a/new-luxc/source/luxc/lang/translation/case.jvm.lux b/new-luxc/source/luxc/lang/translation/case.jvm.lux index e3052c77d..cf2cdb7f1 100644 --- a/new-luxc/source/luxc/lang/translation/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/case.jvm.lux @@ -3,7 +3,7 @@ (lux (control [monad #+ do] ["ex" exception #+ exception:]) (data text/format) - [meta "meta/" Monad]) + [macro "macro/" Monad]) (luxc ["_" lang] (lang [";L" host] (host ["$" jvm] @@ -59,111 +59,111 @@ Nat $;Label $;Label ls;Path (Meta $;Inst)) (case path (^ [_ (#;Form (list [_ (#;Text "lux case exec")] bodyS))]) - (do meta;Monad + (do macro;Monad [bodyI (translate bodyS)] (wrap (|>. (pop-altI stack-depth) bodyI ($i;GOTO @end)))) (^ [_ (#;Form (list [_ (#;Text "lux case pop")]))]) - (meta/wrap popI) + (macro/wrap popI) (^ [_ (#;Form (list [_ (#;Text "lux case bind")] [_ (#;Nat register)]))]) - (meta/wrap (|>. peekI - ($i;ASTORE register))) + (macro/wrap (|>. peekI + ($i;ASTORE register))) [_ (#;Bool value)] - (meta/wrap (let [jumpI (if value $i;IFEQ $i;IFNE)] - (|>. peekI - ($i;unwrap #$;Boolean) - (jumpI @else)))) + (macro/wrap (let [jumpI (if value $i;IFEQ $i;IFNE)] + (|>. peekI + ($i;unwrap #$;Boolean) + (jumpI @else)))) (^template [ ] [_ ( value)] - (meta/wrap (|>. peekI - ($i;unwrap #$;Long) - ($i;long (|> value )) - $i;LCMP - ($i;IFNE @else)))) + (macro/wrap (|>. peekI + ($i;unwrap #$;Long) + ($i;long (|> value )) + $i;LCMP + ($i;IFNE @else)))) ([#;Nat (:! Int)] [#;Int (: Int)] [#;Deg (:! Int)]) [_ (#;Frac value)] - (meta/wrap (|>. peekI - ($i;unwrap #$;Double) - ($i;double value) - $i;DCMPL - ($i;IFNE @else))) + (macro/wrap (|>. peekI + ($i;unwrap #$;Double) + ($i;double value) + $i;DCMPL + ($i;IFNE @else))) [_ (#;Text value)] - (meta/wrap (|>. peekI - ($i;string value) - ($i;INVOKEVIRTUAL "java.lang.Object" - "equals" - ($t;method (list $Object) - (#;Some $t;boolean) - (list)) - false) - ($i;IFEQ @else))) + (macro/wrap (|>. peekI + ($i;string value) + ($i;INVOKEVIRTUAL "java.lang.Object" + "equals" + ($t;method (list $Object) + (#;Some $t;boolean) + (list)) + false) + ($i;IFEQ @else))) (^template [ ] (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)]))]) - (meta/wrap (case idx - +0 - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) - ($i;int 0) - $i;AALOAD - pushI) - - _ - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) - ($i;int (nat-to-int idx)) - ($i;INVOKESTATIC hostL;runtime-class - - ($t;method (list ../runtime;$Tuple $t;int) - (#;Some $Object) - (list)) - false) - pushI)))) + (macro/wrap (case idx + +0 + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) + ($i;int 0) + $i;AALOAD + pushI) + + _ + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) + ($i;int (nat-to-int idx)) + ($i;INVOKESTATIC hostL;runtime-class + + ($t;method (list ../runtime;$Tuple $t;int) + (#;Some $Object) + (list)) + false) + pushI)))) (["lux case tuple left" "pm_left"] ["lux case tuple right" "pm_right"]) (^template [ ] (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)]))]) - (meta/wrap (<| $i;with-label (function [@success]) - $i;with-label (function [@fail]) - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Variant)) - ($i;int (nat-to-int idx)) - - ($i;INVOKESTATIC hostL;runtime-class "pm_variant" - ($t;method (list ../runtime;$Variant ../runtime;$Tag ../runtime;$Flag) - (#;Some ../runtime;$Datum) - (list)) - false) - $i;DUP - ($i;IFNULL @fail) - ($i;GOTO @success) - ($i;label @fail) - $i;POP - ($i;GOTO @else) - ($i;label @success) - pushI)))) + (macro/wrap (<| $i;with-label (function [@success]) + $i;with-label (function [@fail]) + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Variant)) + ($i;int (nat-to-int idx)) + + ($i;INVOKESTATIC hostL;runtime-class "pm_variant" + ($t;method (list ../runtime;$Variant ../runtime;$Tag ../runtime;$Flag) + (#;Some ../runtime;$Datum) + (list)) + false) + $i;DUP + ($i;IFNULL @fail) + ($i;GOTO @success) + ($i;label @fail) + $i;POP + ($i;GOTO @else) + ($i;label @success) + pushI)))) (["lux case variant left" $i;NULL] ["lux case variant right" ($i;string "")]) (^ [_ (#;Form (list [_ (#;Text "lux case seq")] leftP rightP))]) - (do meta;Monad + (do macro;Monad [leftI (translate-path' translate stack-depth @else @end leftP) rightI (translate-path' translate stack-depth @else @end rightP)] (wrap (|>. leftI rightI))) (^ [_ (#;Form (list [_ (#;Text "lux case alt")] leftP rightP))]) - (do meta;Monad + (do macro;Monad [@alt-else $i;make-label leftI (translate-path' translate (n.inc stack-depth) @alt-else @end leftP) rightI (translate-path' translate stack-depth @else @end rightP)] @@ -179,7 +179,7 @@ (def: (translate-path translate path @end) (-> (-> ls;Synthesis (Meta $;Inst)) ls;Path $;Label (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [@else $i;make-label pathI (translate-path' translate +1 @else @end path)] (wrap (|>. pathI @@ -208,7 +208,7 @@ (def: #export (translate-case translate valueS path) (-> (-> ls;Synthesis (Meta $;Inst)) ls;Synthesis ls;Path (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [@end $i;make-label valueI (translate valueS) pathI (translate-path translate path @end)] @@ -222,7 +222,7 @@ (def: #export (translate-let translate register inputS exprS) (-> (-> ls;Synthesis (Meta $;Inst)) Nat ls;Synthesis ls;Synthesis (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [inputI (translate inputS) exprI (translate exprS)] (wrap (|>. inputI diff --git a/new-luxc/source/luxc/lang/translation/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/eval.jvm.lux index 3c4eea048..11baa3856 100644 --- a/new-luxc/source/luxc/lang/translation/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/eval.jvm.lux @@ -2,7 +2,7 @@ lux (lux (control monad) (data text/format) - [meta] + [macro] [host #+ do-to]) (luxc ["&" lang] (lang (host ["$" jvm] @@ -55,8 +55,8 @@ (def: #export (eval valueI) (-> $;Inst (Meta Top)) - (do meta;Monad - [class-name (:: @ map %code (meta;gensym "eval")) + (do macro;Monad + [class-name (:: @ map %code (macro;gensym "eval")) #let [writer (|> (do-to (ClassWriter.new ClassWriter.COMPUTE_MAXS) (ClassWriter.visit [commonT;bytecode-version (i.+ Opcodes.ACC_PUBLIC Opcodes.ACC_SUPER) diff --git a/new-luxc/source/luxc/lang/translation/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/expression.jvm.lux index d592c5001..65bb5b772 100644 --- a/new-luxc/source/luxc/lang/translation/expression.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/expression.jvm.lux @@ -5,8 +5,8 @@ ["p" parser]) (data ["e" error] text/format) - [meta] - (meta ["s" syntax])) + [macro] + (macro ["s" syntax])) (luxc ["&" lang] (lang [";L" variable #+ Variable Register] (host ["$" jvm]) diff --git a/new-luxc/source/luxc/lang/translation/function.jvm.lux b/new-luxc/source/luxc/lang/translation/function.jvm.lux index d12eca16e..d8a2077bc 100644 --- a/new-luxc/source/luxc/lang/translation/function.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/function.jvm.lux @@ -4,7 +4,7 @@ (data [text] text/format (coll [list "list/" Functor Monoid])) - [meta]) + [macro]) (luxc ["&" lang] (lang [";L" host] (host ["$" jvm] @@ -103,7 +103,7 @@ (def: (instance class arity env) (-> Text ls;Arity (List Variable) (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [captureI+ (monad;map @ referenceT;translate-variable env) #let [argsI (if (poly-arg? arity) (|> (nullsI (n.dec arity)) @@ -278,7 +278,7 @@ (with-reset class arity env) applyD ))] - (do meta;Monad + (do macro;Monad [instanceI (instance class arity env)] (wrap [functionD instanceI])))) @@ -286,7 +286,7 @@ (-> (-> ls;Synthesis (Meta $;Inst)) (List Variable) ls;Arity ls;Synthesis (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [@begin $i;make-label [function-class bodyI] (hostL;with-sub-context (hostL;with-anchor [@begin +1] @@ -310,7 +310,7 @@ (-> (-> ls;Synthesis (Meta $;Inst)) ls;Synthesis (List ls;Synthesis) (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [functionI (translate functionS) argsI (monad;map @ translate argsS) #let [applyI (|> (segment runtimeT;num-apply-variants argsI) diff --git a/new-luxc/source/luxc/lang/translation/loop.jvm.lux b/new-luxc/source/luxc/lang/translation/loop.jvm.lux index b5497236f..f5830bf9e 100644 --- a/new-luxc/source/luxc/lang/translation/loop.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/loop.jvm.lux @@ -4,7 +4,7 @@ (data [text] text/format (coll [list "list/" Functor Monoid])) - [meta]) + [macro]) (luxc ["&" lang] (lang [";L" host] (host ["$" jvm] @@ -22,7 +22,7 @@ (-> (-> ls;Synthesis (Meta $;Inst)) (List ls;Synthesis) (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [[@begin offset] hostL;anchor argsI (monad;map @ (function [[register argS]] (let [register' (|> register (n.+ offset))] @@ -47,7 +47,7 @@ (-> (-> ls;Synthesis (Meta $;Inst)) Nat (List ls;Synthesis) ls;Synthesis (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [@begin $i;make-label initsI+ (monad;map @ translate initsS+) bodyI (hostL;with-anchor [@begin (n.inc offset)] diff --git a/new-luxc/source/luxc/lang/translation/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux index f059aa8da..e8522ebfc 100644 --- a/new-luxc/source/luxc/lang/translation/primitive.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux @@ -2,7 +2,7 @@ lux (lux (control monad) (data text/format) - [meta "meta/" Monad]) + [macro "macro/" Monad]) (luxc ["&" lang] (lang [";L" host] (host ["$" jvm] @@ -15,18 +15,18 @@ (def: #export translate-unit (Meta $;Inst) - (meta/wrap ($i;string hostL;unit))) + (macro/wrap ($i;string hostL;unit))) (def: #export (translate-bool value) (-> Bool (Meta $;Inst)) - (meta/wrap ($i;GETSTATIC "java.lang.Boolean" - (if value "TRUE" "FALSE") - ($t;class "java.lang.Boolean" (list))))) + (macro/wrap ($i;GETSTATIC "java.lang.Boolean" + (if value "TRUE" "FALSE") + ($t;class "java.lang.Boolean" (list))))) (do-template [ ] [(def: #export ( value) (-> (Meta $;Inst)) - (meta/wrap (|>. ( value) )))] + (macro/wrap (|>. ( value) )))] [translate-nat Nat (|>. (:! Int) $i;long) ($i;wrap #$;Long)] [translate-int Int $i;long ($i;wrap #$;Long)] diff --git a/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux index 3cab88e48..0e17f99a6 100644 --- a/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/common.jvm.lux @@ -8,9 +8,9 @@ text/format (coll [list "list/" Functor] [dict #+ Dict])) - [meta #+ with-gensyms] - (meta [code] - ["s" syntax #+ syntax:]) + [macro #+ with-gensyms] + (macro [code] + ["s" syntax #+ syntax:]) [host]) (luxc ["&" lang] (lang [";L" host] @@ -84,7 +84,7 @@ (syntax: (arity: [name s;local-symbol] [arity s;nat]) (with-gensyms [g!proc g!name g!translate g!inputs] (do @ - [g!input+ (monad;seq @ (list;repeat arity (meta;gensym "input")))] + [g!input+ (monad;seq @ (list;repeat arity (macro;gensym "input")))] (wrap (list (` (def: #export ((~ (code;local-symbol name)) (~ g!proc)) (-> (-> (;;Vector (~ (code;nat arity)) $;Inst) $;Inst) (-> Text ;;Proc)) @@ -92,7 +92,7 @@ (function [(~ g!translate) (~ g!inputs)] (case (~ g!inputs) (^ (list (~@ g!input+))) - (do meta;Monad + (do macro;Monad [(~@ (|> g!input+ (list/map (function [g!input] (list g!input (` ((~ g!translate) (~ g!input)))))) @@ -100,7 +100,7 @@ ((~' wrap) ((~ g!proc) [(~@ g!input+)]))) (~' _) - (meta;fail (wrong-arity (~ g!name) +1 (list;size (~ g!inputs)))))))))))))) + (macro;fail (wrong-arity (~ g!name) +1 (list;size (~ g!inputs)))))))))))))) (arity: nullary +0) (arity: unary +1) @@ -111,7 +111,7 @@ (-> Variadic (-> Text Proc)) (function [proc-name] (function [translate inputsS] - (do meta;Monad + (do macro;Monad [inputsI (monad;map @ translate inputsS)] (wrap (proc inputsI)))))) diff --git a/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux index 8a28e3cf7..b020fed7b 100644 --- a/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/procedure/host.jvm.lux @@ -10,9 +10,9 @@ ["l" lexer]) (coll [list "list/" Functor] [dict #+ Dict])) - [meta "meta/" Monad] - (meta [code] - ["s" syntax #+ syntax:]) + [macro "macro/" Monad] + (macro [code] + ["s" syntax #+ syntax:]) [host]) (luxc ["&" lang] (lang [";L" host] @@ -280,7 +280,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Nat level)] [_ (#;Text class)] lengthS)) - (do meta;Monad + (do macro;Monad [lengthI (translate lengthS) #let [arrayJT ($t;array level (case class "boolean" $t;boolean @@ -304,7 +304,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] idxS arrayS)) - (do meta;Monad + (do macro;Monad [arrayI (translate arrayS) idxI (translate idxS) #let [loadI (case class @@ -330,7 +330,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] idxS valueS arrayS)) - (do meta;Monad + (do macro;Monad [arrayI (translate arrayS) idxI (translate idxS) valueI (translate valueS) @@ -399,7 +399,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)])) - (do meta;Monad + (do macro;Monad [] (wrap (|>. ($i;string class) ($i;INVOKESTATIC "java.lang.Class" "forName" @@ -415,7 +415,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] objectS)) - (do meta;Monad + (do macro;Monad [objectI (translate objectS)] (wrap (|>. objectI ($i;INSTANCEOF class) @@ -452,7 +452,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] [_ (#;Text field)] [_ (#;Text unboxed)])) - (do meta;Monad + (do macro;Monad [] (case (dict;get unboxed primitives) (#;Some primitive) @@ -479,7 +479,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] [_ (#;Text field)] [_ (#;Text unboxed)] valueS)) - (do meta;Monad + (do macro;Monad [valueI (translate valueS)] (case (dict;get unboxed primitives) (#;Some primitive) @@ -511,7 +511,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] [_ (#;Text field)] [_ (#;Text unboxed)] objectS)) - (do meta;Monad + (do macro;Monad [objectI (translate objectS)] (case (dict;get unboxed primitives) (#;Some primitive) @@ -542,7 +542,7 @@ (-> Text @;Proc) (case inputs (^ (list [_ (#;Text class)] [_ (#;Text field)] [_ (#;Text unboxed)] valueS objectS)) - (do meta;Monad + (do macro;Monad [valueI (translate valueS) objectI (translate objectS)] (case (dict;get unboxed primitives) @@ -605,7 +605,7 @@ (&;throw Invalid-Syntax-For-JVM-Type argD) (#e;Success type) - (meta/wrap type))) + (macro/wrap type))) (def: (prepare-input inputT inputI) (-> $;Type $;Inst $;Inst) @@ -629,10 +629,10 @@ (Meta (List [$;Type $;Inst]))) (case argsS #;Nil - (meta/wrap #;Nil) + (macro/wrap #;Nil) (^ (list& [_ (#;Tuple (list [_ (#;Text argD)] argS))] tail)) - (do meta;Monad + (do macro;Monad [argT (translate-type argD) argI (:: @ map (prepare-input argT) (translate argS)) =tail (translate-args translate tail)] @@ -645,10 +645,10 @@ (-> Text (Meta (Maybe $;Type))) (case description "void" - (meta/wrap #;None) + (macro/wrap #;None) _ - (meta/map (|>. #;Some) (translate-type description)))) + (macro/map (|>. #;Some) (translate-type description)))) (def: (prepare-return returnT returnI) (-> (Maybe $;Type) $;Inst $;Inst) @@ -670,7 +670,7 @@ (case inputs (^ (list& [_ (#;Text class)] [_ (#;Text method)] [_ (#;Text unboxed)] argsS)) - (do meta;Monad + (do macro;Monad [argsTI (translate-args translate argsS) returnT (method-return-type unboxed) #let [callI (|>. ($i;fuse (list/map product;right argsTI)) @@ -688,7 +688,7 @@ (case inputs (^ (list& [_ (#;Text class)] [_ (#;Text method)] [_ (#;Text unboxed)] objectS argsS)) - (do meta;Monad + (do macro;Monad [objectI (translate objectS) argsTI (translate-args translate argsS) returnT (method-return-type unboxed) @@ -712,7 +712,7 @@ (-> Text @;Proc) (case inputs (^ (list& [_ (#;Text class)] argsS)) - (do meta;Monad + (do macro;Monad [argsTI (translate-args translate argsS)] (wrap (|>. ($i;NEW class) $i;DUP diff --git a/new-luxc/source/luxc/lang/translation/reference.jvm.lux b/new-luxc/source/luxc/lang/translation/reference.jvm.lux index b714558b8..9d0cc91e4 100644 --- a/new-luxc/source/luxc/lang/translation/reference.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/reference.jvm.lux @@ -3,7 +3,7 @@ (lux (control [monad #+ do]) (data [text "text/" Hash] text/format) - [meta "meta/" Monad]) + [macro "macro/" Monad]) (luxc ["&" lang] (lang [";L" host] (host ["$" jvm] @@ -24,7 +24,7 @@ (def: #export (translate-captured variable) (-> Variable (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [function-class hostL;context] (wrap (|>. ($i;ALOAD +0) ($i;GETFIELD function-class @@ -33,7 +33,7 @@ (def: #export (translate-local variable) (-> Variable (Meta $;Inst)) - (meta/wrap ($i;ALOAD (int-to-nat variable)))) + (macro/wrap ($i;ALOAD (int-to-nat variable)))) (def: #export (translate-variable variable) (-> Variable (Meta $;Inst)) @@ -44,4 +44,4 @@ (def: #export (translate-definition [def-module def-name]) (-> Ident (Meta $;Inst)) (let [bytecode-name (format def-module "/" (&;normalize-name def-name) (%n (text/hash def-name)))] - (meta/wrap ($i;GETSTATIC bytecode-name commonT;value-field commonT;$Object)))) + (macro/wrap ($i;GETSTATIC bytecode-name commonT;value-field commonT;$Object)))) diff --git a/new-luxc/source/luxc/lang/translation/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/runtime.jvm.lux index fa6d6dcad..87174b192 100644 --- a/new-luxc/source/luxc/lang/translation/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/runtime.jvm.lux @@ -4,7 +4,7 @@ (data text/format (coll [list "list/" Functor])) [math] - [meta] + [macro] [host]) (luxc ["&" lang] (lang [";L" host] @@ -579,7 +579,7 @@ (def: translate-runtime (Meta commonT;Bytecode) - (do meta;Monad + (do macro;Monad [_ (wrap []) #let [bytecode ($d;class #$;V1.6 #$;Public $;finalC hostL;runtime-class (list) ["java.lang.Object" (list)] (list) (|>. adt-methods @@ -594,7 +594,7 @@ (def: translate-function (Meta commonT;Bytecode) - (do meta;Monad + (do macro;Monad [_ (wrap []) #let [applyI (|> (list;n.range +2 num-apply-variants) (list/map (function [arity] @@ -625,7 +625,7 @@ (def: #export translate (Meta [commonT;Bytecode commonT;Bytecode]) - (do meta;Monad + (do macro;Monad [runtime-bc translate-runtime function-bc translate-function] (wrap [runtime-bc function-bc]))) diff --git a/new-luxc/source/luxc/lang/translation/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/statement.jvm.lux index 232519d8b..387181f98 100644 --- a/new-luxc/source/luxc/lang/translation/statement.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/statement.jvm.lux @@ -7,7 +7,7 @@ [text "text/" Monoid Hash] text/format (coll [list "list/" Functor Fold])) - [meta] + [macro] [host]) (luxc ["&" lang] ["&;" io] @@ -34,8 +34,8 @@ (def: #export (translate-def def-name valueT valueI metaI metaV) (-> Text Type $;Inst $;Inst Code (Meta Unit)) - (do meta;Monad - [current-module meta;current-module-name + (do macro;Monad + [current-module macro;current-module-name #let [def-ident [current-module def-name] normal-name (format (&;normalize-name def-name) (%n (text/hash def-name))) bytecode-name (format current-module "/" normal-name) @@ -68,13 +68,13 @@ "Error:\n" error)))) _ (&module;define def-ident [valueT metaV valueV]) - _ (if (meta;type? metaV) - (case (meta;declared-tags metaV) + _ (if (macro;type? metaV) + (case (macro;declared-tags metaV) #;Nil (wrap []) tags - (&module;declare-tags tags (meta;export? metaV) (:! Type valueV))) + (&module;declare-tags tags (macro;export? metaV) (:! Type valueV))) (wrap [])) #let [_ (log! (format "DEF " (%ident def-ident)))]] (commonT;record-artifact (format bytecode-name ".class") bytecode))) diff --git a/new-luxc/source/luxc/lang/translation/structure.jvm.lux b/new-luxc/source/luxc/lang/translation/structure.jvm.lux index 2c04eaa0c..21d72b34b 100644 --- a/new-luxc/source/luxc/lang/translation/structure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/structure.jvm.lux @@ -4,7 +4,7 @@ ["ex" exception #+ exception:]) (data text/format (coll [list])) - [meta] + [macro] [host #+ do-to]) (luxc ["&" lang] (lang [";L" host] @@ -23,7 +23,7 @@ (def: #export (translate-tuple translate members) (-> (-> ls;Synthesis (Meta $;Inst)) (List ls;Synthesis) (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [#let [size (list;size members)] _ (&;assert Not-A-Tuple (%code (` [(~@ members)])) (n.>= +2 size)) @@ -49,7 +49,7 @@ (def: #export (translate-variant translate tag tail? member) (-> (-> ls;Synthesis (Meta $;Inst)) Nat Bool ls;Synthesis (Meta $;Inst)) - (do meta;Monad + (do macro;Monad [memberI (translate member)] (wrap (|>. ($i;int (nat-to-int tag)) (flagI tail?) diff --git a/new-luxc/test/test/luxc/lang/analysis/case.lux b/new-luxc/test/test/luxc/lang/analysis/case.lux index bffa99bce..f99c034e8 100644 --- a/new-luxc/test/test/luxc/lang/analysis/case.lux +++ b/new-luxc/test/test/luxc/lang/analysis/case.lux @@ -12,8 +12,8 @@ (coll [list "L/" Monad] ["S" set])) ["r" math/random "r/" Monad] - [meta #+ Monad] - (meta [code]) + [macro #+ Monad] + (macro [code]) (lang [type "type/" Eq] (type ["tc" check])) test) diff --git a/new-luxc/test/test/luxc/lang/analysis/common.lux b/new-luxc/test/test/luxc/lang/analysis/common.lux index 086a0bd31..e7b9dc486 100644 --- a/new-luxc/test/test/luxc/lang/analysis/common.lux +++ b/new-luxc/test/test/luxc/lang/analysis/common.lux @@ -3,8 +3,8 @@ (lux (control pipe) ["r" math/random "r/" Monad] (data ["e" error]) - [meta] - (meta [code])) + [macro] + (macro [code])) (luxc ["&" lang] (lang (analysis [";A" expression]) [eval])) @@ -40,7 +40,7 @@ [(def: #export ( analysis) (All [a] (-> (Meta a) Bool)) (|> analysis - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) diff --git a/new-luxc/test/test/luxc/lang/analysis/function.lux b/new-luxc/test/test/luxc/lang/analysis/function.lux index 5b84d3dd0..b99e5e2ee 100644 --- a/new-luxc/test/test/luxc/lang/analysis/function.lux +++ b/new-luxc/test/test/luxc/lang/analysis/function.lux @@ -10,8 +10,8 @@ text/format (coll [list "list/" Functor])) ["r" math/random "r/" Monad] - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type "type/" Eq]) test) (luxc ["&" lang] @@ -54,7 +54,7 @@ (def: (check-apply expectedT num-args analysis) (-> Type Nat (Meta [Type la;Analysis]) Bool) (|> analysis - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [applyT applyA]) (let [[funcA argsA] (flatten-apply applyA)] (and (type/= expectedT applyT) @@ -74,31 +74,31 @@ (test "Can analyse function." (|> (&;with-type (type (All [a] (-> a outputT))) (@;analyse-function analyse func-name arg-name outputC)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) succeeds?)) (test "Generic functions can always be specialized." (and (|> (&;with-type (-> inputT outputT) (@;analyse-function analyse func-name arg-name outputC)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) succeeds?) (|> (&;with-type (-> inputT inputT) (@;analyse-function analyse func-name arg-name (code;symbol ["" arg-name]))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) succeeds?))) (test "Can infer function (constant output and unused input)." (|> (@common;with-unknown-type (@;analyse-function analyse func-name arg-name outputC)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (check-type (type (All [a] (-> a outputT)))))) (test "Can infer function (output = input)." (|> (@common;with-unknown-type (@;analyse-function analyse func-name arg-name (code;symbol ["" arg-name]))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (check-type (type (All [a] (-> a a)))))) (test "The function's name is bound to the function's type." (|> (&;with-type (type (Rec self (-> inputT self))) (@;analyse-function analyse func-name arg-name (code;symbol ["" func-name]))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) succeeds?)) )))) diff --git a/new-luxc/test/test/luxc/lang/analysis/primitive.lux b/new-luxc/test/test/luxc/lang/analysis/primitive.lux index 7c2e8b123..cf60d64fe 100644 --- a/new-luxc/test/test/luxc/lang/analysis/primitive.lux +++ b/new-luxc/test/test/luxc/lang/analysis/primitive.lux @@ -6,8 +6,8 @@ (data (text format) ["e" error]) ["r" math/random] - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type "type/" Eq]) test) (luxc ["&" lang] @@ -32,7 +32,7 @@ (test "Can analyse unit." (|> (@common;with-unknown-type @;analyse-unit) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^ (#e;Success [_type (^code [])])) (type/= Unit _type) @@ -43,7 +43,7 @@ [(test (format "Can analyse " ".") (|> (@common;with-unknown-type ( )) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_type [_ ( value)]]) (and (type/= _type) (is value)) diff --git a/new-luxc/test/test/luxc/lang/analysis/procedure/common.lux b/new-luxc/test/test/luxc/lang/analysis/procedure/common.lux index f5b1feb71..91e5267f8 100644 --- a/new-luxc/test/test/luxc/lang/analysis/procedure/common.lux +++ b/new-luxc/test/test/luxc/lang/analysis/procedure/common.lux @@ -9,8 +9,8 @@ [product] (coll [array])) ["r" math/random "r/" Monad] - [meta #+ Monad] - (meta [code]) + [macro #+ Monad] + (macro [code]) (lang [type "type/" Eq]) test) (luxc ["&" lang] @@ -30,7 +30,7 @@ (|> (&;with-scope (&;with-type output-type (@;analyse-procedure analyse evalL;eval procedure params))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) @@ -266,7 +266,7 @@ (@;analyse-procedure analyse evalL;eval "lux array get" (list idxC (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -280,7 +280,7 @@ (list idxC elemC (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -293,7 +293,7 @@ (@;analyse-procedure analyse evalL;eval "lux array remove" (list idxC (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -305,7 +305,7 @@ (&;with-type Nat (@;analyse-procedure analyse evalL;eval "lux array size" (list (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -365,7 +365,7 @@ (&;with-type elemT (@;analyse-procedure analyse evalL;eval "lux atom read" (list (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -379,7 +379,7 @@ (list elemC elemC (code;symbol ["" var-name])))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true diff --git a/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux b/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux index b82eb8206..13645840e 100644 --- a/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux +++ b/new-luxc/test/test/luxc/lang/analysis/procedure/host.jvm.lux @@ -13,8 +13,8 @@ [list "list/" Fold] [dict])) ["r" math/random "r/" Monad] - [meta #+ Monad] - (meta [code]) + [macro #+ Monad] + (macro [code]) (lang [type]) test) (luxc ["&" lang] @@ -38,7 +38,7 @@ (&;with-scope (&;with-type output-type (@;analyse-procedure analyse evalL;eval procedure params)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) diff --git a/new-luxc/test/test/luxc/lang/analysis/reference.lux b/new-luxc/test/test/luxc/lang/analysis/reference.lux index 16cfb9a38..14079c6b8 100644 --- a/new-luxc/test/test/luxc/lang/analysis/reference.lux +++ b/new-luxc/test/test/luxc/lang/analysis/reference.lux @@ -5,7 +5,7 @@ pipe) (data ["e" error]) ["r" math/random] - [meta #+ Monad] + [macro #+ Monad] (lang [type "type/" Eq]) test) (luxc (lang ["&;" scope] @@ -30,7 +30,7 @@ (&scope;with-local [var-name ref-type] (@common;with-unknown-type (@;analyse-reference ["" var-name])))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^ (#e;Success [_type (^code ((~ [_ (#;Int var)])))])) (type/= ref-type _type) @@ -43,7 +43,7 @@ [ref-type (' {}) (:! Void [])])] (@common;with-unknown-type (@;analyse-reference [module-name var-name]))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_type [_ (#;Symbol def-name)]]) (type/= ref-type _type) diff --git a/new-luxc/test/test/luxc/lang/analysis/structure.lux b/new-luxc/test/test/luxc/lang/analysis/structure.lux index cc31622a1..58212359e 100644 --- a/new-luxc/test/test/luxc/lang/analysis/structure.lux +++ b/new-luxc/test/test/luxc/lang/analysis/structure.lux @@ -12,8 +12,8 @@ (coll [list "list/" Functor] ["S" set])) ["r" math/random "r/" Monad] - [meta] - (meta [code]) + [macro] + (macro [code]) (lang [type "type/" Eq] (type ["tc" check])) test) @@ -47,7 +47,7 @@ (|> (&;with-scope (&;with-type variantT (@;analyse-sum analyse choice valueC))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ sumA]) [(la;unfold-variant sumA) (#;Some [tag last? valueA])]) @@ -58,13 +58,13 @@ false))) (test "Can analyse sum through bound type-vars." (|> (&;with-scope - (do meta;Monad + (do macro;Monad [[_ varT] (&;with-type-env tc;var) _ (&;with-type-env (tc;check varT variantT))] (&;with-type varT (@;analyse-sum analyse choice valueC)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ sumA]) [(la;unfold-variant sumA) (#;Some [tag last? valueA])]) @@ -75,11 +75,11 @@ false))) (test "Cannot analyse sum through unbound type-vars." (|> (&;with-scope - (do meta;Monad + (do macro;Monad [[_ varT] (&;with-type-env tc;var)] (&;with-type varT (@;analyse-sum analyse choice valueC)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) false @@ -89,7 +89,7 @@ (|> (&;with-scope (&;with-type (type;ex-q +1 +variantT) (@;analyse-sum analyse +choice +valueC))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -99,7 +99,7 @@ (|> (&;with-scope (&;with-type (type;univ-q +1 +variantT) (@;analyse-sum analyse +choice +valueC))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) (not (n.= choice +choice)) @@ -123,7 +123,7 @@ (test "Can analyse product." (|> (&;with-type (type;tuple (list/map product;left primitives)) (@;analyse-product analyse (list/map product;right primitives))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success tupleA) (n.= size (list;size (la;unfold-tuple tupleA))) @@ -132,7 +132,7 @@ (test "Can infer product." (|> (@common;with-unknown-type (@;analyse-product analyse (list/map product;right primitives))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_type tupleA]) (and (type/= (type;tuple (list/map product;left primitives)) _type) @@ -143,7 +143,7 @@ (test "Can analyse pseudo-product (singleton tuple)" (|> (&;with-type singletonT (analyse (` [(~ singletonC)]))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success singletonA) true @@ -151,13 +151,13 @@ false))) (test "Can analyse product through bound type-vars." (|> (&;with-scope - (do meta;Monad + (do macro;Monad [[_ varT] (&;with-type-env tc;var) _ (&;with-type-env (tc;check varT (type;tuple (list/map product;left primitives))))] (&;with-type varT (@;analyse-product analyse (list/map product;right primitives))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_ tupleA]) (n.= size (list;size (la;unfold-tuple tupleA))) @@ -167,7 +167,7 @@ (|> (&;with-scope (&;with-type (type;ex-q +1 +tupleT) (@;analyse-product analyse (list/map product;right +primitives)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) true @@ -177,7 +177,7 @@ (|> (&;with-scope (&;with-type (type;univ-q +1 +tupleT) (@;analyse-product analyse (list/map product;right +primitives)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success _) false @@ -188,7 +188,7 @@ (def: (check-variant-inference variantT choice size analysis) (-> Type Nat Nat (Meta [Module Scope Type la;Analysis]) Bool) (|> analysis - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ _ sumT sumA]) [(la;unfold-variant sumA) (#;Some [tag last? valueA])]) @@ -202,7 +202,7 @@ (def: (check-record-inference tupleT size analysis) (-> Type Nat (Meta [Module Scope Type la;Analysis]) Bool) (|> analysis - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ _ productT productA]) [(la;unfold-tuple productA) membersA]) @@ -238,7 +238,7 @@ ($_ seq (test "Can infer tagged sum." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false namedT)] (&;with-scope (@common;with-unknown-type @@ -246,7 +246,7 @@ (check-variant-inference variantT choice size))) (test "Tagged sums specialize when type-vars get bound." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false named-polyT)] (&;with-scope (@common;with-unknown-type @@ -254,7 +254,7 @@ (check-variant-inference variantT choice size))) (test "Tagged sum inference retains universal quantification when type-vars are not bound." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false named-polyT)] (&;with-scope (@common;with-unknown-type @@ -262,12 +262,12 @@ (check-variant-inference polyT other-choice size))) (test "Can specialize generic tagged sums." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false named-polyT)] (&;with-scope (&;with-type variantT (@;analyse-tagged-sum analyse [module-name other-choice-tag] other-choiceC))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ _ sumA]) [(la;unfold-variant sumA) (#;Some [tag last? valueA])]) @@ -302,7 +302,7 @@ ($_ seq (test "Can infer record." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false namedT)] (&;with-scope (@common;with-unknown-type @@ -310,7 +310,7 @@ (check-record-inference tupleT size))) (test "Records specialize when type-vars get bound." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false named-polyT)] (&;with-scope (@common;with-unknown-type @@ -318,12 +318,12 @@ (check-record-inference tupleT size))) (test "Can specialize generic records." (|> (@module;with-module +0 module-name - (do meta;Monad + (do macro;Monad [_ (@module;declare-tags tags false named-polyT)] (&;with-scope (&;with-type tupleT (@;analyse-record analyse recordC))))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success [_ _ productA]) [(la;unfold-tuple productA) membersA]) diff --git a/new-luxc/test/test/luxc/lang/analysis/type.lux b/new-luxc/test/test/luxc/lang/analysis/type.lux index ed75f4d6c..b159870c8 100644 --- a/new-luxc/test/test/luxc/lang/analysis/type.lux +++ b/new-luxc/test/test/luxc/lang/analysis/type.lux @@ -12,8 +12,8 @@ [product] (coll [list "list/" Functor Fold])) ["r" math/random "r/" Monad] - [meta #+ Monad] - (meta [code]) + [macro #+ Monad] + (macro [code]) (lang [type "type/" Eq]) test) (luxc ["&" lang] @@ -57,7 +57,7 @@ (&;with-scope (@common;with-unknown-type (@;analyse-check analyse eval;eval typeC exprC)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_ [analysisT analysisA]]) (and (type/= codeT analysisT) (case [exprC analysisA] @@ -82,7 +82,7 @@ (&;with-scope (@common;with-unknown-type (@;analyse-coerce analyse eval;eval typeC exprC)))) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success [_ [analysisT analysisA]]) (type/= codeT analysisT) diff --git a/new-luxc/test/test/luxc/lang/synthesis/case/special.lux b/new-luxc/test/test/luxc/lang/synthesis/case/special.lux index 585c7d349..1ae6ad030 100644 --- a/new-luxc/test/test/luxc/lang/synthesis/case/special.lux +++ b/new-luxc/test/test/luxc/lang/synthesis/case/special.lux @@ -3,7 +3,7 @@ (lux [io] (control [monad #+ do] pipe) - (meta [code]) + (macro [code]) ["r" math/random "r/" Monad] test) (luxc (lang ["la" analysis] diff --git a/new-luxc/test/test/luxc/lang/synthesis/common.lux b/new-luxc/test/test/luxc/lang/synthesis/common.lux index a74c64402..caa2d09dc 100644 --- a/new-luxc/test/test/luxc/lang/synthesis/common.lux +++ b/new-luxc/test/test/luxc/lang/synthesis/common.lux @@ -2,7 +2,7 @@ lux (lux (data [bool "bool/" Eq] [text "text/" Eq]) - (meta [code]) + (macro [code]) ["r" math/random "r/" Monad]) (luxc (lang ["la" analysis] ["ls" synthesis]))) diff --git a/new-luxc/test/test/luxc/lang/synthesis/function.lux b/new-luxc/test/test/luxc/lang/synthesis/function.lux index f364536cb..259bf5a4e 100644 --- a/new-luxc/test/test/luxc/lang/synthesis/function.lux +++ b/new-luxc/test/test/luxc/lang/synthesis/function.lux @@ -10,7 +10,7 @@ (coll [list "list/" Functor Fold] [dict #+ Dict] [set])) - (meta [code]) + (macro [code]) ["r" math/random "r/" Monad] test) (luxc (lang ["la" analysis] diff --git a/new-luxc/test/test/luxc/lang/synthesis/loop.lux b/new-luxc/test/test/luxc/lang/synthesis/loop.lux index 90b303857..386b06dcd 100644 --- a/new-luxc/test/test/luxc/lang/synthesis/loop.lux +++ b/new-luxc/test/test/luxc/lang/synthesis/loop.lux @@ -7,7 +7,7 @@ (coll [list "list/" Functor Fold] ["s" set]) text/format) - (meta [code]) + (macro [code]) ["r" math/random "r/" Monad] test) (luxc (lang ["la" analysis] diff --git a/new-luxc/test/test/luxc/lang/synthesis/primitive.lux b/new-luxc/test/test/luxc/lang/synthesis/primitive.lux index d907a4c04..47f394117 100644 --- a/new-luxc/test/test/luxc/lang/synthesis/primitive.lux +++ b/new-luxc/test/test/luxc/lang/synthesis/primitive.lux @@ -4,7 +4,7 @@ (control [monad #+ do] pipe) (data text/format) - (meta [code]) + (macro [code]) ["r" math/random] test) (luxc (lang ["la" analysis] diff --git a/new-luxc/test/test/luxc/lang/translation/case.lux b/new-luxc/test/test/luxc/lang/translation/case.lux index ace2e0290..d843e6e1c 100644 --- a/new-luxc/test/test/luxc/lang/translation/case.lux +++ b/new-luxc/test/test/luxc/lang/translation/case.lux @@ -7,8 +7,8 @@ text/format (coll [list])) ["r" math/random "r/" Monad] - [meta] - (meta [code]) + [macro] + (macro [code]) test) (luxc (lang ["ls" synthesis] (translation ["@" case] @@ -63,13 +63,14 @@ )))) (context: "Pattern-matching." - (<| (times +100) + (<| (seed +517905247826) + ## (times +100) (do @ [[valueS pathS] gen-case to-bind r;nat] ($_ seq (test "Can translate pattern-matching." - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (@;translate-case expressionT;translate valueS @@ -79,21 +80,21 @@ ("lux case seq" ("lux case bind" +0) ("lux case exec" false)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (:! Bool valueT) (#e;Error error) false))) (test "Can bind values." - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (@;translate-case expressionT;translate (code;nat to-bind) (` ("lux case seq" ("lux case bind" +0) ("lux case exec" (0)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= to-bind (:! Nat valueT)) diff --git a/new-luxc/test/test/luxc/lang/translation/function.lux b/new-luxc/test/test/luxc/lang/translation/function.lux index 999f4f432..726b51b58 100644 --- a/new-luxc/test/test/luxc/lang/translation/function.lux +++ b/new-luxc/test/test/luxc/lang/translation/function.lux @@ -9,8 +9,8 @@ (coll ["a" array] [list "list/" Functor])) ["r" math/random "r/" Monad] - [meta] - (meta [code]) + [macro] + (macro [code]) [host] test) (luxc (lang ["ls" synthesis] @@ -47,11 +47,11 @@ cut-off (|> cut-off (n.min (n.dec last-arg)))]] ($_ seq (test "Can read arguments." - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ("lux call" (~ functionS) (~@ argsS))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= arg-value (:! Nat valueT)) @@ -59,7 +59,7 @@ false))) (test "Can partially apply functions." (or (n.= +1 arity) - (|> (do meta;Monad + (|> (do macro;Monad [#let [partial-arity (n.inc cut-off) preS (list;take partial-arity argsS) postS (list;drop partial-arity argsS)] @@ -68,7 +68,7 @@ ("lux call" (~ functionS) (~@ preS)) (~@ postS))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= arg-value (:! Nat valueT)) @@ -76,7 +76,7 @@ false)))) (test "Can read environment." (or (n.= +1 arity) - (|> (do meta;Monad + (|> (do macro;Monad [#let [env (|> (list;n.range +0 cut-off) (list/map (|>. n.inc nat-to-int))) super-arity (n.inc cut-off) @@ -90,7 +90,7 @@ runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ("lux call" (~ functionS) (~@ argsS))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= arg-value (:! Nat valueT)) diff --git a/new-luxc/test/test/luxc/lang/translation/primitive.lux b/new-luxc/test/test/luxc/lang/translation/primitive.lux index 40e98f109..ad4f57107 100644 --- a/new-luxc/test/test/luxc/lang/translation/primitive.lux +++ b/new-luxc/test/test/luxc/lang/translation/primitive.lux @@ -8,8 +8,8 @@ [bool "B/" Eq] [text "T/" Eq]) ["r" math/random] - [meta] - (meta [code]) + [macro] + (macro [code]) test) (luxc (lang [";L" host] ["ls" synthesis] @@ -31,10 +31,10 @@ (with-expansions [ (do-template [ ] [(test (format "Can translate " ".") - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate ( ))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( (:! valueT)) @@ -49,10 +49,10 @@ ["text" Text code;text %text% T/=])] ($_ seq (test "Can translate unit." - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (' []))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (is hostL;unit (:! Text valueT)) diff --git a/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux b/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux index 38036e420..9eb5050bb 100644 --- a/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux +++ b/new-luxc/test/test/luxc/lang/translation/procedure/common.jvm.lux @@ -12,8 +12,8 @@ (coll ["a" array] [list])) ["r" math/random] - [meta] - (meta [code]) + [macro] + (macro [code]) [host] test) (luxc (lang ["ls" synthesis] @@ -30,11 +30,11 @@ subject r;nat] (with-expansions [ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ( (~ (code;nat subject)) (~ (code;nat param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= ( param subject) (:! Nat valueT)) @@ -49,10 +49,10 @@ )] ($_ seq (test "bit count" - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ("lux bit count" (~ (code;nat subject)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= (bit;count subject) (:! Nat valueT)) @@ -61,12 +61,12 @@ (test "bit shift-right" - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ("lux bit shift-right" (~ (code;int (nat-to-int subject))) (~ (code;nat param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (i.= (bit;signed-shift-right param (nat-to-int subject)) (:! Int valueT)) @@ -83,10 +83,10 @@ (`` ($_ seq (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ()))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (n.= (:! Nat valueT)) @@ -98,10 +98,10 @@ )) (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ( (~ (code;nat subject)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( subject) (:! valueT)) @@ -113,11 +113,11 @@ )) (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;nat subject)) (~ (code;nat param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( param subject) (:! valueT)) @@ -141,10 +141,10 @@ subject r;int] (with-expansions [ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ()))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (i.= (:! Int valueT)) @@ -156,10 +156,10 @@ ) (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ( (~ (code;int subject)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( subject) (:! valueT)) @@ -171,11 +171,11 @@ ) (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;int subject)) (~ (code;int param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( param subject) (:! valueT)) @@ -203,11 +203,11 @@ subject r;frac] (with-expansions [ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;frac subject)) (~ (code;frac param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( param subject) (:! valueT)) @@ -233,10 +233,10 @@ subject r;frac] (with-expansions [ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ()))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( (:! Frac valueT)) @@ -252,11 +252,11 @@ ) (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;frac subject)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( subject) (:! valueT)) @@ -270,11 +270,11 @@ (test "frac encode|decode" - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ("lux frac decode" ("lux frac encode" (~ (code;frac subject))))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (^multi (#e;Success valueT) [(:! (Maybe Frac) valueT) (#;Some value)]) (f.= subject value) @@ -299,10 +299,10 @@ (`` ($_ seq (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ()))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) (d.= (:! Deg valueT)) @@ -314,11 +314,11 @@ )) (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;deg subject)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( subject) (:! valueT)) @@ -329,11 +329,11 @@ )) (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;deg subject)) (~ (code;deg param)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( param subject) (:! valueT)) @@ -350,11 +350,11 @@ )) (~~ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [runtime-bytecode @runtime;translate sampleI (expressionT;translate (` ( (~ (code;deg subject)) (~ (code;nat special)))))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( ( special subject) (:! valueT)) diff --git a/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux b/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux index c2b699ff2..f5b1e97df 100644 --- a/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux +++ b/new-luxc/test/test/luxc/lang/translation/procedure/host.jvm.lux @@ -12,8 +12,8 @@ text/format (coll [list])) ["r" math/random "r/" Monad] - [meta] - (meta [code]) + [macro] + (macro [code]) [host] test) (luxc (lang [";L" host] @@ -31,10 +31,10 @@ #let [frac-sample (int-to-frac int-sample)]] (with-expansions [<2step> (do-template [ ] [(test (format " / " ) - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (|> (~ ( )) (`)))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( (:! valueT)) @@ -62,10 +62,10 @@ (`` ($_ seq (~~ (do-template [ ] [(test (format " / " " / " ) - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (|> (~ ( )) (`)))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( (:! valueT)) @@ -88,10 +88,10 @@ (`` ($_ seq (~~ (do-template [ ] [(test (format " / " " / " ) - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (|> (~ ( )) (`)))] (@eval;eval sampleI)) - (meta;run (init-compiler [])) + (macro;run (init-compiler [])) (case> (#e;Success valueT) ( (:! valueT)) @@ -126,12 +126,12 @@ #let [subject ( param)]] (with-expansions [ (do-template [ ] [(test - (|> (do meta;Monad + (|> (do macro;Monad [sampleI (expressionT;translate (` ( ((~ (code;text )) (
 (~ ( subject)))
                                                                                                 (
 (~ ( param)))))))]
                                                     (@eval;eval sampleI))
-                                                  (meta;run (init-compiler []))
+                                                  (macro;run (init-compiler []))
                                                   (case> (#e;Success valueT)
                                                          ( ( param subject)
                                                                  (:!  valueT))
@@ -164,12 +164,12 @@
            (`` ($_ seq
                    (~~ (do-template [ ]
                          [(test 
-                                (|> (do meta;Monad
+                                (|> (do macro;Monad
                                       [sampleI (expressionT;translate (` ( ((~ (code;text ))
                                                                                   ( (~ (code;nat subject)))
                                                                                   ( (~ (code;nat param)))))))]
                                       (@eval;eval sampleI))
-                                    (meta;run (init-compiler []))
+                                    (macro;run (init-compiler []))
                                     (case> (#e;Success valueT)
                                            (n.= ( param subject)
                                                 (:! Nat valueT))
@@ -197,12 +197,12 @@
            (`` ($_ seq
                    (~~ (do-template [     
]
                          [(test 
-                                (|> (do meta;Monad
+                                (|> (do macro;Monad
                                       [sampleI (expressionT;translate (` ( ((~ (code;text ))
                                                                                   ( (~ (
 subject)))
                                                                                   ("jvm convert long-to-int" (~ (code;nat shift)))))))]
                                       (@eval;eval sampleI))
-                                    (meta;run (init-compiler []))
+                                    (macro;run (init-compiler []))
                                     (case> (#e;Success valueT)
                                            ( ( shift ( subject))
                                                    (:!  valueT))
@@ -228,12 +228,12 @@
             subject ]
            (with-expansions [ (do-template [ ]
                                        [(test 
-                                              (|> (do meta;Monad
+                                              (|> (do macro;Monad
                                                     [sampleI (expressionT;translate (` ((~ (code;text ))
                                                                                         (
 (~ ( subject)))
                                                                                         (
 (~ ( param))))))]
                                                     (@eval;eval sampleI))
-                                                  (meta;run (init-compiler []))
+                                                  (macro;run (init-compiler []))
                                                   (case> (#e;Success valueT)
                                                          (bool/= ( param subject)
                                                                  (:! Bool valueT))
@@ -282,7 +282,7 @@
          valueC gen-int]
         (with-expansions [ (do-template [     ]
                                     [(test 
-                                           (|> (do meta;Monad
+                                           (|> (do macro;Monad
                                                  [sampleI (expressionT;translate (|> (jvm//array//new +0  size)
                                                                                      (jvm//array//write  idx )
                                                                                      (jvm//array//read  idx)
@@ -290,7 +290,7 @@
                                                                                      
                                                                                      (`)))]
                                                  (@eval;eval sampleI))
-                                               (meta;run (init-compiler []))
+                                               (macro;run (init-compiler []))
                                                (case> (#e;Success outputZ)
                                                       (  (:!  outputZ))
 
@@ -331,7 +331,7 @@
          valueC gen-int]
         (with-expansions [ (do-template [     ]
                                     [(test 
-                                           (|> (do meta;Monad
+                                           (|> (do macro;Monad
                                                  [sampleI (expressionT;translate (|> (jvm//array//new +0  size)
                                                                                      (jvm//array//write  idx )
                                                                                      (jvm//array//read  idx)
@@ -339,7 +339,7 @@
                                                                                      
                                                                                      (`)))]
                                                  (@eval;eval sampleI))
-                                               (meta;run (init-compiler []))
+                                               (macro;run (init-compiler []))
                                                (case> (#e;Success outputT)
                                                       (  (:!  outputT))
 
@@ -356,7 +356,7 @@
           ($_ seq
               
               (test "java.lang.Double (level 1)"
-                    (|> (do meta;Monad
+                    (|> (do macro;Monad
                           [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code;nat size)))
                                            ("jvm array write" "java.lang.Double" (~ (code;nat idx)) (~ (code;frac valueD)))
                                            (`))]
@@ -366,17 +366,17 @@
                                                               ("jvm array read" "java.lang.Double" (~ (code;nat idx)))
                                                               (`)))]
                           (@eval;eval sampleI))
-                        (meta;run (init-compiler []))
+                        (macro;run (init-compiler []))
                         (case> (#e;Success outputT)
                                (f.= valueD (:! Frac outputT))
 
                                (#e;Error error)
                                false)))
               (test "jvm array length"
-                    (|> (do meta;Monad
+                    (|> (do macro;Monad
                           [sampleI (expressionT;translate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code;nat size))))))]
                           (@eval;eval sampleI))
-                        (meta;run (init-compiler []))
+                        (macro;run (init-compiler []))
                         (case> (#e;Success outputT)
                                (n.= size (:! Nat outputT))
 
@@ -423,44 +423,44 @@
          instance instance-gen]
         ($_ seq
             (test "jvm object null"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm object null?" ("jvm object null"))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (:! Bool outputT)
 
                              (#e;Error error)
                              false)))
             (test "jvm object null?"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm object null?" (~ (code;int sample)))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (not (:! Bool outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm object synchronized"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm object synchronized" (~ (code;int monitor)) (~ (code;int sample)))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (i.= sample (:! Int outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm object throw"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [_ @runtime;translate
                          sampleI (expressionT;translate (` ("lux try" ("lux function" +1 []
                                                                        ("jvm object throw" ("jvm member invoke constructor"
                                                                                             "java.lang.Throwable"
                                                                                             (~ exception-message$)))))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (case (:! (e;Error Top) outputT)
                                (#e;Error error)
@@ -472,20 +472,20 @@
                              (#e;Error error)
                              false)))
             (test "jvm object class"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm object class" (~ (code;text class)))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (|> outputT (:! Class) (Class.getName []) (text/= class))
 
                              (#e;Error error)
                              false)))
             (test "jvm object instance?"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm object instance?" (~ (code;text instance-class)) (~ instance))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (:! Bool outputT)
 
@@ -512,43 +512,43 @@
                                  (~ type-codeS) (~ idl-typeS) (~ shortS)))]]
         ($_ seq
             (test "jvm member static get"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (i.= GregorianCalendar.AD (:! Int outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm member static put"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member static put" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"
                                                             ("jvm member static get" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (is hostL;unit (:! Text outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm member virtual get"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (text/= sample-string (:! Text outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm member virtual put"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
                                                             ("jvm member virtual put" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
                                                              (~ (code;text other-sample-string)) (~ value-memberS)))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (text/= other-sample-string (:! Text outputT))
 
@@ -570,42 +570,42 @@
                array-listS (` ("jvm member invoke constructor" "java.util.ArrayList" (~ intS)))]]
         ($_ seq
             (test "jvm member invoke static"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member invoke static" "java.lang.Long" "decode" "java.lang.Long" (~ coded-intS))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (i.= sample (:! Int outputT))
 
                              (#e;Error error)
                              false)))
             (test "jvm member invoke virtual"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member invoke virtual" "java.lang.Object" "equals" "boolean"
                                                             (~ (code;int sample)) (~ object-longS))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (:! Bool outputT)
 
                              (#e;Error error)
                              false)))
             (test "jvm member invoke interface"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate (` ("jvm member invoke interface" "java.util.Collection" "add" "boolean"
                                                             (~ array-listS) (~ object-longS))))]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (:! Bool outputT)
 
                              (#e;Error error)
                              false)))
             (test "jvm member invoke constructor"
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (expressionT;translate array-listS)]
                         (@eval;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (host;instance? ArrayList (:! Object outputT))
 
diff --git a/new-luxc/test/test/luxc/lang/translation/reference.lux b/new-luxc/test/test/luxc/lang/translation/reference.lux
index 50d6cffbf..1ad68263d 100644
--- a/new-luxc/test/test/luxc/lang/translation/reference.lux
+++ b/new-luxc/test/test/luxc/lang/translation/reference.lux
@@ -6,8 +6,8 @@
        (data ["e" error]
              [text])
        ["r" math/random]
-       [meta]
-       (meta [code])
+       [macro]
+       (macro [code])
        test)
   (luxc (lang ["_;" module]
               (host ["$" jvm]
@@ -45,12 +45,12 @@
          #let [valueI (|>. ($i;long def-value) ($i;wrap #$;Long))]]
         ($_ seq
             (test "Can refer to definitions."
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [_ (_module;with-module +0 module-name
                              (statementT;translate-def def-name Int valueI empty-metaI (' {})))
                          sampleI (expressionT;translate (code;symbol [module-name def-name]))]
                         (evalT;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success valueT)
                              (i.= def-value (:! Int valueT))
 
@@ -65,13 +65,13 @@
          value r;int]
         ($_ seq
             (test "Can refer to local variables/registers."
-                  (|> (do meta;Monad
+                  (|> (do macro;Monad
                         [sampleI (caseT;translate-let expressionT;translate
                                                       register
                                                       (code;int value)
                                                       (` ((~ (code;int (nat-to-int register))))))]
                         (evalT;eval sampleI))
-                      (meta;run (init-compiler []))
+                      (macro;run (init-compiler []))
                       (case> (#e;Success outputT)
                              (i.= value (:! Int outputT))
 
diff --git a/new-luxc/test/test/luxc/lang/translation/structure.lux b/new-luxc/test/test/luxc/lang/translation/structure.lux
index d8f7bc98f..68a394261 100644
--- a/new-luxc/test/test/luxc/lang/translation/structure.lux
+++ b/new-luxc/test/test/luxc/lang/translation/structure.lux
@@ -11,8 +11,8 @@
              (coll [array]
                    [list]))
        ["r" math/random "r/" Monad]
-       [meta]
-       (meta [code])
+       [macro]
+       (macro [code])
        [host]
        test)
   (luxc (lang [";L" host]
@@ -66,10 +66,10 @@
         [size (|> r;nat (:: @ map (|>. (n.% +10) (n.max +2))))
          members (r;list size gen-primitive)]
         (test "Can translate tuple."
-              (|> (do meta;Monad
+              (|> (do macro;Monad
                     [sampleI (expressionT;translate (code;tuple members))]
                     (@eval;eval sampleI))
-                  (meta;run (init-compiler []))
+                  (macro;run (init-compiler []))
                   (case> (#e;Success valueT)
                          (let [valueT (:! (Array Top) valueT)]
                            (and (n.= size (array;size valueT))
@@ -86,11 +86,11 @@
          #let [last? (n.= (n.dec num-tags) tag)]
          member gen-primitive]
         (test "Can translate variant."
-              (|> (do meta;Monad
+              (|> (do macro;Monad
                     [runtime-bytecode @runtime;translate
                      sampleI (expressionT;translate (` ((~ (code;nat tag)) (~ (code;bool last?)) (~ member))))]
                     (@eval;eval sampleI))
-                  (meta;run (init-compiler []))
+                  (macro;run (init-compiler []))
                   (case> (#e;Success valueT)
                          (let [valueT (:! (Array Top) valueT)]
                            (and (n.= +3 (array;size valueT))
diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux
index d7e296b2f..6d4036b18 100644
--- a/stdlib/source/lux/cli.lux
+++ b/stdlib/source/lux/cli.lux
@@ -7,9 +7,9 @@
              text/format
              ["E" error])
        [io]
-       [meta #+ with-gensyms]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro #+ with-gensyms]
+       (macro [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 7d5c41583..bdf0758c3 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -7,12 +7,12 @@
        (data text/format
              (coll [list "list/" Monoid Monad Fold])
              [product])
-       [meta #+ with-gensyms Monad]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax]
-             (syntax ["cs" common]
-                     (common ["csr" reader]
-                             ["csw" writer])))
+       [macro #+ with-gensyms Monad]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax]
+              (syntax ["cs" common]
+                      (common ["csr" reader]
+                              ["csw" writer])))
        (type opaque)
        (lang [type]))
   (.. ["A" atom]
@@ -152,14 +152,14 @@
    (def: #hidden ( name)
      (-> Ident (Meta Ident))
      (do Monad
-       [name (meta;normalize name)
-        [_ annotations _] (meta;find-def name)]
-       (case (meta;get-tag-ann (ident-for ) annotations)
+       [name (macro;normalize name)
+        [_ annotations _] (macro;find-def name)]
+       (case (macro;get-tag-ann (ident-for ) annotations)
          (#;Some actor-name)
          (wrap actor-name)
 
          _
-         (meta;fail (format "Definition is not "  ".")))))]
+         (macro;fail (format "Definition is not "  ".")))))]
 
   [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 meta;current-module-name
+      [module macro;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 57789d708..d59b96563 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])
              text/format)
-       [meta]
-       (meta ["s" syntax #+ syntax: Syntax]))
+       [macro]
+       (macro ["s" syntax #+ syntax: Syntax]))
   (.. ["&" promise]))
 
 ## [Types]
diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux
index 63cd88c77..115f60dc1 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])
-       [meta]
-       (meta ["s" syntax #+ syntax: Syntax])
+       [macro]
+       (macro ["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 df0ec47a9..8fe9fa583 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 Fold]))
        [io #- run]
-       [meta #+ with-gensyms]
-       (meta [code]
-             ["s" syntax #+ syntax:]
-             (syntax ["cs" common]
-                     (common ["csr" reader]
-                             ["csw" writer])))))
+       [macro #+ with-gensyms]
+       (macro [code]
+              ["s" syntax #+ syntax:]
+              (syntax ["cs" common]
+                      (common ["csr" reader]
+                              ["csw" writer])))))
 
 (with-expansions
   [ [e (A;Actor Top) (Space e)]
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index d1762ee01..7886dda36 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -12,9 +12,9 @@
              maybe
              [number "Nat/" Codec]
              text/format)
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])
+       [macro]
+       (macro [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 fbc3cbf1e..374acee46 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])
-       [meta]
-       (meta ["s" syntax #+ syntax: Syntax])
+       [macro]
+       (macro ["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 549ac19b0..b0ed0f585 100644
--- a/stdlib/source/lux/control/concatenative.lux
+++ b/stdlib/source/lux/control/concatenative.lux
@@ -9,12 +9,12 @@
              text/format
              [maybe "m/" Monad]
              (coll [list "L/" Fold Functor]))
-       [meta #+ with-gensyms Monad]
-       (meta [code]
-             ["s" syntax #+ syntax:]
-             (syntax ["cs" common]
-                     (common ["csr" reader]
-                             ["csw" writer])))))
+       [macro #+ with-gensyms Monad]
+       (macro [code]
+              ["s" syntax #+ syntax:]
+              (syntax ["cs" common]
+                      (common ["csr" reader]
+                              ["csw" writer])))))
 
 ## [Syntax]
 (type: Alias [Text Code])
@@ -57,8 +57,8 @@
       (wrap singleton)
 
       _
-      (meta;fail (format "Cannot expand to more than a single AST/Code node:\n"
-                         (|> expansion (L/map %code) (text;join-with " ")))))))
+      (macro;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 (meta;expand-all (stack-fold (get@ #top inputs) bottomI)))
-         outputC (singleton (meta;expand-all (stack-fold (get@ #top outputs) bottomO)))]
+        [inputC (singleton (macro;expand-all (stack-fold (get@ #top inputs) bottomI)))
+         outputC (singleton (macro;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 (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))))]
+          [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))))]
           (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 (|> (meta;gensym "input") (list;repeat arity) (monad;seq @))]
+      [g!inputs (|> (macro;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 0db72d0fc..81f62eccb 100644
--- a/stdlib/source/lux/control/cont.lux
+++ b/stdlib/source/lux/control/cont.lux
@@ -4,9 +4,9 @@
                 ["A" applicative]
                 monad)
        function
-       [meta #+ with-gensyms]
-       (meta [code]
-             [syntax #+ syntax:])))
+       [macro #+ with-gensyms]
+       (macro [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 5ff6309ec..cc3267715 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)
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax:])))
+       [macro]
+       (macro [code]
+              ["s" syntax #+ syntax:])))
 
 (def: #export (assert! message test)
   (-> Text Bool [])
@@ -30,7 +30,7 @@
               (post i.even?
                     (i.+ 2 2)))}
   (do @
-    [g!output (meta;gensym "")]
+    [g!output (macro;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 9732cd185..010fb562f 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])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax]
-             (syntax ["cs" common]
-                     (common ["csr" reader]
-                             ["csw" writer])))))
+       [macro]
+       (macro [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 meta;current-module-name
+    [current-module macro;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 f2a6950fb..6eb8e8156 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 "L/" Fold Monad]))
-       [meta #+ with-gensyms]
-       (meta ["s" syntax #+ syntax: Syntax]
-             [code])
+       [macro #+ with-gensyms]
+       (macro ["s" syntax #+ syntax: Syntax]
+              [code])
        ))
 
 ## [Syntax]
@@ -98,7 +98,7 @@
                   (exec> [int-to-nat %n log!])
                   (i.* 10)))}
   (do @
-    [g!temp (meta;gensym "")]
+    [g!temp (macro;gensym "")]
     (wrap (list (` (let [(~ g!temp) (~ prev)]
                      (exec (|> (~ g!temp) (~@ body))
                        (~ g!temp))))))))
@@ -112,7 +112,7 @@
                           [Int/encode]))
               "Will become: [50 2 \"5\"]")}
   (do @
-    [g!temp (meta;gensym "")]
+    [g!temp (macro;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 1151a018b..24b6b7c3b 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 Monoid Fold])
              ["p" product]
              [maybe])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [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 90026feab..376624033 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])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [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 c76735d3c..f85558c5e 100644
--- a/stdlib/source/lux/data/coll/sequence.lux
+++ b/stdlib/source/lux/data/coll/sequence.lux
@@ -12,9 +12,9 @@
                    [array "array/" Functor Fold])
              [bit]
              [product])
-       [meta #+ with-gensyms]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])
+       [macro #+ with-gensyms]
+       (macro [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 61e3b3e6c..43ed0087c 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])
-       [meta #+ with-gensyms]
-       (meta ["s" syntax #+ syntax: Syntax])
+       [macro #+ with-gensyms]
+       (macro ["s" syntax #+ syntax: Syntax])
        (data (coll [list "List/" Monad])
              bool)))
 
diff --git a/stdlib/source/lux/data/coll/tree/rose.lux b/stdlib/source/lux/data/coll/tree/rose.lux
index b07f1ed84..546982dba 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 Fold]))
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [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 ddab9d121..c8f9a9059 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])
                    [stack #+ Stack])
              [maybe "M/" Monad])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])))
 
 ## Adapted from the clojure.zip namespace in the Clojure standard library.
 
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index ddc2b48cf..029d8dde7 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -17,10 +17,10 @@
              (coll [list "list/" Fold Monad]
                    [sequence #+ Sequence sequence "sequence/" Monad]
                    [dict #+ Dict]))
-       [meta #+ Monad with-gensyms]
-       (meta ["s" syntax #+ syntax:]
-             [code]
-             [poly #+ poly:])
+       [macro #+ Monad with-gensyms]
+       (macro ["s" syntax #+ syntax:]
+              [code]
+              [poly #+ poly:])
        (lang [type])
        ))
 
@@ -86,7 +86,7 @@
                                (wrap (` [(~ (code;text key-name)) (~ (wrapper value))]))
 
                                _
-                               (meta;fail "Wrong syntax for JSON object.")))
+                               (macro;fail "Wrong syntax for JSON object.")))
                            pairs)]
         (wrap (list (` (: JSON (#Object (dict;from-list text;Hash (list (~@ pairs')))))))))
       
diff --git a/stdlib/source/lux/data/lazy.lux b/stdlib/source/lux/data/lazy.lux
index 547418d51..e344c6a0a 100644
--- a/stdlib/source/lux/data/lazy.lux
+++ b/stdlib/source/lux/data/lazy.lux
@@ -5,8 +5,8 @@
                 ["A" applicative]
                 monad)
        (concurrency ["a" atom])
-       [meta]
-       (meta ["s" syntax #+ syntax:])
+       [macro]
+       (macro ["s" syntax #+ syntax:])
        (type opaque)))
 
 (opaque: #export (Lazy a)
@@ -31,7 +31,7 @@
 
 (syntax: #export (freeze expr)
   (do @
-    [g!_ (meta;gensym "_")]
+    [g!_ (macro;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 870474890..7fc8af1dd 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]))
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])))
 
 (type: #export Complex
   {#real Frac
diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux
index d14e5e1f1..f3f9a1196 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])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])))
+       [macro]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])))
 
 (type: #export Ratio
   {#numerator Nat
diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux
index 7fdd9f552..9f8d2b25f 100644
--- a/stdlib/source/lux/data/text/format.lux
+++ b/stdlib/source/lux/data/text/format.lux
@@ -12,9 +12,9 @@
        (time [instant]
              [duration]
              [date])
-       [meta]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])
+       [macro]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])
        (lang [type])))
 
 ## [Syntax]
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux
index 9ae2bdd8f..5fc638354 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]))
-       (meta [code])))
+       (macro [code])))
 
 (type: Offset Nat)
 
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index bcefa4331..07e2a6ea4 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 Monad]))
-       [meta #- run]
-       (meta [code]
-             ["s" syntax #+ syntax:])))
+       [macro #- run]
+       (macro [code]
+              ["s" syntax #+ syntax:])))
 
 ## [Utils]
 (def: regex-char^
@@ -458,13 +458,13 @@
               (regex "a(.)(.)|b(.)(.)")
               )}
   (do @
-    [current-module meta;current-module-name]
+    [current-module macro;current-module-name]
     (case (|> (regex^ current-module)
               (p;before l;end)
               (l;run pattern))
       (#E;Error error)
-      (meta;fail (format "Error while parsing regular-expression:\n"
-                         error))
+      (macro;fail (format "Error while parsing regular-expression:\n"
+                          error))
 
       (#E;Success regex)
       (wrap (list regex))
@@ -485,7 +485,7 @@
                 _
                 do-something-else))}
   (do @
-    [g!temp (meta;gensym "temp")]
+    [g!temp (macro;gensym "temp")]
     (wrap (list& (` (^multi (~ g!temp)
                             [(l;run (~ g!temp) (regex (~ (code;text pattern))))
                              (#E;Success (~ (maybe;default g!temp
diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux
index e9c987532..fdbc752c4 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]))
-       [meta #+ with-gensyms]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])
+       [macro #+ with-gensyms]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])
        ))
 
 (do-template [ ]
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index 1b77e3016..1298a56d1 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -11,9 +11,9 @@
              [text "text/" Eq Monoid]
              text/format
              [bool "bool/" Codec])
-       [meta #+ with-gensyms Functor Monad]
-       (meta [code]
-             ["s" syntax #+ syntax: Syntax])
+       [macro #+ with-gensyms Functor Monad]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax])
        (lang [type])
        ))
 
@@ -352,21 +352,21 @@
 
 (def: (class-imports compiler)
   (-> Compiler ClassImports)
-  (case (meta;run compiler
-                  (: (Meta ClassImports)
-                     (do Monad
-                       [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)))))
+  (case (macro;run compiler
+                   (: (Meta ClassImports)
+                      (do Monad
+                        [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)))))
     (#;Left _)        (list)
     (#;Right imports) imports))
 
@@ -1305,7 +1305,7 @@
               "(.resolve! container [value]) for calling the \"resolve\" method."
               )}
   (do Monad
-    [current-module meta;current-module-name
+    [current-module macro;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 (meta;gensym "obj")]
+      [g!obj (macro;gensym "obj")]
       (wrap (list (` (: (-> (primitive (~' java.lang.Object)) Bool)
                         (function [(~ g!obj)]
                           ((~ (code;text (format "jvm instanceof" ":" (simple-class$ (list) class)))) (~ g!obj))))))))
@@ -1540,7 +1540,7 @@
     (:: Monad wrap (class->type mode type-params (get@ #import-method-return method)))
 
     _
-    (meta;fail "Only methods have return values.")))
+    (macro;fail "Only methods have return values.")))
 
 (def: (decorate-return-maybe member [return-type return-term])
   (-> ImportMemberDecl [Code Code] [Code Code])
@@ -1842,7 +1842,7 @@
                            #Class))
 
     (#;Left _)
-    (meta;fail (format "Unknown class: " class-name))))
+    (macro;fail (format "Unknown class: " class-name))))
 
 (syntax: #export (import [#let [imports (class-imports *compiler*)]]
                    [long-name? (s;this? (' #long))]
@@ -1937,7 +1937,7 @@
     (#;Apply A F)
     (case (type;apply (list A) F)
       #;None
-      (meta;fail (format "Cannot apply type: " (type;to-text F) " to " (type;to-text A)))
+      (macro;fail (format "Cannot apply type: " (type;to-text F) " to " (type;to-text A)))
 
       (#;Some type')
       (type->class-name type'))
@@ -1949,7 +1949,7 @@
     (:: Monad wrap "java.lang.Object")
     
     (^or #;Void (#;Var _) (#;Ex _) (#;Bound _) (#;Sum _) (#;Product _) (#;Function _) (#;UnivQ _) (#;ExQ _))
-    (meta;fail (format "Cannot convert to JvmType: " (type;to-text type)))
+    (macro;fail (format "Cannot convert to JvmType: " (type;to-text type)))
     ))
 
 (syntax: #export (array-read idx array)
@@ -1958,7 +1958,7 @@
   (case array
     [_ (#;Symbol array-name)]
     (do Monad
-      [array-type (meta;find-type array-name)
+      [array-type (macro;find-type array-name)
        array-jvm-type (type->class-name array-type)]
       (case array-jvm-type
         (^template [ ]
@@ -1987,7 +1987,7 @@
   (case array
     [_ (#;Symbol array-name)]
     (do Monad
-      [array-type (meta;find-type array-name)
+      [array-type (macro;find-type array-name)
        array-jvm-type (type->class-name array-type)]
       (case array-jvm-type
         (^template [ ]
@@ -2071,7 +2071,7 @@
       (wrap fqcn)
 
       #;None
-      (meta;fail (text/compose "Unknown class: " class)))))
+      (macro;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/lang/type.lux b/stdlib/source/lux/lang/type.lux
index 9d6ed5162..974561605 100644
--- a/stdlib/source/lux/lang/type.lux
+++ b/stdlib/source/lux/lang/type.lux
@@ -7,7 +7,7 @@
              [number "nat/" Codec]
              [maybe]
              (coll [list #+ "list/" Monad Monoid Fold]))
-       (meta [code])
+       (macro [code])
        ))
 
 ## [Utils]
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
new file mode 100644
index 000000000..e65e09b58
--- /dev/null
+++ b/stdlib/source/lux/macro.lux
@@ -0,0 +1,653 @@
+(;module: {#;doc "Functions for extracting information from the state of the compiler."}
+  lux
+  (lux (control ["F" functor]
+                ["A" applicative]
+                ["M" monad #+ do Monad])
+       (data [number]
+             [product]
+             [ident "ident/" Codec Eq]
+             [maybe]
+             ["e" error]
+             [text "text/" Monoid Eq]
+             (coll [list "list/" Monoid Monad])))
+  (. [code]))
+
+## (type: (Meta a)
+##   (-> Compiler (e;Error [Compiler a])))
+
+(struct: #export _ (F;Functor Meta)
+  (def: (map f fa)
+    (function [state]
+      (case (fa state)
+        (#e;Error msg)
+        (#e;Error msg)
+
+        (#e;Success [state' a])
+        (#e;Success [state' (f a)])))))
+
+(struct: #export _ (A;Applicative Meta)
+  (def: functor Functor)
+
+  (def: (wrap x)
+    (function [state]
+      (#e;Success [state x])))
+
+  (def: (apply ff fa)
+    (function [state]
+      (case (ff state)
+        (#e;Success [state' f])
+        (case (fa state')
+          (#e;Success [state'' a])
+          (#e;Success [state'' (f a)])
+
+          (#e;Error msg)
+          (#e;Error msg))
+
+        (#e;Error msg)
+        (#e;Error msg)))))
+
+(struct: #export _ (Monad Meta)
+  (def: applicative Applicative)
+  
+  (def: (join mma)
+    (function [state]
+      (case (mma state)
+        (#e;Error msg)
+        (#e;Error msg)
+
+        (#e;Success [state' ma])
+        (ma state')))))
+
+(def: (get k plist)
+  (All [a]
+    (-> Text (List [Text a]) (Maybe a)))
+  (case plist
+    #;Nil
+    #;None
+
+    (#;Cons [k' v] plist')
+    (if (text/= k k')
+      (#;Some v)
+      (get k plist'))))
+
+(def: #export (run' compiler action)
+  (All [a] (-> Compiler (Meta a) (e;Error [Compiler a])))
+  (action compiler))
+
+(def: #export (run compiler action)
+  (All [a] (-> Compiler (Meta a) (e;Error a)))
+  (case (action compiler)
+    (#e;Error error)
+    (#e;Error error)
+
+    (#e;Success [_ output])
+    (#e;Success output)))
+
+(def: #export (either left right)
+  {#;doc "Pick whichever computation succeeds."}
+  (All [a] (-> (Meta a) (Meta a) (Meta a)))
+  (function [compiler]
+    (case (left compiler)
+      (#e;Error error)
+      (right compiler)
+
+      (#e;Success [compiler' output])
+      (#e;Success [compiler' output]))))
+
+(def: #export (assert message test)
+  {#;doc "Fails with the given message if the test is false."}
+  (-> Text Bool (Meta Unit))
+  (function [compiler]
+    (if test
+      (#e;Success [compiler []])
+      (#e;Error message))))
+
+(def: #export (fail msg)
+  {#;doc "Fails with the given message."}
+  (All [a]
+    (-> Text (Meta a)))
+  (function [_]
+    (#e;Error msg)))
+
+(def: #export (find-module name)
+  (-> Text (Meta Module))
+  (function [state]
+    (case (get name (get@ #;modules state))
+      (#;Some module)
+      (#e;Success [state module])
+
+      _
+      (#e;Error ($_ text/compose "Unknown module: " name)))))
+
+(def: #export current-module-name
+  (Meta Text)
+  (function [state]
+    (case (get@ #;current-module state)
+      (#;Some current-module)
+      (#e;Success [state current-module])
+
+      _
+      (#e;Error "No current module.")
+      )))
+
+(def: #export current-module
+  (Meta Module)
+  (do Monad
+    [this-module-name current-module-name]
+    (find-module this-module-name)))
+
+(def: #export (get-ann tag anns)
+  {#;doc "Looks-up a particular annotation's value within the set of annotations."}
+  (-> Ident Code (Maybe Code))
+  (case anns
+    [_ (#;Record anns)]
+    (loop [anns anns]
+      (case anns
+        (#;Cons [key value] anns')
+        (case key
+          [_ (#;Tag tag')]
+          (if (ident/= tag tag')
+            (#;Some value)
+            (recur anns'))
+
+          _
+          (recur anns'))
+        
+        #;Nil
+        #;None))
+
+    _
+    #;None))
+
+(do-template [  ]
+  [(def: #export ( tag anns)
+     (-> Ident Code (Maybe ))
+     (case (get-ann tag anns)
+       (#;Some [_ ( value)])
+       (#;Some value)
+
+       _
+       #;None))]
+
+  [get-bool-ann   #;Bool   Bool]
+  [get-int-ann    #;Int    Int]
+  [get-frac-ann   #;Frac   Frac]
+  [get-text-ann   #;Text   Text]
+  [get-symbol-ann #;Symbol Ident]
+  [get-tag-ann    #;Tag    Ident]
+  [get-form-ann   #;Form   (List Code)]
+  [get-tuple-ann  #;Tuple  (List Code)]
+  [get-record-ann #;Record (List [Code Code])]
+  )
+
+(def: #export (get-doc anns)
+  {#;doc "Looks-up a definition's documentation."}
+  (-> Code (Maybe Text))
+  (get-text-ann ["lux" "doc"] anns))
+
+(def: #export (flag-set? flag-name anns)
+  {#;doc "Finds out whether an annotation-as-a-flag is set (has value 'true')."}
+  (-> Ident Code Bool)
+  (maybe;default false (get-bool-ann flag-name anns)))
+
+(do-template [  ]
+  [(def: #export 
+     {#;doc (code;text ($_ text/compose "Checks whether a definition is "  "."))}
+     (-> Code Bool)
+     (flag-set? (ident-for )))]
+
+  [export?   #;export?   "exported"]
+  [hidden?   #;hidden?   "hidden"]
+  [macro?    #;macro?    "a macro"]
+  [type?     #;type?     "a type"]
+  [struct?   #;struct?   "a structure"]
+  [type-rec? #;type-rec? "a recursive type"]
+  [sig?      #;sig?      "a signature"]
+  )
+
+(do-template [  ]
+  [(def: ( input)
+     (-> Code (Maybe ))
+     (case input
+       [_ ( actual-value)]
+       (#;Some actual-value)
+
+       _
+       #;None))]
+
+  [parse-tuple #;Tuple (List Code)]
+  [parse-text  #;Text  Text]
+  )
+
+(do-template [  ]
+  [(def: #export ( anns)
+     {#;doc }
+     (-> Code (List Text))
+     (maybe;default (list)
+                    (do maybe;Monad
+                      [_args (get-ann (ident-for ) anns)
+                       args (parse-tuple _args)]
+                      (M;map @ parse-text args))))]
+
+  [func-args     #;func-args "Looks up the arguments of a function."]
+  [type-args     #;type-args "Looks up the arguments of a parameterized type."]
+  [declared-tags #;tags      "Looks up the tags of a tagged (variant or record) type."]
+  )
+
+(def: (find-macro' modules this-module module name)
+  (-> (List [Text Module]) Text Text Text
+      (Maybe Macro))
+  (do maybe;Monad
+    [$module (get module modules)
+     [def-type def-anns def-value] (: (Maybe Def) (|> (: Module $module) (get@ #;defs) (get name)))]
+    (if (and (macro? def-anns)
+             (or (export? def-anns) (text/= module this-module)))
+      (#;Some (:! Macro def-value))
+      (case (get-symbol-ann ["lux" "alias"] def-anns)
+        (#;Some [r-module r-name])
+        (find-macro' modules this-module r-module r-name)
+
+        _
+        #;None))))
+
+(def: #export (find-macro ident)
+  (-> Ident (Meta (Maybe Macro)))
+  (do Monad
+    [this-module current-module-name]
+    (let [[module name] ident]
+      (: (Meta (Maybe Macro))
+         (function [state]
+           (#e;Success [state (find-macro' (get@ #;modules state) this-module module name)]))))))
+
+(def: #export (normalize ident)
+  {#;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 (Meta Ident))
+  (case ident
+    ["" name]
+    (do Monad
+      [module-name current-module-name]
+      (wrap [module-name name]))
+
+    _
+    (:: Monad 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 (Meta (List Code)))
+  (case syntax
+    [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
+    (do Monad
+      [name' (normalize name)
+       ?macro (find-macro name')]
+      (case ?macro
+        (#;Some macro)
+        (macro args)
+        
+        #;None
+        (:: Monad wrap (list syntax))))
+
+    _
+    (:: Monad 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 (Meta (List Code)))
+  (case syntax
+    [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
+    (do Monad
+      [name' (normalize name)
+       ?macro (find-macro name')]
+      (case ?macro
+        (#;Some macro)
+        (do Monad
+          [expansion (macro args)
+           expansion' (M;map Monad expand expansion)]
+          (wrap (list/join expansion')))
+        
+        #;None
+        (:: Monad wrap (list syntax))))
+
+    _
+    (:: Monad wrap (list syntax))))
+
+(def: #export (expand-all syntax)
+  {#;doc "Expands all macro-calls everywhere recursively, until only primitive/base code remains."}
+  (-> Code (Meta (List Code)))
+  (case syntax
+    [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
+    (do Monad
+      [name' (normalize name)
+       ?macro (find-macro name')]
+      (case ?macro
+        (#;Some macro)
+        (do Monad
+          [expansion (macro args)
+           expansion' (M;map Monad expand-all expansion)]
+          (wrap (list/join expansion')))
+        
+        #;None
+        (do Monad
+          [parts' (M;map Monad expand-all (list& (code;symbol name) args))]
+          (wrap (list (code;form (list/join parts')))))))
+
+    [_ (#;Form (#;Cons [harg targs]))]
+    (do Monad
+      [harg+ (expand-all harg)
+       targs+ (M;map Monad expand-all targs)]
+      (wrap (list (code;form (list/compose harg+ (list/join (: (List (List Code)) targs+)))))))
+
+    [_ (#;Tuple members)]
+    (do Monad
+      [members' (M;map Monad expand-all members)]
+      (wrap (list (code;tuple (list/join members')))))
+
+    _
+    (:: Monad 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 (Meta Code))
+  (function [state]
+    (#e;Success [(update@ #;seed n.inc state)
+                 (code;symbol ["" ($_ text/compose "__gensym__" prefix (:: number;Codec encode (get@ #;seed state)))])])))
+
+(def: (get-local-symbol ast)
+  (-> Code (Meta Text))
+  (case ast
+    [_ (#;Symbol [_ name])]
+    (:: Monad wrap name)
+
+    _
+    (fail (text/compose "Code is not a local symbol: " (code;to-text ast)))))
+
+(macro: #export (with-gensyms tokens)
+  {#;doc (doc "Creates new symbols and offers them to the body expression."
+              (syntax: #export (synchronized lock body)
+                (with-gensyms [g!lock g!body g!_]
+                  (wrap (list (` (let [(~ g!lock) (~ lock)
+                                       (~ g!_) (;_jvm_monitorenter (~ g!lock))
+                                       (~ g!body) (~ body)
+                                       (~ g!_) (;_jvm_monitorexit (~ g!lock))]
+                                   (~ g!body)))))
+                  )))}
+  (case tokens
+    (^ (list [_ (#;Tuple symbols)] body))
+    (do Monad
+      [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
+                       [(~@ symbol-defs)]
+                       (~ body))))))
+
+    _
+    (fail "Wrong syntax for with-gensyms")))
+
+(def: #export (expand-1 token)
+  {#;doc "Works just like expand, except that it ensures that the output is a single Code token."}
+  (-> Code (Meta Code))
+  (do Monad
+    [token+ (expand token)]
+    (case token+
+      (^ (list token'))
+      (wrap token')
+
+      _
+      (fail "Macro expanded to more than 1 element."))))
+
+(def: #export (module-exists? module)
+  (-> Text (Meta Bool))
+  (function [state]
+    (#e;Success [state (case (get module (get@ #;modules state))
+                         (#;Some _)
+                         true
+                         
+                         #;None
+                         false)])))
+
+(def: (try-both f x1 x2)
+  (All [a b]
+    (-> (-> a (Maybe b)) a a (Maybe b)))
+  (case (f x1)
+    #;None     (f x2)
+    (#;Some y) (#;Some y)))
+
+(def: #export (find-var-type name)
+  {#;doc "Looks-up the type of a local variable somewhere in the environment."}
+  (-> Text (Meta Type))
+  (function [state]
+    (let [test (: (-> [Text [Type Top]] Bool)
+                  (|>. product;left (text/= name)))]
+      (case (do maybe;Monad
+              [scope (list;find (function [env]
+                                  (or (list;any? test (: (List [Text [Type Top]])
+                                                         (get@ [#;locals #;mappings] env)))
+                                      (list;any? test (: (List [Text [Type Top]])
+                                                         (get@ [#;captured #;mappings] env)))))
+                                (get@ #;scopes state))
+               [_ [type _]] (try-both (list;find test)
+                                      (: (List [Text [Type Top]])
+                                         (get@ [#;locals #;mappings] scope))
+                                      (: (List [Text [Type Top]])
+                                         (get@ [#;captured #;mappings] scope)))]
+              (wrap type))
+        (#;Some var-type)
+        (#e;Success [state var-type])
+
+        #;None
+        (#e;Error ($_ text/compose "Unknown variable: " name))))))
+
+(def: #export (find-def name)
+  {#;doc "Looks-up a definition's whole data in the available modules (including the current one)."}
+  (-> Ident (Meta Def))
+  (function [state]
+    (case (: (Maybe Def)
+             (do maybe;Monad
+               [#let [[v-prefix v-name] name]
+                (^slots [#;defs]) (get v-prefix (get@ #;modules state))]
+               (get v-name defs)))
+      (#;Some _anns)
+      (#e;Success [state _anns])
+
+      _
+      (#e;Error ($_ text/compose "Unknown definition: " (ident/encode name))))))
+
+(def: #export (find-def-type name)
+  {#;doc "Looks-up a definition's type in the available modules (including the current one)."}
+  (-> Ident (Meta Type))
+  (do Monad
+    [[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 (Meta Type))
+  (do Monad
+    [#let [[_ _name] name]]
+    (either (find-var-type _name)
+            (do @
+              [name (normalize name)]
+              (find-def-type name)))))
+
+(def: #export (find-type-def name)
+  {#;doc "Finds the value of a type definition (such as Int, Top or Compiler)."}
+  (-> Ident (Meta Type))
+  (do Monad
+    [[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 (Meta (List [Text Def])))
+  (function [state]
+    (case (get module-name (get@ #;modules state))
+      #;None          (#e;Error ($_ text/compose "Unknown module: " module-name))
+      (#;Some module) (#e;Success [state (get@ #;defs module)])
+      )))
+
+(def: #export (exports module-name)
+  {#;doc "All the exported definitions in a module."}
+  (-> Text (Meta (List [Text Def])))
+  (do Monad
+    [defs (defs module-name)]
+    (wrap (list;filter (function [[name [def-type def-anns def-value]]]
+                         (and (export? def-anns)
+                              (not (hidden? def-anns))))
+                       defs))))
+
+(def: #export modules
+  {#;doc "All the available modules (including the current one)."}
+  (Meta (List [Text Module]))
+  (function [state]
+    (|> state
+        (get@ #;modules)
+        [state]
+        #e;Success)))
+
+(def: #export (tags-of type-name)
+  {#;doc "All the tags associated with a type definition."}
+  (-> Ident (Meta (List Ident)))
+  (do Monad
+    [#let [[module name] type-name]
+     module (find-module module)]
+    (case (get name (get@ #;types module))
+      (#;Some [tags _])
+      (wrap tags)
+
+      _
+      (wrap (list)))))
+
+(def: #export cursor
+  {#;doc "The cursor of the current expression being analyzed."}
+  (Meta Cursor)
+  (function [state]
+    (#e;Success [state (get@ #;cursor state)])))
+
+(def: #export expected-type
+  {#;doc "The expected type of the current expression being analyzed."}
+  (Meta Type)
+  (function [state]
+    (case (get@ #;expected state)
+      (#;Some type)
+      (#e;Success [state type])
+
+      #;None
+      (#e;Error "Not expecting any type."))))
+
+(def: #export (imported-modules module-name)
+  {#;doc "All the modules imported by a specified module."}
+  (-> Text (Meta (List Text)))
+  (do Monad
+    [(^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 (Meta [Nat (List Ident) Type]))
+  (do Monad
+    [#let [[module name] tag]
+     =module (find-module module)
+     this-module-name current-module-name]
+    (case (get name (get@ #;tags =module))
+      (#;Some [idx tag-list exported? type])
+      (if (or exported?
+              (text/= this-module-name module))
+        (wrap [idx tag-list type])
+        (fail ($_ text/compose "Cannot access tag: " (ident/encode tag) " from module " this-module-name)))
+
+      _
+      (fail ($_ text/compose "Unknown tag: " (ident/encode tag))))))
+
+(def: #export (tag-lists module)
+  {#;doc "All the tag-lists defined in a module, with their associated types."}
+  (-> Text (Meta (List [(List Ident) Type])))
+  (do Monad
+    [=module (find-module module)
+     this-module-name current-module-name]
+    (wrap (|> (get@ #;types =module)
+              (list;filter (function [[type-name [tag-list exported? type]]]
+                             (or exported?
+                                 (text/= this-module-name module))))
+              (list/map (function [[type-name [tag-list exported? type]]]
+                          [tag-list type]))))))
+
+(def: #export locals
+  {#;doc "All the local variables currently in scope, separated in different scopes."}
+  (Meta (List (List [Text Type])))
+  (function [state]
+    (case (list;inits (get@ #;scopes state))
+      #;None
+      (#e;Error "No local environment")
+
+      (#;Some scopes)
+      (#e;Success [state
+                   (list/map (|>. (get@ [#;locals #;mappings])
+                                  (list/map (function [[name [type _]]]
+                                              [name type])))
+                             scopes)]))))
+
+(def: #export (un-alias def-name)
+  {#;doc "Given an aliased definition's name, returns the original definition being referenced."}
+  (-> Ident (Meta Ident))
+  (do Monad
+    [def-name (normalize def-name)
+     [_ def-anns _] (find-def def-name)]
+    (case (get-symbol-ann (ident-for #;alias) def-anns)
+      (#;Some real-def-name)
+      (wrap real-def-name)
+
+      _
+      (wrap def-name))))
+
+(def: #export get-compiler
+  {#;doc "Obtains the current state of the compiler."}
+  (Meta Compiler)
+  (function [compiler]
+    (#e;Success [compiler compiler])))
+
+(def: #export type-context
+  (Meta Type-Context)
+  (function [compiler]
+    (#e;Success [compiler (get@ #;type-context compiler)])))
+
+(do-template [  ]
+  [(macro: #export ( tokens)
+     {#;doc (doc "Performs a macro-expansion and logs the resulting code."
+                 "You can either use the resulting code, or omit them."
+                 "By omitting them, this macro produces nothing (just like the lux;comment macro)."
+                 ( #omit
+                          (def: (foo bar baz)
+                            (-> Int Int Int)
+                            (i.+ bar baz))))}
+     (case tokens
+       (^ (list [_ (#;Tag ["" "omit"])]
+                token))
+       (do Monad
+         [output ( token)
+          #let [_ (list/map (. log! code;to-text)
+                            output)]]
+         (wrap (list)))
+
+       (^ (list token))
+       (do Monad
+         [output ( token)
+          #let [_ (list/map (. log! code;to-text)
+                            output)]]
+         (wrap output))
+
+       _
+       (fail ($_ text/compose "Wrong syntax for "  "."))))]
+
+  [log-expand      expand      "log-expand"]
+  [log-expand-all  expand-all  "log-expand-all"]
+  [log-expand-once expand-once "log-expand-once"]
+  )
diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux
new file mode 100644
index 000000000..d41dbe240
--- /dev/null
+++ b/stdlib/source/lux/macro/code.lux
@@ -0,0 +1,143 @@
+(;module:
+  lux
+  (lux (control [eq #+ Eq])
+       (data bool
+             number
+             [text #+ Eq "Text/" Monoid]
+             ident
+             (coll [list #* "" Functor Fold])
+             )))
+
+## [Types]
+## (type: (Code' w)
+##   (#;Bool Bool)
+##   (#;Nat Nat)
+##   (#;Int Int)
+##   (#;Frac Frac)
+##   (#;Text Text)
+##   (#;Symbol Text Text)
+##   (#;Tag Text Text)
+##   (#;Form (List (w (Code' w))))
+##   (#;Tuple (List (w (Code' w))))
+##   (#;Record (List [(w (Code' w)) (w (Code' w))])))
+
+## (type: Code
+##   (Ann Cursor (Code' (Ann Cursor))))
+
+## [Utils]
+(def: _cursor Cursor ["" +0 +0])
+
+## [Functions]
+(do-template [  ]
+  [(def: #export ( x)
+     (->  Code)
+     [_cursor ( x)])]
+  
+  [bool   Bool              #;Bool]
+  [nat    Nat               #;Nat]
+  [int    Int               #;Int]
+  [deg    Deg               #;Deg]
+  [frac   Frac              #;Frac]
+  [text   Text              #;Text]
+  [symbol Ident             #;Symbol]
+  [tag    Ident             #;Tag]
+  [form   (List Code)       #;Form]
+  [tuple  (List Code)       #;Tuple]
+  [record (List [Code Code]) #;Record]
+  )
+
+(do-template [  ]
+  [(def: #export ( name)
+     {#;doc }
+     (-> Text Code)
+     [_cursor ( ["" name])])]
+
+  [local-symbol #;Symbol "Produces a local symbol (a symbol with no module prefix)."]
+  [local-tag    #;Tag    "Produces a local tag (a tag with no module prefix)."])
+
+## [Structures]
+(struct: #export _ (Eq Code)
+  (def: (= x y)
+    (case [x y]
+      (^template [ ]
+        [[_ ( x')] [_ ( y')]]
+        (::  = x' y'))
+      ([#;Bool   Eq]
+       [#;Nat    Eq]
+       [#;Int    Eq]
+       [#;Deg    Eq]
+       [#;Frac   Eq]
+       [#;Text   Eq]
+       [#;Symbol Eq]
+       [#;Tag    Eq])
+
+      (^template []
+        [[_ ( xs')] [_ ( ys')]]
+        (and (:: Eq = (size xs') (size ys'))
+             (fold (function [[x' y'] old]
+                     (and old (= x' y')))
+                   true
+                   (zip2 xs' ys'))))
+      ([#;Form]
+       [#;Tuple])
+
+      [[_ (#;Record xs')] [_ (#;Record ys')]]
+      (and (:: Eq = (size xs') (size ys'))
+           (fold (function [[[xl' xr'] [yl' yr']] old]
+                   (and old (= xl' yl') (= xr' yr')))
+                 true
+                 (zip2 xs' ys')))
+      
+      _
+      false)))
+
+## [Values]
+(def: #export (to-text ast)
+  (-> Code Text)
+  (case ast
+    (^template [ ]
+      [_ ( value)]
+      (::  encode value))
+    ([#;Bool   Codec]
+     [#;Nat    Codec]
+     [#;Int    Codec]
+     [#;Deg    Codec]
+     [#;Frac   Codec]
+     [#;Symbol Codec])
+
+    [_ (#;Text value)]
+    (text;encode value)
+
+    [_ (#;Tag ident)]
+    (Text/compose  "#" (:: Codec encode ident))
+
+    (^template [  ]
+      [_ ( members)]
+      ($_ Text/compose  (|> members (map to-text) (interpose " ") (text;join-with "")) ))
+    ([#;Form  "(" ")"]
+     [#;Tuple "[" "]"])
+
+    [_ (#;Record pairs)]
+    ($_ Text/compose "{" (|> pairs (map (function [[left right]] ($_ Text/compose (to-text left) " " (to-text right)))) (interpose " ") (text;join-with "")) "}")
+    ))
+
+(def: #export (replace original substitute ast)
+  {#;doc "Replaces all code that looks like the 'original' with the 'substitute'."}
+  (-> Code Code Code Code)
+  (if (:: Eq = original ast)
+    substitute
+    (case ast
+      (^template []
+        [cursor ( parts)]
+        [cursor ( (map (replace original substitute) parts))])
+      ([#;Form]
+       [#;Tuple])
+
+      [cursor (#;Record parts)]
+      [cursor (#;Record (map (function [[left right]]
+                               [(replace original substitute left)
+                                (replace original substitute right)])
+                             parts))]
+
+      _
+      ast)))
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
new file mode 100644
index 000000000..7ed7fb2ee
--- /dev/null
+++ b/stdlib/source/lux/macro/poly.lux
@@ -0,0 +1,448 @@
+(;module:
+  [lux #- function]
+  (lux (control [monad #+ do Monad]
+                [eq]
+                ["p" parser])
+       [function]
+       (data [text "text/" Monoid]
+             (coll [list "list/" Fold Monad Monoid]
+                   [dict #+ Dict])
+             [number "nat/" Codec]
+             [product]
+             [bool]
+             [maybe]
+             [ident "ident/" Eq Codec]
+             ["e" error])
+       [macro #+ with-gensyms]
+       (macro [code]
+              ["s" syntax #+ syntax: Syntax]
+              (syntax ["cs" common]
+                      (common ["csr" reader]
+                              ["csw" writer])))
+       (lang [type]
+             (type [check]))
+       ))
+
+(type: #export Env (Dict Nat [Type Code]))
+
+(type: #export (Poly a)
+  (p;Parser [Env (List Type)] a))
+
+(def: #export fresh Env (dict;new number;Hash))
+
+(def: (run' env types poly)
+  (All [a] (-> Env (List Type) (Poly a) (e;Error a)))
+  (case (p;run [env types] poly)
+    (#e;Error error)
+    (#e;Error error)
+
+    (#e;Success [[env' remaining] output])
+    (case remaining
+      #;Nil
+      (#e;Success output)
+
+      _
+      (#e;Error (|> remaining
+                    (list/map type;to-text)
+                    (text;join-with ", ")
+                    (text/compose "Unconsumed types: "))))))
+
+(def: #export (run type poly)
+  (All [a] (-> Type (Poly a) (e;Error a)))
+  (run' fresh (list type) poly))
+
+(def: #export env
+  (Poly Env)
+  (;function [[env inputs]]
+    (#e;Success [[env inputs] env])))
+
+(def: (with-env temp poly)
+  (All [a] (-> Env (Poly a) (Poly a)))
+  (;function [[env inputs]]
+    (case (p;run [temp inputs] poly)
+      (#e;Error error)
+      (#e;Error error)
+
+      (#e;Success [[_ remaining] output])
+      (#e;Success [[env remaining] output]))))
+
+(def: #export peek
+  (Poly Type)
+  (;function [[env inputs]]
+    (case inputs
+      #;Nil
+      (#e;Error "Empty stream of types.")
+
+      (#;Cons headT tail)
+      (#e;Success [[env inputs] headT]))))
+
+(def: #export any
+  (Poly Type)
+  (;function [[env inputs]]
+    (case inputs
+      #;Nil
+      (#e;Error "Empty stream of types.")
+
+      (#;Cons headT tail)
+      (#e;Success [[env tail] headT]))))
+
+(def: #export (local types poly)
+  (All [a] (-> (List Type) (Poly a) (Poly a)))
+  (;function [[env pass-through]]
+    (case (run' env types poly)
+      (#e;Error error)
+      (#e;Error error)
+
+      (#e;Success output)
+      (#e;Success [[env pass-through] output]))))
+
+(def: (label idx)
+  (-> Nat Code)
+  (code;local-symbol (text/compose "label\u0000" (nat/encode idx))))
+
+(def: #export (with-extension type poly)
+  (All [a] (-> Type (Poly a) (Poly [Code a])))
+  (;function [[env inputs]]
+    (let [current-id (dict;size env)
+          g!var (label current-id)]
+      (case (p;run [(dict;put current-id [type g!var] env)
+                    inputs]
+                   poly)
+        (#e;Error error)
+        (#e;Error error)
+
+        (#e;Success [[_ inputs'] output])
+        (#e;Success [[env inputs'] [g!var output]])))))
+
+(do-template [  ]
+  [(def: #export 
+     (Poly Unit)
+     (do p;Monad
+       [headT any]
+       (case (type;un-name headT)
+         
+         (wrap [])
+
+         _
+         (p;fail ($_ text/compose "Not "  " type: " (type;to-text headT))))))]
+
+  [void "Void" #;Void]
+  [unit "Unit" #;Unit]
+  [bool "Bool" (#;Primitive "#Bool" #;Nil)]
+  [nat  "Nat"  (#;Primitive "#Nat" #;Nil)]
+  [int  "Int"  (#;Primitive "#Int" #;Nil)]
+  [deg  "Deg"  (#;Primitive "#Deg" #;Nil)]
+  [frac "Frac" (#;Primitive "#Frac" #;Nil)]
+  [text "Text" (#;Primitive "#Text" #;Nil)]
+  )
+
+(def: #export basic
+  (Poly Type)
+  (do p;Monad
+    [headT any]
+    (case (run headT ($_ p;either
+                         void
+                         unit
+                         bool
+                         nat
+                         int
+                         deg
+                         frac
+                         text))
+      (#e;Error error)
+      (p;fail error)
+
+      (#e;Success _)
+      (wrap headT))))
+
+(do-template [  ]
+  [(def: #export ( poly)
+     (All [a] (-> (Poly a) (Poly a)))
+     (do p;Monad
+       [headT any]
+       (let [members ( (type;un-name headT))]
+         (if (n.> +1 (list;size members))
+           (local members poly)
+           (p;fail ($_ text/compose "Not a " (ident/encode (ident-for )) " type: " (type;to-text headT)))))))]
+
+  [variant type;flatten-variant #;Sum]
+  [tuple   type;flatten-tuple   #;Product]
+  )
+
+(def: polymorphic'
+  (Poly [Nat Type])
+  (do p;Monad
+    [headT any
+     #let [[num-arg bodyT] (type;flatten-univ-q (type;un-name headT))]]
+    (if (n.= +0 num-arg)
+      (p;fail ($_ text/compose "Non-polymorphic type: " (type;to-text headT)))
+      (wrap [num-arg bodyT]))))
+
+(def: #export (polymorphic poly)
+  (All [a] (-> (Poly a) (Poly [Code (List Code) a])))
+  (do p;Monad
+    [headT any
+     funcI (:: @ map dict;size ;;env)
+     [num-args non-poly] (local (list headT) polymorphic')
+     env ;;env
+     #let [funcL (label funcI)
+           [all-varsL env'] (loop [current-arg +0
+                                   env' env
+                                   all-varsL (: (List Code) (list))]
+                              (if (n.< num-args current-arg)
+                                (if (n.= +0 current-arg)
+                                  (let [varL (label (n.inc funcI))]
+                                    (recur (n.inc current-arg)
+                                           (|> env'
+                                               (dict;put funcI [headT funcL])
+                                               (dict;put (n.inc funcI) [(#;Bound (n.inc funcI)) varL]))
+                                           (#;Cons varL all-varsL)))
+                                  (let [partialI (|> current-arg (n.* +2) (n.+ funcI))
+                                        partial-varI (n.inc partialI)
+                                        partial-varL (label partial-varI)
+                                        partialC (` ((~ funcL) (~@ (|> (list;n.range +0 (n.dec num-args))
+                                                                       (list/map (|>. (n.* +2) n.inc (n.+ funcI) label))
+                                                                       list;reverse))))]
+                                    (recur (n.inc current-arg)
+                                           (|> env'
+                                               (dict;put partialI [;Void partialC])
+                                               (dict;put partial-varI [(#;Bound partial-varI) partial-varL]))
+                                           (#;Cons partial-varL all-varsL))))
+                                [all-varsL env']))]]
+    (|> (do @
+          [output poly]
+          (wrap [funcL all-varsL output]))
+        (local (list non-poly))
+        (with-env env'))))
+
+(def: #export (function in-poly out-poly)
+  (All [i o] (-> (Poly i) (Poly o) (Poly [i o])))
+  (do p;Monad
+    [headT any
+     #let [[inputsT outputT] (type;flatten-function (type;un-name headT))]]
+    (if (n.> +0 (list;size inputsT))
+      (p;seq (local inputsT in-poly)
+             (local (list outputT) out-poly))
+      (p;fail ($_ text/compose "Non-function type: " (type;to-text headT))))))
+
+(def: #export (apply poly)
+  (All [a] (-> (Poly a) (Poly a)))
+  (do p;Monad
+    [headT any
+     #let [[funcT paramsT] (type;flatten-application (type;un-name headT))]]
+    (if (n.= +0 (list;size paramsT))
+      (p;fail ($_ text/compose "Non-application type: " (type;to-text headT)))
+      (local (#;Cons funcT paramsT) poly))))
+
+(def: #export (this expected)
+  (-> Type (Poly Unit))
+  (do p;Monad
+    [actual any]
+    (if (check;checks? expected actual)
+      (wrap [])
+      (p;fail ($_ text/compose
+                  "Types do not match." "\n"
+                  "Expected: " (type;to-text expected) "\n"
+                  "  Actual: " (type;to-text actual))))))
+
+(def: (adjusted-idx env idx)
+  (-> Env Nat Nat)
+  (let [env-level (n./ +2 (dict;size env))
+        bound-level (n./ +2 idx)
+        bound-idx (n.% +2 idx)]
+    (|> env-level n.dec (n.- bound-level) (n.* +2) (n.+ bound-idx))))
+
+(def: #export bound
+  (Poly Code)
+  (do p;Monad
+    [env ;;env
+     headT any]
+    (case headT
+      (#;Bound idx)
+      (case (dict;get (adjusted-idx env idx) env)
+        (#;Some [poly-type poly-ast])
+        (wrap poly-ast)
+
+        #;None
+        (p;fail ($_ text/compose "Unknown bound type: " (type;to-text headT))))
+
+      _
+      (p;fail ($_ text/compose "Not a bound type: " (type;to-text headT))))))
+
+(def: #export (var id)
+  (-> Nat (Poly Unit))
+  (do p;Monad
+    [env ;;env
+     headT any]
+    (case headT
+      (#;Bound idx)
+      (if (n.= id (adjusted-idx env idx))
+        (wrap [])
+        (p;fail ($_ text/compose "Wrong bound type.\n"
+                    "Expected: " (nat/encode id) "\n"
+                    "  Actual: " (nat/encode idx))))
+
+      _
+      (p;fail ($_ text/compose "Not a bound type: " (type;to-text headT))))))
+
+(def: #export (recursive poly)
+  (All [a] (-> (Poly a) (Poly [Code a])))
+  (do p;Monad
+    [headT any]
+    (case (type;un-name headT)
+      (#;Apply #;Void (#;UnivQ _ headT'))
+      (do @
+        [[recT _ output] (|> poly
+                             (with-extension #;Void)
+                             (with-extension headT)
+                             (local (list headT')))]
+        (wrap [recT output]))
+
+      _
+      (p;fail ($_ text/compose "Not a recursive type: " (type;to-text headT))))))
+
+(def: #export recursive-self
+  (Poly Code)
+  (do p;Monad
+    [env ;;env
+     headT any]
+    (case (type;un-name headT)
+      (^multi (#;Apply #;Void (#;Bound funcT-idx))
+              (n.= +0 (adjusted-idx env funcT-idx))
+              [(dict;get +0 env) (#;Some [self-type self-call])])
+      (wrap self-call)
+
+      _
+      (p;fail ($_ text/compose "Not a recursive type: " (type;to-text headT))))))
+
+(def: #export recursive-call
+  (Poly Code)
+  (do p;Monad
+    [env ;;env
+     [funcT argsT] (apply (p;seq any (p;many any)))
+     _ (local (list funcT) (var +0))
+     allC (let [allT (list& funcT argsT)]
+            (|> allT
+                (monad;map @ (function;const bound))
+                (local allT)))]
+    (wrap (` ((~@ allC))))))
+
+(def: #export log
+  (All [a] (Poly a))
+  (do p;Monad
+    [current any
+     #let [_ (log! ($_ text/compose
+                       "{" (ident/encode (ident-for ;;log)) "} "
+                       (type;to-text current)))]]
+    (p;fail "LOGGING")))
+
+## [Syntax]
+(syntax: #export (poly: [export csr;export]
+                   [name s;local-symbol]
+                   body)
+  (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
+                          [(~ g!type) (macro;find-type-def (~ g!type))]
+                          (case (|> (~ body)
+                                    (;function [(~ g!name)])
+                                    p;rec
+                                    (do p;Monad [])
+                                    (;;run (~ g!type))
+                                    (: (;Either ;Text ;Code)))
+                            (#;Left (~ g!output))
+                            (macro;fail (~ g!output))
+
+                            (#;Right (~ g!output))
+                            ((~' wrap) (;list (~ g!output))))))))))))
+
+(def: (common-poly-name? poly-func)
+  (-> Text Bool)
+  (text;contains? "?" poly-func))
+
+(def: (derivation-name poly args)
+  (-> Text (List Text) (Maybe Text))
+  (if (common-poly-name? poly)
+    (#;Some (list/fold (text;replace-once "?") poly args))
+    #;None))
+
+(syntax: #export (derived: [export csr;export]
+                   [?name (p;maybe s;local-symbol)]
+                   [[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)
+     name (case ?name
+            (#;Some name)
+            (wrap name)
+
+            (^multi #;None
+                    [(derivation-name (product;right poly-func) (list/map product;right poly-args))
+                     (#;Some derived-name)])
+            (wrap derived-name)
+
+            _
+            (p;fail "derived: was given no explicit name, and cannot generate one from given information."))
+     #let [impl (case ?custom-impl
+                  (#;Some custom-impl)
+                  custom-impl
+
+                  #;None
+                  (` ((~ (code;symbol poly-func)) (~@ (list/map code;symbol poly-args)))))]]
+    (wrap (;list (` (def: (~@ (csw;export export))
+                      (~ (code;symbol ["" name]))
+                      {#;struct? true}
+                      (~ impl)))))))
+
+## [Derivers]
+(def: #export (to-ast env type)
+  (-> Env Type Code)
+  (case type
+    (#;Primitive name params)
+    (` (#;Primitive (~ (code;text name))
+                    (list (~@ (list/map (to-ast env) params)))))
+
+    (^template []
+      
+      (` ))
+    ([#;Void] [#;Unit])
+
+    (^template []
+      ( idx)
+      (` ( (~ (code;nat idx)))))
+    ([#;Var] [#;Ex])
+
+    (#;Bound idx)
+    (let [idx (adjusted-idx env idx)]
+      (if (n.= +0 idx)
+        (|> (dict;get idx env) maybe;assume product;left (to-ast env))
+        (` (;$ (~ (code;nat (n.dec idx)))))))
+
+    (#;Apply #;Void (#;Bound idx))
+    (let [idx (adjusted-idx env idx)]
+      (if (n.= +0 idx)
+        (|> (dict;get idx env) maybe;assume product;left (to-ast env))
+        (undefined)))
+    
+    (^template []
+      ( left right)
+      (` ( (~ (to-ast env left))
+                (~ (to-ast env right)))))
+    ([#;Function] [#;Apply])
+
+    (^template [  ]
+      ( left right)
+      (` ( (~@ (list/map (to-ast env) ( type))))))
+    ([#;Sum  | type;flatten-variant]
+     [#;Product & type;flatten-tuple])
+
+    (#;Named name sub-type)
+    (code;symbol name)
+
+    (^template []
+      ( scope body)
+      (` ( (list (~@ (list/map (to-ast env) scope)))
+                (~ (to-ast env body)))))
+    ([#;UnivQ] [#;ExQ])
+    ))
diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux
new file mode 100644
index 000000000..099febb24
--- /dev/null
+++ b/stdlib/source/lux/macro/poly/eq.lux
@@ -0,0 +1,147 @@
+(;module:
+  lux
+  (lux (control [monad #+ do Monad]
+                [eq]
+                ["p" parser])
+       (data [text "text/" Monoid]
+             text/format
+             (coll [list "list/" Monad]
+                   [sequence]
+                   [array]
+                   [queue]
+                   [set]
+                   [dict #+ Dict]
+                   (tree [rose]))
+             [number "nat/" Codec]
+             [product]
+             [bool]
+             [maybe])
+       (time ["du" duration]
+             ["da" date]
+             ["i" instant])
+       [macro]
+       (macro [code]
+              [syntax #+ syntax: Syntax]
+              (syntax [common])
+              [poly #+ poly:])
+       (type [unit])
+       (lang [type])
+       ))
+
+## [Derivers]
+(poly: #export Eq
+  (`` (do @
+        [#let [g!_ (code;local-symbol "\u0000_")]
+         *env* poly;env
+         inputT poly;peek
+         #let [@Eq (: (-> Type Code)
+                      (function [type]
+                        (` (eq;Eq (~ (poly;to-ast *env* type))))))]]
+        ($_ p;either
+            ## Basic types
+            (~~ (do-template [ ]
+                  [(do @
+                     [_ ]
+                     (wrap (` (: (~ (@Eq inputT))
+                                 ))))]
+
+                  [poly;unit (function [(~ g!_) (~ g!_)] true)]
+                  [poly;bool bool;Eq]
+                  [poly;nat  number;Eq]
+                  [poly;int  number;Eq]
+                  [poly;deg  number;Eq]
+                  [poly;frac number;Eq]
+                  [poly;text text;Eq]))
+            ## Composite types
+            (~~ (do-template [ ]
+                  [(do @
+                     [[_ argC] (poly;apply (p;seq (poly;this )
+                                                  Eq))]
+                     (wrap (` (: (~ (@Eq inputT))
+                                 ( (~ argC))))))]
+
+                  [;Maybe            maybe;Eq]
+                  [;List             list;Eq]
+                  [sequence;Sequence sequence;Eq]
+                  [;Array            array;Eq]
+                  [queue;Queue       queue;Eq]
+                  [set;Set           set;Eq]
+                  [rose;Tree         rose;Eq]
+                  ))
+            (do @
+              [[_ _ valC] (poly;apply ($_ p;seq
+                                          (poly;this dict;Dict)
+                                          poly;any
+                                          Eq))]
+              (wrap (` (: (~ (@Eq inputT))
+                          (dict;Eq (~ valC))))))
+            ## Models
+            (~~ (do-template [ ]
+                  [(do @
+                     [_ (poly;this )]
+                     (wrap (` (: (~ (@Eq inputT))
+                                 ))))]
+
+                  [du;Duration du;Eq]
+                  [i;Instant   i;Eq]
+                  [da;Date     da;Eq]
+                  [da;Day      da;Eq]
+                  [da;Month    da;Eq]))
+            (do @
+              [_ (poly;apply (p;seq (poly;this unit;Qty)
+                                    poly;any))]
+              (wrap (` (: (~ (@Eq inputT))
+                          unit;Eq))))
+            ## Variants
+            (do @
+              [members (poly;variant (p;many Eq))
+               #let [g!left (code;local-symbol "\u0000left")
+                     g!right (code;local-symbol "\u0000right")]]
+              (wrap (` (: (~ (@Eq inputT))
+                          (function [(~ g!left) (~ g!right)]
+                            (case [(~ g!left) (~ g!right)]
+                              (~@ (list/join (list/map (function [[tag g!eq]]
+                                                         (list (` [((~ (code;nat tag)) (~ g!left))
+                                                                   ((~ (code;nat tag)) (~ g!right))])
+                                                               (` ((~ g!eq) (~ g!left) (~ g!right)))))
+                                                       (list;enumerate members))))
+                              (~ g!_)
+                              false))))))
+            ## Tuples
+            (do @
+              [g!eqs (poly;tuple (p;many Eq))
+               #let [indices (|> (list;size g!eqs) n.dec (list;n.range +0))
+                     g!lefts (list/map (|>. nat/encode (text/compose "left") code;local-symbol) indices)
+                     g!rights (list/map (|>. nat/encode (text/compose "right") code;local-symbol) indices)]]
+              (wrap (` (: (~ (@Eq inputT))
+                          (function [[(~@ g!lefts)] [(~@ g!rights)]]
+                            (and (~@ (|> (list;zip3 g!eqs g!lefts g!rights)
+                                         (list/map (function [[g!eq g!left g!right]]
+                                                     (` ((~ g!eq) (~ g!left) (~ g!right)))))))))))))
+            ## Type recursion
+            (do @
+              [[g!self bodyC] (poly;recursive Eq)]
+              (wrap (` (: (~ (@Eq inputT))
+                          (eq;rec (;function [(~ g!self)]
+                                    (~ bodyC)))))))
+            poly;recursive-self
+            ## Type applications
+            (do @
+              [[funcC argsC] (poly;apply (p;seq Eq (p;many Eq)))]
+              (wrap (` ((~ funcC) (~@ argsC)))))
+            ## Bound type-vars
+            poly;bound
+            ## Polymorphism
+            (do @
+              [[funcC varsC bodyC] (poly;polymorphic Eq)]
+              (wrap (` (: (All [(~@ varsC)]
+                            (-> (~@ (list/map (|>. (~) eq;Eq (`)) varsC))
+                                (eq;Eq ((~ (poly;to-ast *env* inputT)) (~@ varsC)))))
+                          (function (~ funcC) [(~@ varsC)]
+                            (~ bodyC))))))
+            poly;recursive-call
+            ## If all else fails...
+            (|> poly;any
+                (:: @ map (|>. %type (format "Cannot create Eq for: ") p;fail))
+                (:: @ join))
+            ))))
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux
new file mode 100644
index 000000000..ba847d35b
--- /dev/null
+++ b/stdlib/source/lux/macro/poly/functor.lux
@@ -0,0 +1,95 @@
+(;module:
+  lux
+  (lux (control [monad #+ do Monad]
+                [functor]
+                ["p" parser])
+       (data [text]
+             text/format
+             (coll [list "L/" Monad Monoid])
+             [product])
+       [macro]
+       (macro [code]
+              [syntax #+ syntax: Syntax]
+              (syntax [common])
+              [poly #+ poly:])
+       (lang [type])
+       ))
+
+(poly: #export Functor
+  (do @
+    [#let [type-funcC (code;local-symbol "\u0000type-funcC")
+           funcC (code;local-symbol "\u0000funcC")
+           inputC (code;local-symbol "\u0000inputC")]
+     *env* poly;env
+     inputT poly;peek
+     [polyC varsC non-functorT] (poly;local (list inputT)
+                                            (poly;polymorphic poly;any))
+     #let [num-vars (list;size varsC)]
+     #let [@Functor (: (-> Type Code)
+                       (function [unwrappedT]
+                         (if (n.= +1 num-vars)
+                           (` (functor;Functor (~ (poly;to-ast *env* unwrappedT))))
+                           (let [paramsC (|> num-vars n.dec list;indices (L/map (|>. %n code;local-symbol)))]
+                             (` (All [(~@ paramsC)]
+                                  (functor;Functor ((~ (poly;to-ast *env* unwrappedT)) (~@ paramsC)))))))))
+           Arg (: (-> Code (poly;Poly Code))
+                     (function Arg [valueC]
+                       ($_ p;either
+                           ## Type-var
+                           (do p;Monad
+                             [#let [varI (|> num-vars (n.* +2) n.dec)]
+                              _ (poly;var varI)]
+                             (wrap (` ((~ funcC) (~ valueC)))))
+                           ## Variants
+                           (do @
+                             [_ (wrap [])
+                              membersC (poly;variant (p;many (Arg valueC)))]
+                             (wrap (` (case (~ valueC)
+                                        (~@ (L/join (L/map (function [[tag memberC]]
+                                                             (list (` ((~ (code;nat tag)) (~ valueC)))
+                                                                   (` ((~ (code;nat tag)) (~ memberC)))))
+                                                           (list;enumerate membersC))))))))
+                           ## Tuples
+                           (do p;Monad
+                             [pairsCC (: (poly;Poly (List [Code Code]))
+                                         (poly;tuple (loop [idx +0
+                                                            pairsCC (: (List [Code Code])
+                                                                       (list))]
+                                                       (p;either (let [slotC (|> idx %n (format "\u0000slot") code;local-symbol)]
+                                                                   (do @
+                                                                     [_ (wrap [])
+                                                                      memberC (Arg slotC)]
+                                                                     (recur (n.inc idx)
+                                                                            (L/compose pairsCC (list [slotC memberC])))))
+                                                                 (wrap pairsCC)))))]
+                             (wrap (` (case (~ valueC)
+                                        [(~@ (L/map product;left pairsCC))]
+                                        [(~@ (L/map product;right pairsCC))]))))
+                           ## Functions
+                           (do @
+                             [_ (wrap [])
+                              #let [outL (code;local-symbol "\u0000outL")]
+                              [inT+ outC] (poly;function (p;many poly;any)
+                                            (Arg outL))
+                              #let [inC+ (|> (list;size inT+) n.dec
+                                             (list;n.range +0)
+                                             (L/map (|>. %n (format "\u0000inC") code;local-symbol)))]]
+                             (wrap (` (function [(~@ inC+)]
+                                        (let [(~ outL) ((~ valueC) (~@ inC+))]
+                                          (~ outC))))))
+                           ## Recursion
+                           (do p;Monad
+                             [_ poly;recursive-call]
+                             (wrap (` ((~' map) (~ funcC) (~ valueC)))))
+                           ## Bound type-variables
+                           (do p;Monad
+                             [_ poly;any]
+                             (wrap valueC))
+                           )))]
+     [_ _ outputC] (: (poly;Poly [Code (List Code) Code])
+                      (p;either (poly;polymorphic
+                                 (Arg inputC))
+                                (p;fail (format "Cannot create Functor for: " (%type inputT)))))]
+    (wrap (` (: (~ (@Functor inputT))
+                (struct (def: ((~' map) (~ funcC) (~ inputC))
+                          (~ outputC))))))))
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
new file mode 100644
index 000000000..5c3a645ee
--- /dev/null
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -0,0 +1,312 @@
+(;module: {#;doc "Codecs for values in the JSON format."}
+  lux
+  (lux (control [monad #+ do Monad]
+                [eq #+ Eq]
+                codec
+                ["p" parser "p/" Monad])
+       (data [bool]
+             [bit]
+             [text "text/" Eq Monoid]
+             (text ["l" lexer])
+             [number "frac/" Codec "nat/" Codec]
+             maybe
+             ["e" error]
+             [sum]
+             [product]
+             (coll [list "list/" Fold Monad]
+                   [sequence #+ Sequence sequence "sequence/" Monad]
+                   ["d" dict])
+             (format [".." json #+ JSON]))
+       (time ["i" instant]
+             ["du" duration]
+             ["da" date])
+       [macro #+ with-gensyms]
+       (macro ["s" syntax #+ syntax:]
+              [code]
+              [poly #+ poly:])
+       (type [unit])
+       (lang [type])
+       ))
+
+(def: #hidden _map_
+  (All [a b] (-> (-> a b) (List a) (List b)))
+  list/map)
+
+(def: tag
+  (-> Nat Frac)
+  (|>. nat-to-int int-to-frac))
+
+(def: #hidden (rec-encode non-rec)
+  (All [a] (-> (-> (-> a JSON)
+                   (-> a JSON))
+               (-> a JSON)))
+  (function [input]
+    (non-rec (rec-encode non-rec) input)))
+
+(def: low-mask Nat (|> +1 (bit;shift-left +32) n.dec))
+(def: high-mask Nat (|> low-mask (bit;shift-left +32)))
+
+(struct: #hidden _ (Codec JSON Nat)
+  (def: (encode input)
+    (let [high (|> input (bit;and high-mask) (bit;shift-right +32))
+          low (bit;and low-mask input)]
+      (#..;Array (sequence (|> high nat-to-int int-to-frac #..;Number)
+                           (|> low nat-to-int int-to-frac #..;Number)))))
+  (def: (decode input)
+    (<| (..;run input)
+        (do p;Monad
+          [high ..;number
+           low ..;number])
+        (wrap (n.+ (|> high frac-to-int int-to-nat (bit;shift-left +32))
+                   (|> low frac-to-int int-to-nat))))))
+
+(struct: #hidden _ (Codec JSON Int)
+  (def: encode (|>. int-to-nat (:: Codec encode)))
+  (def: decode
+    (|>. (:: Codec decode) (:: e;Functor map nat-to-int))))
+
+(def: #hidden (nullable writer)
+  {#;doc "Builds a JSON generator for potentially inexistent values."}
+  (All [a] (-> (-> a JSON) (-> (Maybe a) JSON)))
+  (function [elem]
+    (case elem
+      #;None         #..;Null
+      (#;Some value) (writer value))))
+
+(struct: #hidden (Codec carrier)
+  (All [unit] (-> unit (Codec JSON (unit;Qty unit))))
+  (def: encode
+    (|>. unit;out (:: Codec encode)))
+  (def: decode
+    (|>. (:: Codec decode) (:: e;Functor map (unit;in carrier)))))
+
+(poly: #hidden Codec//encode
+  (with-expansions
+    [ (do-template [  ]
+               [(do @
+                  [_ ]
+                  (wrap (` (: (~ (@JSON//encode inputT))
+                              ))))]
+
+               [Unit poly;unit (function [(~ (code;symbol ["" "0"]))] #..;Null)]
+               [Bool poly;bool (|>. #..;Boolean)]
+               [Nat  poly;nat  (:: ;;Codec (~' encode))]
+               [Int  poly;int  (:: ;;Codec (~' encode))]
+               [Frac poly;frac (|>. #..;Number)]
+               [Text poly;text (|>. #..;String)])
+