From 0c32c7f03ad1f8f0db54b623dc407713bbf8cacd Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 6 Jul 2022 12:05:43 -0400 Subject: Moved compiler machinery under lux/meta. --- stdlib/source/test/aedifex/command/deploy.lux | 2 +- stdlib/source/test/aedifex/command/version.lux | 3 +- stdlib/source/test/aedifex/profile.lux | 2 +- stdlib/source/test/lux.lux | 2 - stdlib/source/test/lux/extension.lux | 3 +- stdlib/source/test/lux/meta.lux | 41 +- stdlib/source/test/lux/meta/code.lux | 3 +- stdlib/source/test/lux/meta/compiler/arity.lux | 29 + .../lux/meta/compiler/language/lux/analysis.lux | 627 +++++++++++++ .../compiler/language/lux/analysis/complex.lux | 76 ++ .../compiler/language/lux/analysis/coverage.lux | 468 ++++++++++ .../compiler/language/lux/analysis/inference.lux | 423 +++++++++ .../meta/compiler/language/lux/analysis/macro.lux | 110 +++ .../meta/compiler/language/lux/analysis/module.lux | 354 ++++++++ .../compiler/language/lux/analysis/pattern.lux | 112 +++ .../meta/compiler/language/lux/analysis/scope.lux | 205 +++++ .../meta/compiler/language/lux/analysis/simple.lux | 45 + .../meta/compiler/language/lux/analysis/type.lux | 135 +++ .../meta/compiler/language/lux/phase/analysis.lux | 967 +++++++++++++++++++++ .../compiler/language/lux/phase/analysis/case.lux | 636 ++++++++++++++ .../language/lux/phase/analysis/complex.lux | 659 ++++++++++++++ .../language/lux/phase/analysis/function.lux | 258 ++++++ .../language/lux/phase/analysis/reference.lux | 224 +++++ .../language/lux/phase/analysis/simple.lux | 111 +++ .../meta/compiler/language/lux/phase/extension.lux | 280 ++++++ .../language/lux/phase/extension/analysis/lux.lux | 205 +++++ .../meta/compiler/language/lux/phase/synthesis.lux | 21 + .../compiler/language/lux/phase/synthesis/case.lux | 358 ++++++++ .../language/lux/phase/synthesis/function.lux | 468 ++++++++++ .../compiler/language/lux/phase/synthesis/loop.lux | 293 +++++++ .../language/lux/phase/synthesis/primitive.lux | 98 +++ .../language/lux/phase/synthesis/structure.lux | 85 ++ .../language/lux/phase/synthesis/variable.lux | 338 +++++++ .../test/lux/meta/compiler/language/lux/syntax.lux | 145 +++ .../lux/meta/compiler/language/lux/synthesis.lux | 215 +++++ .../compiler/language/lux/synthesis/access.lux | 14 + .../language/lux/synthesis/access/member.lux | 41 + .../language/lux/synthesis/access/side.lux | 41 + .../compiler/language/lux/synthesis/simple.lux | 45 + .../source/test/lux/meta/compiler/meta/archive.lux | 254 ++++++ .../lux/meta/compiler/meta/archive/artifact.lux | 32 + .../compiler/meta/archive/artifact/category.lux | 44 + .../test/lux/meta/compiler/meta/archive/key.lux | 27 + .../test/lux/meta/compiler/meta/archive/module.lux | 43 + .../compiler/meta/archive/module/descriptor.lux | 58 ++ .../meta/compiler/meta/archive/module/document.lux | 97 +++ .../lux/meta/compiler/meta/archive/registry.lux | 180 ++++ .../lux/meta/compiler/meta/archive/signature.lux | 55 ++ .../test/lux/meta/compiler/meta/archive/unit.lux | 36 + .../source/test/lux/meta/compiler/meta/cache.lux | 54 ++ .../test/lux/meta/compiler/meta/cache/archive.lux | 84 ++ .../test/lux/meta/compiler/meta/cache/artifact.lux | 53 ++ .../test/lux/meta/compiler/meta/cache/module.lux | 94 ++ .../test/lux/meta/compiler/meta/cache/purge.lux | 141 +++ stdlib/source/test/lux/meta/compiler/meta/cli.lux | 143 +++ .../test/lux/meta/compiler/meta/cli/compiler.lux | 49 ++ .../source/test/lux/meta/compiler/meta/context.lux | 56 ++ .../source/test/lux/meta/compiler/meta/export.lux | 120 +++ .../source/test/lux/meta/compiler/meta/import.lux | 156 ++++ stdlib/source/test/lux/meta/compiler/phase.lux | 206 +++++ stdlib/source/test/lux/meta/compiler/reference.lux | 95 ++ .../test/lux/meta/compiler/reference/variable.lux | 45 + stdlib/source/test/lux/meta/compiler/version.lux | 41 + stdlib/source/test/lux/meta/target/ruby.lux | 2 +- stdlib/source/test/lux/tool.lux | 49 -- stdlib/source/test/lux/tool/compiler/arity.lux | 29 - .../lux/tool/compiler/language/lux/analysis.lux | 628 ------------- .../compiler/language/lux/analysis/complex.lux | 76 -- .../compiler/language/lux/analysis/coverage.lux | 468 ---------- .../compiler/language/lux/analysis/inference.lux | 423 --------- .../tool/compiler/language/lux/analysis/macro.lux | 110 --- .../tool/compiler/language/lux/analysis/module.lux | 354 -------- .../compiler/language/lux/analysis/pattern.lux | 112 --- .../tool/compiler/language/lux/analysis/scope.lux | 205 ----- .../tool/compiler/language/lux/analysis/simple.lux | 45 - .../tool/compiler/language/lux/analysis/type.lux | 135 --- .../tool/compiler/language/lux/phase/analysis.lux | 967 --------------------- .../compiler/language/lux/phase/analysis/case.lux | 636 -------------- .../language/lux/phase/analysis/complex.lux | 659 -------------- .../language/lux/phase/analysis/function.lux | 258 ------ .../language/lux/phase/analysis/reference.lux | 224 ----- .../language/lux/phase/analysis/simple.lux | 111 --- .../tool/compiler/language/lux/phase/extension.lux | 280 ------ .../language/lux/phase/extension/analysis/lux.lux | 205 ----- .../tool/compiler/language/lux/phase/synthesis.lux | 21 - .../compiler/language/lux/phase/synthesis/case.lux | 358 -------- .../language/lux/phase/synthesis/function.lux | 468 ---------- .../compiler/language/lux/phase/synthesis/loop.lux | 293 ------- .../language/lux/phase/synthesis/primitive.lux | 98 --- .../language/lux/phase/synthesis/structure.lux | 85 -- .../language/lux/phase/synthesis/variable.lux | 338 ------- .../test/lux/tool/compiler/language/lux/syntax.lux | 145 --- .../lux/tool/compiler/language/lux/synthesis.lux | 216 ----- .../compiler/language/lux/synthesis/access.lux | 14 - .../language/lux/synthesis/access/member.lux | 41 - .../language/lux/synthesis/access/side.lux | 41 - .../compiler/language/lux/synthesis/simple.lux | 45 - .../source/test/lux/tool/compiler/meta/archive.lux | 254 ------ .../lux/tool/compiler/meta/archive/artifact.lux | 32 - .../compiler/meta/archive/artifact/category.lux | 44 - .../test/lux/tool/compiler/meta/archive/key.lux | 27 - .../test/lux/tool/compiler/meta/archive/module.lux | 43 - .../compiler/meta/archive/module/descriptor.lux | 58 -- .../tool/compiler/meta/archive/module/document.lux | 97 --- .../lux/tool/compiler/meta/archive/registry.lux | 180 ---- .../lux/tool/compiler/meta/archive/signature.lux | 55 -- .../test/lux/tool/compiler/meta/archive/unit.lux | 36 - .../source/test/lux/tool/compiler/meta/cache.lux | 54 -- .../test/lux/tool/compiler/meta/cache/archive.lux | 84 -- .../test/lux/tool/compiler/meta/cache/artifact.lux | 53 -- .../test/lux/tool/compiler/meta/cache/module.lux | 94 -- .../test/lux/tool/compiler/meta/cache/purge.lux | 141 --- stdlib/source/test/lux/tool/compiler/meta/cli.lux | 143 --- .../test/lux/tool/compiler/meta/cli/compiler.lux | 49 -- .../source/test/lux/tool/compiler/meta/context.lux | 56 -- .../source/test/lux/tool/compiler/meta/export.lux | 120 --- .../source/test/lux/tool/compiler/meta/import.lux | 156 ---- stdlib/source/test/lux/tool/compiler/phase.lux | 206 ----- stdlib/source/test/lux/tool/compiler/reference.lux | 95 -- .../test/lux/tool/compiler/reference/variable.lux | 45 - stdlib/source/test/lux/tool/compiler/version.lux | 41 - 121 files changed, 10295 insertions(+), 10312 deletions(-) create mode 100644 stdlib/source/test/lux/meta/compiler/arity.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/coverage.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/macro.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/module.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/pattern.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/simple.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/analysis/type.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/case.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/complex.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/reference.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/simple.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/case.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/function.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/loop.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/structure.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/variable.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/synthesis.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux create mode 100644 stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/artifact.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/key.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/module.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/module/descriptor.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/module/document.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/signature.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cache.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cache/archive.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cache/artifact.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cache/module.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cache/purge.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cli.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/cli/compiler.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/context.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/export.lux create mode 100644 stdlib/source/test/lux/meta/compiler/meta/import.lux create mode 100644 stdlib/source/test/lux/meta/compiler/phase.lux create mode 100644 stdlib/source/test/lux/meta/compiler/reference.lux create mode 100644 stdlib/source/test/lux/meta/compiler/reference/variable.lux create mode 100644 stdlib/source/test/lux/meta/compiler/version.lux delete mode 100644 stdlib/source/test/lux/tool.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/arity.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/key.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/module.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cache.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cache/module.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cli.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/context.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/export.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/meta/import.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/phase.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/reference.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/reference/variable.lux delete mode 100644 stdlib/source/test/lux/tool/compiler/version.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index a38f12ad0..6a146cc44 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -25,7 +25,7 @@ ["[0]" set]]] [math ["[0]" random]] - [tool + [meta [compiler [meta ["[0]" export]]]] diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index 983262270..fa22f379b 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -16,8 +16,7 @@ [math ["[0]" random]] [meta - ["lux_[0]" version]] - [tool + ["lux_[0]" version] [compiler ["[0]" version]]] [world diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 815d7fe4c..dbbfdf6b0 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -21,7 +21,7 @@ ["[0]" random (.only Random) (.use "[1]#[0]" monad)] [number ["n" nat]]] - [tool + [meta [compiler [meta [cli diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 9e5adf134..d9e4bbc29 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -56,7 +56,6 @@ ["[1][0]" test] ["[1][0]" time] - ["[1][0]" tool] ["[1][0]" world] ["[1][0]" ffi] @@ -1215,7 +1214,6 @@ /test.test /time.test - /tool.test /world.test /ffi.test diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index 662feb16a..8be85f9c0 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -39,8 +39,7 @@ ["[0]" version] [encoding ["[0]" name]])) - (.,, (.these))))]]] - [tool + (.,, (.these))))]] [compiler ["[0]" phase] [meta diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 8ae07efb8..9b6f168e4 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -48,7 +48,29 @@ "Lua" (.,, (.these ["[1]/[0]" lua])) "Python" (.,, (.these ["[1]/[0]" python])) "Ruby" (.,, (.these ["[1]/[0]" ruby])) - (.,, (.these))))]]))) + (.,, (.these))))] + ["[1][0]/" compiler + ["[1][0]" arity] + ["[1][0]" version] + ["[1][0]" reference] + ["[1][0]" phase] + [language + [lux + ... ["[1][0]" syntax] + ["[1][0]" analysis] + ["[1][0]" synthesis] + ["[1][0]" phase + ["[1]/[0]" extension] + ["[1]/[0]" analysis] + ... ["[1]/[0]" synthesis] + ]]] + ["[1][0]" meta + ["[1]/[0]" archive] + ["[1]/[0]" cli] + ["[1]/[0]" export] + ["[1]/[0]" import] + ["[1]/[0]" context] + ["[1]/[0]" cache]]]]))) (def !expect (template (_ ) @@ -1042,4 +1064,21 @@ @.lua (,, (these /target/lua.test)) @.python (,, (these /target/python.test)) @.ruby (,, (these /target/ruby.test)))) + + /compiler/arity.test + /compiler/version.test + /compiler/reference.test + /compiler/phase.test + /compiler/analysis.test + /compiler/synthesis.test + /compiler/meta/archive.test + /compiler/meta/cli.test + /compiler/meta/export.test + /compiler/meta/import.test + /compiler/meta/context.test + /compiler/meta/cache.test + /compiler/phase/extension.test + /compiler/phase/analysis.test + ... /compiler/syntax.test + ... /compiler/synthesis.test ))))) diff --git a/stdlib/source/test/lux/meta/code.lux b/stdlib/source/test/lux/meta/code.lux index 65d848f76..2a645fcaa 100644 --- a/stdlib/source/test/lux/meta/code.lux +++ b/stdlib/source/test/lux/meta/code.lux @@ -27,8 +27,7 @@ ["[0]" symbol] ["[0]" location] [macro - ["^" pattern]]] - [tool + ["^" pattern]] [compiler [language [lux diff --git a/stdlib/source/test/lux/meta/compiler/arity.lux b/stdlib/source/test/lux/meta/compiler/arity.lux new file mode 100644 index 000000000..ffff0f3e6 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/arity.lux @@ -0,0 +1,29 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]]) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Arity]) + (do [! random.monad] + [arity (at ! each (n.% 3) random.nat)] + (all _.and + (_.coverage [/.nullary?] + (bit#= (n.= 0 arity) (/.nullary? arity))) + (_.coverage [/.unary?] + (bit#= (n.= 1 arity) (/.unary? arity))) + (_.coverage [/.multiary?] + (bit#= (n.>= 2 arity) (/.multiary? arity))) + )))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis.lux new file mode 100644 index 000000000..d153ae458 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis.lux @@ -0,0 +1,627 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + ["[0]" static] + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence]]] + [control + ["<>" parser] + ["[0]" pipe] + ["[0]" try] + ["[0]" exception (.only exception)] + ["[0]" function] + ["[0]" maybe]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text (.use "[1]#[0]" equivalence)] + [collection + ["[0]" list]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat] + ["i" int] + ["f" frac] + ["r" rev]]] + [meta + ["[0]" symbol (.use "[1]#[0]" equivalence)] + [macro + ["[0]" template]] + ["[0]" configuration + ["$[1]" \\test]] + [compiler + [reference (.only Constant) + [variable (.only)]]]]]] + ["[0]" \\parser] + [\\library + ["[0]" / (.only) + [// + [phase + ["[0]" extension]] + [/// + ["[0]" phase] + ["[0]" version]]]]] + ["[0]" / + ["[1][0]" complex] + ["[1][0]" inference] + ["[1][0]" macro] + ["[1][0]" module] + ["[1][0]" pattern] + ["[1][0]" scope] + ["[1][0]" simple] + ["[1][0]" type] + ["[1][0]" coverage] + [//// + ["[1][0]" reference (.only) + ["[2][0]" variable]] + [/// + [meta + ["[1][0]" symbol] + ["[0]" location + ["[2][1]" /] + ["[1]" \\library (.use "[1]#[0]" equivalence)]]]]]]) + +(def !expect + (template (_ ) + [(case + + true + + _ + false)])) + +(def constant + (Random Constant) + (random.and (random.unicode 10) + (random.unicode 10))) + +(def \\parser + Test + (<| (_.covering \\parser._) + (_.for [\\parser.Parser]) + (do [! random.monad] + [] + (`` (all _.and + (do [! random.monad] + [expected (at ! each (|>> /.bit) random.bit)] + (_.coverage [\\parser.result \\parser.any] + (|> (list expected) + (\\parser.result \\parser.any) + (pipe.case + {try.#Success actual} + (at /.equivalence = expected actual) + + {try.#Failure _} + false)))) + (,, (with_template [ <=>] + [(do [! random.monad] + [expected ] + (_.coverage [] + (|> (list ( expected)) + (\\parser.result ) + (pipe.case + {try.#Success actual} + (<=> expected actual) + + {try.#Failure _} + false)))) + (do [! random.monad] + [expected ] + (_.coverage [] + (|> (list ( expected)) + (\\parser.result ( expected)) + (!expect {try.#Success _}))))] + + [\\parser.bit \\parser.this_bit random.bit /.bit bit#=] + [\\parser.nat \\parser.this_nat random.nat /.nat n.=] + [\\parser.int \\parser.this_int random.int /.int i.=] + [\\parser.frac \\parser.this_frac random.safe_frac /.frac f.=] + [\\parser.rev \\parser.this_rev random.rev /.rev r.=] + [\\parser.text \\parser.this_text (random.unicode 10) /.text text#=] + [\\parser.local \\parser.this_local random.nat /.local n.=] + [\\parser.foreign \\parser.this_foreign random.nat /.foreign n.=] + [\\parser.constant \\parser.this_constant ..constant /.constant symbol#=] + )) + (do [! random.monad] + [expected random.bit] + (_.coverage [\\parser.tuple] + (|> (list (/.tuple (list (/.bit expected)))) + (\\parser.result (\\parser.tuple \\parser.bit)) + (pipe.case + {try.#Success actual} + (bit#= expected actual) + + {try.#Failure _} + false)))) + (do [! random.monad] + [dummy random.bit] + (_.coverage [\\parser.end?] + (and (|> (\\parser.result \\parser.end? (list)) + (!expect {try.#Success #1})) + (|> (\\parser.result (do <>.monad + [verdict \\parser.end? + _ \\parser.bit] + (in verdict)) + (list (/.bit dummy))) + (!expect {try.#Success #0}))))) + (do [! random.monad] + [dummy random.bit] + (_.coverage [\\parser.end] + (and (|> (\\parser.result \\parser.end (list)) + (!expect {try.#Success _})) + (|> (\\parser.result \\parser.end (list (/.bit dummy))) + (!expect {try.#Failure _}))))) + (do [! random.monad] + [expected random.bit] + (_.coverage [\\parser.cannot_parse] + (and (|> (list (/.bit expected)) + (\\parser.result \\parser.nat) + (pipe.case + {try.#Success _} + false + + {try.#Failure error} + (exception.match? \\parser.cannot_parse error))) + (|> (list) + (\\parser.result \\parser.bit) + (pipe.case + {try.#Success _} + false + + {try.#Failure error} + (exception.match? \\parser.cannot_parse error)))))) + (do [! random.monad] + [expected random.bit] + (_.coverage [\\parser.unconsumed_input] + (|> (list (/.bit expected) (/.bit expected)) + (\\parser.result \\parser.bit) + (pipe.case + {try.#Success _} + false + + {try.#Failure error} + (exception.match? \\parser.unconsumed_input error))))) + ))))) + +(def (random_branch random) + (All (_ a) (-> (Random a) (Random (/.Branch' a)))) + (all random.and + /pattern.random + random + )) + +(def (random_match multiplicity random) + (All (_ a) (-> Nat (Random a) (Random (/.Match' a)))) + (all random.and + (..random_branch random) + (random.list multiplicity (..random_branch random)) + )) + +(def .public (random multiplicity) + (-> Nat (Random /.Analysis)) + (<| random.rec + (function (_ random)) + (let [random|case (all random.and + random + (..random_match multiplicity random) + ) + random|function (all random.and + (random.list multiplicity random) + random + ) + random|apply (all random.and + random + random + ) + random|extension (all random.and + (random.lower_case 1) + (random.list multiplicity random) + )]) + (all random.or + /simple.random + (/complex.random multiplicity random) + /reference.random + random|case + random|function + random|apply + random|extension + ))) + +(def test|simple + Test + (do random.monad + [bit random.bit + nat random.nat + int random.int + rev random.rev + frac random.frac + text (random.lower_case 1)] + (`` (all _.and + (_.coverage [/.unit] + (case (/.unit) + (/.unit) + true + + _ + false)) + (,, (with_template [ ] + [(_.coverage [] + (case ( ) + ( actual) + (same? actual) + + _ + false))] + + [/.bit bit] + [/.nat nat] + [/.int int] + [/.rev rev] + [/.frac frac] + [/.text text])) + )))) + +(def test|complex + Test + (do random.monad + [expected_left (..random 2) + expected_right (..random 2) + expected_lefts random.nat + expected_right? random.bit] + (all _.and + (_.coverage [/.variant] + (let [expected (if expected_right? + expected_right + expected_left)] + (case (/.variant [expected_lefts expected_right? expected]) + (/.variant [actual_lefts actual_right? actual]) + (and (same? expected_lefts actual_lefts) + (same? expected_right? actual_right?) + (same? expected actual)) + + _ + false))) + (_.coverage [/.tuple] + (case (/.tuple (list expected_left expected_right)) + (/.tuple (list actual_left actual_right)) + (and (same? expected_left actual_left) + (same? expected_right actual_right)) + + _ + false)) + ))) + +(def test|reference + Test + (do random.monad + [expected_register random.nat + expected_constant (/symbol.random 1 1) + expected_variable /variable.random] + (`` (all _.and + (,, (with_template [ ] + [(_.coverage [] + (case ( ) + ( actual) + (same? actual) + + _ + false))] + + [/.local expected_register] + [/.foreign expected_register] + [/.constant expected_constant] + [/.variable expected_variable] + )) + )))) + +(def tagged? + (template (_ ) + [(case + { _} + true + + _ + false)])) + +(def test|reification + Test + (do random.monad + [expected_abstraction (random.only (|>> (..tagged? /.#Apply) not) + (..random 2)) + expected_parameter/0 (..random 2) + expected_parameter/1 (..random 2)] + (all _.and + (_.coverage [/.reified /.reification] + (case (|> [expected_abstraction (list expected_parameter/0 expected_parameter/1)] + /.reified + /.reification) + [actual_abstraction (list actual_parameter/0 actual_parameter/1)] + (and (same? expected_abstraction actual_abstraction) + (same? expected_parameter/0 actual_parameter/0) + (same? expected_parameter/1 actual_parameter/1)) + + _ + false)) + (_.coverage [/.no_op] + (case (/.no_op expected_parameter/0) + (/.no_op actual) + (same? expected_parameter/0 actual) + + _ + false)) + ))) + +(def test|case + Test + (do random.monad + [expected_input (..random 2) + expected_match (random_match 2 (..random 2))] + (all _.and + (_.coverage [/.case] + (case (/.case [expected_input expected_match]) + (/.case [actual_input actual_match]) + (and (same? expected_input actual_input) + (same? expected_match actual_match)) + + _ + false)) + ))) + +(with_expansions [ (static.random_nat) + (template.symbol ["exception_" ])] + (exception ) + + (def test|phase + Test + (do random.monad + [version/0 random.nat + host/0 (random.lower_case 5) + version/1 random.nat + host/1 (random.lower_case 5) + expected_error (random.lower_case 10) + location/0 /location.random + location/1 /location.random + configuration ($configuration.random 5) + .let [state/0 (has .#location location/0 + (/.state (/.info version/0 host/0 configuration))) + state/1 (has .#location location/1 + (/.state (/.info version/1 host/1 configuration)))]] + (all _.and + (_.coverage [/.set_state] + (|> (do phase.monad + [pre (extension.read function.identity) + _ (/.set_state state/1) + post (extension.read function.identity)] + (in (and (same? state/0 pre) + (same? state/1 post)))) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (try.else false))) + (_.coverage [/.failure] + (|> (/.failure expected_error) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (pipe.case + {try.#Failure actual_error} + (and (text.contains? expected_error actual_error) + (text.contains? (location.format location/0) actual_error)) + + _ + false))) + (_.coverage [/.except] + (|> (/.except []) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (pipe.case + {try.#Failure actual_error} + (and (text.contains? (exception.error []) actual_error) + (text.contains? (location.format location/0) actual_error)) + + _ + false))) + (_.coverage [/.with_exception] + (|> (/.failure expected_error) + (/.with_exception []) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (pipe.case + {try.#Failure actual_error} + (and (text.contains? expected_error actual_error) + (text.contains? (exception.error []) actual_error) + (text.contains? (location.format location/0) actual_error)) + + _ + false))) + (_.coverage [/.assertion] + (and (|> (/.assertion [] false) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (pipe.case + {try.#Failure actual_error} + (and (text.contains? (exception.error []) actual_error) + (text.contains? (location.format location/0) actual_error)) + + _ + false)) + (|> (/.assertion [] true) + (phase.result [extension.#bundle extension.empty + extension.#state state/0]) + (pipe.case + {try.#Success _} + true + + _ + false)))) + )))) + +(def test|state + Test + (do random.monad + [version random.nat + host (random.lower_case 5) + + expected_module (random.lower_case 10) + dummy_module (random.lower_case 11) + + location /location.random + + expected_file (random.lower_case 12) + expected_code (random.lower_case 13) + + configuration ($configuration.random 5) + .let [state (has .#location location + (/.state (/.info version host configuration)))]] + (all _.and + (_.coverage [/.info] + (let [it (/.info version host configuration)] + (and (text#= (version.format version) + (the .#version it)) + (same? host + (the .#target it)) + (..tagged? .#Build (the .#mode it)) + (same? configuration (the .#configuration it))))) + (_.coverage [/.state] + (let [info (/.info version host configuration) + it (/.state info)] + (and (same? info + (the .#info it)) + (same? location.dummy + (the .#location it)) + (..tagged? .#None (the .#current_module it)) + (..tagged? .#None (the .#expected it)) + (list.empty? (the .#modules it)) + (list.empty? (the .#scopes it)) + (list.empty? (the [.#type_context .#var_bindings] it)) + (case (the .#source it) + [location 0 ""] + (same? location.dummy location) + + _ + false)))) + (_.coverage [/.set_current_module] + (|> (do phase.monad + [_ (/.set_current_module expected_module)] + (extension.read (|>> (the .#current_module) (maybe.else "")))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (pipe.case + {try.#Success actual} + (same? expected_module actual) + + _ + false))) + (_.coverage [/.with_current_module] + (let [current_module (extension.read (|>> (the .#current_module) (maybe.else "")))] + (|> (do phase.monad + [_ (/.set_current_module expected_module) + pre current_module + mid (/.with_current_module dummy_module + current_module) + post current_module] + (in (and (same? expected_module pre) + (same? dummy_module mid) + (same? expected_module post)))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (try.else false)))) + (_.coverage [/.location /.set_location] + (let [expected (/.location expected_file)] + (|> (do phase.monad + [_ (/.set_location expected)] + (extension.read (the .#location))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (pipe.case + {try.#Success actual} + (same? expected actual) + + _ + false)))) + (_.coverage [/.with_location] + (let [expected (/.location expected_file) + dummy (/.location expected_code) + location (extension.read (the .#location))] + (|> (do phase.monad + [_ (/.set_location expected) + pre location + mid (/.with_location dummy + location) + post location] + (in (and (same? expected pre) + (same? dummy mid) + (same? expected post)))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (try.else false)))) + (_.coverage [/.source /.set_source_code] + (let [expected (/.source expected_file expected_code)] + (|> (do phase.monad + [_ (/.set_source_code expected)] + (extension.read (the .#source))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (pipe.case + {try.#Success actual} + (same? expected actual) + + _ + false)))) + (_.coverage [/.with_source_code] + (let [expected (/.source expected_file expected_code) + dummy (/.source expected_code expected_file) + source (extension.read (the .#source))] + (|> (do phase.monad + [_ (/.set_source_code expected) + pre source + mid (/.with_source_code dummy + source) + post source] + (in (and (same? expected pre) + (same? dummy mid) + (same? expected post)))) + (phase.result [extension.#bundle extension.empty + extension.#state state]) + (try.else false)))) + ))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Analysis]) + (do random.monad + [left (..random 2) + right (..random 2)] + (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..random 2))) + + ..test|simple + ..test|complex + ..test|reference + (_.for [/.Reification] + ..test|reification) + (_.for [/.Branch /.Branch' /.Match /.Match'] + ..test|case) + (_.for [/.Operation /.Phase /.Handler /.Bundle] + ..test|phase) + (_.for [/.State+] + ..test|state) + (_.coverage [/.format] + (bit#= (at /.equivalence = left right) + (text#= (/.format left) (/.format right)))) + + /complex.test + /inference.test + /macro.test + /module.test + /pattern.test + /scope.test + /simple.test + /type.test + /coverage.test + + ..\\parser + )))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux new file mode 100644 index 000000000..069b07187 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/complex.lux @@ -0,0 +1,76 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence] + ["$[0]" hash]]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text (.use "[1]#[0]" equivalence) + ["%" \\format (.only format)]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]]) + +(def test|tag + Test + (do [! random.monad] + [multiplicity (at ! each (n.max 2) random.nat) + tag (at ! each (n.% multiplicity) random.nat) + lefts random.nat + right? random.bit] + (all _.and + (_.coverage [/.tag /.lefts] + (and (|> lefts + (/.tag right?) + (/.lefts right?) + (n.= lefts)) + (|> tag + (/.lefts right?) + (/.tag right?) + (n.= tag)))) + (_.coverage [/.choice] + (let [[lefts right?] (/.choice multiplicity tag)] + (if right? + (n.= (-- tag) lefts) + (n.= tag lefts)))) + ))) + +(def .public (random multiplicity it) + (All (_ a) + (-> Nat (Random a) (Random (/.Complex a)))) + (all random.or + (all random.and + (random#each (n.% (-- multiplicity)) random.nat) + random.bit + it) + (random.list multiplicity it) + )) + +(def .public test + Test + (let [random (..random 3 random.nat)] + (<| (_.covering /._) + (_.for [/.Complex /.Variant /.Tuple]) + (all _.and + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) random)) + (_.for [/.hash] + ($hash.spec (/.hash n.hash) random)) + + (_.for [/.Tag] + ..test|tag) + + (do random.monad + [left random + right random] + (_.coverage [/.format] + (bit#= (at (/.equivalence n.equivalence) = left right) + (text#= (/.format %.nat left) (/.format %.nat right))))) + )))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/coverage.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/coverage.lux new file mode 100644 index 000000000..417413fb0 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/coverage.lux @@ -0,0 +1,468 @@ +(.require + [library + [lux (.except Pattern) + ["_" test (.only Test)] + [abstract + ["[0]" monad (.only do)] + [\\specification + ["$[0]" equivalence]]] + [control + ["[0]" pipe] + ["[0]" try (.only Try) (.use "[1]#[0]" functor)] + ["[0]" exception (.only Exception)] + [function + ["[0]" predicate]]] + [data + ["[0]" product] + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text (.use "[1]#[0]" equivalence) + ["%" \\format]] + [collection + ["[0]" set] + ["[0]" dictionary] + ["[0]" list (.use "[1]#[0]" functor mix)]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat (.use "[1]#[0]" interval)] + ["i" int] + ["r" rev] + ["f" frac]]] + [meta + [macro + ["^" pattern]]]]] + [\\library + ["[0]" / (.only) + ["/[1]" // + ["[1][0]" simple] + ["[1][0]" complex] + ["[1][0]" pattern (.only Pattern)]]]]) + +(def spread 16) + +(def random_tag + (Random Nat) + (random#each (n.% ..spread) random.nat)) + +(def .public random + (Random /.Coverage) + (<| random.rec + (function (_ again)) + (all random.or + (random#in []) + random.bit + (random.set n.hash ..spread random.nat) + (random.set i.hash ..spread random.int) + (random.set r.hash ..spread random.rev) + (random.set f.hash ..spread random.frac) + (random.set text.hash ..spread (random.unicode 1)) + (all random.and + (random.maybe (random#in ..spread)) + (do [! random.monad] + [cases ..random_tag + cases (random.set n.hash cases ..random_tag)] + (|> cases + set.list + (monad.each ! (function (_ case) (at ! each (|>> [case]) again))) + (at ! each (dictionary.of_list n.hash)))) + ) + (random.and again again) + (random.and again again) + ))) + +(def (ranged min range) + (-> Nat Nat (Random Nat)) + (random#each (|>> (n.% (++ range)) (n.+ min)) + random.nat)) + +(def random_pattern + (Random [/.Coverage Pattern]) + (<| random.rec + (function (_ again)) + (`` (all random.either + (random#in [{/.#Exhaustive} + {//pattern.#Simple {//simple.#Unit}}]) + (do random.monad + [it random.bit] + (in [{/.#Bit it} + {//pattern.#Simple {//simple.#Bit it}}])) + (,, (with_template [ ] + [(do random.monad + [it ] + (in [{ (set.of_list (list it))} + {//pattern.#Simple { it}}]))] + + [random.nat n.hash /.#Nat //simple.#Nat] + [random.int i.hash /.#Int //simple.#Int] + [random.rev r.hash /.#Rev //simple.#Rev] + [random.frac f.hash /.#Frac //simple.#Frac] + [(random.unicode 1) text.hash /.#Text //simple.#Text] + )) + + (do [! random.monad] + [tag (at ! each ++ ..random_tag) + right? random.bit + .let [lefts (//complex.lefts right? tag)] + [sub_coverage sub_pattern] again] + (in [{/.#Variant (if right? {.#Some tag} {.#None}) + (dictionary.of_list n.hash (list [tag sub_coverage]))} + {//pattern.#Complex + {//complex.#Variant + [//complex.#lefts lefts + //complex.#right? right? + //complex.#value sub_pattern]}}])) + + (do [! random.monad] + [arity (..ranged 2 (n.- 2 ..spread)) + it (random.list arity again) + .let [coverages (list#each product.left it) + patterns (list#each product.right it)]] + (in [(|> coverages + (list.only (|>> /.exhaustive? not)) + list.reversed + (pipe.case + {.#End} + {/.#Exhaustive} + + {.#Item last prevs} + (list#mix (function (_ left right) + {/.#Seq left right}) + last + prevs))) + {//pattern.#Complex {//complex.#Tuple patterns}}])) + + (do random.monad + [register random.nat] + (in [{/.#Exhaustive} + {//pattern.#Bind register}])) + )))) + +(def (failure? exception it) + (All (_ a) (-> (Exception a) (Try /.Coverage) Bit)) + (case it + {try.#Failure error} + (exception.match? exception error) + + _ + false)) + +(def test|value + Test + (<| (let [(open "/#[0]") /.equivalence]) + (do [! random.monad] + [left ..random + right ..random] + (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (_.coverage [/.exhaustive?] + (bit#= (/#= {/.#Exhaustive} left) + (/.exhaustive? left))) + (_.coverage [/.format] + (bit#= (/#= left right) + (text#= (/.format left) (/.format right)))) + )))) + +(def test|coverage + Test + (<| (let [(open "/#[0]") /.equivalence]) + (do [! random.monad] + [[expected pattern] ..random_pattern] + (all _.and + (_.coverage [/.coverage] + (|> pattern + /.coverage + (try#each (/#= expected)) + (try.else false))) + (_.coverage [/.invalid_tuple] + (let [invalid? (..failure? /.invalid_tuple)] + (and (|> (list) + {//complex.#Tuple} + {//pattern.#Complex} + /.coverage + invalid?) + (|> (list pattern) + {//complex.#Tuple} + {//pattern.#Complex} + /.coverage + invalid?) + (|> (list pattern pattern) + {//complex.#Tuple} + {//pattern.#Complex} + /.coverage + invalid? + not)))) + )))) + +(def random_partial_pattern + (Random [/.Coverage Pattern]) + (random.only (|>> product.left /.exhaustive? not) + ..random_pattern)) + +(def test|variant + Test + (<| (let [(open "/#[0]") /.equivalence]) + (do [! random.monad] + [[expected/0 pattern/0] ..random_partial_pattern + [expected/1 pattern/1] (random.only (|>> product.left (/#= expected/0) not) + ..random_partial_pattern) + expected_maximum (at ! each (n.+ 2) ..random_tag) + .let [random_tag (random#each (n.% expected_maximum) random.nat)] + tag/0 random_tag + tag/1 (random.only (|>> (n.= tag/0) not) random_tag) + .let [cases (dictionary.of_list n.hash (list [tag/0 expected/0] + [tag/1 expected/1])) + expected_minimum (++ (n.max tag/0 tag/1))]] + (all _.and + (_.coverage [/.minimum] + (and (n.= expected_minimum (/.minimum [{.#None} cases])) + (n.= expected_maximum (/.minimum [{.#Some expected_maximum} cases])))) + (_.coverage [/.maximum] + (and (n.= n#top (/.maximum [{.#None} cases])) + (n.= expected_maximum (/.maximum [{.#Some expected_maximum} cases])))) + )))) + +(def random_value_pattern + (Random [/.Coverage Pattern]) + (random.only (function (_ [coverage pattern]) + (case coverage + (^.or {/.#Alt _} {/.#Seq _}) + false + + _ + true)) + ..random_partial_pattern)) + +(def test|composite + Test + (<| (let [(open "/#[0]") /.equivalence]) + (do [! random.monad] + [[expected/0 pattern/0] ..random_value_pattern + [expected/1 pattern/1] (random.only (|>> product.left (/#= expected/0) not) + ..random_value_pattern) + [expected/2 pattern/2] (random.only (all predicate.and + (|>> product.left (/#= expected/0) not) + (|>> product.left (/#= expected/1) not) + (|>> product.left (pipe.case {/.#Variant _} false _ true))) + ..random_value_pattern) + + bit random.bit + nat random.nat + int random.int + rev random.rev + frac random.frac + text (random.unicode 1) + + arity (at ! each (n.+ 2) ..random_tag) + .let [random_tag (random#each (n.% arity) random.nat)] + tag/0 random_tag + tag/1 (random.only (|>> (n.= tag/0) not) random_tag)] + (all _.and + (_.coverage [/.composite] + (let [composes_simples! + (`` (and (|> (/.composite {/.#Bit bit} {/.#Bit (not bit)}) + (try#each (/#= {/.#Exhaustive})) + (try.else false)) + (|> {/.#Bit bit} + (/.composite {/.#Exhaustive}) + (try#each (/#= {/.#Exhaustive})) + (try.else false)) + (,, (with_template [ ] + [(|> (/.composite { (set.of_list (list ))} + { (set.of_list (list (|> )))}) + (try#each (/#= { (set.of_list (list (|> )))})) + (try.else false)) + (|> { (set.of_list (list ))} + (/.composite {/.#Exhaustive}) + (try#each (/#= {/.#Exhaustive})) + (try.else false))] + + [/.#Nat n.hash nat ++] + [/.#Int i.hash int ++] + [/.#Rev r.hash rev ++] + [/.#Frac f.hash frac (f.+ frac)] + [/.#Text text.hash text (%.format text)] + )))) + + composes_variants! + (let [composes_different_variants! + (let [composes? (is (-> (Maybe Nat) (Maybe Nat) (Maybe Nat) Bit) + (function (_ left right both) + (|> (/.composite {/.#Variant left (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant right (dictionary.of_list n.hash (list [tag/1 expected/1]))}) + (try#each (/#= {/.#Variant both (dictionary.of_list n.hash (list [tag/0 expected/0] + [tag/1 expected/1]))})) + (try.else false))))] + (and (composes? {.#None} {.#None} {.#None}) + (composes? {.#Some arity} {.#None} {.#Some arity}) + (composes? {.#None} {.#Some arity} {.#Some arity}) + (composes? {.#Some arity} {.#Some arity} {.#Some arity}))) + + composes_same_variants! + (let [composes? (is (-> (Maybe Nat) (Maybe Nat) (Maybe Nat) Bit) + (function (_ left right both) + (|> (do try.monad + [variant (/.composite {/.#Variant left (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant right (dictionary.of_list n.hash (list [tag/0 expected/1]))}) + expected (/.composite expected/0 expected/1)] + (in (/#= {/.#Variant both (dictionary.of_list n.hash (list [tag/0 expected]))} + variant))) + (try.else false))))] + (and (composes? {.#None} {.#None} {.#None}) + (composes? {.#Some arity} {.#None} {.#Some arity}) + (composes? {.#None} {.#Some arity} {.#Some arity}) + (composes? {.#Some arity} {.#Some arity} {.#Some arity})))] + (and composes_different_variants! + composes_same_variants! + (and (|> {/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + (/.composite {/.#Exhaustive}) + (try#each (/#= {/.#Exhaustive})) + (try.else false)) + (|> {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + (/.composite {/.#Exhaustive}) + (try#each (/#= {/.#Exhaustive})) + (try.else false))))) + + composes_sequences! + (and (|> (/.composite {/.#Seq expected/0 expected/1} + {/.#Seq expected/1 expected/0}) + (try#each (/#= {/.#Alt {/.#Seq expected/0 expected/1} + {/.#Seq expected/1 expected/0}})) + (try.else false)) + (|> (do try.monad + [seq (/.composite {/.#Seq expected/0 expected/0} + {/.#Seq expected/0 expected/1}) + expected (/.composite expected/0 expected/1)] + (in (/#= (if (/.exhaustive? expected) + expected/0 + {/.#Seq expected/0 expected}) + seq))) + (try.else false)) + (|> (do try.monad + [seq (/.composite {/.#Seq expected/0 expected/0} + {/.#Seq expected/1 expected/0}) + expected (/.composite expected/0 expected/1)] + (in (/#= {/.#Seq expected expected/0} + seq))) + (try.else false)) + (|> (/.composite {/.#Seq expected/0 expected/1} + expected/1) + (try#each (/#= {/.#Alt {/.#Seq expected/0 expected/1} + expected/1})) + (try.else false)) + (|> (/.composite expected/1 + {/.#Seq expected/0 expected/1}) + (try#each (/#= {/.#Alt expected/1 + {/.#Seq expected/0 expected/1}})) + (try.else false)) + (|> (/.composite expected/0 + {/.#Seq expected/0 expected/1}) + (try#each (/#= expected/0)) + (try.else false))) + + composes_alts! + (and (|> (do try.monad + [alt (/.composite {/.#Exhaustive} + {/.#Alt expected/0 + expected/1})] + (in (/#= {/.#Exhaustive} + alt))) + (try.else false)) + (|> (do try.monad + [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))} + {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/1]))}})] + (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))} + alt))) + (try.else false)) + (|> (do try.monad + [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))} + {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}})] + (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}] + [tag/1 expected/1]))} + alt))) + (try.else false)) + (|> (do try.monad + [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/2]))} + {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}}) + expected (/.composite expected/2 expected/0)] + (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected] + [tag/1 expected/1]))} + alt))) + (try.else false)) + (|> (do try.monad + [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/2]))} + {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}}) + expected (/.composite expected/2 expected/1)] + (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0] + [tag/1 expected]))} + alt))) + (try.else false)) + (|> (do try.monad + [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))} + {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + expected/2})] + (in (/#= {/.#Alt expected/2 + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0] + [tag/1 expected/1]))}} + alt))) + (try.else false)))] + (and composes_simples! + composes_variants! + composes_sequences! + composes_alts!))) + (_.coverage [/.redundancy] + (let [redundant? (..failure? /.redundancy)] + (`` (and (redundant? (/.composite {/.#Exhaustive} {/.#Exhaustive})) + (,, (with_template [] + [(redundant? (/.composite )) + (redundant? (/.composite {/.#Exhaustive}))] + + [{/.#Bit bit}] + [{/.#Nat (set.of_list n.hash (list nat))}] + [{/.#Int (set.of_list i.hash (list int))}] + [{/.#Rev (set.of_list r.hash (list rev))}] + [{/.#Frac (set.of_list f.hash (list frac))}] + [{/.#Text (set.of_list text.hash (list text))}] + [{/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))}] + [{/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}] + [{/.#Seq expected/0 expected/1}])) + (redundant? (/.composite {/.#Seq expected/0 expected/1} expected/0)))))) + (_.coverage [/.variant_mismatch] + (let [mismatch? (..failure? /.variant_mismatch)] + (and (not (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))) + + (mismatch? (/.composite {/.#Variant {.#Some (++ arity)} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})) + (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some (++ arity)} (dictionary.of_list n.hash (list [tag/1 expected/1]))})) + + (mismatch? (/.composite {/.#Variant {.#Some (-- arity)} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})) + (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some (-- arity)} (dictionary.of_list n.hash (list [tag/1 expected/1]))})) + + (not (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))) + (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [arity expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})) + (not (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [(-- arity) expected/0]))} + {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})))))) + )))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Coverage]) + (all _.and + ..test|value + ..test|coverage + (_.for [/.Variant] + ..test|variant) + ..test|composite + ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux new file mode 100644 index 000000000..24433b8d0 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux @@ -0,0 +1,423 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)]] + [control + ["[0]" maybe (.use "[1]#[0]" functor)] + ["[0]" try (.only Try) (.use "[1]#[0]" functor)] + ["[0]" exception (.only Exception)]] + [data + ["[0]" product] + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text] + [collection + ["[0]" list (.use "[1]#[0]" monad)]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat]]] + [meta + ["[0]" code] + ["[0]" macro] + ["[0]" symbol + ["$[1]" \\test]] + ["[0]" configuration + ["$[1]" \\test]] + ["[0]" type (.use "[1]#[0]" equivalence) + ["[0]" check (.only Check)]]]]] + [\\library + ["[0]" / (.only) + ["/[1]" // (.only) + [evaluation (.only Eval)] + ["[1][0]" macro] + ["[1][0]" type] + ["[1][0]" module] + ["[1][0]" complex] + [// + [phase + ["[2][0]" analysis] + ["[2][0]" extension (.only) + ["[1]/[0]" analysis + ["[1]" lux]]]] + [/// + ["[2][0]" phase (.use "[1]#[0]" monad)] + [meta + ["[0]" archive]]]]]]]) + +(def (eval archive type term) + Eval + (/phase#in [])) + +(def (expander macro inputs state) + //macro.Expander + {try.#Success ((macro.function macro) inputs state)}) + +(def random_state + (Random Lux) + (do random.monad + [version random.nat + host (random.lower_case 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) + +(def primitive + (Random Type) + (do random.monad + [name (random.lower_case 1)] + (in {.#Primitive name (list)}))) + +(def analysis + //.Phase + (/analysis.phase ..expander)) + +(def (fails? exception try) + (All (_ e a) (-> (Exception e) (Try a) Bit)) + (case try + {try.#Success _} + false + + {try.#Failure error} + (text.contains? (the exception.#label exception) error))) + +(def .public simple_parameter + (Random [Type Code]) + (`` (all random.either + (,, (with_template [ ] + [(random#each (|>> []) )] + + [.Bit random.bit code.bit] + [.Nat random.nat code.nat] + [.Int random.int code.int] + [.Rev random.rev code.rev] + [.Frac random.frac code.frac] + [.Text (random.lower_case 1) code.text] + )) + ))) + +(def test|general + Test + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle (/extension/analysis.bundle ..eval) + /extension.#state lux]] + expected ..primitive + name ($symbol.random 1 1) + [type/0 term/0] ..simple_parameter + arity (at ! each (n.% 10) random.nat) + nats (random.list arity random.nat)] + (all _.and + (_.coverage [/.general] + (and (|> (/.general archive.empty ..analysis expected (list)) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try#each (|>> product.left (type#= expected))) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type.function (list.repeated arity .Nat) expected) + (list#each code.nat nats)) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try#each (function (_ [actual analysis/*]) + (and (type#= expected actual) + (at (list.equivalence //.equivalence) = + (list#each (|>> //.nat) nats) + analysis/*)))) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type_literal (-> type/0 expected)) + (list term/0)) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try#each (|>> product.left (type#= expected))) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type_literal {.#Named name (-> type/0 expected)}) + (list term/0)) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try#each (|>> product.left (type#= expected))) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type_literal (All (_ a) (-> a a))) + (list term/0)) + (//type.expecting type/0) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase#each (|>> product.left (check.clean (list)) //type.check)) + /phase#conjoint + (/phase.result state) + (try#each (type#= type/0)) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type_literal ((All (_ a) (-> a a)) type/0)) + (list term/0)) + (//type.expecting type/0) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try#each (|>> product.left (type#= type/0))) + (try.else false)) + (|> (do /phase.monad + [[@var varT] (//type.check check.var) + _ (//type.check (check.check varT (type_literal (-> type/0 expected))))] + (/.general archive.empty ..analysis varT (list term/0))) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase#each (|>> product.left (check.clean (list)) //type.check)) + /phase#conjoint + (/phase.result state) + (try#each (type#= expected)) + (try.else false)) + (|> (/.general archive.empty ..analysis + (type_literal (Ex (_ a) (-> a a))) + (list (` ("lux io error" "")))) + //type.inferring + (//module.with 0 (product.left name)) + (/phase#each (|>> product.right product.left (check.clean (list)) //type.check)) + /phase#conjoint + (/phase.result state) + (try#each //type.existential?) + (try.else false)) + )) + (_.coverage [/.cannot_infer] + (and (|> (/.general archive.empty ..analysis expected (list term/0)) + (//type.expecting expected) + (/phase.result state) + (..fails? /.cannot_infer)) + (|> (do /phase.monad + [[@var varT] (//type.check check.var)] + (/.general archive.empty ..analysis varT (list term/0))) + (//type.expecting expected) + (/phase.result state) + (..fails? /.cannot_infer)))) + (_.coverage [/.cannot_infer_argument] + (|> (/.general archive.empty ..analysis + (type_literal (-> expected expected)) + (list term/0)) + (//type.expecting expected) + (//module.with 0 (product.left name)) + (/phase.result state) + (..fails? /.cannot_infer_argument))) + ))) + +(def test|variant + Test + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle (/extension/analysis.bundle ..eval) + /extension.#state lux]] + name ($symbol.random 1 1) + arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat) + [type/0 term/0] ..simple_parameter + [type/1 term/1] (random.only (|>> product.left (same? type/0) not) + ..simple_parameter) + types/*,terms/* (random.list arity ..simple_parameter) + tag (at ! each (n.% arity) random.nat) + .let [[lefts right?] (//complex.choice arity tag)] + arbitrary_right? random.bit] + (all _.and + (_.coverage [/.variant] + (let [variantT (type.variant (list#each product.left types/*,terms/*)) + [tagT tagC] (|> types/*,terms/* + (list.item tag) + (maybe.else [Any (' [])])) + variant?' (is (-> Type (Maybe Type) Nat Bit Code Bit) + (function (_ variant inferred lefts right? term) + (|> (do /phase.monad + [inferT (/.variant lefts right? variant) + [_ [it _]] (|> (/.general archive.empty ..analysis inferT (list term)) + //type.inferring)] + (case inferred + {.#Some inferred} + (//type.check + (do check.monad + [_ (check.check inferred it) + _ (check.check it inferred)] + (in true))) + + {.#None} + (in true))) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try.else false)))) + variant? (is (-> Type Nat Bit Code Bit) + (function (_ type lefts right? term) + (variant?' type {.#Some type} lefts right? term))) + + can_match_case! + (variant? variantT lefts right? tagC) + + names_do_not_matter! + (variant? {.#Named name variantT} lefts right? tagC) + + cases_independent_of_parameters_conform_to_anything! + (variant? (type_literal (Maybe type/0)) 0 #0 (' [])) + + cases_dependent_on_parameters_are_tettered_to_those_parameters! + (and (variant? (type_literal (Maybe type/0)) 0 #1 term/0) + (not (variant? (type_literal (Maybe type/0)) 0 #1 term/1))) + + only_bottom_conforms_to_tags_outside_of_range! + (`` (and (,, (with_template [ ] + [(bit#= (variant? variantT arity arbitrary_right? ))] + + [#0 term/0] + [#1 (` ("lux io error" ""))])))) + + can_handle_universal_quantification! + (and (variant?' (type_literal (All (_ a) (Maybe a))) + {.#Some Maybe} + 0 #0 (' [])) + (variant?' (type_literal (All (_ a) (Maybe a))) + {.#Some (type_literal (Maybe type/0))} + 0 #1 term/0) + (not (variant?' (type_literal (All (_ a) (Maybe a))) + {.#Some Maybe} + 0 #1 term/0))) + + existential_types_do_not_affect_independent_cases! + (variant?' (type_literal (Ex (_ a) (Maybe a))) + {.#None} + 0 #0 (' [])) + + existential_types_affect_dependent_cases! + (`` (and (,, (with_template [ ] + [(bit#= (variant?' (type_literal (Ex (_ a) (Maybe a))) {.#None} 0 #1 ))] + + [#0 term/0] + [#1 (` ("lux io error" ""))]))))] + (and can_match_case! + names_do_not_matter! + + cases_independent_of_parameters_conform_to_anything! + cases_dependent_on_parameters_are_tettered_to_those_parameters! + + only_bottom_conforms_to_tags_outside_of_range! + + can_handle_universal_quantification! + + existential_types_do_not_affect_independent_cases! + existential_types_affect_dependent_cases! + ))) + (_.coverage [/.not_a_variant] + (let [[tagT tagC] (|> types/*,terms/* + (list.item tag) + (maybe.else [Any (' [])]))] + (|> (/.variant lefts right? tagT) + (/phase.result state) + (..fails? /.not_a_variant)))) + ))) + +(def test|record + Test + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle (/extension/analysis.bundle ..eval) + /extension.#state lux]] + name ($symbol.random 1 1) + arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat) + [type/0 term/0] ..simple_parameter + [type/1 term/1] (random.only (|>> product.left (same? type/0) not) + ..simple_parameter) + types/*,terms/* (random.list arity ..simple_parameter) + .let [record? (is (-> Type (Maybe Type) Nat (List Code) Bit) + (function (_ record expected arity terms) + (|> (do /phase.monad + [inference (/.record arity record) + [_ [it _]] (|> (/.general archive.empty ..analysis inference terms) + //type.inferring)] + (case expected + {.#Some expected} + (//type.check + (do check.monad + [_ (check.check expected it) + _ (check.check it expected)] + (in true))) + + {.#None} + (in true))) + (//module.with 0 (product.left name)) + (/phase#each product.right) + (/phase.result state) + (try.else false)))) + record (type.tuple (list#each product.left types/*,terms/*)) + terms (list#each product.right types/*,terms/*)]] + (all _.and + (_.coverage [/.record] + (let [can_infer_record! + (record? record {.#None} arity terms) + + names_do_not_matter! + (record? {.#Named name record} {.#None} arity terms) + + can_handle_universal_quantification! + (and (record? (All (_ a) (Tuple type/0 a)) + {.#Some (Tuple type/0 type/1)} + 2 (list term/0 term/1)) + (record? (All (_ a) (Tuple a type/0)) + {.#Some (Tuple type/1 type/0)} + 2 (list term/1 term/0))) + + can_handle_existential_quantification! + (and (not (record? (Ex (_ a) (Tuple type/0 a)) + {.#Some (Tuple type/0 type/1)} + 2 (list term/0 term/1))) + (record? (Ex (_ a) (Tuple type/0 a)) + {.#None} + 2 (list term/0 (` ("lux io error" "")))) + (not (record? (Ex (_ a) (Tuple a type/0)) + {.#Some (Tuple type/1 type/0)} + 2 (list term/1 term/0))) + (record? (Ex (_ a) (Tuple a type/0)) + {.#None} + 2 (list (` ("lux io error" "")) term/0)))] + (and can_infer_record! + names_do_not_matter! + can_handle_universal_quantification! + can_handle_existential_quantification! + ))) + (_.coverage [/.not_a_record] + (|> (/.record arity type/0) + (/phase.result state) + (..fails? /.not_a_record))) + ))) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle (/extension/analysis.bundle ..eval) + /extension.#state lux]] + [type/0 term/0] ..simple_parameter + [type/1 term/1] (random.only (|>> product.left (same? type/0) not) + ..simple_parameter) + lefts (at ! each (n.% 10) random.nat) + right? random.bit] + (all _.and + ..test|general + ..test|variant + ..test|record + (_.coverage [/.invalid_type_application] + (and (|> (/.general archive.empty ..analysis (type_literal (type/0 type/1)) (list term/0)) + (/phase.result state) + (..fails? /.invalid_type_application)) + (|> (/.variant lefts right? (type_literal (type/0 type/1))) + (/phase.result state) + (..fails? /.invalid_type_application)) + (|> (/.record lefts (type_literal (type/0 type/1))) + (/phase.result state) + (..fails? /.invalid_type_application)))) + )))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/macro.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/macro.lux new file mode 100644 index 000000000..19c701bef --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/macro.lux @@ -0,0 +1,110 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence]]] + [control + ["[0]" pipe] + ["[0]" maybe (.use "[1]#[0]" functor)] + ["[0]" try (.use "[1]#[0]" functor)] + ["[0]" exception]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text (.use "[1]#[0]" equivalence)] + [collection + ["[0]" list (.use "[1]#[0]" monad)]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat]]] + ["[0]" meta (.only) + ["[0]" code (.use "[1]#[0]" equivalence)] + ["[0]" macro] + ["[0]" configuration + ["$[1]" \\test]]]]] + ["$" /////// + [meta + ["[1][0]" symbol] + ["[1][0]" code]]] + [\\library + ["[0]" / (.only) + ["/[1]" //]]]) + +(def random_state + (Random Lux) + (do random.monad + [version random.nat + host (random.lower_case 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) + +(def (expander macro inputs state) + /.Expander + {try.#Success ((macro.function macro) inputs state)}) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Expander]) + (do [! random.monad] + [multiplicity (at ! each (|>> (n.% 8) (n.+ 2)) + random.nat) + choice (at ! each (n.% multiplicity) + random.nat) + expected_error (random.upper_case 5) + + name ($symbol.random 2 2) + mono $code.random + poly (random.list multiplicity $code.random) + + lux ..random_state + .let [singular (<| (as Macro) + (is Macro') + (function (_ inputs state) + (case (list.item choice inputs) + {.#Some it} + {try.#Success [state (list it)]} + + {.#None} + {try.#Failure expected_error}))) + multiple (<| (as Macro) + (is Macro') + (function (_ inputs state) + {try.#Success [state (|> inputs + (list.repeated multiplicity) + list#conjoint)]}))]]) + (all _.and + (_.coverage [/.expansion] + (|> (/.expansion ..expander name multiple (list mono)) + (meta.result lux) + (try#each (at (list.equivalence code.equivalence) = + (list.repeated multiplicity mono))) + (try.else false))) + (_.coverage [/.expansion_failed] + (|> (/.expansion ..expander name singular (list)) + (meta.result lux) + (pipe.case + {try.#Failure it} + (and (text.contains? expected_error it) + (text.contains? (the exception.#label /.expansion_failed) it)) + + _ + false))) + (_.coverage [/.single_expansion] + (|> (/.single_expansion ..expander name singular poly) + (meta.result lux) + (try#each (code#= (|> poly (list.item choice) maybe.trusted))) + (try.else false))) + (_.coverage [/.must_have_single_expansion] + (|> (/.single_expansion ..expander name multiple (list mono)) + (meta.result lux) + (pipe.case + {try.#Failure it} + (text.contains? (the exception.#label /.must_have_single_expansion) it) + + _ + false))) + ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/module.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/module.lux new file mode 100644 index 000000000..7a68264d7 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/module.lux @@ -0,0 +1,354 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + ["[0]" monad (.only do)]] + [control + ["[0]" pipe] + ["[0]" try (.use "[1]#[0]" functor)] + ["[0]" exception]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)] + ["[0]" text (.use "[1]#[0]" equivalence)] + [collection + ["[0]" list] + ["[0]" set]]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + ["[0]" meta (.only) + ["[0]" configuration + ["$[1]" \\test]]]]] + [\\library + ["[0]" / (.only) + ["/[1]" // (.only) + [// + [phase + ["[2][0]" extension]] + [/// + ["[2][0]" phase]]]]]]) + +(def random_state + (Random Lux) + (do random.monad + [version random.nat + host (random.lower_case 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) + +(def primitive + (Random Type) + (do random.monad + [name (random.lower_case 1)] + (in {.#Primitive name (list)}))) + +(def (new? hash it) + (-> Nat .Module Bit) + (and (same? hash (the .#module_hash it)) + (list.empty? (the .#module_aliases it)) + (list.empty? (the .#definitions it)) + (list.empty? (the .#imports it)) + (case (the .#module_state it) + {.#Active} + true + + _ + false))) + +(def test|module + Test + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle /extension.empty + /extension.#state lux]] + name (random.lower_case 1) + hash random.nat + expected_import (random.lower_case 2) + expected_alias (random.lower_case 3)] + (all _.and + (_.coverage [/.empty] + (..new? hash (/.empty hash))) + (_.coverage [/.create] + (|> (do /phase.monad + [_ (/.create hash name)] + (/extension.lifted (meta.module name))) + (/phase.result state) + (try#each (..new? hash)) + (try.else false))) + (_.coverage [/.exists?] + (|> (do /phase.monad + [pre (/.exists? name) + _ (/.create hash name) + post (/.exists? name)] + (in (and (not pre) post))) + (/phase.result state) + (try.else false))) + (_.coverage [/.with] + (|> (do /phase.monad + [[it _] (/.with hash name + (in []))] + (in it)) + (/phase.result state) + (try#each (..new? hash)) + (try.else false))) + (_.coverage [/.import] + (`` (and (,, (with_template [] + [(|> (do [! /phase.monad] + [_ (/.create hash expected_import) + [it ?] (/.with hash name + (do ! + [_ (if + (/.import expected_import) + (in []))] + (/extension.lifted + (meta.imported? expected_import))))] + (in ?)) + (/phase.result state) + (try#each (bit#= )) + (try.else false))] + + [false] + [true]))))) + (_.coverage [/.alias] + (|> (do [! /phase.monad] + [_ (/.create hash expected_import) + [it _] (/.with hash name + (do ! + [_ (/.import expected_import)] + (/.alias expected_alias expected_import)))] + (in it)) + (/phase.result state) + (try#each (|>> (the .#module_aliases) + (pipe.case + (list [actual_alias actual_import]) + (and (same? expected_alias actual_alias) + (same? expected_import actual_import)) + + _ + false))) + (try.else false))) + ))) + +(def test|state + Test + (do [! random.monad] + [lux ..random_state + .let [state [/extension.#bundle /extension.empty + /extension.#state lux]] + name (random.lower_case 1) + hash random.nat] + (`` (all _.and + (,, (with_template [ ] + [(_.coverage [ ] + (|> (do [! /phase.monad] + [[it ?] (/.with hash name + (do ! + [_ ( name) + ? ( name) + ~0 ( name) + ~1 ( name)] + (in (and ? (not ~0) (not ~1)))))] + (in ?)) + (/phase.result state) + (try.else false)))] + + [/.set_active /.active? /.compiled? /.cached?] + [/.set_compiled /.compiled? /.cached? /.active?] + [/.set_cached /.cached? /.active? /.compiled?] + )) + (_.coverage [/.can_only_change_state_of_active_module] + (and (,, (with_template [
 ]
+                          [(|> (/.with hash name
+                                 (do /phase.monad
+                                   [_ (
 name)]
+                                   ( name)))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _}
+                                 false
+                                 
+                                 {try.#Failure error}
+                                 (text.contains? (the exception.#label /.can_only_change_state_of_active_module) error)))]
+
+                          [/.set_compiled /.set_active]
+                          [/.set_compiled /.set_compiled]
+                          [/.set_compiled /.set_cached]
+                          [/.set_cached /.set_active]
+                          [/.set_cached /.set_compiled]
+                          [/.set_cached /.set_cached]
+                          ))))
+             (_.coverage [/.unknown_module]
+               (and (,, (with_template []
+                          [(|> ( name)
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _}
+                                 false
+                                 
+                                 {try.#Failure error}
+                                 (text.contains? (the exception.#label /.unknown_module) error)))]
+
+                          [/.set_active]
+                          [/.set_compiled]
+                          [/.set_cached]
+                          ))))
+             ))))
+
+(def test|definition
+  Test
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [/extension.#bundle /extension.empty
+                  /extension.#state lux]]
+     module_name (random.lower_case 1)
+     hash random.nat
+     def_name (random.lower_case 2)
+     alias_name (random.lower_case 3)
+
+     public? random.bit
+     def_type ..primitive
+     arity (at ! each (|>> (n.% 10) ++) random.nat)
+     labels|head (random.lower_case 1)
+     labels|tail (|> (random.lower_case 1)
+                     (random.only (|>> (text#= labels|head) not))
+                     (random.set text.hash (-- arity))
+                     (at ! each set.list))
+     index (at ! each (n.% arity) random.nat)
+     .let [definition {.#Definition [public? def_type []]}
+           alias {.#Alias [module_name def_name]}]]
+    (all _.and
+         (_.coverage [/.define]
+           (`` (and (,, (with_template []
+                          [(|> (/.with hash module_name
+                                 (/.define def_name ))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _} true
+                                 {try.#Failure _} false))]
+
+                          [definition]
+                          [{.#Type [public? def_type {.#Left [labels|head labels|tail]}]}]
+                          [{.#Type [public? def_type {.#Right [labels|head labels|tail]}]}]
+                          [{.#Tag [public? def_type (list.partial labels|head labels|tail) index]}]
+                          [{.#Slot [public? def_type (list.partial labels|head labels|tail) index]}]))
+                    (|> (/.with hash module_name
+                          (do /phase.monad
+                            [_ (/.define def_name definition)]
+                            (/.define alias_name alias)))
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} true
+                          {try.#Failure _} false)))))
+         (_.coverage [/.cannot_define_more_than_once]
+           (`` (and (,, (with_template []
+                          [(|> (/.with hash module_name
+                                 (do /phase.monad
+                                   [_ (/.define def_name )]
+                                   (/.define def_name )))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _} false
+                                 {try.#Failure _} true))]
+
+                          [{.#Definition [public? def_type []]}]
+                          [{.#Type [public? def_type {.#Left [labels|head labels|tail]}]}]
+                          [{.#Type [public? def_type {.#Right [labels|head labels|tail]}]}]
+                          [{.#Tag [public? def_type (list.partial labels|head labels|tail) index]}]
+                          [{.#Slot [public? def_type (list.partial labels|head labels|tail) index]}]))
+                    (|> (/.with hash module_name
+                          (do /phase.monad
+                            [_ (/.define def_name definition)
+                             _ (/.define alias_name alias)]
+                            (/.define alias_name alias)))
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} false
+                          {try.#Failure _} true)))))
+         )))
+
+(def test|label
+  Test
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [/extension.#bundle /extension.empty
+                  /extension.#state lux]]
+     module_name (random.lower_case 1)
+     hash random.nat
+     def_name (random.lower_case 2)
+     foreign_module (random.lower_case 3)
+
+     public? random.bit
+     def_type ..primitive
+     arity (at ! each (|>> (n.% 10) ++) random.nat)
+     labels|head (random.lower_case 1)
+     labels|tail (|> (random.lower_case 1)
+                     (random.only (|>> (text#= labels|head) not))
+                     (random.set text.hash (-- arity))
+                     (at ! each set.list))]
+    (all _.and
+         (_.coverage [/.declare_labels]
+           (`` (and (,, (with_template [   ]
+                          [(|> (/.with hash module_name
+                                 (do [! /phase.monad]
+                                   [.let [it {.#Named [module_name def_name] def_type}]
+                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})
+                                    _ (/.declare_labels  (list.partial labels|head labels|tail) public? it)]
+                                   (monad.each ! (|>> [module_name]  /extension.lifted)
+                                               (list.partial labels|head labels|tail))))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _} 
+                                 {try.#Failure _} (not )))]
+
+                          [.#Left false meta.tag true]
+                          [.#Left false meta.slot false]
+                          [.#Right true meta.slot true]
+                          [.#Right true meta.tag false])))))
+         (_.coverage [/.cannot_declare_labels_for_anonymous_type]
+           (`` (and (,, (with_template [ ]
+                          [(|> (/.with hash module_name
+                                 (do [! /phase.monad]
+                                   [.let [it def_type]
+                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})]
+                                   (/.declare_labels  (list.partial labels|head labels|tail) public? it)))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _}
+                                 false
+                                 
+                                 {try.#Failure error}
+                                 (text.contains? (the exception.#label /.cannot_declare_labels_for_anonymous_type) error)))]
+
+                          [.#Left false]
+                          [.#Right true])))))
+         (_.coverage [/.cannot_declare_labels_for_foreign_type]
+           (`` (and (,, (with_template [ ]
+                          [(|> (/.with hash module_name
+                                 (do [! /phase.monad]
+                                   [.let [it {.#Named [foreign_module def_name] def_type}]
+                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})]
+                                   (/.declare_labels  (list.partial labels|head labels|tail) public? it)))
+                               (/phase.result state)
+                               (pipe.case
+                                 {try.#Success _}
+                                 false
+                                 
+                                 {try.#Failure error}
+                                 (text.contains? (the exception.#label /.cannot_declare_labels_for_foreign_type) error)))]
+
+                          [.#Left false]
+                          [.#Right true])))))
+         )))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           ..test|module
+           ..test|state
+           ..test|definition
+           (_.for [/.Label]
+                  ..test|label)
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/pattern.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/pattern.lux
new file mode 100644
index 000000000..e3034f93c
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/pattern.lux
@@ -0,0 +1,112 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
+    [number
+     ["f" frac]]]]]
+ [\\library
+  ["[0]" /]]
+ ["[0]" //
+  ["[1][0]" simple]
+  ["[1][0]" complex]])
+
+(def .public random
+  (Random /.Pattern)
+  (random.rec
+   (function (_ random)
+     (all random.or
+          //simple.random
+          (//complex.random 4 random)
+          random.nat
+          ))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Pattern])
+      (do random.monad
+        [expected_register random.nat
+         expected_bit random.bit
+         expected_nat random.nat
+         expected_int random.int
+         expected_rev random.rev
+         expected_frac random.frac
+         expected_text (random.lower_case 2)
+
+         expected_lefts random.nat
+         expected_right? random.bit
+
+         left ..random
+         right ..random])
+      (`` (all _.and
+               (_.for [/.equivalence]
+                      ($equivalence.spec /.equivalence ..random))
+               
+               (_.coverage [/.format]
+                 (bit#= (at /.equivalence = left right)
+                        (text#= (/.format left) (/.format right))))
+               (_.coverage [/.unit]
+                 (case (/.unit)
+                   (/.unit)
+                   true
+
+                   _
+                   false))
+               (,, (with_template [ ]
+                     [(_.coverage []
+                        (case ( )
+                          ( actual)
+                          (same?  actual)
+
+                          _
+                          false))]
+
+                     [/.bind expected_register]
+                     [/.bit expected_bit]
+                     [/.nat expected_nat]
+                     [/.int expected_int]
+                     [/.rev expected_rev]
+                     [/.frac expected_frac]
+                     [/.text expected_text]
+                     ))
+               (_.coverage [/.variant]
+                 (case (/.variant [expected_lefts expected_right? (/.text expected_text)])
+                   (/.variant [actual_lefts actual_right? (/.text actual_text)])
+                   (and (same? expected_lefts actual_lefts)
+                        (same? expected_right? actual_right?)
+                        (same? expected_text actual_text))
+
+                   _
+                   false))
+               (_.coverage [/.tuple]
+                 (case (/.tuple (list (/.bit expected_bit)
+                                      (/.nat expected_nat)
+                                      (/.int expected_int)
+                                      (/.rev expected_rev)
+                                      (/.frac expected_frac)
+                                      (/.text expected_text)))
+                   (/.tuple (list (/.bit actual_bit)
+                                  (/.nat actual_nat)
+                                  (/.int actual_int)
+                                  (/.rev actual_rev)
+                                  (/.frac actual_frac)
+                                  (/.text actual_text)))
+                   (and (same? expected_bit actual_bit)
+                        (same? expected_nat actual_nat)
+                        (same? expected_int actual_int)
+                        (same? expected_rev actual_rev)
+                        (same? expected_frac actual_frac)
+                        (same? expected_text actual_text))
+
+                   _
+                   false))
+               ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux
new file mode 100644
index 000000000..5fb2ad044
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/scope.lux
@@ -0,0 +1,205 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" maybe (.use "[1]#[0]" functor)]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    [collection
+     ["[0]" list]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" type
+     ["$[1]" \\test]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    [//
+     [phase
+      ["[1][0]" extension]]
+     [///
+      ["[1][0]" phase (.use "[1]#[0]" monad)]
+      [reference
+       ["[1][0]" variable (.only Register Variable)]]]]]]]
+ ["$[0]" //
+  ["[1][0]" type]])
+
+(with_template [ ]
+  [(def ( expected_type expected_register [actual_type actual_var])
+     (-> Type Register [Type Variable] Bit)
+     (and (same? expected_type actual_type)
+          (case actual_var
+            { actual_register}
+            (n.= expected_register actual_register)
+            
+            _
+            false)))]
+
+  [local? //variable.#Local]
+  [foreign? //variable.#Foreign]
+  )
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux $//type.random_state
+         .let [state [//extension.#bundle //extension.empty
+                      //extension.#state lux]]
+         name/0 (random.lower_case 1)
+         name/1 (random.lower_case 2)
+         type/0 ($type.random 0)
+         type/1 ($type.random 0)]
+        (all _.and
+             (_.coverage [/.variable]
+               (|> (/.variable name/0)
+                   /.with
+                   (//phase.result state)
+                   (try#each (|>> product.right
+                                  (pipe.case
+                                    {.#None} true
+                                    {.#Some _} false)))
+                   (try.else false)))
+             (_.coverage [/.with_local]
+               (|> (/.with_local [name/0 type/0]
+                     (/.variable name/0))
+                   /.with
+                   (//phase.result state)
+                   (try#each (|>> product.right
+                                  (maybe#each (..local? type/0 0))
+                                  (maybe.else false)))
+                   (try.else false)))
+             (_.coverage [/.next]
+               (|> (<| (do [! //phase.monad]
+                         [register/0 /.next])
+                       (/.with_local [name/0 type/0])
+                       (do !
+                         [var/0 (/.variable name/0)])
+                       (do !
+                         [register/1 /.next])
+                       (/.with_local [name/1 type/1])
+                       (do !
+                         [var/1 (/.variable name/1)])
+                       (in (do maybe.monad
+                             [var/0 var/0
+                              var/1 var/1]
+                             (in [[register/0 var/0] [register/1 var/1]]))))
+                   /.with
+                   (//phase.result state)
+                   (try#each (|>> product.right
+                                  (maybe#each (function (_ [[register/0 var/0] [register/1 var/1]])
+                                                (and (..local? type/0 register/0 var/0)
+                                                     (..local? type/1 register/1 var/1))))
+                                  (maybe.else false)))
+                   (try.else false)))
+             (_.coverage [/.no_scope]
+               (and (|> (/.with_local [name/0 type/0]
+                          (//phase#in false))
+                        (//phase.result state)
+                        (exception.otherwise (exception.match? /.no_scope)))
+                    (|> (do //phase.monad
+                          [_ /.next]
+                          (in false))
+                        (//phase.result state)
+                        (exception.otherwise (exception.match? /.no_scope)))))
+             (_.coverage [/.reset]
+               (and (|> /.next
+                        (/.with_local [name/0 type/0])
+                        /.with
+                        (//phase.result state)
+                        (try#each (|>> product.right
+                                       (n.= 1)))
+                        (try.else false))
+                    (|> /.next
+                        /.reset
+                        (/.with_local [name/0 type/0])
+                        /.with
+                        (//phase.result state)
+                        (try#each (|>> product.right
+                                       (n.= 0)))
+                        (try.else false))))
+             (_.coverage [/.drained]
+               (|> (function (_ [bundle state])
+                     {try.#Success [[bundle (has .#scopes (list) state)]
+                                    false]})
+                   (/.with_local [name/0 type/0])
+                   /.with
+                   (//phase#each product.right)
+                   (//phase.result state)
+                   (exception.otherwise (exception.match? /.drained))))
+             (_.coverage [/.with]
+               (|> (<| /.with
+                       (/.with_local [name/0 type/0])
+                       (do //phase.monad
+                         [var/0' (/.variable name/0)
+                          [scope/1 var/0''] (/.with (/.variable name/0))]
+                         (<| //phase.lifted
+                             try.of_maybe
+                             (do maybe.monad
+                               [var/0' var/0'
+                                var/0'' var/0'']
+                               (in [var/0' scope/1 var/0''])))))
+                   (//phase.result state)
+                   (try#each (function (_ [scope/0 var/0' scope/1 var/0''])
+                               (and (local? type/0 0 var/0')
+                                    (n.= 0 (list.size (the [.#locals .#mappings] scope/0)))
+                                    (n.= 0 (list.size (the [.#captured .#mappings] scope/0)))
+
+                                    (foreign? type/0 0 var/0'')
+                                    (n.= 0 (list.size (the [.#locals .#mappings] scope/1)))
+                                    (n.= 1 (list.size (the [.#captured .#mappings] scope/1))))))
+                   (try.else false)))
+             (_.coverage [/.environment]
+               (let [(open "list#[0]") (list.equivalence //variable.equivalence)]
+                 (and (|> (<| /.with
+                              (/.with_local [name/0 type/0])
+                              (/.with_local [name/1 type/1])
+                              (do //phase.monad
+                                [[scope/1 _] (/.with (in []))]
+                                (in (/.environment scope/1))))
+                          (//phase.result state)
+                          (try#each (|>> product.right
+                                         (list#= (list))))
+                          (try.else false))
+                      (|> (<| /.with
+                              (do [! //phase.monad]
+                                [register/0 /.next])
+                              (/.with_local [name/0 type/0])
+                              (/.with_local [name/1 type/1])
+                              (do !
+                                [[scope/1 _] (/.with (/.variable name/0))]
+                                (in [register/0 (/.environment scope/1)])))
+                          (//phase.result state)
+                          (try#each (function (_ [_ [register/0 environment]])
+                                      (list#= (list {//variable.#Local register/0})
+                                              environment)))
+                          (try.else false))
+                      (|> (<| /.with
+                              (do [! //phase.monad]
+                                [register/0 /.next])
+                              (/.with_local [name/0 type/0])
+                              (do [! //phase.monad]
+                                [register/1 /.next])
+                              (/.with_local [name/1 type/1])
+                              (do [! //phase.monad]
+                                [[scope/1 _] (/.with (do !
+                                                       [_ (/.variable name/1)
+                                                        _ (/.variable name/0)]
+                                                       (in [])))]
+                                (in [register/0 register/1 (/.environment scope/1)])))
+                          (//phase.result state)
+                          (try#each (function (_ [_ [register/0 register/1 environment]])
+                                      (list#= (list {//variable.#Local register/1}
+                                                    {//variable.#Local register/0})
+                                              environment)))
+                          (try.else false)))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/simple.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/simple.lux
new file mode 100644
index 000000000..b029f6add
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/simple.lux
@@ -0,0 +1,45 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
+    [number
+     ["f" frac]]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Simple)
+  (all random.or
+       (random#in [])
+       random.bit
+       random.nat
+       random.int
+       random.rev
+       (random.only (|>> f.not_a_number? not) random.frac)
+       (random.lower_case 5)
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Simple])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence ..random))
+           
+           (do random.monad
+             [left ..random
+              right ..random]
+             (_.coverage [/.format]
+               (bit#= (at /.equivalence = left right)
+                      (text#= (/.format left) (/.format right)))))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/type.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/type.lux
new file mode 100644
index 000000000..805939c68
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/type.lux
@@ -0,0 +1,135 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" product]]
+   [math
+    ["[0]" random (.only Random)]]
+   [meta
+    ["[0]" configuration
+     ["$[1]" \\test]]
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["[0]" check]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    ["[2][0]" module]
+    [//
+     [phase
+      ["[2][0]" extension]]
+     [///
+      ["[2][0]" phase (.use "[1]#[0]" functor)]]]]]])
+
+(def .public random_state
+  (Random Lux)
+  (do random.monad
+    [version random.nat
+     host (random.lower_case 1)
+     configuration ($configuration.random 5)]
+    (in (//.state (//.info version host configuration)))))
+
+(def primitive
+  (Random Type)
+  (do random.monad
+    [name (random.lower_case 1)]
+    (in {.#Primitive name (list)})))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux ..random_state
+         .let [state [/extension.#bundle /extension.empty
+                      /extension.#state lux]]
+         expected ..primitive
+         dummy (random.only (|>> (type#= expected) not)
+                            ..primitive)
+         module (random.lower_case 1)]
+        (all _.and
+             (_.coverage [/.expecting /.inference]
+               (and (|> (/.inference expected)
+                        (/.expecting expected)
+                        (/module.with 0 module)
+                        (/phase#each product.right)
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} true
+                          {try.#Failure _} false))
+                    (|> (/.inference dummy)
+                        (/.expecting expected)
+                        (/module.with 0 module)
+                        (/phase#each product.right)
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} false
+                          {try.#Failure _} true))
+                    (|> (/.inference expected)
+                        (/.expecting dummy)
+                        (/module.with 0 module)
+                        (/phase#each product.right)
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} false
+                          {try.#Failure _} true))))
+             (_.coverage [/.inferring]
+               (|> (/.inference expected)
+                   /.inferring
+                   (/module.with 0 module)
+                   (/phase#each product.right)
+                   (/phase.result state)
+                   (try#each (|>> product.left (type#= expected)))
+                   (try.else false)))
+             (_.coverage [/.check]
+               (|> (do /phase.monad
+                     [exT (/.check (do check.monad
+                                     [[id type] check.existential]
+                                     (in type)))]
+                     (|> (/.inference exT)
+                         (/.expecting exT)))
+                   (/module.with 0 module)
+                   (/phase#each product.right)
+                   (/phase.result state)
+                   (pipe.case
+                     {try.#Success _} true
+                     {try.#Failure _} false)))
+             (_.coverage [/.existential /.existential?]
+               (|> (do /phase.monad
+                     [:it: /.existential]
+                     (in (/.existential? :it:)))
+                   (/module.with 0 module)
+                   (/phase#each product.right)
+                   (/phase.result state)
+                   (try.else false)))
+             (_.coverage [/.fresh]
+               (and (|> (do /phase.monad
+                          [varT (/.check (do check.monad
+                                           [[id type] check.var]
+                                           (in type)))]
+                          (|> (/.inference expected)
+                              (/.expecting varT)))
+                        (/module.with 0 module)
+                        (/phase#each product.right)
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} true
+                          {try.#Failure _} false))
+                    (|> (do /phase.monad
+                          [varT (/.check (do check.monad
+                                           [[id type] check.var]
+                                           (in type)))]
+                          (|> (/.inference expected)
+                              (/.expecting varT)
+                              /.fresh))
+                        (/module.with 0 module)
+                        (/phase#each product.right)
+                        (/phase.result state)
+                        (pipe.case
+                          {try.#Success _} false
+                          {try.#Failure _} true))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux
new file mode 100644
index 000000000..91614f4b2
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux
@@ -0,0 +1,967 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    ["[0]" text]
+    [collection
+     ["[0]" list]]]
+   [math
+    ["[0]" random]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" code]
+    ["[0]" macro]
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["[0]" check]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [//
+    ["[0]" extension (.only)
+     ["[1]/[0]" analysis
+      ["[1]" lux]]]
+    [//
+     ["/[1]" analysis (.only Analysis Operation)
+      [evaluation (.only Eval)]
+      ["[1][0]" macro]
+      ["[1][0]" scope]
+      ["[1][0]" module]
+      ["[1][0]" pattern]
+      ["[1][0]" type (.only)
+       ["$[1]" \\test]]]
+     [///
+      ["[0]" phase (.use "[1]#[0]" monad)]
+      [meta
+       ["[0]" archive]]]]]]]
+ ["[0]" /
+  ["[1][0]" simple]
+  ["[1][0]" complex]
+  ["[1][0]" reference]
+  ["[1][0]" function]
+  ["[1][0]" case]])
+
+(def (eval archive type term)
+  Eval
+  (phase#in []))
+
+(def (expander macro inputs state)
+  //macro.Expander
+  {try.#Success ((macro.function macro) inputs state)})
+
+(def (can_analyse_unit! lux module/0)
+  (-> Lux Text Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]]
+    (|> (do phase.monad
+          [[:it: it] (|> (' [])
+                         (/.phase ..expander archive.empty)
+                         //type.inferring)]
+          (in (and (type#= .Any :it:)
+                   (case it
+                     (//.unit)
+                     true
+
+                     _
+                     false))))
+        //scope.with
+        (//module.with 0 module/0)
+        (phase#each (|>> product.right product.right))
+        (phase.result state)
+        (try.else false))))
+
+(def (can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+  (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]]
+    (`` (and (,, (with_template [   ]
+                   [(|> (do phase.monad
+                          [[:it: it] (|> 
+                                         
+                                         (/.phase ..expander archive.empty)
+                                         //type.inferring)]
+                          (in (and (type#=  :it:)
+                                   (case it
+                                     ( it)
+                                     (same?  it)
+
+                                     _
+                                     false))))
+                        //scope.with
+                        (//module.with 0 module/0)
+                        (phase#each (|>> product.right product.right))
+                        (phase.result state)
+                        (try.else false))]
+                   
+                   [bit/0 code.bit .Bit //.bit]
+                   [nat/0 code.nat .Nat //.nat]
+                   [int/0 code.int .Int //.int]
+                   [rev/0 code.rev .Rev //.rev]
+                   [frac/0 code.frac .Frac //.frac]
+                   [text/0 code.text .Text //.text]
+
+                   ... Singleton tuple
+                   [bit/0 (<| code.tuple list code.bit) .Bit //.bit]
+                   [nat/0 (<| code.tuple list code.nat) .Nat //.nat]
+                   [int/0 (<| code.tuple list code.int) .Int //.int]
+                   [rev/0 (<| code.tuple list code.rev) .Rev //.rev]
+                   [frac/0 (<| code.tuple list code.frac) .Frac //.frac]
+                   [text/0 (<| code.tuple list code.text) .Text //.text]
+                   ))
+             ))))
+
+(def (can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
+  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+        :record: (And .Any .Bit .Nat .Int .Rev .Frac .Text)
+        :variant: (Or .Any .Bit .Nat .Int .Rev .Frac .Text)
+
+        can_analyse_unary!
+        (`` (and (|> (do phase.monad
+                       [it (|> (code.variant (list (code.nat 0) (code.bit #0) (` [])))
+                               (/.phase ..expander archive.empty)
+                               (//type.expecting :variant:))]
+                       (in (case it
+                             (//.variant [0 #0 (//.unit)])
+                             true
+
+                             _
+                             false)))
+                     //scope.with
+                     (//module.with 0 module/0)
+                     (phase#each (|>> product.right product.right))
+                     (phase.result state)
+                     (try.else false))
+                 (,, (with_template [     ]
+                       [(|> (do phase.monad
+                              [it (|> (code.variant (list (code.nat ) (code.bit ) ( )))
+                                      (/.phase ..expander archive.empty)
+                                      (//type.expecting :variant:))]
+                              (in (case it
+                                    (//.variant [  ( actual)])
+                                    (same?  actual)
+
+                                    _
+                                    false)))
+                            //scope.with
+                            (//module.with 0 module/0)
+                            (phase#each (|>> product.right product.right))
+                            (phase.result state)
+                            (try.else false))]
+
+                       [1 #0 bit/0 @bit code.bit //.bit]
+                       [2 #0 nat/0 @nat code.nat //.nat]
+                       [3 #0 int/0 @int code.int //.int]
+                       [4 #0 rev/0 @rev code.rev //.rev]
+                       [5 #0 frac/0 @frac code.frac //.frac]
+                       [5 #1 text/0 @text code.text //.text]
+                       ))))
+
+        can_analyse_nullary!
+        (|> (do phase.monad
+              [.let [:either: (Or .Any :record:)]
+               it (|> (code.variant (list (code.nat 0) (code.bit #0)))
+                      (/.phase ..expander archive.empty)
+                      (//type.expecting :either:))]
+              (in (case it
+                    (//.variant [0 #0 (//.unit)])
+                    true
+
+                    _
+                    false)))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        can_analyse_multiary!
+        (|> (do phase.monad
+              [.let [:either: (Or .Any :record:)]
+               it (|> (code.variant (list (code.nat 0)
+                                          (code.bit #1)
+                                          (` [])
+                                          (code.bit bit/0)
+                                          (code.nat nat/0)
+                                          (code.int int/0)
+                                          (code.rev rev/0)
+                                          (code.frac frac/0)
+                                          (code.text text/0)))
+                      (/.phase ..expander archive.empty)
+                      (//type.expecting :either:))]
+              (in (case it
+                    (//.variant [0 #1 (//.tuple (list (//.unit)
+                                                      (//.bit bit/?)
+                                                      (//.nat nat/?)
+                                                      (//.int int/?)
+                                                      (//.rev rev/?)
+                                                      (//.frac frac/?)
+                                                      (//.text text/?)))])
+                    (and (same? bit/0 bit/?)
+                         (same? nat/0 nat/?)
+                         (same? int/0 int/?)
+                         (same? rev/0 rev/?)
+                         (same? frac/0 frac/?)
+                         (same? text/0 text/?))
+
+                    _
+                    false)))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))]
+    (and can_analyse_unary!
+         can_analyse_nullary!
+         can_analyse_multiary!
+         )))
+
+(def (can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
+  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+        :record: {.#Named [module/0 @text]
+                          (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])}
+        slots/* (list @any @bit @nat @int @rev @frac @text)
+        :variant: {.#Named [module/0 @text]
+                           (type_literal (Or .Any .Bit .Nat .Int .Rev .Frac .Text))}
+        tags/* (list @any @bit @nat @int @rev @frac @text)
+
+        can_analyse_unary!
+        (`` (and (|> (do phase.monad
+                       [_ (//module.declare_labels false tags/* false :variant:)
+                        [:it: it] (|> (code.variant (list (code.local @any) (` [])))
+                                      (/.phase ..expander archive.empty)
+                                      //type.inferring)]
+                       (in (and (type#= :variant:
+                                        :it:)
+                                (case it
+                                  (//.variant [0 #0 (//.unit)])
+                                  true
+
+                                  _
+                                  false))))
+                     //scope.with
+                     (//module.with 0 module/0)
+                     (phase#each (|>> product.right product.right))
+                     (phase.result state)
+                     (try.else false))
+                 (,, (with_template [     ]
+                       [(|> (do phase.monad
+                              [_ (//module.declare_labels false tags/* false :variant:)
+                               [:it: it] (|> (code.variant (list (code.local ) ( )))
+                                             (/.phase ..expander archive.empty)
+                                             //type.inferring)]
+                              (in (and (type#= :variant:
+                                               :it:)
+                                       (case it
+                                         (//.variant [  ( actual)])
+                                         (same?  actual)
+
+                                         _
+                                         false))))
+                            //scope.with
+                            (//module.with 0 module/0)
+                            (phase#each (|>> product.right product.right))
+                            (phase.result state)
+                            (try.else false))]
+
+                       [1 #0 bit/0 @bit code.bit //.bit]
+                       [2 #0 nat/0 @nat code.nat //.nat]
+                       [3 #0 int/0 @int code.int //.int]
+                       [4 #0 rev/0 @rev code.rev //.rev]
+                       [5 #0 frac/0 @frac code.frac //.frac]
+                       [5 #1 text/0 @text code.text //.text]
+                       ))))
+
+        can_analyse_nullary!
+        (|> (do phase.monad
+              [_ (//module.declare_labels true slots/* false :record:)
+               .let [:either: {.#Named [module/0 module/0]
+                                       (type_literal (Or .Any :record:))}]
+               _ (//module.declare_labels false (list @left @right) false :either:)
+               [:it: it] (|> (code.variant (list (code.local @left)))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= :either:
+                               :it:)
+                       (case it
+                         (//.variant [0 #0 (//.unit)])
+                         true
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        can_analyse_multiary!
+        (|> (do phase.monad
+              [_ (//module.declare_labels true slots/* false :record:)
+               .let [:either: {.#Named [module/0 module/0]
+                                       (type_literal (Or .Any :record:))}]
+               _ (//module.declare_labels false (list @left @right) false :either:)
+               [:it: it] (|> (code.variant (list (code.local @right)
+                                                 (` [])
+                                                 (code.bit bit/0)
+                                                 (code.nat nat/0)
+                                                 (code.int int/0)
+                                                 (code.rev rev/0)
+                                                 (code.frac frac/0)
+                                                 (code.text text/0)))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= :either:
+                               :it:)
+                       (case it
+                         (//.variant [0 #1 (//.tuple (list (//.unit)
+                                                           (//.bit bit/?)
+                                                           (//.nat nat/?)
+                                                           (//.int int/?)
+                                                           (//.rev rev/?)
+                                                           (//.frac frac/?)
+                                                           (//.text text/?)))])
+                         (and (same? bit/0 bit/?)
+                              (same? nat/0 nat/?)
+                              (same? int/0 int/?)
+                              (same? rev/0 rev/?)
+                              (same? frac/0 frac/?)
+                              (same? text/0 text/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))]
+    (and can_analyse_unary!
+         can_analyse_nullary!
+         can_analyse_multiary!)))
+
+(def (can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+  (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]]
+    (|> (do phase.monad
+          [[:it: it] (|> (code.tuple (list (` [])
+                                           (code.bit bit/0)
+                                           (code.nat nat/0)
+                                           (code.int int/0)
+                                           (code.rev rev/0)
+                                           (code.frac frac/0)
+                                           (code.text text/0)))
+                         (/.phase ..expander archive.empty)
+                         //type.inferring)]
+          (in (and (type#= (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])
+                           :it:)
+                   (case it
+                     (//.tuple (list (//.unit)
+                                     (//.bit bit/?)
+                                     (//.nat nat/?)
+                                     (//.int int/?)
+                                     (//.rev rev/?)
+                                     (//.frac frac/?)
+                                     (//.text text/?)))
+                     (and (same? bit/0 bit/?)
+                          (same? nat/0 nat/?)
+                          (same? int/0 int/?)
+                          (same? rev/0 rev/?)
+                          (same? frac/0 frac/?)
+                          (same? text/0 text/?))
+
+                     _
+                     false))))
+        //scope.with
+        (//module.with 0 module/0)
+        (phase#each (|>> product.right product.right))
+        (phase.result state)
+        (try.else false))))
+
+(def (can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+        :record: {.#Named [module/0 @text]
+                          (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])}
+        slots/* (list @any @bit @nat @int @rev @frac @text)]
+    (|> (do phase.monad
+          [_ (//module.declare_labels true slots/* false :record:)
+           [:it: it] (|> (code.tuple (list (code.local @text) (code.text text/0)
+                                           (code.local @bit) (code.bit bit/0)
+                                           (code.local @rev) (code.rev rev/0)
+                                           (code.local @int) (code.int int/0)
+                                           (code.local @nat) (code.nat nat/0)
+                                           (code.local @frac) (code.frac frac/0)
+                                           (code.local @any) (` [])))
+                         (/.phase ..expander archive.empty)
+                         //type.inferring)]
+          (in (and (type#= :record:
+                           :it:)
+                   (case it
+                     (//.tuple (list (//.unit)
+                                     (//.bit bit/?)
+                                     (//.nat nat/?)
+                                     (//.int int/?)
+                                     (//.rev rev/?)
+                                     (//.frac frac/?)
+                                     (//.text text/?)))
+                     (and (same? bit/0 bit/?)
+                          (same? nat/0 nat/?)
+                          (same? int/0 int/?)
+                          (same? rev/0 rev/?)
+                          (same? frac/0 frac/?)
+                          (same? text/0 text/?))
+
+                     _
+                     false))))
+        //scope.with
+        (//module.with 0 module/0)
+        (phase#each (|>> product.right product.right))
+        (phase.result state)
+        (try.else false))))
+
+(def (can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
+  (-> Lux Text Nat [Code Code Code Code] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+
+        can_make_abstraction!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)] (, (code.nat nat/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= (All (_ a) (-> a .Nat))
+                               :it:)
+                       (case it
+                         {//.#Function (list) (//.nat nat/?)}
+                         (same? nat/0 nat/?)
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        can_nest_abstraction!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
+                                 ([(, $abstraction/1) (, $parameter/1)]
+                                  (, (code.nat nat/0)))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= (All (_ a) (-> a (All (_ b) (-> b .Nat))))
+                               :it:)
+                       (case it
+                         {//.#Function (list) {//.#Function (list) (//.nat nat/?)}}
+                         (same? nat/0 nat/?)
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        can_refer_to_parameter!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
+                                 ([(, $abstraction/1) (, $parameter/1)]
+                                  (, $parameter/1))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= (All (_ a) (-> a (All (_ b) (-> b b))))
+                               :it:)
+                       (case it
+                         {//.#Function (list) {//.#Function (list) (//.local 1)}}
+                         true
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        can_refer_to_closure!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
+                                 ([(, $abstraction/1) (, $parameter/1)]
+                                  (, $parameter/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (case it
+                         {//.#Function (list) {//.#Function (list (//.local 1)) (//.foreign 0)}}
+                         true
+
+                         _
+                         false)
+                       ... TODO: Un-comment
+                       ... (type#= (All (_ a) (-> a (All (_ b) (-> b a))))
+                       ...         :it:)
+                       )))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))]
+    (and can_make_abstraction!
+         can_nest_abstraction!
+         can_refer_to_parameter!
+         can_refer_to_closure!
+         ... TODO: Un-comment
+         ... (|> (do phase.monad
+         ...       [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
+         ...                          ([(, $abstraction/1) (, $parameter/1)]
+         ...                           (, $abstraction/1))))
+         ...                      (/.phase ..expander archive.empty)
+         ...                      //type.inferring)]
+         ...       (in (case it
+         ...             {//.#Function (list) {//.#Function (list) (//.local 0)}}
+         ...             true
+
+         ...             _
+         ...             false)))
+         ...     //scope.with
+         ...     (//module.with 0 module/0)
+         ...     (phase#each (|>> product.right product.right))
+         ...     (phase.result state)
+         ...     (try.else false))
+         ... TODO: Un-comment
+         ... (|> (do phase.monad
+         ...       [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
+         ...                          ([(, $abstraction/1) (, $parameter/1)]
+         ...                           (, $abstraction/0))))
+         ...                      (/.phase ..expander archive.empty)
+         ...                      //type.inferring)]
+         ...       (in (case it
+         ...             {//.#Function (list) {//.#Function (list (//.local 0)) (//.foreign 0)}}
+         ...             true
+
+         ...             _
+         ...             false)))
+         ...     //scope.with
+         ...     (//module.with 0 module/0)
+         ...     (phase#each (|>> product.right product.right))
+         ...     (phase.result state)
+         ...     (try.else false))
+         )))
+
+(def (can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
+  (-> Lux Text Bit Nat [Code Code Code Code] Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+
+        constant!
+        (|> (do phase.monad
+              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)] (, (code.bit bit/0)))
+                                 (, (code.nat nat/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= .Bit :it:)
+                       (case it
+                         {//.#Apply (//.nat nat/?)
+                                    {//.#Function (list) (//.bit bit/?)}}
+                         (and (same? bit/0 bit/?)
+                              (same? nat/0 nat/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        variable!
+        (|> (do phase.monad
+              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)] (, $parameter/0))
+                                 (, (code.nat nat/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= .Nat :it:)
+                       (case it
+                         {//.#Apply (//.nat nat/?)
+                                    {//.#Function (list) (//.local 1)}}
+                         (same? nat/0 nat/?)
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        partial!
+        (|> (do phase.monad
+              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)]
+                                  ([(, $abstraction/1) (, $parameter/1)]
+                                   (, (code.bit bit/0))))
+                                 (, (code.nat nat/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (check.subsumes? (All (_ a) (-> a Bit)) :it:)
+                       (case it
+                         {//.#Apply (//.nat nat/?)
+                                    {//.#Function (list)
+                                                  {//.#Function (list) (//.bit bit/?)}}}
+                         (and (same? bit/0 bit/?)
+                              (same? nat/0 nat/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))]
+    (and constant!
+         variable!
+         partial!)))
+
+(def (can_analyse_extension! lux module/0 text/0)
+  (-> Lux Text Text Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]]
+    (|> (do phase.monad
+          [[:it: it] (|> (` ("lux text concat" (, (code.text text/0)) (, (code.text text/0))))
+                         (/.phase ..expander archive.empty)
+                         //type.inferring)]
+          (in (and (type#= .Text :it:)
+                   (case it
+                     {//.#Extension "lux text concat" (list (//.text left) (//.text right))}
+                     (and (same? text/0 left)
+                          (same? text/0 right))
+
+                     _
+                     false))))
+        //scope.with
+        (//module.with 0 module/0)
+        (phase#each (|>> product.right product.right))
+        (phase.result state)
+        (try.else false))))
+
+(def (can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0)
+  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Code Bit)
+  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
+               extension.#state lux]
+        
+        :variant: {.#Named [module/0 module/0]
+                           (type_literal (Or .Any .Bit .Nat .Int .Rev .Frac .Text))}
+        tags/* (list @any @bit @nat @int @rev @frac @text)
+
+        :record: {.#Named [module/0 module/0]
+                          (type_literal (And .Any .Bit .Nat .Int .Rev .Frac .Text))}
+        slots/* (list @any @bit @nat @int @rev @frac @text)
+
+        simple!
+        (`` (and (,, (with_template [   ]
+                       [(|> (do phase.monad
+                              [[:it: it] (|> (` ({(, $parameter/0) (, (code.frac frac/0))} (, ( ))))
+                                             (/.phase ..expander archive.empty)
+                                             //type.inferring)]
+                              (in (and (type#= .Frac :it:)
+                                       (case it
+                                         {//.#Case ( input/?)
+                                                   [[//.#when (//pattern.bind 0)
+                                                     //.#then (//.frac frac/?)]
+                                                    (list)]}
+                                         (and (same?  input/?)
+                                              (same? frac/0 frac/?))
+
+                                         _
+                                         false))))
+                            //scope.with
+                            (//module.with 0 module/0)
+                            (phase#each (|>> product.right product.right))
+                            (phase.result state)
+                            (try.else false))
+                        (|> (do phase.monad
+                              [[:it: it] (|> (` ({(, ( ))
+                                                  (, (code.frac frac/0))
+
+                                                  (, $parameter/0)
+                                                  (, (code.frac frac/0))}
+                                                 (, ( ))))
+                                             (/.phase ..expander archive.empty)
+                                             //type.inferring)]
+                              (in (and (type#= .Frac :it:)
+                                       (case it
+                                         {//.#Case ( input/?)
+                                                   [[//.#when ( pattern/?)
+                                                     //.#then (//.frac frac/?)]
+                                                    (list [//.#when (//pattern.bind 0)
+                                                           //.#then (//.frac frac/?)])]}
+                                         (and (same?  input/?)
+                                              (same?  pattern/?)
+                                              (same? frac/0 frac/?))
+
+                                         _
+                                         false))))
+                            //scope.with
+                            (//module.with 0 module/0)
+                            (phase#each (|>> product.right product.right))
+                            (phase.result state)
+                            (try.else false))]
+
+                       [bit/0 code.bit //.bit //pattern.bit]
+                       [nat/0 code.nat //.nat //pattern.nat]
+                       [int/0 code.int //.int //pattern.int]
+                       [rev/0 code.rev //.rev //pattern.rev]
+                       [frac/0 code.frac //.frac //pattern.frac]
+                       [text/0 code.text //.text //pattern.text]
+                       ))))
+
+        bit!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ({#0
+                                  (, (code.frac frac/0))
+
+                                  #1
+                                  (, (code.frac frac/0))}
+                                 (, (code.bit bit/0))))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= .Frac :it:)
+                       (case it
+                         {//.#Case (//.bit bit/?)
+                                   [[//.#when (//pattern.bit #0)
+                                     //.#then (//.frac false/?)]
+                                    (list [//.#when (//pattern.bit #1)
+                                           //.#then (//.frac true/?)])]}
+                         (and (same? bit/0 bit/?)
+                              (same? frac/0 false/?)
+                              (same? frac/0 true/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        variant!
+        (`` (and (,, (with_template [      ]
+                       [(|> (do phase.monad
+                              [_ (//module.declare_labels false tags/* false :variant:)
+                               [:it: it] (|> (` ({{(, (code.local )) (, ( ))}
+                                                  (, (code.frac frac/0))
+
+                                                  (, $parameter/0)
+                                                  (, (code.frac frac/0))}
+                                                 {(, (code.local )) (, ( ))}))
+                                             (/.phase ..expander archive.empty)
+                                             //type.inferring)]
+                              (in (and (type#= .Frac :it:)
+                                       (case it
+                                         {//.#Case (//.variant [  ( analysis/?)])
+                                                   [[//.#when (//pattern.variant [  ( pattern/?)])
+                                                     //.#then (//.frac match/?)]
+                                                    (list [//.#when (//pattern.bind 0)
+                                                           //.#then (//.frac mismatch/?)])]}
+                                         (and (same?  analysis/?)
+                                              (same?  pattern/?)
+                                              (same? frac/0 match/?)
+                                              (same? frac/0 mismatch/?))
+
+                                         _
+                                         false))))
+                            //scope.with
+                            (//module.with 0 module/0)
+                            (phase#each (|>> product.right product.right))
+                            (phase.result state)
+                            (try.else false))]
+
+                       [1 #0 bit/0 @bit code.bit //.bit //pattern.bit]
+                       [2 #0 nat/0 @nat code.nat //.nat //pattern.nat]
+                       [3 #0 int/0 @int code.int //.int //pattern.int]
+                       [4 #0 rev/0 @rev code.rev //.rev //pattern.rev]
+                       [5 #0 frac/0 @frac code.frac //.frac //pattern.frac]
+                       [5 #1 text/0 @text code.text //.text //pattern.text]
+                       ))))
+
+        tuple!
+        (|> (do phase.monad
+              [[:it: it] (|> (` ({[#0 (, $parameter/0)]
+                                  (, (code.frac frac/0))
+
+                                  [#1 (, $parameter/0)]
+                                  (, (code.frac frac/0))}
+                                 [(, (code.bit bit/0))
+                                  (, (code.nat nat/0))]))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= .Frac :it:)
+                       (case it
+                         {//.#Case (//.tuple (list (//.bit bit/?) (//.nat nat/?)))
+                                   [[//.#when (//pattern.tuple (list (//pattern.bit #0) (//pattern.bind 0)))
+                                     //.#then (//.frac false/?)]
+                                    (list [//.#when (//pattern.tuple (list (//pattern.bit #1) (//pattern.bind 0)))
+                                           //.#then (//.frac true/?)])]}
+                         (and (same? bit/0 bit/?)
+                              (same? nat/0 nat/?)
+                              (same? frac/0 false/?)
+                              (same? frac/0 true/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))
+
+        record!
+        (|> (do phase.monad
+              [_ (//module.declare_labels true slots/* false :record:)
+               [:it: it] (|> (` ({[(, (code.symbol [module/0 @any])) []
+                                   (, (code.symbol [module/0 @bit])) (, (code.bit bit/0))
+                                   (, (code.symbol [module/0 @nat])) (, (code.nat nat/0))
+                                   (, (code.symbol [module/0 @int])) (, (code.int int/0))
+                                   (, (code.symbol [module/0 @rev])) (, (code.rev rev/0))
+                                   (, (code.symbol [module/0 @frac])) (, (code.frac frac/0))
+                                   (, (code.symbol [module/0 @text])) (, (code.text text/0))]
+                                  (, (code.frac frac/0))
+
+                                  (, $parameter/0)
+                                  (, (code.frac frac/0))}
+                                 [(, (code.local @any)) []
+                                  (, (code.local @bit)) (, (code.bit bit/0))
+                                  (, (code.local @nat)) (, (code.nat nat/0))
+                                  (, (code.local @int)) (, (code.int int/0))
+                                  (, (code.local @rev)) (, (code.rev rev/0))
+                                  (, (code.local @frac)) (, (code.frac frac/0))
+                                  (, (code.local @text)) (, (code.text text/0))]))
+                             (/.phase ..expander archive.empty)
+                             //type.inferring)]
+              (in (and (type#= .Frac :it:)
+                       (case it
+                         {//.#Case (//.tuple (list (//.unit)
+                                                   (//.bit bit/?)
+                                                   (//.nat nat/?)
+                                                   (//.int int/?)
+                                                   (//.rev rev/?)
+                                                   (//.frac frac/?)
+                                                   (//.text text/?)))
+                                   [[//.#when (//pattern.tuple (list (//pattern.unit)
+                                                                     (//pattern.bit bit/?')
+                                                                     (//pattern.nat nat/?')
+                                                                     (//pattern.int int/?')
+                                                                     (//pattern.rev rev/?')
+                                                                     (//pattern.frac frac/?')
+                                                                     (//pattern.text text/?')))
+                                     //.#then (//.frac match/?)]
+                                    (list [//.#when (//pattern.bind 0)
+                                           //.#then (//.frac mismatch/?)])]}
+                         (and (same? bit/0 bit/?) (same? bit/0 bit/?')
+                              (same? nat/0 nat/?) (same? nat/0 nat/?')
+                              (same? int/0 int/?) (same? int/0 int/?')
+                              (same? rev/0 rev/?) (same? rev/0 rev/?')
+                              (same? frac/0 frac/?) (same? frac/0 frac/?')
+                              (same? text/0 text/?) (same? text/0 text/?')
+                              (same? frac/0 match/?)
+                              (same? frac/0 mismatch/?))
+
+                         _
+                         false))))
+            //scope.with
+            (//module.with 0 module/0)
+            (phase#each (|>> product.right product.right))
+            (phase.result state)
+            (try.else false))]
+    (and simple!
+         bit!
+         variant!
+         tuple!
+         record!)))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux $//type.random_state
+         .let [state [extension.#bundle (extension/analysis.bundle ..eval)
+                      extension.#state lux]]
+
+         .let [[module/0 _] (symbol ._)]
+         
+         bit/0 random.bit
+         nat/0 random.nat
+         int/0 random.int
+         rev/0 random.rev
+         frac/0 random.frac
+         text/0 (random.lower_case 1)
+
+         @any (random.lower_case 2)
+         @bit (random.lower_case 3)
+         @nat (random.lower_case 4)
+         @int (random.lower_case 5)
+         @rev (random.lower_case 6)
+         @frac (random.lower_case 7)
+         @text (random.lower_case 8)
+
+         @left (random.lower_case 9)
+         @right (random.lower_case 10)
+
+         $abstraction/0 (at ! each code.local (random.lower_case 11))
+         $parameter/0 (at ! each code.local (random.lower_case 12))
+         $abstraction/1 (at ! each code.local (random.lower_case 13))
+         $parameter/1 (at ! each code.local (random.lower_case 14))])
+      (all _.and
+           (_.coverage [/.phase]
+             (and (..can_analyse_unit! lux module/0)
+                  (..can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+                  (..can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
+                  (..can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
+                  (..can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+                  (..can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
+                  (..can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
+                  (..can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
+                  (..can_analyse_extension! lux module/0 text/0)
+                  (..can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0)
+                  ))
+           (_.coverage [/.invalid]
+             (`` (and (,, (with_template []
+                            [(|> (do phase.monad
+                                   [_ (|> 
+                                          (/.phase ..expander archive.empty)
+                                          (//type.expecting .Any))]
+                                   (in false))
+                                 //scope.with
+                                 (//module.with 0 module/0)
+                                 (phase#each (|>> product.right product.right))
+                                 (phase.result state)
+                                 (exception.otherwise (text.contains? (the exception.#label /.invalid))))]
+
+                            [(` ({#0} (, (code.bit bit/0))))]
+                            [(` ({#0 [] #1} (, (code.bit bit/0))))]
+                            [(` {(, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0))})]
+                            [(` {(, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0))})]
+                            [(` {(, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0))})]
+                            [(` {(, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0))})]
+                            [(` {(, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0))})]
+                            [(` {(, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0))})]
+                            ))
+                      )))
+           
+           /simple.test
+           /complex.test
+           /reference.test
+           /function.test
+           /case.test
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/case.lux
new file mode 100644
index 000000000..5c1752fe3
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/case.lux
@@ -0,0 +1,636 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    ["[0]" text (.only)
+     ["%" \\format]]]
+   [math
+    ["[0]" random]]
+   [meta
+    ["[0]" code]
+    ["[0]" macro]
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["[0]" check]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    [//
+     ["[1][0]" extension (.only)
+      ["[1]/[0]" analysis
+       ["[1]" lux]]]
+     [//
+      ["[1][0]" analysis (.only)
+       [evaluation (.only Eval)]
+       ["[2][0]" macro]
+       ["[2][0]" scope]
+       ["[2][0]" module]
+       ["[2][0]" coverage]
+       ["[2][0]" type (.only)
+        ["$[1]" \\test]]
+       ["[2][0]" inference
+        ["$[1]" \\test]]]
+      [///
+       ["[1][0]" phase (.use "[1]#[0]" monad)]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def (eval archive type term)
+  Eval
+  (//phase#in []))
+
+(def (expander macro inputs state)
+  //macro.Expander
+  {try.#Success ((macro.function macro) inputs state)})
+
+(def analysis
+  //analysis.Phase
+  (//.phase ..expander))
+
+(def test|tuple
+  Test
+  (do [! random.monad]
+    [lux $//type.random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     module/0 (random.lower_case 1)
+     name/0 (at ! each (|>> [module/0]) (random.lower_case 2))
+     [input/0 simple/0] $//inference.simple_parameter
+     [input/1 simple/1] $//inference.simple_parameter
+     [input/2 simple/2] $//inference.simple_parameter
+     $binding/0 (at ! each code.local (random.lower_case 3))
+     $binding/1 (at ! each code.local (random.lower_case 4))
+     $binding/2 (at ! each code.local (random.lower_case 5))]
+    (all _.and
+         (_.coverage [/.tuple]
+           (let [tuple? (is (-> Type Type Bit)
+                            (function (_ :input: :expected:)
+                              (and (|> :input:
+                                       /.tuple
+                                       (check.result check.fresh_context)
+                                       (try#each (|>> product.right (type#= :expected:)))
+                                       (try.else false))
+                                   (|> (do check.monad
+                                         [[@var :var:] check.var
+                                          _ (check.check :var: :input:)]
+                                         (/.tuple :var:))
+                                       (check.result check.fresh_context)
+                                       (try#each (|>> product.right (type#= :expected:)))
+                                       (try.else false)))))]
+             (and (tuple? input/0
+                          (type.anonymous input/0))
+                  (tuple? (Tuple input/0 input/1 input/2)
+                          (Tuple input/0 input/1 input/2))
+                  (tuple? {.#Named name/0 (Tuple input/0 input/1 input/2)}
+                          (Tuple input/0 input/1 input/2))
+                  (tuple? (All (_ a b c) (Tuple input/0 input/1 input/2))
+                          (Tuple (All (_ a b c) input/0)
+                                 (All (_ a b c) input/1)
+                                 (All (_ a b c) input/2)))
+                  (tuple? (type_literal ((All (_ a b c) (Tuple a b c)) input/0 input/1 input/2))
+                          (Tuple input/0 input/1 input/2))
+                  (|> (do check.monad
+                        [[@var :var:] check.var
+                         _ (check.bind (All (_ a b c) (Tuple a b c)) @var)]
+                        (/.tuple (type_literal (:var: input/0 input/1 input/2))))
+                      (check.result check.fresh_context)
+                      (try#each (|>> product.right (type#= (Tuple input/0 input/1 input/2))))
+                      (try.else false))
+                  (|> (do check.monad
+                        [[@0 :0:] check.existential
+                         [@1 :1:] check.existential
+                         [_ :tuple:] (/.tuple (Ex (_ a b c) (Tuple a input/1 c)))
+                         context check.context
+                         _ (check.with context)
+                         _ (check.check (Tuple :0: input/1 :1:) :tuple:)
+                         _ (check.with context)
+                         _ (check.check :tuple: (Tuple :0: input/1 :1:))]
+                        (in true))
+                      (check.result check.fresh_context)
+                      (try.else false)))))
+         (_.coverage [/.non_tuple]
+           (and (|> (do check.monad
+                      [[@var :var:] check.var
+                       _ (/.tuple :var:)]
+                      (in false))
+                    (check.result check.fresh_context)
+                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
+                (|> (do check.monad
+                      [[@var :var:] check.var
+                       _ (/.tuple (type_literal (:var: input/0 input/1 input/2)))]
+                      (in false))
+                    (check.result check.fresh_context)
+                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
+                (|> (do check.monad
+                      [_ (/.tuple (type_literal (input/0 input/1 input/2)))]
+                      (in false))
+                    (check.result check.fresh_context)
+                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
+                (|> (do check.monad
+                      [[@var :var:] check.var
+                       _ (check.bind input/0 @var)
+                       _ (/.tuple (type_literal (:var: input/1 input/2)))]
+                      (in false))
+                    (check.result check.fresh_context)
+                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))))
+         )))
+
+(def (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
+  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
+  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+               //extension.#state lux]
+        case? (is (-> Code (List [Code Code]) Bit)
+                  (function (_ input branches)
+                    (|> (do //phase.monad
+                          [analysis (|> (/.case ..analysis branches archive.empty input)
+                                        (//type.expecting output/0))]
+                          (in true))
+                        //scope.with
+                        (//module.with 0 module/0)
+                        (//phase#each (|>> product.right product.right))
+                        (//phase.result state)
+                        (try.else false))))
+
+        body_types_mismatch!
+        (and (not (case? (code.bit bit/0) (list [(` #0) body/1]
+                                                [(` #1) body/1])))
+             (not (case? (code.bit bit/0) (list [(` #0) body/0]
+                                                [(` #1) body/1]))))
+
+        input_types_mismatch!
+        (and (not (case? (code.nat nat/0) (list [(` #0) body/0]
+                                                [(` #1) body/0])))
+             (not (case? (code.bit bit/0) (list [(code.nat nat/0) body/0]
+                                                [$binding/0 body/0]))))
+
+        handles_singletons!
+        (and (case? simple/0 (list [(` [(, $binding/0)]) body/0]))
+             (case? simple/0 (list [(` [(, simple/0)]) body/0]
+                                   [(` [(, $binding/0)]) body/0]))
+             (case? (code.bit bit/0) (list [(` [#0]) body/0]
+                                           [(` [#1]) body/0])))
+
+        can_infer_body!
+        (|> (do //phase.monad
+              [[:actual: analysis] (|> (code.bit bit/0)
+                                       (/.case ..analysis
+                                         (list [(` #0) body/0]
+                                               [(` #1) body/0])
+                                         archive.empty)
+                                       //type.inferring)]
+              (in (type#= output/0 :actual:)))
+            //scope.with
+            (//module.with 0 module/0)
+            (//phase#each (|>> product.right product.right))
+            (//phase.result state)
+            (try.else false))
+
+        ensures_consistent_bodies!
+        (|> (do //phase.monad
+              [[:actual: analysis] (|> (code.bit bit/0)
+                                       (/.case ..analysis
+                                         (list [(` #0) body/0]
+                                               [(` #1) body/1])
+                                         archive.empty)
+                                       //type.inferring)]
+              (in false))
+            //scope.with
+            (//module.with 0 module/0)
+            (//phase#each (|>> product.right product.right))
+            (//phase.result state)
+            (try.else true))]
+    (and body_types_mismatch!
+         input_types_mismatch!
+         handles_singletons!
+         can_infer_body!
+         ensures_consistent_bodies!
+
+         (case? (` [])
+                (list [(` []) body/0]))
+         (case? (` [])
+                (list [$binding/0 body/0]))
+
+         (case? (code.bit bit/0) (list [(` #0) body/0]
+                                       [(` #1) body/0]))
+         (case? (code.bit bit/0) (list [(` #1) body/0]
+                                       [(` #0) body/0]))
+
+         (case? simple/0 (list [$binding/0 body/0]))
+         (case? simple/0 (list [simple/0 body/0]
+                               [$binding/0 body/0]))
+         
+         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
+                (list [$binding/0 body/0]))
+         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
+                (list [(` [(, $binding/0) (, $binding/1)]) body/0]))
+         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
+                (list [(` [(, simple/0) (, simple/1) (, simple/2)]) body/0]
+                      ... 000
+                      [(` [(, $binding/0) (, simple/1) (, simple/2)]) body/0]
+                      ... 001
+                      [(` [(, simple/0) (, $binding/1) (, simple/2)]) body/0]
+                      ... 010
+                      [(` [(, $binding/0) (, $binding/1) (, simple/2)]) body/0]
+                      ... 011
+                      [(` [(, simple/0) (, simple/1) (, $binding/2)]) body/0]
+                      ... 100
+                      [(` [(, $binding/0) (, simple/1) (, $binding/2)]) body/0]
+                      ... 101
+                      [(` [(, simple/0) (, $binding/1) (, $binding/2)]) body/0]
+                      ... 110
+                      [(` [(, $binding/0) (, $binding/1) (, $binding/2)]) body/0]
+                      ... 111
+                      )))))
+
+(def (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] bit/0)
+  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] Bit Bit)
+  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+               //extension.#state lux]
+        redundant? (is (-> Code (List [Code Code]) Bit)
+                       (function (_ input branches)
+                         (|> (do //phase.monad
+                               [analysis (|> (/.case ..analysis branches archive.empty input)
+                                             (//type.expecting output/0))]
+                               (in true))
+                             //scope.with
+                             (//module.with 0 module/0)
+                             (//phase#each (|>> product.right product.right))
+                             (//phase.result state)
+                             (exception.otherwise (text.contains? (the exception.#label //coverage.redundancy))))))]
+    (and (redundant? (` [])
+                     (list [(` []) body/0]
+                           [(` []) body/0]))
+         (redundant? (` [])
+                     (list [$binding/0 body/0]
+                           [$binding/0 body/0]))
+         (redundant? (code.bit bit/0) (list [(` #0) body/0]
+                                            [(` #1) body/0]
+                                            [(` #0) body/0]))
+         (redundant? (code.bit bit/0) (list [(` #0) body/0]
+                                            [(` #1) body/0]
+                                            [(` #1) body/0]))
+         (redundant? (code.bit bit/0) (list [(` #0) body/0]
+                                            [(` #1) body/0]
+                                            [$binding/0 body/0]))
+         (redundant? simple/0 (list [$binding/0 body/0]
+                                    [$binding/0 body/0]))
+         (redundant? simple/0 (list [simple/0 body/0]
+                                    [$binding/0 body/0]
+                                    [$binding/0 body/0]))
+         (redundant? simple/0 (list [$binding/0 body/0]
+                                    [simple/0 body/0]))
+         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
+                     (list [$binding/0 body/0]
+                           [$binding/0 body/0]))
+         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
+                     (list [(` [(, $binding/0) (, $binding/1)]) body/0]
+                           [(` [(, $binding/0) (, $binding/1)]) body/0]))
+         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
+                     (list [(` [(, $binding/0) (, $binding/1)]) body/0]
+                           [$binding/0 body/0]))
+         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
+                     (list [$binding/0 body/0]
+                           [(` [(, $binding/0) (, $binding/1)]) body/0])))))
+
+(def (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
+  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
+  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+               //extension.#state lux]
+        
+        tag/0 (%.code $binding/0)
+        tag/1 (%.code $binding/1)
+        tag/2 (%.code $binding/2)
+
+        tags/* (list tag/0 tag/1 tag/2)
+        :variant: {.#Named [module/0 name/0] (type.variant (list input/0 input/1 input/2))}
+
+        tag/0 (code.symbol [module/0 tag/0])
+        tag/1 (code.symbol [module/0 tag/1])
+        tag/2 (code.symbol [module/0 tag/2])
+        
+        variant? (is (-> Code (List [Code Code]) Bit)
+                     (function (_ input branches)
+                       (|> (do //phase.monad
+                             [_ (//module.declare_labels false tags/* false :variant:)
+                              analysis (|> (/.case ..analysis branches archive.empty input)
+                                           (//type.expecting output/0))]
+                             (in true))
+                           //scope.with
+                           (//module.with 0 module/0)
+                           (//phase#each (|>> product.right product.right))
+                           (//phase.result state)
+                           (try.else false))))
+
+        can_bind!
+        (and (variant? (` {(, tag/0) (, simple/0)})
+                       (list [$binding/0 body/0]))
+             (variant? (` {(, tag/1) (, simple/1)})
+                       (list [$binding/0 body/0]))
+             (variant? (` {(, tag/2) (, simple/2)})
+                       (list [$binding/0 body/0])))
+
+        can_bind_variant!
+        (variant? (` {(, tag/0) (, simple/0)})
+                  (list [(` {(, tag/0) (, $binding/0)}) body/0]
+                        [(` {(, tag/1) (, $binding/1)}) body/0]
+                        [(` {(, tag/2) (, $binding/2)}) body/0]))
+
+        can_bind_sum!
+        (variant? (` {(, tag/0) (, simple/0)})
+                  (list [(` {0 #0 (, $binding/0)}) body/0]
+                        [(` {1 #0 (, $binding/1)}) body/0]
+                        [(` {1 #1 (, $binding/2)}) body/0]))
+
+        can_check_exhaustiveness!
+        (variant? (` {(, tag/0) (, simple/0)})
+                  (list [(` {(, tag/0) (, simple/0)}) body/0]
+                        [(` {(, tag/0) (, $binding/0)}) body/0]
+
+                        [(` {(, tag/1) (, simple/1)}) body/0]
+                        [(` {(, tag/1) (, $binding/1)}) body/0]
+
+                        [(` {(, tag/2) (, simple/2)}) body/0]
+                        [(` {(, tag/2) (, $binding/2)}) body/0]))
+
+        can_bind_partial_variant!
+        (variant? (` {(, tag/0) (, simple/0)})
+                  (list [(` {(, tag/0) (, $binding/0)}) body/0]
+                        [(` {0 #1 (, $binding/1)}) body/0]))]
+    (and can_bind!
+         can_bind_variant!
+         can_bind_sum!
+         can_check_exhaustiveness!
+         can_bind_partial_variant!
+         )))
+
+(def (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
+  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
+  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+               //extension.#state lux]
+        
+        slot/0 (%.code $binding/0)
+        slot/1 (%.code $binding/1)
+        slot/2 (%.code $binding/2)
+
+        slots/* (list slot/0 slot/1 slot/2)
+        :record: {.#Named [module/0 name/0] (type.tuple (list input/0 input/1 input/2))}
+
+        slot/0 (code.symbol [module/0 slot/0])
+        slot/1 (code.symbol [module/0 slot/1])
+        slot/2 (code.symbol [module/0 slot/2])
+        
+        record? (is (-> Code (List [Code Code]) Bit)
+                    (function (_ input branches)
+                      (|> (do //phase.monad
+                            [_ (//module.declare_labels true slots/* false :record:)
+                             analysis (|> (/.case ..analysis branches archive.empty input)
+                                          (//type.expecting output/0))]
+                            (in true))
+                          //scope.with
+                          (//module.with 0 module/0)
+                          (//phase#each (|>> product.right product.right))
+                          (//phase.result state)
+                          (try.else false))))
+
+        can_bind!
+        (record? (` [(, slot/0) (, simple/0)
+                     (, slot/1) (, simple/1)
+                     (, slot/2) (, simple/2)])
+                 (list [$binding/0 body/0]))
+
+        can_bind_record!
+        (record? (` [(, slot/0) (, simple/0)
+                     (, slot/1) (, simple/1)
+                     (, slot/2) (, simple/2)])
+                 (list [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, $binding/2)]) body/0]))
+
+        can_bind_tuple!
+        (record? (` [(, slot/0) (, simple/0)
+                     (, slot/1) (, simple/1)
+                     (, slot/2) (, simple/2)])
+                 (list [(` [(, $binding/0) (, $binding/1) (, $binding/2)]) body/0]))
+
+        can_deduce_record!
+        (record? (` [(, simple/0)
+                     (, simple/1)
+                     (, simple/2)])
+                 (list [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, $binding/2)]) body/0]))
+
+        can_check_exhaustiveness!
+        (record? (` [(, slot/0) (, simple/0)
+                     (, slot/1) (, simple/1)
+                     (, slot/2) (, simple/2)])
+                 (list [(` [(, slot/0) (, simple/0)
+                            (, slot/1) (, simple/1)
+                            (, slot/2) (, simple/2)]) body/0]
+                       ... 000
+                       [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, simple/1)
+                            (, slot/2) (, simple/2)]) body/0]
+                       ... 001
+                       [(` [(, slot/0) (, simple/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, simple/2)]) body/0]
+                       ... 010
+                       [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, simple/2)]) body/0]
+                       ... 011
+                       [(` [(, slot/0) (, simple/0)
+                            (, slot/1) (, simple/1)
+                            (, slot/2) (, $binding/2)]) body/0]
+                       ... 100
+                       [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, simple/1)
+                            (, slot/2) (, $binding/2)]) body/0]
+                       ... 101
+                       [(` [(, slot/0) (, simple/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, $binding/2)]) body/0]
+                       ... 110
+                       [(` [(, slot/0) (, $binding/0)
+                            (, slot/1) (, $binding/1)
+                            (, slot/2) (, $binding/2)]) body/0]
+                       ... 111
+                       ))
+
+        cannot_repeat_slot!
+        (not (record? (` [(, slot/0) (, simple/0)
+                          (, slot/1) (, simple/1)
+                          (, slot/2) (, simple/2)])
+                      (list [(` [(, slot/0) (, $binding/0)
+                                 (, slot/1) (, $binding/1)
+                                 (, slot/2) (, $binding/2)
+                                 (, slot/2) (, $binding/2)]) body/0])))
+
+        cannot_omit_slot!
+        (not (record? (` [(, slot/0) (, simple/0)
+                          (, slot/1) (, simple/1)
+                          (, slot/2) (, simple/2)])
+                      (list [(` [(, slot/0) (, $binding/0)
+                                 (, slot/1) (, $binding/1)]) body/0])))
+
+        can_bind_partial_tuple!
+        (record? (` [(, slot/0) (, simple/0)
+                     (, slot/1) (, simple/1)
+                     (, slot/2) (, simple/2)])
+                 (list [(` [(, $binding/0) (, $binding/1)]) body/0]))]
+    (and can_bind!
+         can_bind_record!
+         can_bind_tuple!
+         can_deduce_record!
+         can_check_exhaustiveness!
+         cannot_repeat_slot!
+         cannot_omit_slot!
+         can_bind_partial_tuple!)))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux $//type.random_state
+         .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                      //extension.#state lux]]
+         module/0 (random.lower_case 1)
+         name/0 (random.lower_case 2)
+         [input/0 simple/0] $//inference.simple_parameter
+         [input/1 simple/1] $//inference.simple_parameter
+         [input/2 simple/2] $//inference.simple_parameter
+         [output/0 body/0] $//inference.simple_parameter
+         [output/1 body/1] (random.only (|>> product.left (same? output/0) not)
+                                        $//inference.simple_parameter)
+         $binding/0 (at ! each code.local (random.lower_case 3))
+         $binding/1 (at ! each code.local (random.lower_case 4))
+         $binding/2 (at ! each code.local (random.lower_case 5))
+         extension/0 (at ! each code.text (random.lower_case 6))
+         bit/0 random.bit
+         nat/0 random.nat]
+        (all _.and
+             (_.coverage [/.case]
+               (and (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
+                    (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/1] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [bit/0])
+                    (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
+                    (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])))
+             (_.coverage [/.empty_branches]
+               (|> (do //phase.monad
+                     [analysis (|> (/.case ..analysis (list) archive.empty simple/0)
+                                   (//type.expecting output/0))]
+                     (in false))
+                   //scope.with
+                   (//module.with 0 module/0)
+                   (//phase#each (|>> product.right product.right))
+                   (//phase.result state)
+                   (exception.otherwise (text.contains? (the exception.#label /.empty_branches)))))
+             (_.coverage [/.non_exhaustive]
+               (let [non_exhaustive? (is (-> (List [Code Code]) Bit)
+                                         (function (_ branches)
+                                           (|> (do //phase.monad
+                                                 [analysis (|> (/.case ..analysis branches archive.empty simple/0)
+                                                               (//type.expecting output/0))]
+                                                 (in false))
+                                               //scope.with
+                                               (//module.with 0 module/0)
+                                               (//phase#each (|>> product.right product.right))
+                                               (//phase.result state)
+                                               (exception.otherwise (text.contains? (the exception.#label /.non_exhaustive))))))]
+                 (and (non_exhaustive? (list [simple/0 body/0]))
+                      (not (non_exhaustive? (list [simple/0 body/0]
+                                                  [$binding/0 body/0]))))))
+             (_.coverage [/.invalid]
+               (let [invalid? (is (-> (List [Code Code]) Bit)
+                                  (function (_ branches)
+                                    (|> (do //phase.monad
+                                          [analysis (|> (/.case ..analysis branches archive.empty simple/0)
+                                                        (//type.expecting output/0))]
+                                          (in false))
+                                        //scope.with
+                                        (//module.with 0 module/0)
+                                        (//phase#each (|>> product.right product.right))
+                                        (//phase.result state)
+                                        (exception.otherwise (text.contains? (the exception.#label /.invalid))))))]
+                 (and (invalid? (list [(` ((, extension/0) (, $binding/0) (, $binding/1) (, $binding/2)))
+                                       body/0]))
+                      (invalid? (list [(` {(, extension/0) (, $binding/0) (, $binding/1) (, $binding/2)})
+                                       body/0]))
+                      (invalid? (list [(` {[] (, $binding/0) (, $binding/1) (, $binding/2)})
+                                       body/0])))))
+             (_.coverage [/.sum_has_no_case]
+               (let [tag/0 (%.code $binding/0)
+                     tag/1 (%.code $binding/1)
+                     tag/2 (%.code $binding/2)
+
+                     tags/* (list tag/0 tag/1 tag/2)
+                     :variant: {.#Named [module/0 name/0] (type.variant (list input/0 input/1 input/2))}
+
+                     tag/0 (code.symbol [module/0 tag/0])
+                     tag/1 (code.symbol [module/0 tag/1])
+                     tag/2 (code.symbol [module/0 tag/2])]
+                 (|> (do //phase.monad
+                       [_ (//module.declare_labels false tags/* false :variant:)
+                        analysis (|> (` {(, tag/0) (, simple/0)})
+                                     (/.case ..analysis
+                                       (list [(` {0 #0 (, $binding/0)}) body/0]
+                                             [(` {1 #0 (, $binding/1)}) body/0]
+                                             [(` {2 #0 (, $binding/2)}) body/0]
+                                             [(` {2 #1 (, $binding/2)}) body/0])
+                                       archive.empty)
+                                     (//type.expecting output/0))]
+                       (in false))
+                     //scope.with
+                     (//module.with 0 module/0)
+                     (//phase#each (|>> product.right product.right))
+                     (//phase.result state)
+                     (exception.otherwise (text.contains? (the exception.#label /.sum_has_no_case))))))
+             (_.coverage [/.mismatch]
+               (let [slot/0 (%.code $binding/0)
+                     slot/1 (%.code $binding/1)
+                     slot/2 (%.code $binding/2)
+
+                     slots/* (list slot/0 slot/1 slot/2)
+                     :record: {.#Named [module/0 name/0] (type.tuple (list input/0 input/1 input/2))}
+
+                     slot/0 (code.symbol [module/0 slot/0])
+                     slot/1 (code.symbol [module/0 slot/1])
+                     slot/2 (code.symbol [module/0 slot/2])]
+                 (and (|> (do //phase.monad
+                            [analysis (|> (` (, simple/0))
+                                          (/.case ..analysis
+                                            (list [(` {0 #0 (, $binding/0)}) body/0]
+                                                  [(` {1 #0 (, $binding/1)}) body/0]
+                                                  [(` {1 #1 (, $binding/2)}) body/0])
+                                            archive.empty)
+                                          (//type.expecting output/0))]
+                            (in false))
+                          //scope.with
+                          (//module.with 0 module/0)
+                          (//phase#each (|>> product.right product.right))
+                          (//phase.result state)
+                          (exception.otherwise (text.contains? (the exception.#label /.mismatch))))
+                      (|> (do //phase.monad
+                            [_ (//module.declare_labels true slots/* false :record:)
+                             analysis (|> (` (, simple/0))
+                                          (/.case ..analysis
+                                            (list [(` [(, slot/0) (, $binding/0)
+                                                       (, slot/1) (, $binding/1)
+                                                       (, slot/2) (, $binding/2)]) body/0])
+                                            archive.empty)
+                                          (//type.expecting output/0))]
+                            (in false))
+                          //scope.with
+                          (//module.with 0 module/0)
+                          (//phase#each (|>> product.right product.right))
+                          (//phase.result state)
+                          (exception.otherwise (text.contains? (the exception.#label /.mismatch)))))))
+             
+             ..test|tuple
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/complex.lux
new file mode 100644
index 000000000..46232997f
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/complex.lux
@@ -0,0 +1,659 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" maybe (.use "[1]#[0]" functor)]
+    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
+    ["[0]" exception (.only Exception)]]
+   [data
+    ["[0]" product]
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.only)
+     ["%" \\format (.only format)]]
+    [collection
+     ["[0]" list (.use "[1]#[0]" monad monoid)]
+     ["[0]" set]]]
+   [math
+    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
+    [number
+     ["n" nat]
+     ["f" frac]]]
+   [meta
+    ["[0]" code]
+    ["[0]" macro (.only)
+     ["^" pattern]]
+    ["[0]" symbol (.only)
+     ["$[1]" \\test]]
+    ["[0]" configuration
+     ["$[1]" \\test]]
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["[0]" check]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    [//
+     ["[1][0]" extension (.only)
+      ["[1]/[0]" analysis
+       ["[1]" lux]]]
+     [//
+      ["[1][0]" analysis (.only Analysis)
+       [evaluation (.only Eval)]
+       ["[2][0]" macro]
+       ["[2][0]" type]
+       ["[2][0]" module]
+       ["[2][0]" complex]
+       ["[2][0]" scope]]
+      [///
+       ["[1][0]" phase (.use "[1]#[0]" monad)]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def (eval archive type term)
+  Eval
+  (//phase#in []))
+
+(def (expander macro inputs state)
+  //macro.Expander
+  {try.#Success ((macro.function macro) inputs state)})
+
+(def random_state
+  (Random Lux)
+  (do random.monad
+    [version random.nat
+     host (random.lower_case 1)
+     configuration ($configuration.random 5)]
+    (in (//analysis.state (//analysis.info version host configuration)))))
+
+(def primitive
+  (Random Type)
+  (do random.monad
+    [name (random.lower_case 1)]
+    (in {.#Primitive name (list)})))
+
+(def analysis
+  //analysis.Phase
+  (//.phase ..expander))
+
+(def (failure? exception try)
+  (All (_ e a) (-> (Exception e) (Try a) Bit))
+  (case try
+    {try.#Success _}
+    false
+    
+    {try.#Failure error}
+    (text.contains? (the exception.#label exception) error)))
+
+(def simple_parameter
+  (Random [Type Code])
+  (`` (all random.either
+           (,, (with_template [  ]
+                 [(random#each (|>>  []) )]
+
+                 [.Bit random.bit code.bit]
+                 [.Nat random.nat code.nat]
+                 [.Int random.int code.int]
+                 [.Rev random.rev code.rev]
+                 [.Frac (random.only (|>> f.not_a_number? not) random.frac) code.frac]
+                 [.Text (random.lower_case 1) code.text]
+                 ))
+           )))
+
+(def (analysed? expected actual)
+  (-> Code Analysis Bit)
+  (case [expected actual]
+    [[_ {.#Tuple (list)}] (//analysis.unit)]
+    true
+
+    [[_ {.#Tuple expected}] (//analysis.tuple actual)]
+    (and (n.= (list.size expected)
+              (list.size actual))
+         (list.every? (function (_ [expected actual])
+                        (analysed? expected actual))
+                      (list.zipped_2 expected actual)))
+    
+    (^.with_template [ ]
+      [[[_ { expected}] ( actual)]
+       (same? expected actual)])
+    ([.#Bit //analysis.bit]
+     [.#Nat //analysis.nat]
+     [.#Int //analysis.int]
+     [.#Rev //analysis.rev]
+     [.#Frac //analysis.frac]
+     [.#Text //analysis.text])
+
+    _
+    false))
+
+(def test|sum
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     name ($symbol.random 1 1)
+     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+     types/*,terms/* (random.list arity ..simple_parameter)
+     tag (at ! each (n.% arity) random.nat)
+     .let [[lefts right?] (//complex.choice arity tag)
+           [tagT tagC] (|> types/*,terms/*
+                           (list.item tag)
+                           (maybe.else [Any (' [])]))]]
+    (all _.and
+         (_.coverage [/.sum]
+           (let [variantT (type.variant (list#each product.left types/*,terms/*))
+                 sum? (is (-> Type Nat Bit Code Bit)
+                          (function (_ type lefts right? code)
+                            (|> (do //phase.monad
+                                  [analysis (|> (/.sum ..analysis lefts right? archive.empty code)
+                                                (//type.expecting type))]
+                                  (in (case analysis
+                                        (//analysis.variant [lefts' right?' analysis])
+                                        (and (n.= lefts lefts')
+                                             (bit#= right? right?')
+                                             (..analysed? code analysis))
+
+                                        _
+                                        false)))
+                                (//module.with 0 (product.left name))
+                                (//phase#each product.right)
+                                (//phase.result state)
+                                (try.else false))))]
+             (and (sum? variantT lefts right? tagC)
+                  (sum? {.#Named name variantT} lefts right? tagC)
+                  (|> (do //phase.monad
+                        [[@var varT] (//type.check check.var)
+                         _ (//type.check (check.check varT variantT))
+                         analysis (|> (/.sum ..analysis lefts right? archive.empty tagC)
+                                      (//type.expecting varT))]
+                        (in (case analysis
+                              (//analysis.variant [lefts' right?' it])
+                              (and (n.= lefts lefts')
+                                   (bit#= right? right?')
+                                   (..analysed? tagC it))
+
+                              _
+                              false)))
+                      (//module.with 0 (product.left name))
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false))
+                  (and (sum? (type_literal (Maybe tagT)) 0 #0 (` []))
+                       (sum? (type_literal (Maybe tagT)) 0 #1 tagC))
+                  (and (sum? (type_literal (All (_ a) (Maybe a))) 0 #0 (` []))
+                       (not (sum? (type_literal (All (_ a) (Maybe a))) 0 #1 tagC)))
+                  (and (sum? (type_literal (Ex (_ a) (Maybe a))) 0 #0 (` []))
+                       (sum? (type_literal (Ex (_ a) (Maybe a))) 0 #1 tagC)))))
+         (_.for [/.cannot_analyse_variant]
+                (let [failure? (is (All (_ a) (-> (Exception a) (//analysis.Operation Any) Bit))
+                                   (function (_ exception analysis)
+                                     (let [it (//phase.result state analysis)]
+                                       (and (..failure? /.cannot_analyse_variant it)
+                                            (..failure? exception it)))))]
+                  (all _.and
+                       (_.coverage [/.invalid_variant_type]
+                         (and (|> (/.sum ..analysis lefts right? archive.empty tagC)
+                                  (//type.expecting tagT)
+                                  (failure? /.invalid_variant_type))
+                              (|> (do //phase.monad
+                                    [[@var varT] (//type.check check.var)]
+                                    (|> (/.sum ..analysis lefts right? archive.empty tagC)
+                                        (//type.expecting (type_literal (varT tagT)))))
+                                  (failure? /.invalid_variant_type))))
+                       (_.coverage [/.cannot_infer_sum]
+                         (|> (do //phase.monad
+                               [[@var varT] (//type.check check.var)]
+                               (|> (/.sum ..analysis lefts right? archive.empty tagC)
+                                   (//type.expecting varT)))
+                             (failure? /.cannot_infer_sum)))
+                       )))
+         )))
+
+(def test|variant
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     name ($symbol.random 1 1)
+     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+     types/*,terms/* (random.list arity ..simple_parameter)
+     tag (at ! each (n.% arity) random.nat)
+     .let [[lefts right?] (//complex.choice arity tag)]
+     tags (|> (random.lower_case 1)
+              (random.set text.hash arity)
+              (at ! each set.list))
+     .let [module (product.left name)
+           sumT (type.variant (list#each product.left types/*,terms/*))
+           variantT {.#Named name sumT}
+           [tagT tagC] (|> types/*,terms/*
+                           (list.item tag)
+                           (maybe.else [Any (' [])]))
+           tag (|> tags
+                   (list.item tag)
+                   (maybe.else ""))]]
+    (all _.and
+         (_.coverage [/.variant]
+           (let [expected_variant? (is (-> Symbol Bit)
+                                       (function (_ tag)
+                                         (|> (do //phase.monad
+                                               [_ (//module.declare_labels false tags false variantT)
+                                                analysis (|> (/.variant ..analysis tag archive.empty tagC)
+                                                             (//type.expecting variantT))]
+                                               (in (case analysis
+                                                     (//analysis.variant [lefts' right?' analysis])
+                                                     (and (n.= lefts lefts')
+                                                          (bit#= right? right?')
+                                                          (..analysed? tagC analysis))
+
+                                                     _
+                                                     false)))
+                                             (//module.with 0 module)
+                                             (//phase#each product.right)
+                                             (//phase.result state)
+                                             (try.else false))))
+                 inferred_variant? (is (-> Symbol Bit)
+                                       (function (_ tag)
+                                         (|> (do //phase.monad
+                                               [_ (//module.declare_labels false tags false variantT)
+                                                [actualT analysis] (|> (/.variant ..analysis tag archive.empty tagC)
+                                                                       //type.inferring)]
+                                               (in (case analysis
+                                                     (//analysis.variant [lefts' right?' analysis])
+                                                     (and (n.= lefts lefts')
+                                                          (bit#= right? right?')
+                                                          (..analysed? tagC analysis)
+                                                          (type#= variantT actualT))
+
+                                                     _
+                                                     false)))
+                                             (//module.with 0 module)
+                                             (//phase#each product.right)
+                                             (//phase.result state)
+                                             (try.else false))))]
+             (and (expected_variant? [module tag])
+                  (expected_variant? ["" tag])
+                  (inferred_variant? [module tag])
+                  (inferred_variant? ["" tag])
+
+                  ... TODO: Test what happens when tags are shadowed by local bindings.
+                  )))
+         )))
+
+(type (Triple a)
+  [a a a])
+
+(def test|product
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     name ($symbol.random 1 1)
+     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+     types/*,terms/* (random.list arity ..simple_parameter)
+     [type/0 term/0] ..simple_parameter
+     [type/1 term/1] ..simple_parameter
+     [type/2 term/2] ..simple_parameter
+     .let [module (product.left name)
+           productT (type.tuple (list#each product.left types/*,terms/*))
+           expected (list#each product.right types/*,terms/*)]]
+    (all _.and
+         (_.coverage [/.product]
+           (let [product? (is (-> Type (List Code) Bit)
+                              (function (_ type expected)
+                                (|> (do //phase.monad
+                                      [analysis (|> expected
+                                                    (/.product ..analysis archive.empty)
+                                                    (//type.expecting type))]
+                                      (in (case analysis
+                                            (//analysis.tuple actual)
+                                            (and (n.= (list.size expected)
+                                                      (list.size actual))
+                                                 (list.every? (function (_ [expected actual])
+                                                                (..analysed? expected actual))
+                                                              (list.zipped_2 expected actual)))
+
+                                            _
+                                            false)))
+                                    (//module.with 0 module)
+                                    (//phase#each product.right)
+                                    (//phase.result state)
+                                    (try.else false))))]
+             (and (product? productT expected)
+                  (product? {.#Named name productT} expected)
+                  (product? (type_literal (Ex (_ a) [a a])) (list term/0 term/0))
+                  (not (product? (type_literal (All (_ a) [a a])) (list term/0 term/0)))
+                  (product? (type_literal (Triple type/0)) (list term/0 term/0 term/0))
+                  (|> (do //phase.monad
+                        [[@var varT] (//type.check check.var)
+                         _ (//type.check (check.check varT productT))
+                         analysis (|> expected
+                                      (/.product ..analysis archive.empty)
+                                      (//type.expecting varT))]
+                        (in (case analysis
+                              (//analysis.tuple actual)
+                              (and (n.= (list.size expected)
+                                        (list.size actual))
+                                   (list.every? (function (_ [expected actual])
+                                                  (..analysed? expected actual))
+                                                (list.zipped_2 expected actual)))
+
+                              _
+                              false)))
+                      (//module.with 0 module)
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false))
+                  (|> (do //phase.monad
+                        [[:inferred: analysis] (|> expected
+                                                   (/.product ..analysis archive.empty)
+                                                   //type.inferring)]
+                        (in (case analysis
+                              (//analysis.tuple actual)
+                              (and (n.= (list.size expected)
+                                        (list.size actual))
+                                   (list.every? (function (_ [expected actual])
+                                                  (..analysed? expected actual))
+                                                (list.zipped_2 expected actual))
+                                   (type#= productT :inferred:))
+
+                              _
+                              false)))
+                      (//module.with 0 module)
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false))
+                  (|> (do [! //phase.monad]
+                        [[@var varT] (//type.check check.var)
+                         [:inferred: analysis] (//type.inferring
+                                                (do !
+                                                  [_ (//type.inference (Tuple type/0 type/1 varT))]
+                                                  (/.product ..analysis archive.empty
+                                                             (list term/0 term/1 term/2 term/2 term/2))))
+                         :inferred: (//type.check (check.clean (list @var) :inferred:))]
+                        (in (case analysis
+                              (//analysis.tuple (list analysis/0 analysis/1 (//analysis.tuple (list analysis/2 analysis/3 analysis/4))))
+                              (and (type#= (Tuple type/0 type/1 type/2 type/2 type/2)
+                                           :inferred:)
+                                   (..analysed? term/0 analysis/0)
+                                   (..analysed? term/1 analysis/1)
+                                   (..analysed? term/2 analysis/2)
+                                   (..analysed? term/2 analysis/3)
+                                   (..analysed? term/2 analysis/4))
+
+                              _
+                              false)))
+                      (//module.with 0 module)
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false))
+                  (|> (do [! //phase.monad]
+                        [analysis (|> (list term/0 term/1 (code.tuple (list term/2 term/2 term/2)))
+                                      (/.product ..analysis archive.empty)
+                                      (//type.expecting (Tuple type/0 type/1 type/2 type/2 type/2)))]
+                        (in (case analysis
+                              (//analysis.tuple (list analysis/0 analysis/1 (//analysis.tuple (list analysis/2 analysis/3 analysis/4))))
+                              (and (..analysed? term/0 analysis/0)
+                                   (..analysed? term/1 analysis/1)
+                                   (..analysed? term/2 analysis/2)
+                                   (..analysed? term/2 analysis/3)
+                                   (..analysed? term/2 analysis/4))
+
+                              _
+                              false)))
+                      (//module.with 0 module)
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false)))))
+         (_.for [/.cannot_analyse_tuple]
+                (_.coverage [/.invalid_tuple_type]
+                  (let [failure? (is (All (_ a) (-> (Exception a) (//analysis.Operation Any) Bit))
+                                     (function (_ exception operation)
+                                       (let [it (//phase.result state operation)]
+                                         (and (..failure? /.cannot_analyse_tuple it)
+                                              (..failure? exception it)))))]
+                    (and (|> expected
+                             (/.product ..analysis archive.empty)
+                             (//type.expecting (|> types/*,terms/*
+                                                   list.head
+                                                   (maybe#each product.left)
+                                                   (maybe.else .Any)))
+                             (failure? /.invalid_tuple_type))
+                         (|> (do //phase.monad
+                               [[@var varT] (//type.check check.var)]
+                               (|> expected
+                                   (/.product ..analysis archive.empty)
+                                   (//type.expecting (type_literal (varT type/0)))))
+                             (failure? /.invalid_tuple_type))))))
+         )))
+
+(def test|record
+  (do [! random.monad]
+    [lux ..random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     name ($symbol.random 1 1)
+     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+     slice (at ! each (|>> (n.% (-- arity)) ++) random.nat)
+     [type/0 term/0] ..simple_parameter
+     slot/0 (random.lower_case 1)
+     types/*,terms/* (random.list arity ..simple_parameter)
+     slots/0 (|> (random.lower_case 1)
+                 (random.set text.hash arity))
+     slots/1 (|> (random.lower_case 1)
+                 (random.only (|>> (set.member? slots/0) not))
+                 (random.set text.hash arity))
+     .let [slots/0 (set.list slots/0)
+           slots/1 (set.list slots/1)
+           module (product.left name)
+           :record: {.#Named name (type.tuple (list#each product.left types/*,terms/*))}
+           tuple (list#each product.right types/*,terms/*)
+           local_record (|> tuple
+                            (list.zipped_2 (list#each (|>> [""] code.symbol) slots/0))
+                            (list#each (function (_ [slot value])
+                                         (list slot value)))
+                            list#conjoint)
+           global_record (|> tuple
+                             (list.zipped_2 (list#each (|>> [module] code.symbol) slots/0))
+                             (list#each (function (_ [slot value])
+                                          (list slot value)))
+                             list#conjoint)
+           expected_record (list.zipped_2 (list#each (|>> [module]) slots/0)
+                                          tuple)
+           head_slot/0 (|> slots/0 list.head maybe.trusted)
+           head_term/0 (|> types/*,terms/* list.head maybe.trusted product.right)
+           head_slot/1 (|> slots/1 list.head maybe.trusted)
+           slots/01 (case slots/1
+                      {.#Item _ tail}
+                      {.#Item head_slot/0 tail}
+
+                      _
+                      slots/0)]]
+    (all _.and
+         (_.coverage [/.normal]
+           (let [normal? (is (-> (List [Symbol Code]) (List Code) Bit)
+                             (function (_ expected input)
+                               (|> (do //phase.monad
+                                     [_ (//module.declare_labels true slots/0 false :record:)]
+                                     (/.normal false input))
+                                   (//module.with 0 module)
+                                   (//phase#each product.right)
+                                   (//phase.result state)
+                                   (pipe.case
+                                     {try.#Success {.#Some actual}}
+                                     (let [(open "list#[0]") (list.equivalence (product.equivalence symbol.equivalence code.equivalence))]
+                                       (list#= expected (list.reversed actual)))
+                                     
+                                     _
+                                     false))))]
+             (and (normal? (list) (list))
+                  (normal? expected_record global_record)
+                  (normal? expected_record local_record)
+                  (|> (/.normal false tuple)
+                      (//phase.result state)
+                      (pipe.case
+                        {try.#Success {.#None}}
+                        true
+                        
+                        _
+                        false)))))
+         (_.coverage [/.order]
+           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/0) tuple)
+                 global_record (list.zipped_2 (list#each (|>> [module]) slots/0) tuple)
+                 ordered? (is (-> Bit (List [Symbol Code]) Bit)
+                              (function (_ pattern_matching? input)
+                                (|> (do //phase.monad
+                                      [_ (//module.declare_labels true slots/0 false :record:)]
+                                      (/.order pattern_matching? input))
+                                    //scope.with
+                                    (//module.with 0 module)
+                                    (//phase#each (|>> product.right product.right))
+                                    (//phase.result state)
+                                    (pipe.case
+                                      {try.#Success {.#Some [actual_arity actual_tuple actual_type]}}
+                                      (and (n.= arity actual_arity)
+                                           (at code.equivalence = (code.tuple tuple) (code.tuple actual_tuple))
+                                           (type#= :record: actual_type))
+
+                                      _
+                                      false))))
+                 unit? (is (-> Bit Bit)
+                           (function (_ pattern_matching?)
+                             (|> (/.order false (list))
+                                 (//phase.result state)
+                                 (pipe.case
+                                   {try.#Success {.#Some [0 (list) actual_type]}}
+                                   (same? .Any actual_type)
+
+                                   _
+                                   false))))]
+             (and (ordered? false global_record)
+                  (ordered? false (list.reversed global_record))
+                  (ordered? false local_record)
+                  (ordered? false (list.reversed local_record))
+
+                  (ordered? true global_record)
+                  (ordered? true (list.reversed global_record))
+                  (not (ordered? true local_record))
+                  (not (ordered? true (list.reversed local_record)))
+
+                  (unit? false)
+                  (unit? true)
+
+                  ... TODO: Test what happens when slots are shadowed by local bindings.
+                  )))
+         (_.coverage [/.cannot_repeat_slot]
+           (let [repeated? (is (-> Bit Bit)
+                               (function (_ pattern_matching?)
+                                 (|> (do //phase.monad
+                                       [_ (//module.declare_labels true slots/0 false :record:)]
+                                       (/.order pattern_matching? (list.repeated arity [[module head_slot/0] head_term/0])))
+                                     (//module.with 0 module)
+                                     (//phase#each product.right)
+                                     (//phase.result state)
+                                     (..failure? /.cannot_repeat_slot))))]
+             (and (repeated? false)
+                  (repeated? true))))
+         (_.coverage [/.record_size_mismatch]
+           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/0) tuple)
+                 global_record (list.zipped_2 (list#each (|>> [module]) slots/0) tuple)
+                 mismatched? (is (-> Bit (List [Symbol Code]) Bit)
+                                 (function (_ pattern_matching? input)
+                                   (|> (do //phase.monad
+                                         [_ (//module.declare_labels true slots/0 false :record:)]
+                                         (/.order pattern_matching? input))
+                                       //scope.with
+                                       (//module.with 0 module)
+                                       (//phase.result state)
+                                       (..failure? /.record_size_mismatch))))]
+             (and (mismatched? false (list.first slice local_record))
+                  (mismatched? false (list#composite local_record (list.first slice local_record)))
+
+                  (mismatched? false (list.first slice global_record))
+                  (mismatched? true (list.first slice global_record))
+                  (mismatched? false (list#composite global_record (list.first slice global_record)))
+                  (mismatched? true (list#composite global_record (list.first slice global_record))))))
+         (_.coverage [/.slot_does_not_belong_to_record]
+           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/01) tuple)
+                 global_record (list.zipped_2 (list#each (|>> [module]) slots/01) tuple)
+                 mismatched? (is (-> Bit (List [Symbol Code]) Bit)
+                                 (function (_ pattern_matching? input)
+                                   (|> (do //phase.monad
+                                         [_ (//module.declare_labels true slots/0 false :record:)
+                                          _ (//module.declare_labels true slots/1 false :record:)]
+                                         (/.order pattern_matching? input))
+                                       //scope.with
+                                       (//module.with 0 module)
+                                       (//phase.result state)
+                                       (..failure? /.slot_does_not_belong_to_record))))]
+             (and (mismatched? false local_record)
+
+                  (mismatched? false global_record)
+                  (mismatched? true global_record))))
+         (_.coverage [/.record]
+           (let [record? (is (-> Type (List Text) (List Code) Code Bit)
+                             (function (_ type slots tuple expected)
+                               (|> (do //phase.monad
+                                     [_ (//module.declare_labels true slots false type)]
+                                     (/.record ..analysis archive.empty tuple))
+                                   (//type.expecting type)
+                                   //scope.with
+                                   (//module.with 0 module)
+                                   (//phase#each (|>> product.right product.right))
+                                   (//phase.result state)
+                                   (try#each (analysed? expected))
+                                   (try.else false))))
+                 inferred? (is (-> (List Code) Bit)
+                               (function (_ record)
+                                 (|> (do //phase.monad
+                                       [_ (//module.declare_labels true slots/0 false :record:)]
+                                       (//type.inferring
+                                        (/.record ..analysis archive.empty record)))
+                                     //scope.with
+                                     (//module.with 0 module)
+                                     (//phase#each (|>> product.right product.right))
+                                     (//phase.result state)
+                                     (try#each (function (_ [actual_type actual_term])
+                                                 (and (same? :record: actual_type)
+                                                      (analysed? (code.tuple tuple) actual_term))))
+                                     (try.else false))))]
+             (and (record? {.#Named name .Any} (list) (list) (' []))
+                  (record? {.#Named name type/0} (list) (list term/0) term/0)
+                  (record? {.#Named name type/0} (list slot/0) (list term/0) term/0)
+                  (record? :record: slots/0 tuple (code.tuple tuple))
+                  (record? :record: slots/0 local_record (code.tuple tuple))
+                  (record? :record: slots/0 global_record (code.tuple tuple))
+                  (inferred? local_record)
+                  (inferred? global_record))))
+         )))
+
+(def .public test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux ..random_state
+         .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                      //extension.#state lux]]
+         arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+         types/*,terms/* (random.list arity ..simple_parameter)
+         [type/0 term/0] ..simple_parameter
+         [type/1 term/1] ..simple_parameter
+         tag (at ! each (n.% arity) random.nat)
+         .let [[lefts right?] (//complex.choice arity tag)]]
+        (all _.and
+             ..test|sum
+             ..test|variant
+             ..test|product
+             ..test|record
+             (_.coverage [/.not_a_quantified_type]
+               (and (|> (/.sum ..analysis lefts right? archive.empty term/0)
+                        (//type.expecting (type_literal (type/0 type/1)))
+                        (//phase.result state)
+                        (..failure? /.not_a_quantified_type))
+                    (|> types/*,terms/*
+                        (list#each product.right)
+                        (/.product ..analysis archive.empty)
+                        (//type.expecting (type_literal (type/0 type/1)))
+                        (//phase.result state)
+                        (..failure? /.not_a_quantified_type))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux
new file mode 100644
index 000000000..efd22de9a
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux
@@ -0,0 +1,258 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" function]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    ["[0]" text (.only)
+     ["%" \\format]]
+    [collection
+     ["[0]" list]]]
+   [math
+    ["[0]" random]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" code]
+    ["[0]" macro]
+    ["[0]" symbol
+     ["$[1]" \\test]]
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["$[1]" \\test]
+     ["[0]" check]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    [//
+     ["[1][0]" extension (.only)
+      ["[1]/[0]" analysis
+       ["[1]" lux]]]
+     [//
+      ["[1][0]" analysis (.only Analysis)
+       [evaluation (.only Eval)]
+       ["[2][0]" macro]
+       ["[2][0]" module]
+       ["[2][0]" type (.only)
+        ["$[1]" \\test]]
+       ["[2][0]" inference
+        ["$[1]" \\test]]]
+      [///
+       ["[1][0]" phase (.use "[1]#[0]" monad)]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def (eval archive type term)
+  Eval
+  (//phase#in []))
+
+(def (expander macro inputs state)
+  //macro.Expander
+  {try.#Success ((macro.function macro) inputs state)})
+
+(def analysis
+  //analysis.Phase
+  (//.phase ..expander))
+
+(def test|function
+  Test
+  (do [! random.monad]
+    [lux $//type.random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     input/0 ($type.random 0)
+     input/1 ($type.random 0)
+     function/0 (random.lower_case 1)
+     function/1 (random.lower_case 2)
+     argument/0 (random.lower_case 3)
+     argument/1 (random.lower_case 4)
+     module/0 (random.lower_case 5)
+     [output/0 term/0] $//inference.simple_parameter
+     [output/1 term/1] (random.only (|>> product.left (same? output/0) not)
+                                    $//inference.simple_parameter)
+     name/0 ($symbol.random 1 1)
+     .let [$function/0 (code.local function/0)
+           $function/1 (code.local function/1)
+           $argument/0 (code.local argument/0)
+           $argument/1 (code.local argument/1)]]
+    (all _.and
+         (_.coverage [/.function]
+           (let [function?' (is (-> Type Code (-> [(List Analysis) Analysis] Bit) Bit)
+                                (function (_ function_type output_term ?)
+                                  (|> (do //phase.monad
+                                        [analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
+                                                        output_term)
+                                                      (//type.expecting function_type))]
+                                        (in (case analysis
+                                              {//analysis.#Function it}
+                                              (? it)
+
+                                              _
+                                              false)))
+                                      (//module.with 0 module/0)
+                                      (//phase#each product.right)
+                                      (//phase.result state)
+                                      (try.else false))))
+                 function? (is (-> Type Code Bit)
+                               (function (_ function_type output_term)
+                                 (function?' function_type output_term (function.constant true))))
+                 inferring? (is (-> Type Code Bit)
+                                (function (_ :expected: term)
+                                  (|> (do //phase.monad
+                                        [[:actual: analysis] (|> (/.function ..analysis function/0 argument/0 archive.empty
+                                                                   term)
+                                                                 //type.inferring)]
+                                        (in (case analysis
+                                              {//analysis.#Function [actual_env actual_body]}
+                                              (type#= :expected: :actual:)
+
+                                              _
+                                              false)))
+                                      (//module.with 0 module/0)
+                                      (//phase#each product.right)
+                                      (//phase.result state)
+                                      (try.else false))))]
+             (and (function? (-> input/0 output/0) term/0)
+                  (function? (-> input/0 input/0) $argument/0)
+
+                  (function? {.#Named name/0 (-> input/0 output/0)} term/0)
+                  
+                  (function? (All (_ a) (-> a a)) $argument/0)
+                  (function? (Ex (_ a) (-> a a)) $argument/0)
+                  (function? (Ex (_ a) (-> input/0 a)) term/0)
+                  (function? (Ex (_ a) (-> a a)) term/0)
+                  (function? (Rec self (-> input/0 self)) $function/0)
+
+                  (function? (type_literal ((All (_ a) (-> a a)) output/0)) term/0)
+                  (not (function? (type_literal ((All (_ a) (-> a a)) output/1)) term/0))
+
+                  (function? (type_literal ((Ex (_ a) (-> a a)) output/0)) term/0)
+                  (not (function? (type_literal ((Ex (_ a) (-> a a)) output/1)) term/0))
+
+                  (function?' (-> input/0 input/1 input/0) (` ([(, $function/1) (, $argument/1)] (, $argument/0)))
+                              (function (_ [outer body])
+                                (and (list.empty? outer)
+                                     (case body
+                                       {//analysis.#Function [inner body]}
+                                       (n.= 1 (list.size inner))
+
+                                       _
+                                       false))))
+                  (function?' (-> input/0 input/1 input/1) (` ([(, $function/1) (, $argument/1)] (, $argument/1)))
+                              (function (_ [outer body])
+                                (and (list.empty? outer)
+                                     (case body
+                                       {//analysis.#Function [inner body]}
+                                       (n.= 0 (list.size inner))
+
+                                       _
+                                       false))))
+
+                  (|> (do //phase.monad
+                        [[@var :var:] (//type.check check.var)
+                         _ (//type.check (check.check :var: (-> input/0 output/0)))
+                         analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
+                                        term/0)
+                                      (//type.expecting :var:))]
+                        (in (case analysis
+                              {//analysis.#Function [actual_env actual_body]}
+                              true
+
+                              _
+                              false)))
+                      (//module.with 0 module/0)
+                      (//phase#each product.right)
+                      (//phase.result state)
+                      (try.else false))
+                  
+                  (inferring? (All (_ a) (-> a output/0)) term/0)
+                  (inferring? (All (_ a) (-> a a)) $argument/0)
+                  (inferring? (All (_ @0) (-> @0 @0 (And .Bit @0)))
+                              (` ([(, $function/1) (, $argument/1)]
+                                  [("lux is" (, $argument/0) (, $argument/1))
+                                   (, $argument/1)]))))))
+         (_.coverage [/.cannot_analyse]
+           (|> (do //phase.monad
+                 [analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
+                                 term/1)
+                               (//type.expecting (-> input/0 output/0)))]
+                 (in (case analysis
+                       {//analysis.#Function [actual_env actual_body]}
+                       true
+
+                       _
+                       false)))
+               (//module.with 0 module/0)
+               (//phase#each product.right)
+               (//phase.result state)
+               (exception.otherwise (text.contains? (the exception.#label /.cannot_analyse)))))
+         )))
+
+(def test|apply
+  Test
+  (do [! random.monad]
+    [lux $//type.random_state
+     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
+                  //extension.#state lux]]
+     [input/0 term/0] $//inference.simple_parameter
+     [input/1 term/1] (random.only (|>> product.left (same? input/0) not)
+                                   $//inference.simple_parameter)
+     output/0 ($type.random 0)
+     module/0 (random.lower_case 1)]
+    (all _.and
+         (_.coverage [/.apply]
+           (let [reification? (is (-> Type (List Code) Type Bit)
+                                  (function (_ :abstraction: terms :expected:)
+                                    (|> (do //phase.monad
+                                          [[:actual: analysis] (|> (/.apply ..analysis terms
+                                                                            :abstraction:
+                                                                            (//analysis.unit)
+                                                                            archive.empty
+                                                                            (' []))
+                                                                   //type.inferring)]
+                                          (in (and (check.subsumes? :expected: :actual:)
+                                                   (case analysis
+                                                     {//analysis.#Apply _}
+                                                     true
+
+                                                     _
+                                                     false))))
+                                        (//module.with 0 module/0)
+                                        (//phase#each product.right)
+                                        (//phase.result state)
+                                        (try.else false))))]
+             (and (reification? (-> input/0 input/1 output/0) (list term/0 term/1) output/0)
+                  (reification? (-> input/0 input/1 output/0) (list term/0) (-> input/1 output/0))
+                  (reification? (All (_ a) (-> a a)) (list term/0) input/0)
+                  (reification? (All (_ a) (-> a a a)) (list term/0) (-> input/0 input/0))
+                  (reification? (All (_ a) (-> input/0 a)) (list term/0) .Nothing)
+                  (reification? (All (_ a b) (-> a b a)) (list term/0) (All (_ b) (-> b input/0)))
+                  (reification? (Ex (_ a) (-> a input/0)) (list (` ("lux io error" ""))) input/0)
+                  (reification? (Ex (_ a) (-> input/0 a)) (list term/0) .Any))))
+         (_.coverage [/.cannot_apply]
+           (|> (do //phase.monad
+                 [_ (|> (/.apply ..analysis (list term/1 term/0)
+                                 (-> input/0 input/1 output/0)
+                                 (//analysis.unit)
+                                 archive.empty
+                                 (' []))
+                        (//type.expecting output/0))]
+                 (in false))
+               (//module.with 0 module/0)
+               (//phase#each product.right)
+               (//phase.result state)
+               (exception.otherwise (text.contains? (the exception.#label /.cannot_apply)))))
+         )))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           ..test|function
+           ..test|apply
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/reference.lux
new file mode 100644
index 000000000..e88482764
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/reference.lux
@@ -0,0 +1,224 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    ["[0]" text]]
+   [math
+    ["[0]" random]]
+   [meta
+    ["[0]" type (.use "[1]#[0]" equivalence)
+     ["$[1]" \\test]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" //
+    [//
+     ["[1][0]" extension]
+     [//
+      ["[1][0]" analysis (.only)
+       ["[2][0]" scope]
+       ["[2][0]" module]
+       ["[2][0]" type (.only)
+        ["$[1]" \\test]]]
+      [///
+       ["[1][0]" phase (.use "[1]#[0]" monad)]]]]]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [lux $//type.random_state
+         .let [state [//extension.#bundle //extension.empty
+                      //extension.#state lux]]
+         expected_name (random.lower_case 1)
+         expected_type ($type.random 0)
+         expected_module (random.lower_case 2)
+         import (random.lower_case 3)
+         expected_label (random.lower_case 4)
+         record? random.bit]
+        (all _.and
+             (_.coverage [/.reference]
+               (let [can_find_local_variable!
+                     (|> (/.reference ["" expected_name])
+                         (//scope.with_local [expected_name expected_type])
+                         //type.inferring
+                         //scope.with
+                         (//module.with 0 expected_module)
+                         (//phase#each product.right)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.local 0)]
+                                          (type#= expected_type actual_type)
+
+                                          _
+                                          false)))
+                         (try.else false))
+
+                     can_find_foreign_variable!
+                     (|> (/.reference ["" expected_name])
+                         //type.inferring
+                         //scope.with
+                         (//scope.with_local [expected_name expected_type])
+                         //scope.with
+                         (//module.with 0 expected_module)
+                         (//phase#each product.right)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.foreign 0)]
+                                          (type#= expected_type actual_type)
+
+                                          _
+                                          false)))
+                         (try.else false))
+
+                     can_find_local_definition!
+                     (|> (do //phase.monad
+                           [_ (//module.define expected_name {.#Definition [#0 expected_type []]})]
+                           (/.reference ["" expected_name]))
+                         //type.inferring
+                         (//module.with 0 expected_module)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.constant [actual_module actual_name])]
+                                          (and (type#= expected_type actual_type)
+                                               (same? expected_module actual_module)
+                                               (same? expected_name actual_name))
+
+                                          _
+                                          false)))
+                         (try.else false))
+
+                     can_find_foreign_definition!
+                     (|> (do //phase.monad
+                           [_ (//module.with 0 import
+                                (//module.define expected_name {.#Definition [#1 expected_type []]}))
+                            _ (//module.import import)]
+                           (/.reference [import expected_name]))
+                         //type.inferring
+                         (//module.with 0 expected_module)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.constant [actual_module actual_name])]
+                                          (and (type#= expected_type actual_type)
+                                               (same? import actual_module)
+                                               (same? expected_name actual_name))
+
+                                          _
+                                          false)))
+                         (try.else false))
+
+                     can_find_alias!
+                     (|> (do //phase.monad
+                           [_ (//module.with 0 import
+                                (//module.define expected_name {.#Definition [#1 expected_type []]}))
+                            _ (//module.import import)
+                            _ (//module.define expected_name {.#Alias [import expected_name]})]
+                           (/.reference [expected_module expected_name]))
+                         //type.inferring
+                         (//module.with 0 expected_module)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.constant [actual_module actual_name])]
+                                          (and (type#= expected_type actual_type)
+                                               (same? import actual_module)
+                                               (same? expected_name actual_name))
+
+                                          _
+                                          false)))
+                         (try.else false))
+
+                     can_find_type!
+                     (|> (do //phase.monad
+                           [_ (//module.define expected_name {.#Type [#0 expected_type
+                                                                      (if record?
+                                                                        {.#Right [expected_label (list)]}
+                                                                        {.#Left [expected_label (list)]})]})]
+                           (/.reference [expected_module expected_name]))
+                         //type.inferring
+                         (//module.with 0 expected_module)
+                         (//phase.result state)
+                         (try#each (|>> product.right
+                                        (pipe.case
+                                          [actual_type (//analysis.constant [actual_module actual_name])]
+                                          (and (type#= .Type actual_type)
+                                               (same? expected_module actual_module)
+                                               (same? expected_name actual_name))
+
+                                          _
+                                          false)))
+                         (try.else false))]
+                 (and can_find_local_variable!
+                      can_find_foreign_variable!
+                      
+                      can_find_local_definition!
+                      can_find_foreign_definition!
+
+                      can_find_alias!
+                      can_find_type!)))
+             (_.coverage [/.foreign_module_has_not_been_imported]
+               (let [scenario (is (-> Type Global Bit)
+                                  (function (_ expected_type it)
+                                    (|> (do //phase.monad
+                                          [_ (//module.with 0 import
+                                               (//module.define expected_name it))
+                                           _ (/.reference [import expected_name])]
+                                          (in false))
+                                        (//type.expecting expected_type)
+                                        (//module.with 0 expected_module)
+                                        (//phase#each product.right)
+                                        (//phase.result state)
+                                        (exception.otherwise (text.contains? (the exception.#label /.foreign_module_has_not_been_imported)))
+                                        )))]
+                 (and (scenario expected_type {.#Definition [#1 expected_type []]})
+                      (scenario .Type {.#Type [#1 expected_type
+                                               (if record?
+                                                 {.#Right [expected_label (list)]}
+                                                 {.#Left [expected_label (list)]})]}))))
+             (_.coverage [/.definition_has_not_been_exported]
+               (let [scenario (is (-> Type Global Bit)
+                                  (function (_ expected_type it)
+                                    (|> (do //phase.monad
+                                          [_ (//module.with 0 import
+                                               (//module.define expected_name it))
+                                           _ (/.reference [import expected_name])]
+                                          (in false))
+                                        (//type.expecting expected_type)
+                                        (//module.with 0 expected_module)
+                                        (//phase#each product.right)
+                                        (//phase.result state)
+                                        (exception.otherwise (text.contains? (the exception.#label /.definition_has_not_been_exported)))
+                                        )))]
+                 (and (scenario expected_type {.#Definition [#0 expected_type []]})
+                      (scenario .Type {.#Type [#0 expected_type
+                                               (if record?
+                                                 {.#Right [expected_label (list)]}
+                                                 {.#Left [expected_label (list)]})]}))))
+             (_.coverage [/.labels_are_not_definitions]
+               (let [scenario (is (-> Type Global Bit)
+                                  (function (_ expected_type it)
+                                    (|> (do //phase.monad
+                                          [_ (//module.with 0 import
+                                               (//module.define expected_label it))
+                                           _ (/.reference [import expected_label])]
+                                          (in false))
+                                        (//type.expecting expected_type)
+                                        (//module.with 0 expected_module)
+                                        (//phase#each product.right)
+                                        (//phase.result state)
+                                        (exception.otherwise (text.contains? (the exception.#label /.labels_are_not_definitions))))))]
+                 (and (scenario expected_type {.#Tag [#1 expected_type (list) 0]})
+                      (scenario expected_type {.#Slot [#1 expected_type (list) 0]}))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/simple.lux
new file mode 100644
index 000000000..bceb035c6
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/simple.lux
@@ -0,0 +1,111 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try]]
+   [data
+    ["[0]" product]]
+   [math
+    ["[0]" random]]
+   [meta
+    ["[0]" type (.use "[1]#[0]" equivalence)]
+    ["[0]" configuration
+     ["$[1]" \\test]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [///
+    ["[1][0]" extension]
+    [//
+     ["[1][0]" analysis (.only Analysis Operation)
+      ["[2][0]" type]
+      ["[2][0]" module]]
+     [///
+      ["[1][0]" phase (.use "[1]#[0]" functor)]]]]]])
+
+(def (analysis state module type it ?)
+  (-> Lux Text Type (Operation Analysis) (-> Analysis Bit) Bit)
+  (and (|> it
+           (/type.expecting type)
+           (/module.with 0 module)
+           (/phase#each product.right)
+           (/phase.result [/extension.#bundle /extension.empty
+                           /extension.#state state])
+           (pipe.case
+             {try.#Success analysis}
+             (? analysis)
+
+             _
+             false))
+       (|> it
+           (/type.expecting .Nothing)
+           (/module.with 0 module)
+           (/phase#each product.right)
+           (/phase.result [/extension.#bundle /extension.empty
+                           /extension.#state state])
+           (pipe.case
+             {try.#Failure error}
+             true
+
+             _
+             false))
+       (|> it
+           /type.inferring
+           (/module.with 0 module)
+           (/phase#each product.right)
+           (/phase.result [/extension.#bundle /extension.empty
+                           /extension.#state state])
+           (pipe.case
+             {try.#Success [inferred analysis]}
+             (and (type#= type inferred)
+                  (? analysis))
+
+             _
+             false))))
+
+(def analysis?
+  (template (_  )
+    [(is (->  Analysis Bit)
+         (function (_ expected)
+           (|>> (pipe.case
+                  ( actual)
+                  (same? expected actual)
+
+                  _
+                  false))))]))
+
+(def .public test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [version random.nat
+         host (random.lower_case 1)
+         module (random.lower_case 2)
+         configuration ($configuration.random 5)
+         .let [state (/analysis.state (/analysis.info version host configuration))]]
+        (`` (all _.and
+                 (_.coverage [/.unit]
+                   (..analysis state module .Any /.unit
+                     (|>> (pipe.case
+                            (/analysis.unit)
+                            true
+                            
+                            _
+                            false))))
+                 (,, (with_template [   ]
+                       [(do !
+                          [sample ]
+                          (_.coverage []
+                            (..analysis state module  ( sample)
+                              ((..analysis?  ) sample))))]
+
+                       [/.bit .Bit random.bit /analysis.bit]
+                       [/.nat .Nat random.nat /analysis.nat]
+                       [/.int .Int random.int /analysis.int]
+                       [/.rev .Rev random.rev /analysis.rev]
+                       [/.frac .Frac random.frac /analysis.frac]
+                       [/.text .Text (random.unicode 1) /analysis.text]
+                       ))
+                 )))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux
new file mode 100644
index 000000000..08e310f54
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux
@@ -0,0 +1,280 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    ["[0]" monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try]
+    ["[0]" exception]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format (.only format)]]
+    [collection
+     ["[0]" dictionary]
+     ["[0]" list (.use "[1]#[0]" mix)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]
+     ["i" int]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [/////
+    ["[0]" phase]
+    [meta
+     ["[0]" archive]]]]])
+
+(def .public random
+  (Random (/.Extension Nat))
+  (all random.and
+       (random.lower_case 5)
+       (random.list 2 random.nat)
+       ))
+
+(def test|state
+  Test
+  (do [! random.monad]
+    [state random.int
+     dummy (random.only (|>> (i.= state) not)
+                        random.int)]
+    (all _.and
+         (_.coverage [/.read]
+           (|> (is (/.Operation Int Nat Nat Text)
+                   (/.read %.int))
+               (at phase.functor each (text#= (%.int state)))
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (try.else false)))
+         (_.coverage [/.update]
+           (|> (is (/.Operation Int Nat Nat Text)
+                   (do phase.monad
+                     [_ (/.update ++)]
+                     (/.read %.int)))
+               (at phase.functor each (text#= (%.int (++ state))))
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (try.else false)))
+         (_.coverage [/.temporary]
+           (|> (is (/.Operation Int Nat Nat Text)
+                   (do phase.monad
+                     [|state'| (/.temporary ++ (/.read %.int))
+                      |state| (/.read %.int)]
+                     (in (format |state'| " " |state|))))
+               (at phase.functor each (text#= (format (%.int (++ state)) " " (%.int state))))
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (try.else false)))
+         (_.coverage [/.with_state]
+           (|> (is (/.Operation Int Nat Nat Text)
+                   (/.with_state state
+                     (/.read %.int)))
+               (at phase.functor each (text#= (%.int state)))
+               (phase.result [/.#bundle /.empty
+                              /.#state dummy])
+               (try.else false)))
+         (_.coverage [/.localized]
+           (|> (is (/.Operation Int Nat Nat Text)
+                   (do phase.monad
+                     [|state| (/.localized %.int
+                                           (function (_ _ old) (++ old))
+                                           (text.enclosed ["<" ">"])
+                                           (/.read %.int))
+                      |state'| (/.read %.int)]
+                     (in (format |state'| " " |state|))))
+               (at phase.functor each (text#= (format (%.int (i.+ +2 state))
+                                                      " " (%.int (i.+ +1 state)))))
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (try.else false))))
+    ))
+
+(def extender
+  /.Extender
+  (|>> as_expected))
+
+(def handler/0
+  (/.Handler Int Nat Nat)
+  (function (_ @self phase archive inputs)
+    (at phase.monad in (list#mix n.+ 0 inputs))))
+
+(def handler/1
+  (/.Handler Int Nat Nat)
+  (function (_ @self phase archive inputs)
+    (at phase.monad in (list#mix n.* 1 inputs))))
+
+(def test|name
+  Test
+  (do [! random.monad]
+    [state random.int
+     extension (random.lower_case 1)
+     left random.nat
+     right random.nat]
+    (all _.and
+         (_.coverage [/.cannot_overwrite]
+           (|> (do phase.monad
+                 [_ (/.install extender extension handler/0)]
+                 (/.install extender extension handler/1))
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (pipe.case
+                 {try.#Failure error}
+                 (exception.match? /.cannot_overwrite error)
+
+                 _
+                 false)))
+         (_.coverage [/.unknown]
+           (|> (/.apply archive.empty (function (_ archive input)
+                                        (at phase.monad in (++ input)))
+                        [extension (list left right)])
+               (phase.result [/.#bundle /.empty
+                              /.#state state])
+               (pipe.case
+                 {try.#Failure error}
+                 (exception.match? /.unknown error)
+
+                 _
+                 false)))
+         )))
+
+(def test|bundle
+  Test
+  (let [phase (is (/.Phase Int Nat Nat)
+                  (function (_ archive input)
+                    (at phase.monad in (++ input))))]
+    (do [! random.monad]
+      [state random.int
+
+       extension (random.lower_case 1)
+       left random.nat
+       right random.nat]
+      (all _.and
+           (_.coverage [/.empty]
+             (dictionary.empty? /.empty))
+           (<| (_.for [/.Extender /.Handler])
+               (all _.and
+                    (_.coverage [/.install /.apply]
+                      (|> (do phase.monad
+                            [_ (/.install extender extension handler/0)]
+                            (/.apply archive.empty phase [extension (list left right)]))
+                          (at phase.functor each (n.= (n.+ left right)))
+                          (phase.result [/.#bundle /.empty
+                                         /.#state state])
+                          (try.else false)))
+                    (_.coverage [/.Phase]
+                      (let [handler (is (/.Handler Int Nat Nat)
+                                        (function (_ @self phase archive inputs)
+                                          (let [! phase.monad]
+                                            (|> inputs
+                                                (monad.each ! (phase archive))
+                                                (at ! each (list#mix n.+ 0))))))]
+                        (|> (do phase.monad
+                              [_ (/.install extender extension handler)]
+                              (/.apply archive.empty phase [extension (list left right)]))
+                            (at phase.functor each (n.= (n.+ (++ left) (++ right))))
+                            (phase.result [/.#bundle /.empty
+                                           /.#state state])
+                            (try.else false))))
+                    (_.coverage [/.with]
+                      (|> (do phase.monad
+                            [_ (/.with extender (dictionary.of_list text.hash (list [extension handler/1])))]
+                            (/.apply archive.empty (function (_ archive input)
+                                                     (at phase.monad in (++ input)))
+                                     [extension (list left right)]))
+                          (at phase.functor each (n.= (n.* left right)))
+                          (phase.result [/.#bundle /.empty
+                                         /.#state state])
+                          (try.else false)))
+                    (_.coverage [/.incorrect_arity]
+                      (let [handler (is (/.Handler Int Nat Nat)
+                                        (function (_ @self phase archive inputs)
+                                          (phase.except /.incorrect_arity [@self 2 (list.size inputs)])))]
+                        (|> (do phase.monad
+                              [_ (/.install extender extension handler)]
+                              (/.apply archive.empty phase [extension (list)]))
+                            (phase.result [/.#bundle /.empty
+                                           /.#state state])
+                            (pipe.case
+                              {try.#Failure error}
+                              (exception.match? /.incorrect_arity error)
+
+                              _
+                              false))))
+                    (_.coverage [/.invalid_syntax]
+                      (let [handler (is (/.Handler Int Nat Nat)
+                                        (function (_ @self phase archive inputs)
+                                          (phase.except /.invalid_syntax [@self %.nat inputs])))]
+                        (|> (do phase.monad
+                              [_ (/.install extender extension handler)]
+                              (/.apply archive.empty phase [extension (list left right)]))
+                            (phase.result [/.#bundle /.empty
+                                           /.#state state])
+                            (pipe.case
+                              {try.#Failure error}
+                              (exception.match? /.invalid_syntax error)
+
+                              _
+                              false))))
+                    (_.for [/.Name]
+                           ..test|name)
+                    ))
+           ))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Extension])
+      (do [! random.monad]
+        [state random.int
+         dummy (random.only (|>> (i.= state) not)
+                            random.int)
+         expected random.nat
+         expected_error (random.lower_case 1)]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec (/.equivalence n.equivalence) ..random))
+             (_.for [/.hash]
+                    ($hash.spec (/.hash n.hash) ..random))
+             
+             (<| (_.for [/.Operation])
+                 (all _.and
+                      (_.coverage [/.lifted]
+                        (and (|> (is (/.Operation Int Nat Nat Nat)
+                                     (/.lifted (do phase.monad
+                                                 []
+                                                 (in expected))))
+                                 (at phase.functor each (same? expected))
+                                 (phase.result [/.#bundle /.empty
+                                                /.#state state])
+                                 (try.else false))
+                             (|> (is (/.Operation Int Nat Nat Nat)
+                                     (/.lifted (phase.lifted {try.#Failure expected_error})))
+                                 (phase.result [/.#bundle /.empty
+                                                /.#state state])
+                                 (pipe.case
+                                   {try.#Failure actual_error}
+                                   (same? expected_error actual_error)
+
+                                   _
+                                   false))))
+                      (_.coverage [/.up]
+                        (|> (do phase.monad
+                              []
+                              (in expected))
+                            (is (/.Operation Int Nat Nat Nat))
+                            /.up
+                            (is (phase.Operation Int Nat))
+                            (at phase.functor each (same? expected))
+                            (phase.result state)
+                            (try.else false)))
+                      ))
+             (_.for [/.State]
+                    ..test|state)
+             (_.for [/.Bundle]
+                    ..test|bundle)
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
new file mode 100644
index 000000000..4876aa0be
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
@@ -0,0 +1,205 @@
+(.require
+ [lux (.except i64 int primitive)
+  [abstract
+   ["[0]" monad (.only do)]]
+  [data
+   ["%" text/format (.only format)]]
+  ["r" math/random (.only Random)]
+  ["_" test (.only Test)]
+  [control
+   [io (.only IO)]
+   ["[0]" pipe]
+   ["[0]" try]
+   [concurrency
+    ["[0]" atom]]]
+  [data
+   ["[0]" product]]
+  [meta
+   ["[0]" code]
+   ["[0]" symbol]
+   ["[0]" type (.use "[1]#[0]" equivalence)]]]
+ [////
+  [analysis
+   ["_[0]" primitive]]]
+ [\\
+  ["[0]" / (.only)
+   ["///[1]" ////
+    [analysis
+     ["[1][0]" scope]
+     ["[1][0]" type]]
+    [////
+     ["[0]" phase]
+     [meta
+      ["[0]" archive]]]]]])
+
+(with_template [  ]
+  [(def ( procedure params output_type)
+     (-> Text (List Code) Type Bit)
+     (|> (////scope.with_scope ""
+           (////type.with_type output_type
+             (_primitive.phase archive.empty (` ((, (code.text procedure)) (,* params))))))
+         (phase.result _primitive.state)
+         (pipe.case
+           {try.#Success _}
+           
+
+           {try.#Failure _}
+           )))]
+
+  [check_success+ true false]
+  [check_failure+ false true]
+  )
+
+(def primitive
+  (Random [Type Code])
+  (r.only (|>> product.left (same? Any) not) _primitive.primitive))
+
+(def lux
+  Test
+  (do r.monad
+    [[primT primC] ..primitive
+     [antiT antiC] (|> ..primitive
+                       (r.only (|>> product.left (type#= primT) not)))]
+    (all _.and
+         (_.property "Can test for reference equality."
+           (check_success+ "lux is" (list primC primC) Bit))
+         (_.property "Reference equality must be done with elements of the same type."
+           (check_failure+ "lux is" (list primC antiC) Bit))
+         (_.property "Can 'try' risky IO computations."
+           (check_success+ "lux try"
+                           (list (` ("lux io error" "YOLO")))
+                           (type_literal (Either Text primT))))
+         )))
+
+(def i64
+  Test
+  (do [! r.monad]
+    [subjectC (|> r.nat (at ! each code.nat))
+     signedC (|> r.int (at ! each code.int))
+     paramC (|> r.nat (at ! each code.nat))]
+    (all _.and
+         (_.property "i64 'and'."
+           (check_success+ "lux i64 and" (list paramC subjectC) Nat))
+         (_.property "i64 'or'."
+           (check_success+ "lux i64 or" (list paramC subjectC) Nat))
+         (_.property "i64 'xor'."
+           (check_success+ "lux i64 xor" (list paramC subjectC) Nat))
+         (_.property "i64 left-shift."
+           (check_success+ "lux i64 left-shift" (list paramC subjectC) Nat))
+         (_.property "i64 logical-right-shift."
+           (check_success+ "lux i64 logical-right-shift" (list paramC subjectC) Nat))
+         (_.property "i64 arithmetic-right-shift."
+           (check_success+ "lux i64 arithmetic-right-shift" (list paramC signedC) Int))
+         (_.property "i64 equivalence."
+           (check_success+ "lux i64 =" (list paramC subjectC) Bit))
+         (_.property "i64 addition."
+           (check_success+ "lux i64 +" (list paramC subjectC) Int))
+         (_.property "i64 subtraction."
+           (check_success+ "lux i64 -" (list paramC subjectC) Int))
+         )))
+
+(def int
+  Test
+  (do [! r.monad]
+    [subjectC (|> r.int (at ! each code.int))
+     paramC (|> r.int (at ! each code.int))]
+    (all _.and
+         (_.property "Can multiply integers."
+           (check_success+ "lux i64 *" (list paramC subjectC) Int))
+         (_.property "Can divide integers."
+           (check_success+ "lux i64 /" (list paramC subjectC) Int))
+         (_.property "Can calculate remainder of integers."
+           (check_success+ "lux i64 %" (list paramC subjectC) Int))
+         (_.property "Can compare integers."
+           (check_success+ "lux i64 <" (list paramC subjectC) Bit))
+         (_.property "Can convert integer to text."
+           (check_success+ "lux i64 char" (list subjectC) Text))
+         (_.property "Can convert integer to fraction."
+           (check_success+ "lux i64 f64" (list subjectC) Frac))
+         )))
+
+(def frac
+  Test
+  (do [! r.monad]
+    [subjectC (|> r.safe_frac (at ! each code.frac))
+     paramC (|> r.safe_frac (at ! each code.frac))
+     encodedC (|> r.safe_frac (at ! each (|>> %.frac code.text)))]
+    (all _.and
+         (_.property "Can add frac numbers."
+           (check_success+ "lux f64 +" (list paramC subjectC) Frac))
+         (_.property "Can subtract frac numbers."
+           (check_success+ "lux f64 -" (list paramC subjectC) Frac))
+         (_.property "Can multiply frac numbers."
+           (check_success+ "lux f64 *" (list paramC subjectC) Frac))
+         (_.property "Can divide frac numbers."
+           (check_success+ "lux f64 /" (list paramC subjectC) Frac))
+         (_.property "Can calculate remainder of frac numbers."
+           (check_success+ "lux f64 %" (list paramC subjectC) Frac))
+         (_.property "Can test equivalence of frac numbers."
+           (check_success+ "lux f64 =" (list paramC subjectC) Bit))
+         (_.property "Can compare frac numbers."
+           (check_success+ "lux f64 <" (list paramC subjectC) Bit))
+         (_.property "Can obtain minimum frac number."
+           (check_success+ "lux f64 min" (list) Frac))
+         (_.property "Can obtain maximum frac number."
+           (check_success+ "lux f64 max" (list) Frac))
+         (_.property "Can obtain smallest frac number."
+           (check_success+ "lux f64 smallest" (list) Frac))
+         (_.property "Can convert frac number to integer."
+           (check_success+ "lux f64 i64" (list subjectC) Int))
+         (_.property "Can convert frac number to text."
+           (check_success+ "lux f64 encode" (list subjectC) Text))
+         (_.property "Can convert text to frac number."
+           (check_success+ "lux f64 decode" (list encodedC) (type_literal (Maybe Frac))))
+         )))
+
+(def text
+  Test
+  (do [! r.monad]
+    [subjectC (|> (r.unicode 5) (at ! each code.text))
+     paramC (|> (r.unicode 5) (at ! each code.text))
+     replacementC (|> (r.unicode 5) (at ! each code.text))
+     fromC (|> r.nat (at ! each code.nat))
+     toC (|> r.nat (at ! each code.nat))]
+    (all _.and
+         (_.property "Can test text equivalence."
+           (check_success+ "lux text =" (list paramC subjectC) Bit))
+         (_.property "Compare texts in lexicographical order."
+           (check_success+ "lux text <" (list paramC subjectC) Bit))
+         (_.property "Can concatenate one text to another."
+           (check_success+ "lux text concat" (list subjectC paramC) Text))
+         (_.property "Can find the index of a piece of text inside a larger one that (may) contain it."
+           (check_success+ "lux text index" (list fromC paramC subjectC) (type_literal (Maybe Nat))))
+         (_.property "Can query the size/length of a text."
+           (check_success+ "lux text size" (list subjectC) Nat))
+         (_.property "Can obtain the character code of a text at a given index."
+           (check_success+ "lux text char" (list fromC subjectC) Nat))
+         (_.property "Can clip a piece of text between 2 indices."
+           (check_success+ "lux text clip" (list fromC toC subjectC) Text))
+         )))
+
+(def io
+  Test
+  (do [! r.monad]
+    [logC (|> (r.unicode 5) (at ! each code.text))
+     exitC (|> r.int (at ! each code.int))]
+    (all _.and
+         (_.property "Can log messages to standard output."
+           (check_success+ "lux io log" (list logC) Any))
+         (_.property "Can throw a run-time error."
+           (check_success+ "lux io error" (list logC) Nothing))
+         (_.property "Can query the current time (as milliseconds since epoch)."
+           (check_success+ "lux io current-time" (list) Int))
+         )))
+
+(def .public test
+  Test
+  (<| (_.context (symbol.module (symbol /._)))
+      (all _.and
+           ..lux
+           ..i64
+           ..int
+           ..frac
+           ..text
+           ..io
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis.lux
new file mode 100644
index 000000000..e4a2814b4
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis.lux
@@ -0,0 +1,21 @@
+(.require
+ [lux (.except)
+  ["_" test (.only Test)]]
+ ["[0]" /
+  ["[1][0]" primitive]
+  ["[1][0]" structure]
+  ["[1][0]" case]
+  ["[1][0]" function]
+  ["[1][0]" loop]
+  ["[1][0]" variable]])
+
+(def .public test
+  Test
+  (all _.and
+       /primitive.test
+       /structure.test
+       /case.test
+       /function.test
+       /loop.test
+       /variable.test
+       ))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/case.lux
new file mode 100644
index 000000000..7f348e194
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/case.lux
@@ -0,0 +1,358 @@
+(.require
+ [lux (.except)
+  ["_" test (.only Test)]
+  [abstract
+   [hash (.only Hash)]
+   ["[0]" monad (.only do)]]
+  [control
+   ["[0]" pipe]
+   ["[0]" try (.use "[1]#[0]" functor)]]
+  [data
+   ["[0]" sum]
+   ["[0]" text (.only)
+    ["%" \\format (.only format)]]
+   [number
+    ["n" nat]
+    ["[0]" int]
+    ["[0]" rev]
+    ["[0]" frac]]
+   [collection
+    ["[0]" list (.use "[1]#[0]" functor mix monoid)]
+    ["[0]" set]]]
+  [math
+   ["[0]" random (.only Random)]]]
+ ["[0]" //
+  ["[1][0]" primitive]]
+ [\\
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    ["/[1]" //
+     [extension
+      ["[1][0]" bundle]]
+     ["/[1]" // (.only)
+      ["[0]" analysis (.only Branch Match Analysis)]
+      ["[0]" synthesis (.only Path Synthesis)]
+      [///
+       ["[1][0]" reference (.only)
+        [variable (.only Register)]]
+       ["[0]" phase]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def masking_test
+  Test
+  (do [! random.monad]
+    [maskedA //primitive.primitive
+     temp (|> random.nat (at ! each (n.% 100)))
+     .let [maskA (analysis.case
+                   [maskedA
+                    [[{analysis.#Bind temp}
+                      {analysis.#Reference (////reference.local temp)}]
+                     (list)]])]]
+    (_.coverage [/.synthesize_masking]
+      (|> maskA
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty synthesis.init])
+          (try#each (//primitive.corresponds? maskedA))
+          (try.default false)))))
+
+(def let_test
+  Test
+  (do random.monad
+    [registerA random.nat
+     inputA //primitive.primitive
+     outputA //primitive.primitive
+     .let [letA (analysis.case
+                  [inputA
+                   [[{analysis.#Bind registerA}
+                     outputA]
+                    (list)]])]]
+    (_.coverage [/.synthesize_let]
+      (|> letA
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty synthesis.init])
+          (pipe.case
+            {try.#Success (synthesis.branch/let [inputS registerS outputS])}
+            (and (n.= registerA registerS)
+                 (//primitive.corresponds? inputA inputS)
+                 (//primitive.corresponds? outputA outputS))
+
+            _
+            false)))))
+
+(def if_test
+  Test
+  (do random.monad
+    [then|else random.bit
+     inputA //primitive.primitive
+     thenA //primitive.primitive
+     elseA //primitive.primitive
+     .let [thenB (is Branch
+                     [{analysis.#Simple {analysis.#Bit true}}
+                      thenA])
+           elseB (is Branch
+                     [{analysis.#Simple {analysis.#Bit false}}
+                      elseA])
+           ifA (if then|else
+                 (analysis.case [inputA [thenB (list elseB)]])
+                 (analysis.case [inputA [elseB (list thenB)]]))]]
+    (_.coverage [/.synthesize_if]
+      (|> ifA
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty synthesis.init])
+          (pipe.case
+            {try.#Success (synthesis.branch/if [inputS thenS elseS])}
+            (and (//primitive.corresponds? inputA inputS)
+                 (//primitive.corresponds? thenA thenS)
+                 (//primitive.corresponds? elseA elseS))
+
+            _
+            false)))))
+
+(def random_member
+  (Random synthesis.Member)
+  (do [! random.monad]
+    [lefts (|> random.nat (at ! each (n.% 10)))
+     right? random.bit]
+    (in (if right?
+          {.#Right lefts}
+          {.#Left lefts}))))
+
+(def random_path
+  (Random (analysis.Tuple synthesis.Member))
+  (do [! random.monad]
+    [size_1 (|> random.nat (at ! each (|>> (n.% 10) ++)))]
+    (random.list size_1 ..random_member)))
+
+(def (get_pattern path)
+  (-> (analysis.Tuple synthesis.Member)
+      (Random [analysis.Pattern Register]))
+  (do random.monad
+    [@member random.nat]
+    (in [(list#mix (function (_ member inner)
+                     (case member
+                       {.#Left lefts}
+                       (analysis.pattern/tuple
+                        (list#composite (list.repeated lefts (analysis.pattern/unit))
+                                        (list inner (analysis.pattern/unit))))
+                       
+                       {.#Right lefts}
+                       (analysis.pattern/tuple
+                        (list#composite (list.repeated (++ lefts) (analysis.pattern/unit))
+                                        (list inner)))))
+                   {analysis.#Bind @member}
+                   (list.reversed path))
+         @member])))
+
+(def get_test
+  Test
+  (do [! random.monad]
+    [recordA (|> random.nat
+                 (at ! each (|>> analysis.nat))
+                 (random.list 10)
+                 (at ! each (|>> analysis.tuple)))
+     pathA ..random_path
+     [pattern @member] (get_pattern pathA)
+     .let [getA (analysis.case [recordA [[pattern
+                                          {analysis.#Reference (////reference.local @member)}]
+                                         (list)]])]]
+    (_.coverage [/.synthesize_get]
+      (|> getA
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty synthesis.init])
+          (pipe.case
+            {try.#Success (synthesis.branch/get [pathS recordS])}
+            (and (at (list.equivalence (sum.equivalence n.= n.=)) = pathA pathS)
+                 (//primitive.corresponds? recordA recordS))
+
+            _
+            false)))))
+
+(def random_bit
+  (Random [Path Match])
+  (do [! random.monad]
+    [test random.bit
+     then random.nat
+     else random.nat]
+    (in [{synthesis.#Alt {synthesis.#Seq (synthesis.path/bit test)
+                                         {synthesis.#Then (synthesis.i64 (.i64 then))}}
+                         {synthesis.#Seq (synthesis.path/bit (not test))
+                                         {synthesis.#Then (synthesis.i64 (.i64 else))}}}
+         [[analysis.#when (analysis.pattern/bit test)
+           analysis.#then (analysis.nat then)]
+          (list [analysis.#when (analysis.pattern/bit (not test))
+                 analysis.#then (analysis.nat else)])]])))
+
+(def (random_five hash random_element)
+  (All (_ a) (-> (Hash a) (Random a) (Random [a a a a a])))
+  (|> random_element
+      (random.set hash 5)
+      (at random.monad each (|>> set.list
+                                 (pipe.case
+                                   (list s0 s1 s2 s3 s4)
+                                   [s0 s1 s2 s3 s4]
+
+                                   _
+                                   (undefined))))))
+
+(with_template [      ]
+  [(def 
+     (Random [Path Match])
+     (do [! random.monad]
+       [[test/0 test/1 test/2 test/3 test/4] (random_five  )
+        [body/0 body/1 body/2 body/3 body/4] (random_five  )]
+       (in [(all {synthesis.#Alt}
+                 {synthesis.#Seq ( test/0) {synthesis.#Then ( body/0)}}
+                 {synthesis.#Seq ( test/1) {synthesis.#Then ( body/1)}}
+                 {synthesis.#Seq ( test/2) {synthesis.#Then ( body/2)}}
+                 {synthesis.#Seq ( test/3) {synthesis.#Then ( body/3)}}
+                 {synthesis.#Seq ( test/4) {synthesis.#Then ( body/4)}})
+            [[analysis.#when ( test/0) analysis.#then ( body/0)]
+             (list [analysis.#when ( test/1) analysis.#then ( body/1)]
+                   [analysis.#when ( test/2) analysis.#then ( body/2)]
+                   [analysis.#when ( test/3) analysis.#then ( body/3)]
+                   [analysis.#when ( test/4) analysis.#then ( body/4)])]])))]
+
+  [random_nat n.hash random.nat (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/nat analysis.nat]
+  [random_int int.hash random.int (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/int analysis.int]
+  [random_rev rev.hash random.rev (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/rev analysis.rev]
+  [random_frac frac.hash random.frac synthesis.path/f64 synthesis.f64 analysis.pattern/frac analysis.frac]
+  [random_text text.hash (random.unicode 1) synthesis.path/text synthesis.text analysis.pattern/text analysis.text]
+  )
+
+(def random_simple
+  (all random.either
+       ..random_bit
+       ..random_nat
+       ..random_int
+       ..random_rev
+       ..random_frac
+       ..random_text
+       ))
+
+(def random_variant
+  (Random [Path Match])
+  (do [! random.monad]
+    [[lefts/0 lefts/1 lefts/2 lefts/3 lefts/4] (random_five n.hash random.nat)
+     [value/0 value/1 value/2 value/3 value/4] (random_five text.hash (random.unicode 1))
+     last_is_right? random.bit
+     [body/0 body/1 body/2 body/3 body/4] (random_five frac.hash random.frac)
+     .let [path (is (-> Nat Bit Text Frac Path)
+                    (function (_ lefts right? value body)
+                      (all {synthesis.#Seq}
+                           (synthesis.path/side (if right?
+                                                  {.#Right lefts}
+                                                  {.#Left lefts}))
+                           (synthesis.path/text value)
+                           {synthesis.#Then (synthesis.f64 body)})))
+           branch (is (-> Nat Bit Text Frac Branch)
+                      (function (_ lefts right? value body)
+                        [analysis.#when (analysis.pattern/variant [analysis.#lefts lefts
+                                                                   analysis.#right? right?
+                                                                   analysis.#value (analysis.pattern/text value)])
+                         analysis.#then (analysis.frac body)]))]]
+    (in [(all {synthesis.#Alt}
+              (path lefts/0 false value/0 body/0)
+              (path lefts/1 false value/1 body/1)
+              (path lefts/2 false value/2 body/2)
+              (path lefts/3 false value/3 body/3)
+              (path lefts/4 last_is_right? value/4 body/4))
+         [(branch lefts/0 false value/0 body/0)
+          (list (branch lefts/1 false value/1 body/1)
+                (branch lefts/2 false value/2 body/2)
+                (branch lefts/3 false value/3 body/3)
+                (branch lefts/4 last_is_right? value/4 body/4))]])))
+
+(def random_tuple
+  (Random [Path Match])
+  (do [! random.monad]
+    [mid_size (at ! each (n.% 4) random.nat)
+
+     value/first (random.unicode 1)
+     value/mid (random.list mid_size (random.unicode 1))
+     value/last (random.unicode 1)
+
+     body/first random.frac
+     body/mid (random.list mid_size random.frac)
+     body/last random.frac
+     .let [path (is (-> Nat Bit Text Frac Path)
+                    (function (_ lefts right? value body)
+                      (if right?
+                        (all {synthesis.#Seq}
+                             (synthesis.path/member (if right?
+                                                      {.#Right lefts}
+                                                      {.#Left lefts}))
+                             (synthesis.path/text value)
+                             {synthesis.#Then (synthesis.f64 body)})
+                        (all {synthesis.#Seq}
+                             (synthesis.path/member (if right?
+                                                      {.#Right lefts}
+                                                      {.#Left lefts}))
+                             (synthesis.path/text value)
+                             {synthesis.#Pop}
+                             {synthesis.#Then (synthesis.f64 body)}))))
+           branch (is (-> Nat Bit Text Frac Branch)
+                      (function (_ lefts right? value body)
+                        [analysis.#when (if right?
+                                          (analysis.pattern/tuple (list#composite (list.repeated (++ lefts) (analysis.pattern/unit))
+                                                                                  (list (analysis.pattern/text value))))
+                                          (analysis.pattern/tuple (all list#composite
+                                                                       (list.repeated lefts (analysis.pattern/unit))
+                                                                       (list (analysis.pattern/text value)
+                                                                             (analysis.pattern/unit)))))
+                         analysis.#then (analysis.frac body)]))]]
+    (in [(list#mix (function (_ left right)
+                     {synthesis.#Alt left right})
+                   (path (++ mid_size) true value/last body/last)
+                   (|> (list.zipped_2 value/mid body/mid)
+                       {.#Item [value/first body/first]}
+                       list.enumeration
+                       (list#each (function (_ [lefts' [value body]])
+                                    (path lefts' false value body)))
+                       list.reversed))
+         [(branch 0 false value/first body/first)
+          (list#composite (|> (list.zipped_2 value/mid body/mid)
+                              list.enumeration
+                              (list#each (function (_ [lefts' [value body]])
+                                           (branch (++ lefts') false value body))))
+                          (list (branch (++ mid_size) true value/last body/last)))]])))
+
+(def random_complex
+  (all random.either
+       ..random_variant
+       ..random_tuple
+       ))
+
+(def random_case
+  (all random.either
+       ..random_simple
+       ..random_complex
+       ))
+
+(def case_test
+  Test
+  (do [! random.monad]
+    [expected_input (at ! each (|>> .i64 synthesis.i64) random.nat)
+     [expected_path match] ..random_case]
+    (_.coverage [/.synthesize_case]
+      (|> (/.synthesize_case //.phase archive.empty expected_input match)
+          (phase.result [///bundle.empty synthesis.init])
+          (pipe.case
+            {try.#Success (synthesis.branch/case [actual_input actual_path])}
+            (and (at synthesis.equivalence = expected_input actual_input)
+                 (at synthesis.path_equivalence = expected_path actual_path))
+
+            _
+            false)))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.synthesize])
+      (all _.and
+           ..masking_test
+           ..let_test
+           ..if_test
+           ..get_test
+           ..case_test
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/function.lux
new file mode 100644
index 000000000..579f52354
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/function.lux
@@ -0,0 +1,468 @@
+(.require
+ [lux (.except)
+  ["_" test (.only Test)]
+  [abstract
+   ["[0]" monad (.only do)]]
+  [control
+   ["[0]" try]]
+  [data
+   ["[0]" product]
+   ["[0]" text (.only)
+    ["%" \\format (.only format)]]
+   [number
+    ["n" nat]]
+   [collection
+    ["[0]" list (.use "[1]#[0]" functor mix monoid)]
+    ["[0]" dictionary (.only Dictionary)]
+    ["[0]" set]]]
+  [math
+   ["[0]" random (.only Random)]]
+  [meta
+   [macro
+    ["^" pattern]]]]
+ ["[0]" //
+  ["[1][0]" primitive]]
+ [\\
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    ["/[1]" //
+     [extension
+      ["[1][0]" bundle]]
+     ["/[1]" // (.only)
+      ["[0]" analysis (.only Analysis)]
+      ["[0]" synthesis (.only Synthesis)]
+      [///
+       [arity (.only Arity)]
+       ["[0]" reference (.only)
+        ["[0]" variable (.only Variable)]]
+       ["[0]" phase]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def (n_function loop? arity body)
+  (-> Bit Arity Synthesis Synthesis)
+  (synthesis.function/abstraction
+   [synthesis.#environment (list)
+    synthesis.#arity arity
+    synthesis.#body (if loop?
+                      (synthesis.loop/scope
+                       [synthesis.#start 1
+                        synthesis.#inits (list)
+                        synthesis.#iteration body])
+                      body)]))
+
+(def (n_abstraction arity body)
+  (-> Arity Analysis Analysis)
+  (list#mix (function (_ arity_1 body)
+              (case arity_1
+                0 {analysis.#Function (list) body}
+                _ {analysis.#Function (all list#composite
+                                           (list#each (|>> {variable.#Foreign})
+                                                      (list.indices arity_1))
+                                           (list {variable.#Local 1}))
+                                      body}))
+            body
+            (list.reversed (list.indices arity))))
+
+(def !expect
+  (template (_  )
+    (case 
+      
+      true
+      
+      _
+      false)))
+
+(type Circumstance
+  (Record
+   [#loop? Bit
+    #expectation Synthesis
+    #reality Analysis]))
+
+(type Scenario
+  (-> Bit (Random Circumstance)))
+
+(def (random_unit output?)
+  Scenario
+  (at random.monad in
+      [true
+       (synthesis.text synthesis.unit)
+       (analysis.unit)]))
+
+(with_template [   ]
+  [(def ( output?)
+     Scenario
+     (do [! random.monad]
+       [value ]
+       (in [true
+            ( value)
+            ( value)])))]
+
+  [random_bit random.bit synthesis.bit analysis.bit]
+  [random_nat random.nat (|>> .i64 synthesis.i64) analysis.nat]
+  [random_int random.int (|>> .i64 synthesis.i64) analysis.int]
+  [random_rev random.rev (|>> .i64 synthesis.i64) analysis.rev]
+  [random_frac random.frac synthesis.f64 analysis.frac]
+  [random_text (random.unicode 1) synthesis.text analysis.text]
+  )
+
+(def (random_primitive output?)
+  Scenario
+  (random.either (random.either (..random_unit output?)
+                                (random.either (..random_bit output?)
+                                               (..random_nat output?)))
+                 (random.either (random.either (..random_int output?)
+                                               (..random_rev output?))
+                                (random.either (..random_frac output?)
+                                               (..random_text output?)))))
+
+(def (random_variant random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [lefts random.nat
+     right? random.bit
+     [loop? expected_value actual_value] (random_value false)]
+    (in [loop?
+         (synthesis.variant
+          [analysis.#lefts lefts
+           analysis.#right? right?
+           analysis.#value expected_value])
+         (analysis.variant
+          [analysis.#lefts lefts
+           analysis.#right? right?
+           analysis.#value actual_value])])))
+
+(def (random_tuple random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [[loop?_left expected_left actual_left] (random_value false)
+     [loop?_right expected_right actual_right] (random_value false)]
+    (in [(and loop?_left
+              loop?_right)
+         (synthesis.tuple (list expected_left expected_right))
+         (analysis.tuple (list actual_left actual_right))])))
+
+(def (random_structure random_value output?)
+  (-> Scenario Scenario)
+  (all random.either
+       (..random_variant random_value output?)
+       (..random_tuple random_value output?)))
+
+(def (random_variable arity output?)
+  (-> Arity Scenario)
+  (do [! random.monad]
+    [register (at ! each (|>> (n.% arity) ++) random.nat)]
+    (in [(not (n.= 0 register))
+         (synthesis.variable/local register)
+         (if (n.= arity register)
+           {analysis.#Reference (reference.local 1)}
+           {analysis.#Reference (reference.foreign register)})])))
+
+(def (random_constant output?)
+  Scenario
+  (do [! random.monad]
+    [module (random.unicode 1)
+     short (random.unicode 1)]
+    (in [true
+         (synthesis.constant [module short])
+         {analysis.#Reference (reference.constant [module short])}])))
+
+(def (random_reference arity output?)
+  (-> Arity Scenario)
+  (random.either (..random_variable arity output?)
+                 (..random_constant output?)))
+
+(def (random_case arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (do [! random.monad]
+    [bit_test random.bit
+     i64_test random.nat
+     f64_test random.frac
+     text_test (random.unicode 1)
+     [loop?_input expected_input actual_input] (random_value false)
+     [loop?_output expected_output actual_output] (random_value output?)
+     lefts (|> random.nat (at ! each (n.% 10)))
+     right? random.bit
+     .let [side|member (if right?
+                         {.#Right lefts}
+                         {.#Left lefts})]]
+    (in [(and loop?_input
+              loop?_output)
+         (synthesis.branch/case [expected_input
+                                 (all synthesis.path/alt
+                                      (synthesis.path/then expected_output)
+                                      (synthesis.path/seq (synthesis.path/bit bit_test)
+                                                          (synthesis.path/then expected_output))
+                                      (synthesis.path/seq (synthesis.path/i64 (.i64 i64_test))
+                                                          (synthesis.path/then expected_output))
+                                      (synthesis.path/seq (synthesis.path/f64 f64_test)
+                                                          (synthesis.path/then expected_output))
+                                      (synthesis.path/seq (synthesis.path/text text_test)
+                                                          (synthesis.path/then expected_output))
+                                      (synthesis.path/seq (synthesis.path/bind (++ arity))
+                                                          (synthesis.path/then expected_output))
+                                      (all synthesis.path/seq
+                                           (synthesis.path/side side|member)
+                                           (synthesis.path/bind (++ arity))
+                                           (synthesis.path/then expected_output))
+                                      (if right?
+                                        (all synthesis.path/seq
+                                             (synthesis.path/member side|member)
+                                             (synthesis.path/bind (++ arity))
+                                             (synthesis.path/then expected_output)) 
+                                        (all synthesis.path/seq
+                                             (synthesis.path/member side|member)
+                                             (synthesis.path/bind (++ arity))
+                                             synthesis.path/pop
+                                             (synthesis.path/then expected_output))))])
+         {analysis.#Case actual_input
+                         [[analysis.#when (analysis.pattern/unit)
+                           analysis.#then actual_output]
+                          (list [analysis.#when (analysis.pattern/bit bit_test)
+                                 analysis.#then actual_output]
+                                [analysis.#when (analysis.pattern/nat (.nat i64_test))
+                                 analysis.#then actual_output]
+                                [analysis.#when (analysis.pattern/frac f64_test)
+                                 analysis.#then actual_output]
+                                [analysis.#when (analysis.pattern/text text_test)
+                                 analysis.#then actual_output]
+                                [analysis.#when {analysis.#Bind 2}
+                                 analysis.#then actual_output]
+                                [analysis.#when (analysis.pattern/variant
+                                                 [analysis.#lefts lefts
+                                                  analysis.#right? right?
+                                                  analysis.#value {analysis.#Bind 2}])
+                                 analysis.#then actual_output]
+                                [analysis.#when (analysis.pattern/tuple
+                                                 (list#composite (list.repeated lefts (analysis.pattern/unit))
+                                                                 (if right?
+                                                                   (list (analysis.pattern/unit) {analysis.#Bind 2})
+                                                                   (list {analysis.#Bind 2} (analysis.pattern/unit)))))
+                                 analysis.#then actual_output])]}])))
+
+(def (random_let arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (do [! random.monad]
+    [[loop?_input expected_input actual_input] (random_value false)
+     [loop?_output expected_output actual_output] (random_value output?)]
+    (in [(and loop?_input
+              loop?_output)
+         (synthesis.branch/let [expected_input
+                                (++ arity)
+                                expected_output])
+         {analysis.#Case actual_input
+                         [[analysis.#when {analysis.#Bind 2}
+                           analysis.#then actual_output]
+                          (list)]}])))
+
+(def (random_if random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [[loop?_test expected_test actual_test] (random_value false)
+     [loop?_then expected_then actual_then] (random_value output?)
+     [loop?_else expected_else actual_else] (random_value output?)
+     flip? random.bit]
+    (in [(and loop?_test
+              loop?_then
+              loop?_else)
+         (synthesis.branch/if [expected_test
+                               expected_then
+                               expected_else])
+         (if flip?
+           {analysis.#Case actual_test
+                           [[analysis.#when (analysis.pattern/bit false)
+                             analysis.#then actual_else]
+                            (list [analysis.#when (analysis.pattern/bit true)
+                                   analysis.#then actual_then])]}
+           {analysis.#Case actual_test
+                           [[analysis.#when (analysis.pattern/bit true)
+                             analysis.#then actual_then]
+                            (list [analysis.#when (analysis.pattern/bit false)
+                                   analysis.#then actual_else])]})])))
+
+(def (random_get random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [lefts (|> random.nat (at ! each (n.% 10)))
+     right? random.bit
+     [loop?_record expected_record actual_record] (random_value false)]
+    (in [loop?_record
+         (synthesis.branch/get [(list (if right?
+                                        {.#Right lefts}
+                                        {.#Left lefts}))
+                                expected_record])
+         {analysis.#Case actual_record
+                         [[analysis.#when (analysis.pattern/tuple
+                                           (list#composite (list.repeated lefts (analysis.pattern/unit))
+                                                           (if right?
+                                                             (list (analysis.pattern/unit) {analysis.#Bind 2})
+                                                             (list {analysis.#Bind 2} (analysis.pattern/unit)))))
+                           analysis.#then {analysis.#Reference (reference.local 2)}]
+                          (list)]}])))
+
+(def (random_branch arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (random.either (random.either (..random_case arity random_value output?)
+                                (..random_let arity random_value output?))
+                 (random.either (..random_if random_value output?)
+                                (..random_get random_value output?))))
+
+(def (random_again arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (do [! random.monad]
+    [resets (random.list arity (random_value false))]
+    (in [true
+         (synthesis.loop/again (list#each (|>> product.right product.left) resets))
+         (analysis.apply [{analysis.#Reference (case arity
+                                                 1 (reference.local 0)
+                                                 _ (reference.foreign 0))}
+                          (list#each (|>> product.right product.right) resets)])])))
+
+(def (random_scope arity output?)
+  (-> Arity Scenario)
+  (do [! random.monad]
+    [resets (random.list arity (..random_variable arity output?))
+     [_ expected_output actual_output] (..random_nat output?)]
+    (in [(list#mix (function (_ new old)
+                     (and new old))
+                   true
+                   (list#each product.left resets))
+         (synthesis.loop/scope
+          [synthesis.#start (++ arity)
+           synthesis.#inits (list#each (|>> product.right product.left) resets)
+           synthesis.#iteration expected_output])
+         (analysis.apply [(..n_abstraction arity actual_output)
+                          (list#each (|>> product.right product.right) resets)])])))
+
+(def (random_loop arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (if output?
+    (all random.either
+         (..random_again arity random_value output?)
+         (..random_scope arity output?)
+         )
+    (..random_scope arity output?)))
+
+(def (random_abstraction' output?)
+  Scenario
+  (do [! random.monad]
+    [[loop?_output expected_output actual_output] (..random_nat output?)
+     arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
+     .let [environment (all list#composite
+                            (list#each (|>> {variable.#Foreign})
+                                       (list.indices arity))
+                            (list {variable.#Local 1}))]]
+    (in [true
+         (synthesis.function/abstraction
+          [synthesis.#environment environment
+           synthesis.#arity 1
+           synthesis.#body (synthesis.loop/scope
+                            [synthesis.#start 1
+                             synthesis.#inits (list)
+                             synthesis.#iteration expected_output])])
+         {analysis.#Function environment
+                             actual_output}])))
+
+(def (random_apply random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [[loop?_abstraction expected_abstraction actual_abstraction] (..random_nat output?)
+     arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
+     inputs (random.list arity (random_value false))]
+    (in [(list#mix (function (_ new old)
+                     (and new old))
+                   loop?_abstraction
+                   (list#each product.left inputs))
+         (synthesis.function/apply [expected_abstraction
+                                    (list#each (|>> product.right product.left) inputs)])
+         (analysis.apply [actual_abstraction
+                          (list#each (|>> product.right product.right) inputs)])])))
+
+(def (random_function random_value output?)
+  (-> Scenario Scenario)
+  (if output?
+    (..random_apply random_value output?)
+    (all random.either
+         (..random_abstraction' output?)
+         (..random_apply random_value output?)
+         )))
+
+(def (random_control arity random_value output?)
+  (-> Arity Scenario Scenario)
+  (all random.either
+       (..random_branch arity random_value output?)
+       (..random_loop arity random_value output?)
+       (..random_function random_value output?)
+       ))
+
+(def (random_extension random_value output?)
+  (-> Scenario Scenario)
+  (do [! random.monad]
+    [name (random.unicode 1)
+     [loop?_first expected_first actual_first] (random_value false)
+     [loop?_second expected_second actual_second] (random_value false)
+     [loop?_third expected_third actual_third] (random_value false)]
+    (in [(and loop?_first
+              loop?_second
+              loop?_third)
+         {synthesis.#Extension name (list expected_first expected_second expected_third)}
+         {analysis.#Extension name (list actual_first actual_second actual_third)}])))
+
+(def (random_body arity)
+  (-> Arity Scenario)
+  (function (random_value output?)
+    (random.rec
+     (function (_ _)
+       (all random.either
+            (..random_primitive output?)
+            (..random_structure random_value output?)
+            (..random_reference arity output?)
+            (..random_control arity random_value output?)
+            (..random_extension random_value output?))))))
+
+(def random_abstraction
+  (Random [Synthesis Analysis])
+  (do [! random.monad]
+    [arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
+     [loop? expected_body actual_body] (random_body arity true)]
+    (in [(..n_function loop? arity expected_body)
+         (..n_abstraction arity actual_body)])))
+
+(def abstraction
+  Test
+  (do random.monad
+    [[expected input] ..random_abstraction]
+    (_.coverage [/.abstraction]
+      (|> input
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty synthesis.init])
+          (!expect (^.multi {try.#Success actual}
+                            (at synthesis.equivalence = expected actual)))))))
+
+(def application
+  Test
+  (do [! random.monad]
+    [arity (|> random.nat (at ! each (|>> (n.% 10) (n.max 1))))
+     funcA //primitive.primitive
+     argsA (random.list arity //primitive.primitive)]
+    (_.coverage [/.apply]
+      (and (|> (analysis.apply [funcA argsA])
+               (//.phase archive.empty)
+               (phase.result [///bundle.empty synthesis.init])
+               (!expect (^.multi {try.#Success (synthesis.function/apply [funcS argsS])}
+                                 (and (//primitive.corresponds? funcA funcS)
+                                      (list.every? (product.uncurried //primitive.corresponds?)
+                                                   (list.zipped_2 argsA argsS))))))
+           (|> (analysis.apply [funcA (list)])
+               (//.phase archive.empty)
+               (phase.result [///bundle.empty synthesis.init])
+               (!expect (^.multi {try.#Success funcS}
+                                 (//primitive.corresponds? funcA funcS))))))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           ..abstraction
+           ..application
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/loop.lux
new file mode 100644
index 000000000..76df6ec77
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/loop.lux
@@ -0,0 +1,293 @@
+(.require
+ [lux (.except structure loop function)
+  ["_" test (.only Test)]
+  [abstract
+   [monad (.only do)]]
+  [control
+   ["[0]" try]
+   ["[0]" exception]]
+  [data
+   [number
+    ["n" nat]]
+   [collection
+    ["[0]" list (.use "[1]#[0]" functor)]]]
+  [math
+   ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]
+ [\\
+  ["[0]" /
+   [////
+    ["[0]" analysis (.only Environment)]
+    ["/[1]" synthesis (.only Member Path Synthesis)]
+    [///
+     [arity (.only Arity)]
+     ["[0]" reference (.only Constant)
+      ["[0]" variable (.only Register Variable)]]]]]])
+
+(type (Scenario a)
+  (-> Register Arity Register (Random [Register [a a]])))
+
+(def (primitive offset arity next)
+  (Scenario Synthesis)
+  (`` (all random.either
+           (,, (with_template [ ]
+                 [(do [! random.monad]
+                    [example (at ! each (|>> ) )]
+                    (in [next
+                         [example
+                          example]]))]
+
+                 [//.bit random.bit]
+                 [//.i64 (at ! each .i64 random.nat)]
+                 [//.f64 random.frac]
+                 [//.text (random.unicode 1)]
+                 ))
+           )))
+
+(def (constant offset arity next)
+  (Scenario Constant)
+  (do random.monad
+    [name (random.and (random.unicode 1)
+                      (random.unicode 1))]
+    (in [next
+         [name
+          name]])))
+
+(def (variable offset arity next)
+  (Scenario Variable)
+  (let [local (do [! random.monad]
+                [register (at ! each (|>> (n.% arity) ++) random.nat)]
+                (in [next
+                     [{variable.#Local (/.register_optimization offset register)}
+                      {variable.#Local register}]]))]
+    (case offset
+      0 local
+      _ (all random.either
+             local
+             (do [! random.monad]
+               [foreign (at ! each (n.% offset) random.nat)]
+               (in [next
+                    [{variable.#Local foreign}
+                     {variable.#Foreign foreign}]]))))))
+
+(def (reference offset arity next)
+  (Scenario Synthesis)
+  (`` (all random.either
+           (,, (with_template [ ]
+                 [(do [! random.monad]
+                    [[next [exampleE exampleA]] ( offset arity next)]
+                    (in [next
+                         [( exampleE)
+                          ( exampleA)]]))]
+
+                 [//.constant ..constant]
+                 [//.variable ..variable]
+                 )))))
+
+(def (structure offset arity next)
+  (Scenario Synthesis)
+  (all random.either
+       (do [! random.monad]
+         [lefts random.nat
+          right? random.bit
+          [next [valueE valueA]] (..reference offset arity next)]
+         (in [next
+              [(//.variant
+                [analysis.#lefts lefts
+                 analysis.#right? right?
+                 analysis.#value valueE])
+               (//.variant
+                [analysis.#lefts lefts
+                 analysis.#right? right?
+                 analysis.#value valueA])]]))
+       (do [! random.monad]
+         [[next [leftE leftA]] (..reference offset arity next)
+          [next [rightE rightA]] (..reference offset arity next)]
+         (in [next
+              [(//.tuple (list leftE rightE))
+               (//.tuple (list leftA rightA))]]))
+       ))
+
+(def path
+  (Scenario Path)
+  (let [pattern (is (Scenario Path)
+                    (.function (again offset arity next)
+                      (`` (all random.either
+                               (random#in [next
+                                           [//.path/pop
+                                            //.path/pop]])
+                               (,, (with_template [ ]
+                                     [(do [! random.monad]
+                                        [example (at ! each (|>> ) )]
+                                        (in [next
+                                             [example
+                                              example]]))]
+
+                                     [//.path/bit random.bit]
+                                     [//.path/i64 (at ! each .i64 random.nat)]
+                                     [//.path/f64 random.frac]
+                                     [//.path/text (random.unicode 1)]
+                                     ))
+                               (,, (with_template []
+                                     [(do [! random.monad]
+                                        [example (at ! each (|>> )
+                                                     (random.or random.nat
+                                                                random.nat))]
+                                        (in [next
+                                             [example
+                                              example]]))]
+
+                                     [//.path/side]
+                                     [//.path/member]
+                                     ))
+                               (random#in [(++ next)
+                                           [(//.path/bind (/.register_optimization offset next))
+                                            (//.path/bind next)]])
+                               ))))
+        sequential (is (Scenario Path)
+                       (.function (again offset arity next)
+                         (do random.monad
+                           [[next [patternE patternA]] (pattern offset arity next)
+                            [next [bodyE bodyA]] (..reference offset arity next)]
+                           (in [next
+                                [(//.path/seq patternE (//.path/then bodyE))
+                                 (//.path/seq patternA (//.path/then bodyA))]]))))]
+    (.function (again offset arity next)
+      (do random.monad
+        [[next [leftE leftA]] (sequential offset arity next)
+         [next [rightE rightA]] (sequential offset arity next)]
+        (in [next
+             [(//.path/alt leftE rightE)
+              (//.path/alt leftA rightA)]])))))
+
+(def (branch offset arity next)
+  (Scenario Synthesis)
+  (let [random_member (is (Random Member)
+                          (random.or random.nat
+                                     random.nat))]
+    (all random.either
+         (all random.either
+              (do [! random.monad]
+                [[next [inputE inputA]] (..reference offset arity next)
+                 [next [bodyE bodyA]] (..reference offset arity next)]
+                (in [next
+                     [(//.branch/let [inputE (/.register_optimization offset next) bodyE])
+                      (//.branch/let [inputA next bodyA])]]))
+              (do [! random.monad]
+                [[next [testE testA]] (..reference offset arity next)
+                 [next [thenE thenA]] (..reference offset arity next)
+                 [next [elseE elseA]] (..reference offset arity next)]
+                (in [next
+                     [(//.branch/if [testE thenE elseE])
+                      (//.branch/if [testA thenA elseA])]])))
+         (all random.either
+              (do [! random.monad]
+                [[next [recordE recordA]] (..reference offset arity next)
+                 path_length (at ! each (|>> (n.% 5) ++) random.nat)
+                 path (random.list path_length random_member)]
+                (in [next
+                     [(//.branch/get [path recordE])
+                      (//.branch/get [path recordA])]]))
+              (do [! random.monad]
+                [[next [inputE inputA]] (..reference offset arity next)
+                 [next [pathE pathA]] (..path offset arity next)]
+                (in [next
+                     [(//.branch/case [inputE pathE])
+                      (//.branch/case [inputA pathA])]])))
+         )))
+
+(def (loop offset arity next)
+  (Scenario Synthesis)
+  (all random.either
+       (do random.monad
+         [[next [firstE firstA]] (..reference offset arity next)
+          [next [secondE secondA]] (..reference offset arity next)
+          [next [iterationE iterationA]] (..reference offset arity next)]
+         (in [next
+              [(//.loop/scope
+                [//.#start (/.register_optimization offset next)
+                 //.#inits (list firstE secondE)
+                 //.#iteration iterationE])
+               (//.loop/scope
+                [//.#start next
+                 //.#inits (list firstA secondA)
+                 //.#iteration iterationA])]]))
+       ))
+
+(def (function offset arity next)
+  (Scenario Synthesis)
+  (all random.either
+       (do [! random.monad]
+         [[next [firstE firstA]] (..variable offset arity next)
+          [next [secondE secondA]] (..variable offset arity next)
+          arity (at ! each (n.max 1) random.nat)
+          [next [bodyE bodyA]] (..primitive 0 arity next)]
+         (in [next
+              [(//.function/abstraction
+                [//.#environment (list firstE secondE)
+                 //.#arity arity
+                 //.#body bodyE])
+               (//.function/abstraction
+                [//.#environment (list firstA secondA)
+                 //.#arity arity
+                 //.#body bodyA])]]))
+       ))
+
+(def (control offset arity next)
+  (Scenario Synthesis)
+  (all random.either
+       (..branch offset arity next)
+       (..loop offset arity next)
+       (..function offset arity next)
+       ))
+
+(def (extension offset arity next)
+  (Scenario Synthesis)
+  (do random.monad
+    [name (random.unicode 10)
+     [next [firstE firstA]] (..reference offset arity next)
+     [next [secondE secondA]] (..reference offset arity next)
+     [next [thirdE thirdA]] (..reference offset arity next)]
+    (in [next
+         [{//.#Extension name (list firstE secondE thirdE)}
+          {//.#Extension name (list firstA secondA thirdA)}]])))
+
+(def (scenario offset arity next)
+  (Scenario Synthesis)
+  (all random.either
+       (..primitive offset arity next)
+       (..structure offset arity next)
+       (..reference offset arity next)
+       (..control offset arity next)
+       (..extension offset arity next)
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           (do [! random.monad]
+             [expected_offset (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
+              arity (at ! each (|>> (n.% 5) ++) random.nat)
+              expected_inits (|> random.nat
+                                 (at ! each (|>> .i64 //.i64))
+                                 (random.list arity))
+              [_ [expected iteration]] (..scenario expected_offset arity 0)]
+             (_.coverage [/.Transform /.optimization /.register_optimization]
+               (case (/.optimization true expected_offset expected_inits
+                                     [//.#environment (|> expected_offset
+                                                          list.indices
+                                                          (list#each (|>> {variable.#Local})))
+                                      //.#arity arity
+                                      //.#body iteration])
+                 {.#Some (//.loop/scope [actual_offset actual_inits
+                                         actual])}
+                 (and (n.= expected_offset
+                           actual_offset)
+                      (at (list.equivalence //.equivalence) =
+                          expected_inits
+                          actual_inits)
+                      (at //.equivalence = expected actual))
+                 
+                 _
+                 false)))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux
new file mode 100644
index 000000000..07414ac90
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux
@@ -0,0 +1,98 @@
+(.require
+ [lux (.except primitive)
+  [abstract ["[0]" monad (.only do)]]
+  [control
+   ["[0]" pipe]
+   ["[0]" try]]
+  [data
+   ["%" text/format (.only format)]
+   [number
+    ["n" nat]]
+   [collection
+    ["[0]" list]]]
+  ["r" math/random (.only Random) (.use "[1]#[0]" monad)]
+  ["_" test (.only Test)]
+  [meta
+   ["[0]" symbol]]]
+ [\\
+  ["[0]" /
+   ["/[1]" // (.only)
+    ["/[1]" //
+     [extension
+      ["[1][0]" bundle]]
+     ["/[1]" // (.only)
+      ["[1][0]" analysis (.only Analysis)]
+      ["[1][0]" synthesis (.only Synthesis)]
+      [///
+       ["[0]" phase]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def .public primitive
+  (Random Analysis)
+  (do r.monad
+    [primitive (is (Random ////analysis.Primitive)
+                   (all r.or
+                        (in [])
+                        r.bit
+                        r.nat
+                        r.int
+                        r.rev
+                        r.frac
+                        (r.unicode 5)))]
+    (in {////analysis.#Primitive primitive})))
+
+(def .public (corresponds? analysis synthesis)
+  (-> Analysis Synthesis Bit)
+  (`` (case [analysis synthesis]
+        (,, (with_template [   ]
+              [[{////analysis.#Primitive { expected}}
+                {////synthesis.#Primitive { actual}}]
+               (same? (|> expected )
+                      (|> actual ))]
+
+              [////analysis.#Unit (as Text) ////synthesis.#Text (|>)]
+              [////analysis.#Bit  (|>) ////synthesis.#Bit (|>)]
+              [////analysis.#Nat  .i64 ////synthesis.#I64 .i64]
+              [////analysis.#Int  .i64 ////synthesis.#I64 .i64]
+              [////analysis.#Rev  .i64 ////synthesis.#I64 .i64]
+              [////analysis.#Frac (|>) ////synthesis.#F64 (|>)]
+              [////analysis.#Text (|>) ////synthesis.#Text (|>)]
+              ))
+
+        [(////analysis.tuple expected)
+         (////synthesis.tuple actual)]
+        (and (n.= (list.size expected)
+                  (list.size actual))
+             (list.every? (function (_ [expected actual])
+                            (corresponds? expected actual))
+                          (list.zipped_2 expected actual)))
+        
+        _
+        false)))
+
+(def .public test
+  Test
+  (<| (_.context (%.symbol (symbol ////synthesis.#Primitive)))
+      (`` (all _.and
+               (,, (with_template [  ]
+                     [(do r.monad
+                        [expected ]
+                        (_.property (%.symbol (symbol ))
+                          (|> {////analysis.#Primitive { expected}}
+                              (//.phase archive.empty)
+                              (phase.result [///bundle.empty ////synthesis.init])
+                              (pipe.case
+                                {try.#Success {////synthesis.#Primitive { actual}}}
+                                (same? expected actual)
+
+                                _
+                                false))))]
+
+                     [////analysis.#Unit ////synthesis.#Text (r#in ////synthesis.unit)]
+                     [////analysis.#Bit  ////synthesis.#Bit  r.bit]
+                     [////analysis.#Nat  ////synthesis.#I64  (r#each .i64 r.nat)]
+                     [////analysis.#Int  ////synthesis.#I64  (r#each .i64 r.int)]
+                     [////analysis.#Rev  ////synthesis.#I64  (r#each .i64 r.rev)]
+                     [////analysis.#Frac ////synthesis.#F64  r.frac]
+                     [////analysis.#Text ////synthesis.#Text (r.unicode 5)]))))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/structure.lux
new file mode 100644
index 000000000..d17044f40
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/structure.lux
@@ -0,0 +1,85 @@
+(.require
+ [lux (.except)
+  [abstract
+   ["[0]" monad (.only do)]]
+  [data
+   ["%" text/format (.only format)]]
+  ["r" math/random (.only Random)]
+  ["_" test (.only Test)]
+  [control
+   ["[0]" pipe]
+   ["[0]" try]]
+  [data
+   ["[0]" bit (.use "[1]#[0]" equivalence)]
+   ["[0]" product]
+   [number
+    ["n" nat]]
+   [collection
+    ["[0]" list]]]
+  [meta
+   ["[0]" symbol]]]
+ ["[0]" //
+  ["[1][0]" primitive]]
+ [\\
+  ["[0]" /
+   ["/[1]" // (.only)
+    ["/[1]" //
+     [extension
+      ["[1][0]" bundle]]
+     ["/[1]" // (.only)
+      ["[1][0]" analysis (.only Analysis)]
+      ["[1][0]" synthesis (.only Synthesis)]
+      [///
+       ["[0]" phase]
+       [meta
+        ["[0]" archive]]]]]]]])
+
+(def variant
+  Test
+  (do [! r.monad]
+    [size (|> r.nat (at ! each (|>> (n.% 10) (n.+ 2))))
+     tagA (|> r.nat (at ! each (n.% size)))
+     .let [right? (n.= (-- size) tagA)
+           lefts (if right?
+                   (-- tagA)
+                   tagA)]
+     memberA //primitive.primitive]
+    (_.property "Can synthesize variants."
+      (|> (////analysis.variant [lefts right? memberA])
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty ////synthesis.init])
+          (pipe.case
+            {try.#Success (////synthesis.variant [leftsS right?S valueS])}
+            (let [tagS (if right?S (++ leftsS) leftsS)]
+              (and (n.= tagA tagS)
+                   (|> tagS (n.= (-- size)) (bit#= right?S))
+                   (//primitive.corresponds? memberA valueS)))
+            
+            _
+            false)))))
+
+(def tuple
+  Test
+  (do [! r.monad]
+    [size (|> r.nat (at ! each (|>> (n.% 10) (n.max 2))))
+     membersA (r.list size //primitive.primitive)]
+    (_.property "Can synthesize tuple."
+      (|> (////analysis.tuple membersA)
+          (//.phase archive.empty)
+          (phase.result [///bundle.empty ////synthesis.init])
+          (pipe.case
+            {try.#Success (////synthesis.tuple membersS)}
+            (and (n.= size (list.size membersS))
+                 (list.every? (product.uncurried //primitive.corresponds?)
+                              (list.zipped_2 membersA membersS)))
+
+            _
+            false)))))
+
+(def .public test
+  Test
+  (<| (_.context (%.symbol (symbol ////synthesis.#Structure)))
+      (all _.and
+           ..variant
+           ..tuple
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/variable.lux
new file mode 100644
index 000000000..309ba20ff
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/variable.lux
@@ -0,0 +1,338 @@
+(.require
+ [lux (.except)
+  ["_" test (.only Test)]
+  [abstract
+   ["[0]" monad (.only do)]]
+  [control
+   ["[0]" try]]
+  [data
+   ["[0]" product]
+   ["[0]" text
+    ["%" \\format (.only format)]]
+   [number
+    ["n" nat]]
+   [collection
+    ["[0]" list (.use "[1]#[0]" functor mix)]
+    ["[0]" dictionary (.only Dictionary)]]]
+  [math
+   ["[0]" random (.only Random)]]
+  [meta
+   [macro
+    ["^" pattern]]]]
+ [\\
+  ["[0]" /
+   [////
+    ["[0]" analysis]
+    ["[0]" synthesis (.only Side Member Path Synthesis)]
+    [///
+     [reference
+      ["[0]" variable]]]]]])
+
+(def !expect
+  (template (_  )
+    (case 
+      
+      true
+      
+      _
+      false)))
+
+(type Context
+  [#redundants Nat
+   #necessary (Dictionary Nat Nat)])
+
+(type (Scenario a)
+  (-> Context (Random [a a])))
+
+(with_template [  ]
+  [(def ( context)
+     (Scenario Synthesis)
+     (do [! random.monad]
+       [value ]
+       (in [( value)
+            ( value)])))]
+
+  [bit_scenario synthesis.bit random.bit]
+  [i64_scenario synthesis.i64 (at ! each .i64 random.nat)]
+  [f64_scenario synthesis.f64 random.frac]
+  [text_scenario synthesis.text (random.unicode 1)]
+  )
+
+(def (primitive_scenario context)
+  (Scenario Synthesis)
+  (random.either (random.either (..bit_scenario context)
+                                (..i64_scenario context))
+                 (random.either (..f64_scenario context)
+                                (..text_scenario context))))
+
+(def (with_redundancy scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [redundant? random.bit]
+    (if redundant?
+      (do !
+        [let? random.bit
+         [expected_input actual_input] (..primitive_scenario context)
+         .let [fake_register (n.+ (the #redundants context)
+                                  (dictionary.size (the #necessary context)))]
+         [expected_output actual_output] (scenario (revised #redundants ++ context))]
+        (in [(synthesis.branch/case [expected_input
+                                     {synthesis.#Seq {synthesis.#Pop}
+                                                     {synthesis.#Then expected_output}}])
+             (if let?
+               (synthesis.branch/let [actual_input fake_register actual_output])
+               (synthesis.branch/case [actual_input
+                                       {synthesis.#Seq {synthesis.#Bind fake_register}
+                                                       {synthesis.#Seq {synthesis.#Pop}
+                                                                       {synthesis.#Then actual_output}}}]))]))
+      (scenario context))))
+
+(def (variant_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [lefts random.nat
+     right? random.bit
+     [expected input] (scenario context)]
+    (in [(synthesis.variant [lefts right? expected])
+         (synthesis.variant [lefts right? input])])))
+
+(def (tuple_scenario context)
+  (Scenario Synthesis)
+  (let [registers (dictionary.entries (the #necessary context))]
+    (at random.monad in
+        [(synthesis.tuple (list#each (|>> product.left synthesis.variable/local) registers))
+         (synthesis.tuple (list#each (|>> product.right synthesis.variable/local) registers))])))
+
+(def (structure_scenario context)
+  (Scenario Synthesis)
+  (random.either (..variant_scenario (..with_redundancy ..tuple_scenario) context)
+                 (..tuple_scenario context)))
+
+(def (let_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do random.monad
+    [_ (in [])
+     [expected_input actual_input] (scenario context)
+     .let [real_register (dictionary.size (the #necessary context))
+           fake_register (n.+ (the #redundants context)
+                              (dictionary.size (the #necessary context)))]
+     [expected_output actual_output] (scenario (revised #necessary (dictionary.has real_register fake_register) context))]
+    (in [(synthesis.branch/let [expected_input real_register expected_output])
+         (synthesis.branch/let [actual_input fake_register actual_output])])))
+
+(def (if_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do random.monad
+    [_ (in [])
+     [expected_test actual_test] (scenario context)
+     [expected_then actual_then] (scenario context)
+     [expected_else actual_else] (scenario context)]
+    (in [(synthesis.branch/if [expected_test
+                               expected_then
+                               expected_else])
+         (synthesis.branch/if [actual_test
+                               actual_then
+                               actual_else])])))
+
+(def random_member
+  (Random Member)
+  (do random.monad
+    [lefts random.nat
+     right? random.bit]
+    (in (if right?
+          {.#Right lefts}
+          {.#Left lefts}))))
+
+(def (get_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [length (at ! each (|>> (n.% 5) ++) random.nat)
+     path (random.list length ..random_member)
+     [expected_record actual_record] (scenario context)]
+    (in [(synthesis.branch/get [path expected_record])
+         (synthesis.branch/get [path actual_record])])))
+
+(def random_side
+  (Random Side)
+  ..random_member)
+
+(def (path_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Path))
+  (`` (all random.either
+           (all random.either
+                (do [! random.monad]
+                  [_ (in [])
+                   [expected_then actual_then] (scenario context)]
+                  (in [{synthesis.#Seq {synthesis.#Pop}
+                                       {synthesis.#Then expected_then}}
+                       {synthesis.#Seq {synthesis.#Pop}
+                                       {synthesis.#Then actual_then}}]))
+                (do [! random.monad]
+                  [_ (in [])
+                   .let [real_register (dictionary.size (the #necessary context))
+                         fake_register (n.+ (the #redundants context)
+                                            (dictionary.size (the #necessary context)))]
+                   [expected_then actual_then] (scenario (revised #necessary (dictionary.has real_register fake_register) context))]
+                  (in [{synthesis.#Seq {synthesis.#Bind real_register}
+                                       {synthesis.#Seq {synthesis.#Pop}
+                                                       {synthesis.#Then expected_then}}}
+                       {synthesis.#Seq {synthesis.#Bind fake_register}
+                                       {synthesis.#Seq {synthesis.#Pop}
+                                                       {synthesis.#Then actual_then}}}])))
+           (all random.either
+                (,, (with_template [ ]
+                      [(do [! random.monad]
+                         [test 
+                          [expected_then actual_then] (scenario context)]
+                         (in [{synthesis.#Seq {synthesis.#Test { test}}
+                                              {synthesis.#Then expected_then}}
+                              {synthesis.#Seq {synthesis.#Test { test}}
+                                              {synthesis.#Then actual_then}}]))]
+
+                      [synthesis.#Bit random.bit]
+                      [synthesis.#I64 (at ! each .i64 random.nat)]
+                      [synthesis.#F64 random.frac]
+                      [synthesis.#Text (random.unicode 1)]
+                      )))
+           (all random.either
+                (do [! random.monad]
+                  [side ..random_side
+                   [expected_next actual_next] (path_scenario scenario context)]
+                  (in [{synthesis.#Seq {synthesis.#Access {synthesis.#Side side}}
+                                       expected_next}
+                       {synthesis.#Seq {synthesis.#Access {synthesis.#Side side}}
+                                       actual_next}]))
+                (do [! random.monad]
+                  [member ..random_member
+                   [expected_next actual_next] (path_scenario scenario context)]
+                  (in [{synthesis.#Seq {synthesis.#Access {synthesis.#Member member}}
+                                       expected_next}
+                       {synthesis.#Seq {synthesis.#Access {synthesis.#Member member}}
+                                       actual_next}])))
+           (do [! random.monad]
+             [_ (in [])
+              [expected_left actual_left] (path_scenario scenario context)
+              [expected_right actual_right] (path_scenario scenario context)]
+             (in [{synthesis.#Alt expected_left expected_right}
+                  {synthesis.#Alt actual_left actual_right}]))
+           )))
+
+(def (case_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [_ (in [])
+     [expected_input actual_input] (scenario context)
+     [expected_path actual_path] (..path_scenario scenario context)]
+    (in [(synthesis.branch/case [expected_input expected_path])
+         (synthesis.branch/case [actual_input actual_path])])))
+
+(def (branch_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (all random.either
+       (..let_scenario scenario context)
+       (..if_scenario scenario context)
+       (..get_scenario scenario context)
+       (..case_scenario scenario context)
+       ))
+
+(def scope_arity 5)
+
+(def (scope_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [_ (in [])
+     .let [real_start (dictionary.size (the #necessary context))
+           fake_start (n.+ (the #redundants context)
+                           real_start)]
+     inits (random.list ..scope_arity (scenario context))
+     [expected_iteration actual_iteration] (scenario (revised #necessary
+                                                              (function (_ necessary)
+                                                                (list#mix (function (_ [idx _] context)
+                                                                            (dictionary.has (n.+ real_start idx)
+                                                                                            (n.+ fake_start idx)
+                                                                                            context))
+                                                                          necessary
+                                                                          (list.enumeration inits)))
+                                                              context))]
+    (in [(synthesis.loop/scope [real_start (list#each product.left inits) expected_iteration])
+         (synthesis.loop/scope [fake_start (list#each product.right inits) actual_iteration])])))
+
+(def (again_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [_ (in [])
+     resets (random.list ..scope_arity (scenario context))]
+    (in [(synthesis.loop/again (list#each product.left resets))
+         (synthesis.loop/again (list#each product.right resets))])))
+
+(def (loop_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (all random.either
+       (..scope_scenario scenario context)
+       (..again_scenario scenario context)
+       ))
+
+(def (abstraction_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [_ (in [])
+     .let [registers (dictionary.entries (the #necessary context))
+           expected_environment (list#each (|>> product.left {variable.#Local}) registers)
+           actual_environment (list#each (|>> product.right {variable.#Local}) registers)]
+     [expected_body actual_body] (..primitive_scenario context)]
+    (in [(synthesis.function/abstraction [expected_environment 1 expected_body])
+         (synthesis.function/abstraction [actual_environment 1 actual_body])])))
+
+(def (apply_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (do [! random.monad]
+    [abstraction (at ! each (|>> synthesis.constant)
+                     (random.and (random.unicode 1)
+                                 (random.unicode 1)))
+     inputs (random.list ..scope_arity (scenario context))]
+    (in [(synthesis.function/apply [abstraction (list#each product.left inputs)])
+         (synthesis.function/apply [abstraction (list#each product.right inputs)])])))
+
+(def (function_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (all random.either
+       (..abstraction_scenario scenario context)
+       (..apply_scenario scenario context)
+       ))
+
+(def (control_scenario scenario context)
+  (-> (Scenario Synthesis) (Scenario Synthesis))
+  (all random.either
+       (..branch_scenario scenario context)
+       (..loop_scenario scenario context)
+       (..function_scenario scenario context)
+       ))
+
+(def (scenario context)
+  (Scenario Synthesis)
+  (all random.either
+       (..primitive_scenario context)
+       (..structure_scenario context)
+       (..control_scenario (..with_redundancy
+                             (..control_scenario
+                              (..with_redundancy
+                                ..structure_scenario)))
+                           context)
+       ))
+
+(def default
+  Context
+  [#redundants 0
+   #necessary (dictionary.empty n.hash)])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           (do random.monad
+             [[expected input] (..scenario ..default)]
+             (_.coverage [/.optimization]
+               (|> (/.optimization input)
+                   (!expect (^.multi {try.#Success actual}
+                                     (at synthesis.equivalence = expected actual))))))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux
new file mode 100644
index 000000000..a87bcbd66
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux
@@ -0,0 +1,145 @@
+(.require
+ [lux (.except)
+  [abstract/monad (.only do)]
+  [data
+   ["%" text/format (.only format)]
+   [number
+    ["n" nat]]]
+  ["r" math/random (.only Random) (.use "[1]#[0]" monad)]
+  ["_" test (.only Test)]
+  [control
+   ["[0]" try]
+   [parser
+    ["l" text]]]
+  [data
+   ["[0]" text]
+   [collection
+    ["[0]" list]
+    ["[0]" dictionary (.only Dictionary)]]]
+  [meta
+   ["[0]" code]
+   ["[0]" location]
+   ["[0]" symbol]]]
+ [\\
+  ["[0]" /]])
+
+(def symbol_part^
+  (Random Text)
+  (do [! r.monad]
+    [size (|> r.nat (at ! each (|>> (n.% 20) (n.max 1))))]
+    (r.lower_case_alpha size)))
+
+(def symbol^
+  (Random Symbol)
+  (r.and symbol_part^ symbol_part^))
+
+(def code^
+  (Random Code)
+  (let [numeric^ (is (Random Code)
+                     (all r.either
+                          (|> r.bit (r#each code.bit))
+                          (|> r.nat (r#each code.nat))
+                          (|> r.int (r#each code.int))
+                          (|> r.rev (r#each code.rev))
+                          (|> r.safe_frac (r#each code.frac))))
+        textual^ (is (Random Code)
+                     (all r.either
+                          (do r.monad
+                            [size (|> r.nat (r#each (n.% 20)))]
+                            (|> (r.upper_case_alpha size) (r#each code.text)))
+                          (|> symbol^ (r#each code.symbol))
+                          (|> symbol^ (r#each code.tag))))
+        simple^ (is (Random Code)
+                    (all r.either
+                         numeric^
+                         textual^))]
+    (r.rec
+     (function (_ code^)
+       (let [multi^ (do r.monad
+                      [size (|> r.nat (r#each (n.% 3)))]
+                      (r.list size code^))
+             composite^ (is (Random Code)
+                            (all r.either
+                                 (|> multi^ (r#each code.form))
+                                 (|> multi^ (r#each code.tuple))
+                                 (do r.monad
+                                   [size (|> r.nat (r#each (n.% 3)))]
+                                   (|> (r.list size (r.and code^ code^))
+                                       (r#each code.record)))))]
+         (all r.either
+              simple^
+              composite^))))))
+
+(def code
+  Test
+  (do [! r.monad]
+    [sample code^]
+    (all _.and
+         (_.property "Can parse Lux code."
+           (case (let [source_code (%.code sample)]
+                   (/.parse "" (dictionary.empty text.hash) (text.size source_code)
+                            [location.dummy 0 source_code]))
+             {.#Left error}
+             false
+
+             {.#Right [_ parsed]}
+             (at code.equivalence = parsed sample)))
+         (do !
+           [other code^]
+           (_.property "Can parse multiple Lux code nodes."
+             (let [source_code (format (%.code sample) " " (%.code other))
+                   source_code//size (text.size source_code)]
+               (case (/.parse "" (dictionary.empty text.hash) source_code//size
+                              [location.dummy 0 source_code])
+                 {.#Left error}
+                 false
+
+                 {.#Right [remaining =sample]}
+                 (case (/.parse "" (dictionary.empty text.hash) source_code//size
+                                remaining)
+                   {.#Left error}
+                   false
+
+                   {.#Right [_ =other]}
+                   (and (at code.equivalence = sample =sample)
+                        (at code.equivalence = other =other)))))))
+         )))
+
+(def comment_text^
+  (Random Text)
+  (let [char_gen (|> r.nat (r.only (|>> (n.= (`` (char (,, (static text.new_line))))) not)))]
+    (do r.monad
+      [size (|> r.nat (r#each (n.% 20)))]
+      (r.text char_gen size))))
+
+(def comment^
+  (Random Text)
+  (do r.monad
+    [comment comment_text^]
+    (in (format "... " comment text.new_line))))
+
+(def comments
+  Test
+  (do r.monad
+    [sample code^
+     comment comment^]
+    (all _.and
+         (_.property "Can handle comments."
+           (case (let [source_code (format comment (%.code sample))
+                       source_code//size (text.size source_code)]
+                   (/.parse "" (dictionary.empty text.hash) source_code//size
+                            [location.dummy 0 source_code]))
+             {.#Left error}
+             false
+
+             {.#Right [_ parsed]}
+             (at code.equivalence = parsed sample)))
+         )))
+
+(def .public test
+  Test
+  (<| (_.context (symbol.module (symbol /._)))
+      (all _.and
+           ..code
+           ..comments
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis.lux
new file mode 100644
index 000000000..2bfe91fca
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis.lux
@@ -0,0 +1,215 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    ["[0]" monad (.only do)]]
+   [control
+    ["<>" parser]
+    ["[0]" try]
+    ["[0]" exception]]
+   [data
+    ["[0]" bit]
+    ["[0]" text]
+    [collection
+     ["[0]" list (.use "[1]#[0]" functor)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]
+     ["[0]" i64]
+     ["[0]" frac]]]
+   [meta
+    ["[0]" symbol]
+    [macro
+     ["^" pattern]]
+    [compiler
+     [reference (.only)
+      ["[0]" variable (.only Variable)]]
+     [language
+      [lux
+       [analysis (.only Environment)]
+       ["[0]" synthesis (.only Synthesis)]]]]]]]
+ ["[0]" \\parser]
+ ["[0]" /
+  ["[1][0]" simple]
+  ["[1][0]" access]])
+
+(def !expect
+  (template (_  )
+    [(case 
+       
+       true
+       
+       _
+       false)]))
+
+(def random_constant
+  (Random Symbol)
+  (random.and (random.unicode 1)
+              (random.unicode 1)))
+
+(def random_variable
+  (Random Variable)
+  (random.or random.nat
+             random.nat))
+
+(def random_environment
+  (Random (Environment Synthesis))
+  (do [! random.monad]
+    [size (at ! each (n.% 5) random.nat)]
+    (|> ..random_variable
+        (at ! each (|>> synthesis.variable))
+        (random.list size))))
+
+(def simple
+  Test
+  (`` (all _.and
+           (,, (with_template [    ]
+                 [(do [! random.monad]
+                    [expected 
+                     dummy (|>  (random.only (|>> (at  = expected) not)))]
+                    (all _.and
+                         (_.coverage []
+                           (|> (\\parser.result  (list ( expected)))
+                               (!expect (^.multi {try.#Success actual}
+                                                 (at  = expected actual)))))
+                         (_.coverage []
+                           (and (|> (\\parser.result ( expected) (list ( expected)))
+                                    (!expect {try.#Success _}))
+                                (|> (\\parser.result ( expected) (list ( dummy)))
+                                    (!expect (^.multi {try.#Failure error}
+                                                      (exception.match? \\parser.cannot_parse error))))))
+                         ))]
+
+                 [\\parser.bit \\parser.this_bit random.bit synthesis.bit bit.equivalence]
+                 [\\parser.i64 \\parser.this_i64 random.i64 synthesis.i64 i64.equivalence]
+                 [\\parser.f64 \\parser.this_f64 random.safe_frac synthesis.f64 frac.equivalence]
+                 [\\parser.text \\parser.this_text (random.unicode 1) synthesis.text text.equivalence]
+                 [\\parser.local \\parser.this_local random.nat synthesis.variable/local n.equivalence]
+                 [\\parser.foreign \\parser.this_foreign random.nat synthesis.variable/foreign n.equivalence]
+                 [\\parser.constant \\parser.this_constant ..random_constant synthesis.constant symbol.equivalence]
+                 ))
+           )))
+
+(def complex
+  Test
+  (all _.and
+       (do [! random.monad]
+         [expected_bit random.bit
+          expected_i64 random.i64
+          expected_f64 random.safe_frac
+          expected_text (random.unicode 1)]
+         (_.coverage [\\parser.tuple]
+           (and (|> (\\parser.result (\\parser.tuple (all <>.and \\parser.bit \\parser.i64 \\parser.f64 \\parser.text))
+                                     (list (synthesis.tuple (list (synthesis.bit expected_bit)
+                                                                  (synthesis.i64 expected_i64)
+                                                                  (synthesis.f64 expected_f64)
+                                                                  (synthesis.text expected_text)))))
+                    (!expect (^.multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]}
+                                      (and (at bit.equivalence = expected_bit actual_bit)
+                                           (at i64.equivalence = expected_i64 actual_i64)
+                                           (at frac.equivalence = expected_f64 actual_f64)
+                                           (at text.equivalence = expected_text actual_text)))))
+                (|> (\\parser.result (\\parser.tuple (all <>.and \\parser.bit \\parser.i64 \\parser.f64 \\parser.text))
+                                     (list (synthesis.text expected_text)))
+                    (!expect (^.multi {try.#Failure error}
+                                      (exception.match? \\parser.cannot_parse error)))))))
+       (do [! random.monad]
+         [arity random.nat
+          expected_environment ..random_environment
+          expected_body (random.unicode 1)]
+         (_.coverage [\\parser.function]
+           (and (|> (\\parser.result (\\parser.function arity \\parser.text)
+                                     (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
+                    (!expect (^.multi {try.#Success [actual_environment actual_body]}
+                                      (and (at (list.equivalence synthesis.equivalence) =
+                                               expected_environment
+                                               actual_environment)
+                                           (at text.equivalence = expected_body actual_body)))))
+                (|> (\\parser.result (\\parser.function arity \\parser.text)
+                                     (list (synthesis.text expected_body)))
+                    (!expect (^.multi {try.#Failure error}
+                                      (exception.match? \\parser.cannot_parse error)))))))
+       (do [! random.monad]
+         [arity random.nat
+          expected_environment ..random_environment
+          expected_body (random.unicode 1)]
+         (_.coverage [\\parser.wrong_arity]
+           (|> (\\parser.result (\\parser.function (++ arity) \\parser.text)
+                                (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
+               (!expect (^.multi {try.#Failure error}
+                                 (exception.match? \\parser.wrong_arity error))))))
+       (do [! random.monad]
+         [arity (at ! each (|>> (n.% 10) ++) random.nat)
+          expected_offset random.nat
+          expected_inits (random.list arity random.bit)
+          expected_body (random.unicode 1)]
+         (_.coverage [\\parser.loop]
+           (and (|> (\\parser.result (\\parser.loop (<>.many \\parser.bit) \\parser.text)
+                                     (list (synthesis.loop/scope [expected_offset
+                                                                  (list#each (|>> synthesis.bit) expected_inits)
+                                                                  (synthesis.text expected_body)])))
+                    (!expect (^.multi {try.#Success [actual_offset actual_inits actual_body]}
+                                      (and (at n.equivalence = expected_offset actual_offset)
+                                           (at (list.equivalence bit.equivalence) =
+                                               expected_inits
+                                               actual_inits)
+                                           (at text.equivalence = expected_body actual_body)))))
+                (|> (\\parser.result (\\parser.loop (<>.many \\parser.bit) \\parser.text)
+                                     (list (synthesis.text expected_body)))
+                    (!expect (^.multi {try.#Failure error}
+                                      (exception.match? \\parser.cannot_parse error)))))))
+       ))
+
+(def \\parser
+  Test
+  (<| (_.covering \\parser._)
+      (_.for [\\parser.Parser])
+      (all _.and
+           (do [! random.monad]
+             [expected (at ! each (|>> synthesis.i64) random.i64)]
+             (_.coverage [\\parser.result \\parser.any]
+               (|> (\\parser.result \\parser.any (list expected))
+                   (!expect (^.multi {try.#Success actual}
+                                     (at synthesis.equivalence = expected actual))))))
+           (_.coverage [\\parser.empty_input]
+             (|> (\\parser.result \\parser.any (list))
+                 (!expect (^.multi {try.#Failure error}
+                                   (exception.match? \\parser.empty_input error)))))
+           (do [! random.monad]
+             [expected (at ! each (|>> synthesis.i64) random.i64)]
+             (_.coverage [\\parser.unconsumed_input]
+               (|> (\\parser.result \\parser.any (list expected expected))
+                   (!expect (^.multi {try.#Failure error}
+                                     (exception.match? \\parser.unconsumed_input error))))))
+           (do [! random.monad]
+             [dummy (at ! each (|>> synthesis.i64) random.i64)]
+             (_.coverage [\\parser.end \\parser.expected_empty_input]
+               (and (|> (\\parser.result \\parser.end (list))
+                        (!expect {try.#Success _}))
+                    (|> (\\parser.result \\parser.end (list dummy))
+                        (!expect (^.multi {try.#Failure error}
+                                          (exception.match? \\parser.expected_empty_input error)))))))
+           (do [! random.monad]
+             [dummy (at ! each (|>> synthesis.i64) random.i64)]
+             (_.coverage [\\parser.end?]
+               (and (|> (\\parser.result \\parser.end? (list))
+                        (!expect {try.#Success #1}))
+                    (|> (\\parser.result (<>.before \\parser.any \\parser.end?) (list dummy))
+                        (!expect {try.#Success #0})))))
+           (_.for [\\parser.cannot_parse]
+                  (all _.and
+                       ..simple
+                       ..complex
+                       ))
+           )))
+
+(def .public test
+  Test
+  (all _.and
+       ..\\parser
+
+       /simple.test
+       /access.test
+       ))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access.lux
new file mode 100644
index 000000000..67022657e
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access.lux
@@ -0,0 +1,14 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]]]
+ ["[0]" /
+  ["[1][0]" side]
+  ["[1][0]" member]])
+
+(def .public test
+  Test
+  (all _.and
+       /side.test
+       /member.test
+       ))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux
new file mode 100644
index 000000000..f9a892715
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/member.lux
@@ -0,0 +1,41 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Member)
+  (all random.and
+       random.nat
+       random.bit
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Member])
+      (do [! random.monad]
+        [left ..random
+         right  ..random]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec /.equivalence ..random))
+             (_.for [/.hash]
+                    ($hash.spec /.hash ..random))
+             
+             (_.coverage [/.format]
+               (bit#= (at /.equivalence = left right)
+                      (text#= (/.format left) (/.format right))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux
new file mode 100644
index 000000000..236f373e1
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/access/side.lux
@@ -0,0 +1,41 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Side)
+  (all random.and
+       random.nat
+       random.bit
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Side])
+      (do [! random.monad]
+        [left ..random
+         right  ..random]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec /.equivalence ..random))
+             (_.for [/.hash]
+                    ($hash.spec /.hash ..random))
+             
+             (_.coverage [/.format]
+               (bit#= (at /.equivalence = left right)
+                      (text#= (/.format left) (/.format right))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux
new file mode 100644
index 000000000..67cf4f719
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/synthesis/simple.lux
@@ -0,0 +1,45 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Simple)
+  (all random.or
+       random.bit
+       random.i64
+       random.frac
+       (random.lower_case 1)
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Simple])
+      (do [! random.monad]
+        [left ..random
+         right ..random]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec /.equivalence ..random))
+             (_.for [/.hash]
+                    ($hash.spec /.hash ..random))
+
+             (_.coverage [/.format]
+               (bit#= (text#= (/.format left) (/.format right))
+                      (at /.equivalence = left right)))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive.lux b/stdlib/source/test/lux/meta/compiler/meta/archive.lux
new file mode 100644
index 000000000..2ada929d2
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive.lux
@@ -0,0 +1,254 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    ["[0]" exception]]
+   [data
+    ["[0]" product]
+    ["[0]" text (.only)
+     ["%" \\format (.only format)]]
+    [collection
+     ["[0]" list]
+     ["[0]" set (.use "[1]#[0]" equivalence)]
+     ["[0]" sequence]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["[1][0]" key]
+   ["[1][0]" registry]
+   ["[1][0]" signature]
+   ["[1][0]" module (.only)
+    ["[2][0]" document]
+    ["[2][0]" descriptor]]]]
+ ["$[0]" /
+  ["[1][0]" signature]
+  ["[1][0]" key]
+  ["[1][0]" artifact]
+  ["[1][0]" registry]
+  ["[1][0]" module]
+  ["[1][0]" unit]])
+
+(def .public (descriptor module hash)
+  (-> /descriptor.Module Nat /descriptor.Descriptor)
+  [/descriptor.#name module
+   /descriptor.#file (format module ".lux")
+   /descriptor.#hash hash
+   /descriptor.#state {.#Active}
+   /descriptor.#references (set.empty text.hash)])
+
+(def test|entry
+  Test
+  (do random.monad
+    [module/0 (random.lower_case 1)
+     module/1 (random.lower_case 2)
+     signature $/signature.random
+     .let [version (the /signature.#version signature)]
+     fake_version (random.only (|>> (n.= version) not) random.nat)
+     content/0 random.nat
+     content/1 (random.only (|>> (n.= content/0) not) random.nat)
+     hash random.nat
+     .let [key (/key.key signature content/0)]]
+    (all _.and
+         (_.coverage [/.has /.find]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  .let [entry [/.#module [/module.#id @module/0
+                                          /module.#descriptor (..descriptor module/0 hash)
+                                          /module.#document (/document.document key content/0)]
+                               /.#output sequence.empty
+                               /.#registry /registry.empty]]
+                  archive (/.has module/0 entry archive)
+                  entry' (/.find module/0 archive)]
+                 (in (same? entry entry')))
+               (try.else false)))
+         (_.coverage [/.module_is_only_reserved]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  entry' (/.find module/0 archive)]
+                 (in false))
+               (exception.otherwise (exception.match? /.module_is_only_reserved))))
+         (_.coverage [/.cannot_replace_document]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  .let [entry/0 [/.#module [/module.#id @module/0
+                                            /module.#descriptor (..descriptor module/0 hash)
+                                            /module.#document (/document.document key content/0)]
+                                 /.#output sequence.empty
+                                 /.#registry /registry.empty]
+                        entry/1 [/.#module [/module.#id @module/0
+                                            /module.#descriptor (..descriptor module/0 hash)
+                                            /module.#document (/document.document key content/1)]
+                                 /.#output sequence.empty
+                                 /.#registry /registry.empty]]
+                  archive (/.has module/0 entry/0 archive)
+                  archive (/.has module/0 entry/1 archive)]
+                 (in false))
+               (exception.otherwise (exception.match? /.cannot_replace_document))))
+         (_.coverage [/.module_must_be_reserved_before_it_can_be_added]
+           (|> (do try.monad
+                 [.let [entry [/.#module [/module.#id 0
+                                          /module.#descriptor (..descriptor module/0 hash)
+                                          /module.#document (/document.document key content/0)]
+                               /.#output sequence.empty
+                               /.#registry /registry.empty]]
+                  archive (/.has module/0 entry /.empty)]
+                 (in false))
+               (exception.otherwise (exception.match? /.module_must_be_reserved_before_it_can_be_added))))
+         (_.coverage [/.archived?]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  .let [pre (/.archived? archive module/0)
+                        entry [/.#module [/module.#id @module/0
+                                          /module.#descriptor (..descriptor module/0 hash)
+                                          /module.#document (/document.document key content/0)]
+                               /.#output sequence.empty
+                               /.#registry /registry.empty]]
+                  archive (/.has module/0 entry archive)
+                  .let [post (/.archived? archive module/0)]]
+                 (in (and (not pre) post)))
+               (try.else false)))
+         (_.coverage [/.unknown_document]
+           (and (|> (do try.monad
+                      [_ (/.id module/0 /.empty)]
+                      (in false))
+                    (exception.otherwise (exception.match? /.unknown_document)))
+                (|> (do try.monad
+                      [_ (/.find module/0 /.empty)]
+                      (in false))
+                    (exception.otherwise (exception.match? /.unknown_document)))))
+         (_.coverage [/.archived]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  .let [pre (/.archived archive)
+                        entry [/.#module [/module.#id @module/0
+                                          /module.#descriptor (..descriptor module/0 hash)
+                                          /module.#document (/document.document key content/0)]
+                               /.#output sequence.empty
+                               /.#registry /registry.empty]]
+                  archive (/.has module/0 entry archive)
+                  .let [post (/.archived archive)
+                        (open "list#[0]") (list.equivalence text.equivalence)]]
+                 (in (and (list#= (list) pre)
+                          (list#= (list module/0) post))))
+               (try.else false)))
+         (_.coverage [/.entries]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  .let [pre (/.entries archive)
+                        entry [/.#module [/module.#id @module/0
+                                          /module.#descriptor (..descriptor module/0 hash)
+                                          /module.#document (/document.document key content/0)]
+                               /.#output sequence.empty
+                               /.#registry /registry.empty]]
+                  archive (/.has module/0 entry archive)]
+                 (in (and (list.empty? pre)
+                          (case (/.entries archive)
+                            (list [module/0' @module/0' entry'])
+                            (and (same? module/0 module/0')
+                                 (same? @module/0 @module/0')
+                                 (same? entry entry'))
+
+                            _
+                            false))))
+               (try.else false)))
+         (_.coverage [/.export /.import]
+           (|> (do try.monad
+                 [[@module/0 archive] (/.reserve module/0 /.empty)
+                  [@module/1 archive] (/.reserve module/1 archive)
+                  .let [entry/0 [/.#module [/module.#id @module/0
+                                            /module.#descriptor (..descriptor module/0 hash)
+                                            /module.#document (/document.document key content/0)]
+                                 /.#output sequence.empty
+                                 /.#registry /registry.empty]
+                        entry/1 [/.#module [/module.#id @module/1
+                                            /module.#descriptor (..descriptor module/1 hash)
+                                            /module.#document (/document.document key content/1)]
+                                 /.#output sequence.empty
+                                 /.#registry /registry.empty]]
+                  archive (/.has module/0 entry/0 archive)
+                  archive (/.has module/1 entry/1 archive)
+                  .let [pre (/.reserved archive)]
+                  archive (|> archive
+                              (/.export version)
+                              (/.import version))
+                  .let [post (/.reserved archive)]]
+                 (in (set#= (set.of_list text.hash pre)
+                            (set.of_list text.hash post))))
+               (try.else false)))
+         (_.coverage [/.version_mismatch]
+           (|> (do try.monad
+                 [archive (|> /.empty
+                              (/.export version)
+                              (/.import fake_version))]
+                 (in false))
+               (exception.otherwise (exception.match? /.version_mismatch))))
+         )))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Archive])
+      (do random.monad
+        [module/0 (random.lower_case 1)
+         module/1 (random.lower_case 2)
+         signature $/signature.random
+         content/0 random.nat
+         content/1 (random.only (|>> (n.= content/0) not) random.nat)
+         hash random.nat
+         .let [key (/key.key signature content/0)]])
+      (all _.and
+           (_.coverage [/.empty]
+             (list.empty? (/.entries /.empty)))
+           (_.coverage [/.reserve /.id]
+             (|> (do try.monad
+                   [[@module/0 archive] (/.reserve module/0 /.empty)
+                    [@module/1 archive] (/.reserve module/1 archive)
+                    @module/0' (/.id module/0 archive)
+                    @module/1' (/.id module/1 archive)]
+                   (in (and (same? @module/0 @module/0')
+                            (same? @module/1 @module/1'))))
+                 (try.else false)))
+           (_.coverage [/.reserved]
+             (|> (do try.monad
+                   [[@module/0 archive] (/.reserve module/0 /.empty)
+                    [@module/1 archive] (/.reserve module/1 archive)]
+                   (in (set#= (set.of_list text.hash (list module/0 module/1))
+                              (set.of_list text.hash (/.reserved archive)))))
+                 (try.else false)))
+           (_.coverage [/.reservations]
+             (|> (do try.monad
+                   [[@module/0 archive] (/.reserve module/0 /.empty)
+                    [@module/1 archive] (/.reserve module/1 archive)
+                    .let [hash (product.hash text.hash n.hash)]]
+                   (in (set#= (set.of_list hash (list [module/0 @module/0] [module/1 @module/1]))
+                              (set.of_list hash (/.reservations archive)))))
+                 (try.else false)))
+           (_.coverage [/.module_has_already_been_reserved]
+             (|> (do try.monad
+                   [[@module/0 archive] (/.reserve module/0 /.empty)
+                    _ (/.reserve module/0 archive)]
+                   (in false))
+                 (exception.otherwise (exception.match? /.module_has_already_been_reserved))))
+           (_.coverage [/.reserved?]
+             (|> (do try.monad
+                   [[@module/0 archive] (/.reserve module/0 /.empty)]
+                   (in (and (/.reserved? archive module/0)
+                            (not (/.reserved? archive module/1)))))
+                 (try.else false)))
+           (_.for [/.Entry]
+                  ..test|entry)
+
+           $/signature.test
+           $/key.test
+           $/artifact.test
+           $/registry.test
+           $/module.test
+           $/unit.test
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/artifact.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact.lux
new file mode 100644
index 000000000..4801f7569
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact.lux
@@ -0,0 +1,32 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [\\specification
+     ["$[0]" equivalence]]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ ["[0]" /
+  ["[1][0]" category]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Artifact)
+  (all random.and
+       random.nat
+       /category.random
+       random.bit
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Artifact /.ID])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence ..random))
+
+           /category.test
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux
new file mode 100644
index 000000000..5eb23ba3e
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/artifact/category.lux
@@ -0,0 +1,44 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [\\specification
+     ["$[0]" equivalence]]]
+   [math
+    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def random_definition
+  (Random /.Definition)
+  (all random.and
+       (random.lower_case 1)
+       (random.maybe
+        (all random.and
+             random.nat
+             random.nat
+             random.nat
+             ))
+       ))
+
+(def .public random
+  (Random /.Category)
+  (all random.or
+       (random#in [])
+       ..random_definition
+       (random.lower_case 2)
+       (random.lower_case 3)
+       (random.lower_case 4)
+       (random.lower_case 5)
+       (random.lower_case 6)
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Category])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence ..random))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/key.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/key.lux
new file mode 100644
index 000000000..fe3230d7c
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/key.lux
@@ -0,0 +1,27 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [math
+    ["[0]" random]]]]
+ [\\library
+  ["[0]" /]]
+ ["[0]" //
+  ["[1][0]" signature]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Key])
+      (do random.monad
+        [expected //signature.random
+         document random.nat]
+        (all _.and
+             (_.coverage [/.key /.signature]
+               (|> document
+                   (/.key expected)
+                   /.signature
+                   (same? expected)))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/module.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/module.lux
new file mode 100644
index 000000000..33aed16e6
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/module.lux
@@ -0,0 +1,43 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["[0]" document]
+   [//
+    ["[0]" key]
+    ["[0]" signature
+     ["$[1]" \\test]]]]]
+ ["[0]" /
+  ["[1][0]" document]
+  ["[1][0]" descriptor]])
+
+(def .public (random it)
+  (All (_ a) (-> (Random a) (Random (/.Module a))))
+  (all random.and
+       random.nat
+       (/descriptor.random 0)
+       (do random.monad
+         [signature $signature.random
+          example it]
+         (in (document.document (key.key signature example)
+                                example)))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Module])
+      (all _.and
+           (_.coverage [/.ID /.runtime]
+             (n.= 0 /.runtime))
+
+           /document.test
+           /descriptor.test
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/module/descriptor.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/module/descriptor.lux
new file mode 100644
index 000000000..fd3103d21
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/module/descriptor.lux
@@ -0,0 +1,58 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]]]
+   [control
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" text (.use "[1]#[0]" equivalence)]
+    ["[0]" binary
+     ["[1]" \\format]
+     ["<[1]>" \\parser]]]
+   [math
+    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def random_module_state
+  (Random Module_State)
+  (all random.or
+       (random#in [])
+       (random#in [])
+       (random#in [])
+       ))
+
+(def .public (random imports)
+  (-> Nat (Random /.Descriptor))
+  (all random.and
+       (random.lower_case 1)
+       (random.lower_case 1)
+       random.nat
+       ..random_module_state
+       (random.set text.hash imports (random.lower_case 2))
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Descriptor])
+      (do random.monad
+        [expected (..random 5)])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence (..random 1)))
+
+           (_.for [/.Module]
+                  (_.coverage [/.runtime]
+                    (text#= "" /.runtime)))
+           (_.coverage [/.format /.parser]
+             (|> expected
+                 (binary.result /.format)
+                 (.result /.parser)
+                 (try#each (|>> (at /.equivalence = (has /.#state {.#Cached} expected))))
+                 (try.else false)))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/module/document.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/module/document.lux
new file mode 100644
index 000000000..b1ab4c5ec
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/module/document.lux
@@ -0,0 +1,97 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception]]
+   [data
+    ["[0]" binary
+     ["[1]F" \\format]
+     ["<[1]>" \\parser]]]
+   [math
+    ["[0]" random]
+    [number
+     ["[0]" nat]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [///
+    ["[1][0]" signature (.use "[1]#[0]" equivalence)]
+    ["[1][0]" key]]]]
+ ["[0]" ///
+  ["[1][0]" signature]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Document])
+      (do random.monad
+        [signature/0 ///signature.random
+         signature/1 (random.only (|>> (/signature#= signature/0) not)
+                                  ///signature.random)
+         .let [key/0 (/key.key signature/0 0)
+               key/1 (/key.key signature/1 0)]
+         expected random.nat]
+        (all _.and
+             (_.coverage [/.document /.content]
+               (|> expected
+                   (/.document key/0)
+                   (/.content key/0)
+                   (try#each (same? expected))
+                   (try.else false)))
+             (_.coverage [/.signature]
+               (|> expected
+                   (/.document key/0)
+                   /.signature
+                   (same? signature/0)))
+             (_.coverage [/.marked?]
+               (and (|> expected
+                        (/.document key/0)
+                        (/.marked? key/0)
+                        (pipe.case
+                          {try.#Success it} true
+                          {try.#Failure error} false))
+                    (|> expected
+                        (/.document key/0)
+                        (/.marked? key/1)
+                        (pipe.case
+                          {try.#Success it} false
+                          {try.#Failure error} true))))
+             (_.coverage [/.invalid_signature]
+               (and (|> expected
+                        (/.document key/0)
+                        (/.content key/1)
+                        (pipe.case
+                          {try.#Success it}
+                          false
+                          
+                          {try.#Failure error}
+                          (exception.match? /.invalid_signature error)))
+                    (|> expected
+                        (/.document key/0)
+                        (/.marked? key/1)
+                        (pipe.case
+                          {try.#Success it}
+                          false
+                          
+                          {try.#Failure error}
+                          (exception.match? /.invalid_signature error)))))
+             (_.coverage [/.format /.parser]
+               (|> expected
+                   (/.document key/0)
+                   (binaryF.result (/.format binaryF.nat))
+                   (.result (/.parser key/0 .nat))
+                   (pipe.case
+                     {try.#Success it}
+                     (and (/signature#= signature/0 (/.signature it))
+                          (|> it
+                              (/.content key/0)
+                              (try#each (nat.= expected))
+                              (try.else false)))
+                     
+                     {try.#Failure error}
+                     false)))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux
new file mode 100644
index 000000000..ef21f8b7d
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux
@@ -0,0 +1,180 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" maybe (.use "[1]#[0]" functor)]
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" product]
+    ["[0]" text]
+    ["[0]" binary
+     ["[1]" \\format]
+     ["<[1]>" \\parser]]
+    [collection
+     ["[0]" sequence (.only Sequence)]
+     ["[0]" set (.only Set)]
+     ["[0]" list (.use "[1]#[0]" mix functor)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [//
+    ["[0]" unit]
+    ["[0]" artifact (.only)
+     ["[0]" category]]]]])
+
+(def tagged?
+  (template (_  )
+    [(case 
+       { _}
+       true
+       
+       _
+       false)]))
+
+(def random_dependency
+  (Random unit.ID)
+  (all random.and
+       random.nat
+       random.nat
+       ))
+
+(def (random_dependencies amount)
+  (-> Nat (Random (Set unit.ID)))
+  (random.set unit.hash amount ..random_dependency))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Registry])
+      (do [! random.monad]
+        [expected_name (random.lower_case 5)
+         mandatory? random.bit
+         expected_dependencies (..random_dependencies 5)
+         
+         expected_amount (at ! each (n.% 10) random.nat)
+         expected_names (|> (random.lower_case 1)
+                            (random.set text.hash expected_amount)
+                            (at ! each set.list))]
+        (`` (all _.and
+                 (_.coverage [/.empty]
+                   (|> /.empty
+                       /.artifacts
+                       sequence.size
+                       (n.= 0)))
+                 (_.coverage [/.resource]
+                   (let [[@it registry] (/.resource mandatory? expected_dependencies /.empty)]
+                     (case (sequence.list (/.artifacts registry))
+                       (list [artifact actual_dependencies])
+                       (and (same? @it (the artifact.#id artifact))
+                            (same? mandatory? (the artifact.#mandatory? artifact))
+                            (tagged? category.#Anonymous (the artifact.#category artifact))
+                            (same? expected_dependencies actual_dependencies))
+
+                       _
+                       false)))
+                 (,, (with_template [ '    ']
+                       [(_.coverage [ ]
+                          (let [ '
+                                 ']
+                            (and (let [[@it registry] (  mandatory? expected_dependencies /.empty)]
+                                   (and (case ( registry)
+                                          (list actual_name)
+                                          (same?  actual_name)
+
+                                          _
+                                          false)
+                                        (case (sequence.list (/.artifacts registry))
+                                          (list [artifact actual_dependencies])
+                                          (and (same? @it (the artifact.#id artifact))
+                                               (same? mandatory? (the artifact.#mandatory? artifact))
+                                               (case (the artifact.#category artifact)
+                                                 { actual_name}
+                                                 (same?  actual_name)
+
+                                                 _
+                                                 false)
+                                               (same? expected_dependencies actual_dependencies))
+
+                                          _
+                                          false)))
+                                 (let [[@it registry] (  mandatory? expected_dependencies /.empty)]
+                                   (case ( registry)
+                                     (list)
+                                     true
+
+                                     _
+                                     false)))))]
+
+                       [/.definition (is category.Definition [expected_name {.#None}]) /.definitions category.#Definition /.analyser expected_name]
+                       [/.analyser expected_name /.analysers category.#Analyser /.synthesizer expected_name]
+                       [/.synthesizer expected_name /.synthesizers category.#Synthesizer /.generator expected_name]
+                       [/.generator expected_name /.generators category.#Generator /.declaration expected_name]
+                       [/.declaration expected_name /.declarations category.#Declaration /.custom expected_name]
+                       [/.custom expected_name /.customs category.#Custom /.definition (is category.Definition [expected_name {.#None}])]
+                       ))
+                 (_.coverage [/.id]
+                   (and (,, (with_template [ ' ]
+                              [(let [ '
+                                     [@expected registry] (  mandatory? expected_dependencies /.empty)]
+                                 (|> (/.id ( ) registry)
+                                     (maybe#each (same? @expected))
+                                     (maybe.else false)))]
+
+                              [/.definition (is category.Definition [expected_name {.#None}]) product.left]
+                              [/.analyser expected_name |>]
+                              [/.synthesizer expected_name |>]
+                              [/.generator expected_name |>]
+                              [/.declaration expected_name |>]
+                              [/.custom expected_name |>]
+                              ))))
+                 (_.coverage [/.artifacts]
+                   (and (,, (with_template [   <$>]
+                              [(let [expected/* (list#each <$> expected_names)
+                                     [ids registry] (is [(Sequence artifact.ID) /.Registry]
+                                                        (list#mix (function (_ expected [ids registry])
+                                                                    (let [[@new registry] ( expected mandatory? expected_dependencies registry)]
+                                                                      [(sequence.suffix @new ids) registry]))
+                                                                  [sequence.empty /.empty]
+                                                                  expected/*))
+                                     it (/.artifacts registry)]
+                                 (and (n.= expected_amount (sequence.size it))
+                                      (list.every? (function (_ [@it [it dependencies]])
+                                                     (same? @it (the artifact.#id it)))
+                                                   (list.zipped_2 (sequence.list ids) (sequence.list it)))
+                                      (at (list.equivalence ) = expected/* ( registry))))]
+
+                              [/.definition /.definitions category.definition_equivalence (is (-> Text category.Definition)
+                                                                                              (function (_ it)
+                                                                                                [it {.#None}]))]
+                              [/.analyser /.analysers text.equivalence (|>>)]
+                              [/.synthesizer /.synthesizers text.equivalence (|>>)]
+                              [/.generator /.generators text.equivalence (|>>)]
+                              [/.declaration /.declarations text.equivalence (|>>)]
+                              [/.custom /.customs text.equivalence (|>>)]
+                              ))))
+                 (_.coverage [/.format /.parser]
+                   (and (,, (with_template [ ' ]
+                              [(let [ '
+                                     [@expected before] (  mandatory? expected_dependencies /.empty)]
+                                 (|> before
+                                     (binary.result /.format)
+                                     (.result /.parser)
+                                     (try#each (|>> (/.id ( ))
+                                                    (maybe#each (same? @expected))
+                                                    (maybe.else false)))
+                                     (try.else false)))]
+
+                              [/.definition (is category.Definition [expected_name {.#None}]) product.left]
+                              [/.analyser expected_name |>]
+                              [/.synthesizer expected_name |>]
+                              [/.generator expected_name |>]
+                              [/.declaration expected_name |>]
+                              [/.custom expected_name |>]
+                              ))))
+                 )))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/signature.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/signature.lux
new file mode 100644
index 000000000..2d75deca0
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/signature.lux
@@ -0,0 +1,55 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]]]
+   [control
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)]
+    ["[0]" binary
+     ["[1]F" \\format]
+     ["<[1]>" \\parser]]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ [\\library
+  ["[0]" /]]
+ ["[0]" ////
+  ["[1][0]" version]])
+
+(def .public random
+  (Random /.Signature)
+  (all random.and
+       (all random.and
+            (random.upper_case 1)
+            (random.lower_case 1))
+       ////version.random
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Signature])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence ..random))
+           
+           (do random.monad
+             [left ..random
+              right ..random]
+             (_.coverage [/.description]
+               (bit#= (at /.equivalence = left right)
+                      (text#= (/.description left) (/.description right)))))
+           (do random.monad
+             [expected ..random]
+             (_.coverage [/.format /.parser]
+               (|> expected
+                   (binaryF.result /.format)
+                   (.result /.parser)
+                   (try#each (at /.equivalence = expected))
+                   (try.else false))))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux
new file mode 100644
index 000000000..3bdef20a8
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/archive/unit.lux
@@ -0,0 +1,36 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    [collection
+     ["[0]" set]]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.ID)
+  (all random.and
+       random.nat
+       random.nat
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.ID])
+      (all _.and
+           (_.for [/.equivalence]
+                  ($equivalence.spec /.equivalence ..random))
+           (_.for [/.hash]
+                  ($hash.spec /.hash ..random))
+           
+           (_.coverage [/.none]
+             (set.empty? /.none))
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cache.lux b/stdlib/source/test/lux/meta/compiler/meta/cache.lux
new file mode 100644
index 000000000..68ba4e7fb
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cache.lux
@@ -0,0 +1,54 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    [concurrency
+     ["[0]" async]]]
+   [math
+    ["[0]" random]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" /]]
+ ["[0]" /
+  ["[1][0]" archive]
+  ["[1][0]" module]
+  ["[1][0]" artifact]
+  ["[1][0]" purge]
+  ["$/[1]" //
+   ["[1][0]" context]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [.let [/ "/"
+               fs (file.mock /)]
+         context $//context.random]
+        (all _.and
+             (in (do [! async.monad]
+                   [pre/0 (at fs directory? (/.path fs context))
+                    pre/1 (/.enabled? fs context)
+                    outcome (/.enable! ! fs context)
+                    post/0 (at fs directory? (/.path fs context))
+                    post/1 (/.enabled? fs context)]
+                   (_.coverage' [/.path /.enabled? /.enable!]
+                     (and (not pre/0)
+                          (not pre/1)
+                          
+                          (case outcome
+                            {try.#Success _} true
+                            {try.#Failure _} false)
+                          
+                          post/0
+                          post/1))))
+
+             /archive.test
+             /module.test
+             /artifact.test
+             /purge.test
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cache/archive.lux b/stdlib/source/test/lux/meta/compiler/meta/cache/archive.lux
new file mode 100644
index 000000000..09821245e
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cache/archive.lux
@@ -0,0 +1,84 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try (.use "[1]#[0]" functor)]
+    [concurrency
+     ["[0]" async]]]
+   [data
+    ["[0]" binary (.use "[1]#[0]" equivalence)]
+    [collection
+     ["[0]" sequence]]]
+   [math
+    ["[0]" random]
+    [number
+     ["n" nat]]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" // (.only)
+    ["/[1]" // (.only)
+     ["[0]" archive (.only)
+      ["[0]" signature]
+      ["[0]" key]
+      ["[0]" registry]
+      ["[0]" module (.only)
+       ["[0]" document]]]]]]]
+ ["$" //
+  [//
+   ["[1][0]" context]
+   ["[1][0]" archive (.only)
+    ["[2][0]" signature]]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [.let [/ "/"
+               fs (file.mock /)]
+         context $context.random
+         module/0 (random.lower_case 1)
+         module/1 (random.lower_case 2)
+         content/0 random.nat
+         content/1 (random.only (|>> (n.= content/0) not) random.nat)
+         hash random.nat
+         signature $signature.random
+         .let [key (key.key signature content/0)
+               [archive expected] (|> (do try.monad
+                                        [[@module/0 archive] (archive.reserve module/0 archive.empty)
+                                         [@module/1 archive] (archive.reserve module/1 archive)
+                                         .let [entry/0 [archive.#module [module.#id @module/0
+                                                                         module.#descriptor ($archive.descriptor module/0 hash)
+                                                                         module.#document (document.document key content/0)]
+                                                        archive.#output sequence.empty
+                                                        archive.#registry registry.empty]
+                                               entry/1 [archive.#module [module.#id @module/1
+                                                                         module.#descriptor ($archive.descriptor module/1 hash)
+                                                                         module.#document (document.document key content/1)]
+                                                        archive.#output sequence.empty
+                                                        archive.#registry registry.empty]]
+                                         archive (archive.has module/0 entry/0 archive)
+                                         archive (archive.has module/1 entry/1 archive)]
+                                        (in [archive (archive.export ///.version archive)]))
+                                      try.trusted)]]
+        (all _.and
+             (in (do [! async.monad]
+                   [pre/0 (at fs file? (/.descriptor fs context))
+                    enabled? (//.enable! ! fs context)
+                    cached? (/.cache! fs context archive)
+                    actual (at fs read (/.descriptor fs context))
+                    post/0 (at fs file? (/.descriptor fs context))]
+                   (_.coverage' [/.descriptor /.cache!]
+                     (and (not pre/0)
+                          (|> (do try.monad
+                                [_ enabled?
+                                 _ cached?]
+                                actual)
+                              (try#each (binary#= expected))
+                              (try.else false))
+                          post/0))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cache/artifact.lux b/stdlib/source/test/lux/meta/compiler/meta/cache/artifact.lux
new file mode 100644
index 000000000..7d3fa626d
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cache/artifact.lux
@@ -0,0 +1,53 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    [concurrency
+     ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]]
+   [data
+    ["[0]" binary (.use "[1]#[0]" equivalence)
+     ["$[1]" \\test]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" //
+    ["[1][0]" module]]]]
+ ["$[0]" ///
+  ["[1][0]" context]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [.let [/ "/"
+               fs (file.mock /)]
+         context $///context.random
+         @module random.nat
+         @artifact random.nat
+         expected ($binary.random 1)]
+        (all _.and
+             (in (do [! async.monad]
+                   [pre (at fs file? (/.path fs context @module @artifact))
+                    _ (//module.enable! ! fs context @module)
+                    write! (/.cache! fs context @module @artifact expected)
+                    post (at fs file? (/.path fs context @module @artifact))
+                    read! (/.cache fs context @module @artifact)]
+                   (_.coverage' [/.path /.cache! /.cache]
+                     (and (not pre)
+                          (case write!
+                            {try.#Success _} true
+                            {try.#Failure _} false)
+                          post
+                          (case read!
+                            {try.#Success actual} (binary#= expected actual)
+                            {try.#Failure _} false)))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cache/module.lux b/stdlib/source/test/lux/meta/compiler/meta/cache/module.lux
new file mode 100644
index 000000000..bce9082e5
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cache/module.lux
@@ -0,0 +1,94 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    ["[0]" exception]
+    [concurrency
+     ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]]
+   [math
+    ["[0]" random]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" /]]
+ ["$[0]" ///
+  ["[1][0]" context]])
+
+(`` (def (bad it)
+      (-> (file.System Async) (file.System Async))
+      (implementation
+       (,, (with_template []
+             [(def 
+                (at it ))]
+
+             [separator]
+             [file?]
+             [directory?]
+             [modify]
+             [write]
+             [append]
+             [move]
+             [directory_files]
+             [sub_directories]
+             [file_size]
+             [last_modified]
+             [can_execute?]
+             [read]
+             [delete]
+             ))
+
+       (def (make_directory path)
+         (async#in {try.#Failure ""}))
+       )))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [context $///context.random
+         @module random.nat]
+        (all _.and
+             (in (do [! async.monad]
+                   [.let [/ "/"
+                          fs (file.mock /)]
+                    pre/0 (at fs directory? (/.path fs context @module))
+                    pre/1 (/.enabled? fs context @module)
+                    outcome (/.enable! ! fs context @module)
+                    post/0 (at fs directory? (/.path fs context @module))
+                    post/1 (/.enabled? fs context @module)]
+                   (_.coverage' [/.path /.enabled? /.enable!]
+                     (and (not pre/0)
+                          (not pre/1)
+                          
+                          (case outcome
+                            {try.#Success _} true
+                            {try.#Failure _} false)
+                          
+                          post/0
+                          post/1))))
+             (in (do [! async.monad]
+                   [.let [/ "/"
+                          fs (file.mock /)]
+                    pre/0 (at fs directory? (/.path fs context @module))
+                    pre/1 (/.enabled? fs context @module)
+                    outcome (/.enable! ! (..bad fs) context @module)
+                    post/0 (at fs directory? (/.path fs context @module))
+                    post/1 (/.enabled? fs context @module)]
+                   (_.coverage' [/.cannot_enable]
+                     (and (not pre/0)
+                          (not pre/1)
+                          
+                          (case outcome
+                            {try.#Success _}
+                            false
+                            
+                            {try.#Failure error}
+                            (exception.match? /.cannot_enable error))
+                          
+                          (not post/0)
+                          (not post/1)))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cache/purge.lux b/stdlib/source/test/lux/meta/compiler/meta/cache/purge.lux
new file mode 100644
index 000000000..02d6402fb
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cache/purge.lux
@@ -0,0 +1,141 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" try]
+    ["[0]" exception]
+    [concurrency
+     ["[0]" async]]]
+   [data
+    ["[0]" text (.only)
+     ["%" \\format]]
+    ["[0]" binary
+     ["$[1]" \\test]]
+    [collection
+     ["[0]" dictionary]
+     ["[0]" sequence]
+     ["[0]" set]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["/[1]" //
+    ["[1][0]" module]
+    ["[0]" dependency
+     ["[1]" module]]
+    ["/[1]" //
+     ["[0]" context (.only)
+      ["$[1]" \\test]]
+     ["[0]" archive (.only)
+      ["[0]" registry]
+      ["[0]" module (.only)
+       ["$[1]" \\test]
+       ["[0]" descriptor (.only)
+        ["$[1]" \\test]]]]
+     ["/[1]" //]]]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [descriptor ($descriptor.random 0)
+         source_code (random.upper_case 1)
+         name/0 (random.lower_case 1)
+         module/0 ($module.random random.nat)
+         content/0 ($binary.random 1)
+         name/1 (random.lower_case 2)
+         module/1 (|> ($module.random random.nat)
+                      (at ! each (has [module.#descriptor descriptor.#references]
+                                      (set.of_list text.hash (list name/0)))))
+         content/1 ($binary.random 2)
+         .let [id/0 (the module.#id module/0)
+               id/1 (the module.#id module/1)
+               input [////.#module (the descriptor.#name descriptor)
+                      ////.#file (the descriptor.#file descriptor)
+                      ////.#hash (the descriptor.#hash descriptor)
+                      ////.#code source_code]
+               / "/"
+               fs (file.mock /)]
+         context $context.random]
+        (all _.and
+             (_.for [/.Cache]
+                    (all _.and
+                         (_.coverage [/.valid?]
+                           (and (/.valid? descriptor input)
+                                (not (/.valid? descriptor (has ////.#module source_code input)))
+                                (not (/.valid? descriptor (has ////.#file source_code input)))
+                                (not (/.valid? descriptor (revised ////.#hash ++ input)))))
+                         ))
+             (_.for [/.Purge]
+                    (all _.and
+                         (_.coverage [/.purge]
+                           (and (dictionary.empty? (/.purge (list) (list)))
+                                (let [order (is (dependency.Order Nat)
+                                                (list [name/0 id/0
+                                                       [archive.#module module/0
+                                                        archive.#output (sequence.sequence)
+                                                        archive.#registry registry.empty]]))]
+                                  (and (let [cache (is (List /.Cache)
+                                                       (list [#1 name/0 id/0 module/0 registry.empty]))]
+                                         (dictionary.empty? (/.purge cache order)))
+                                       (let [cache (is (List /.Cache)
+                                                       (list [#0 name/0 id/0 module/0 registry.empty]))]
+                                         (dictionary.key? (/.purge cache order) name/0))))
+                                (let [order (is (dependency.Order Nat)
+                                                (list [name/0 id/0
+                                                       [archive.#module module/0
+                                                        archive.#output (sequence.sequence)
+                                                        archive.#registry registry.empty]]
+                                                      [name/1 id/1
+                                                       [archive.#module module/1
+                                                        archive.#output (sequence.sequence)
+                                                        archive.#registry registry.empty]]))]
+                                  (and (let [cache (is (List /.Cache)
+                                                       (list [#1 name/0 id/0 module/0 registry.empty]
+                                                             [#1 name/1 id/1 module/1 registry.empty]))
+                                             purge (/.purge cache order)]
+                                         (dictionary.empty? purge))
+                                       (let [cache (is (List /.Cache)
+                                                       (list [#1 name/0 id/0 module/0 registry.empty]
+                                                             [#0 name/1 id/1 module/1 registry.empty]))
+                                             purge (/.purge cache order)]
+                                         (and (not (dictionary.key? (/.purge cache order) name/0))
+                                              (dictionary.key? (/.purge cache order) name/1)))
+                                       (let [cache (is (List /.Cache)
+                                                       (list [#0 name/0 id/0 module/0 registry.empty]
+                                                             [#1 name/1 id/1 module/1 registry.empty]))
+                                             purge (/.purge cache order)]
+                                         (and (dictionary.key? (/.purge cache order) name/0)
+                                              (dictionary.key? (/.purge cache order) name/1)))))))
+                         (in (do [! async.monad]
+                               [_ (//module.enable! ! fs context id/0)
+                                .let [dir (//module.path fs context id/0)
+                                      file/0 (%.format dir / name/0)
+                                      file/1 (%.format dir / name/1)]
+                                _ (at fs write file/0 content/0)
+                                _ (at fs write file/1 content/1)
+                                pre (at fs directory_files dir)
+                                _ (/.purge! fs context id/0)
+                                post (at fs directory_files dir)]
+                               (_.coverage' [/.purge!]
+                                 (<| (try.else false)
+                                     (do try.monad
+                                       [pre pre]
+                                       (in (and (at set.equivalence =
+                                                    (set.of_list text.hash pre)
+                                                    (set.of_list text.hash (list file/0 file/1)))
+                                                (case post
+                                                  {try.#Failure error}
+                                                  (exception.match? file.cannot_find_directory error)
+
+                                                  success
+                                                  false))))))))
+                         ))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cli.lux b/stdlib/source/test/lux/meta/compiler/meta/cli.lux
new file mode 100644
index 000000000..28bc83c3b
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cli.lux
@@ -0,0 +1,143 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["<>" parser]
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" product]
+    ["[0]" text]
+    [collection
+     ["[0]" list (.use "[1]#[0]" monoid monad)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" configuration (.use "[1]#[0]" equivalence)
+     ["$[1]" \\test]]]
+   ["[0]" program
+    ["<[1]>" \\parser]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["[1][0]" compiler (.only Compiler)]]]
+ ["$[0]" /
+  ["[1][0]" compiler]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Service /.service])
+      (let [(open "list#[0]") (list.equivalence text.equivalence)])
+      (do [! random.monad]
+        [amount (at ! each (|>> (n.% 5) ++) random.nat)
+         sources (random.list amount (random.lower_case 1))
+         host_dependencies (random.list amount (random.lower_case 2))
+         libraries (random.list amount (random.lower_case 3))
+         target (random.lower_case 4)
+         module (random.lower_case 5)
+         compilers (random.list amount $/compiler.random)
+         configuration ($configuration.random 5)
+         .let [compilation' (all list#composite
+                                 (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies))
+                                 (list#conjoint (list#each (|>> (list "--library")) libraries))
+                                 (list#conjoint (list#each (|>> /compiler.format (list "--compiler")) compilers))
+                                 (list#conjoint (list#each (|>> (list "--source")) sources))
+                                 (list "--target" target
+                                       "--module" module
+                                       "--configuration" (configuration.format configuration)))
+               export (all list#composite
+                           (list#conjoint (list#each (|>> (list "--source")) sources))
+                           (list "--target" target))]]
+        (all _.and
+             (_.for [/.Compilation]
+                    (`` (all _.and
+                             (,, (with_template [  ]
+                                   [(_.coverage []
+                                      (|> (list.partial "build" compilation')
+                                          (.result /.service)
+                                          (try#each (|>> (pipe.case
+                                                           {/.#Compilation it}
+                                                           (|> it
+                                                               (the )
+                                                               )
+                                                           
+                                                           _
+                                                           false)))
+                                          (try.else false)))]
+
+                                   [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)]
+                                   [/.Library /.#libraries (list#= libraries)]
+                                   [/compiler.Compiler /.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
+                                   [/.Source /.#sources (list#= sources)]
+                                   [/.Target /.#target (same? target)]
+                                   [/.Module /.#module (same? module)]
+                                   [configuration.Configuration /.#configuration (configuration#= configuration)]
+                                   ))
+                             )))
+             (_.coverage [/.Interpretation]
+               (`` (and (,, (with_template [ ]
+                              [(|> (list.partial "repl" compilation')
+                                   (.result /.service)
+                                   (try#each (|>> (pipe.case
+                                                    {/.#Interpretation it}
+                                                    (|> it
+                                                        (the )
+                                                        )
+                                                    
+                                                    _
+                                                    false)))
+                                   (try.else false))]
+
+                              [/.#host_dependencies (list#= host_dependencies)]
+                              [/.#libraries (list#= libraries)]
+                              [/.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
+                              [/.#sources (list#= sources)]
+                              [/.#target (same? target)]
+                              [/.#module (same? module)]
+                              [/.#configuration (configuration#= configuration)]
+                              )))))
+             (_.coverage [/.Export]
+               (`` (and (,, (with_template [ ]
+                              [(|> (list.partial "export" export)
+                                   (.result /.service)
+                                   (try#each (|>> (pipe.case
+                                                    {/.#Export it}
+                                                    (|> it
+                                                        
+                                                        )
+                                                    
+                                                    _
+                                                    false)))
+                                   (try.else false))]
+
+                              [product.left (list#= sources)]
+                              [product.right (same? target)]
+                              )))))
+             (_.coverage [/.target]
+               (`` (and (,, (with_template []
+                              [(same? target (/.target ))]
+
+                              [{/.#Compilation [/.#host_dependencies host_dependencies
+                                                /.#libraries libraries
+                                                /.#compilers compilers
+                                                /.#sources sources
+                                                /.#target target
+                                                /.#module module
+                                                /.#configuration configuration]}]
+                              [{/.#Interpretation [/.#host_dependencies host_dependencies
+                                                   /.#libraries libraries
+                                                   /.#compilers compilers
+                                                   /.#sources sources
+                                                   /.#target target
+                                                   /.#module module
+                                                   /.#configuration configuration]}]
+                              [{/.#Export [sources target]}]
+                              )))))
+
+             $/compiler.test
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/cli/compiler.lux b/stdlib/source/test/lux/meta/compiler/meta/cli/compiler.lux
new file mode 100644
index 000000000..66a7997d5
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/cli/compiler.lux
@@ -0,0 +1,49 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]]]
+   [control
+    ["[0]" try (.use "[1]#[0]" functor)]]
+   [data
+    ["[0]" text
+     ["<[1]>" \\parser]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" symbol
+     ["$[1]" \\test]]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Compiler)
+  (do [! random.monad]
+    [definition ($symbol.random 1 1)
+     amount (at ! each (n.% 5) random.nat)
+     parameters (random.list amount (random.lower_case 2))]
+    (in [/.#definition definition
+         /.#parameters parameters])))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Compiler])
+      (do [! random.monad]
+        [expected ..random]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec /.equivalence ..random))
+
+             (_.coverage [/.format /.parser]
+               (|> expected
+                   /.format
+                   (.result /.parser)
+                   (try#each (at /.equivalence = expected))
+                   (try.else false)))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/context.lux b/stdlib/source/test/lux/meta/compiler/meta/context.lux
new file mode 100644
index 000000000..d6ecdceec
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/context.lux
@@ -0,0 +1,56 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [data
+    ["[0]" text]
+    [collection
+     ["[0]" set]
+     ["[0]" list (.use "[1]#[0]" functor)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Context)
+  (do [! random.monad]
+    [context (all random.either
+                  (in /.js)
+                  (in /.jvm)
+                  (in /.lua)
+                  (in /.python)
+                  (in /.ruby))]
+    (at ! each context (random.lower_case 1))))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Context /.Extension])
+      (do [! random.monad]
+        [target (random.lower_case 1)]
+        (all _.and
+             (_.coverage [/.js /.jvm /.lua /.python /.ruby]
+               (let [contexts (list (/.js target)
+                                    (/.jvm target)
+                                    (/.lua target)
+                                    (/.python target)
+                                    (/.ruby target))
+                     maximum (list.size contexts)]
+                 (`` (and (,, (with_template [ ]
+                                [(|> contexts
+                                     (list#each (the ))
+                                     (set.of_list text.hash)
+                                     set.size
+                                     (n.= ))]
+
+                                [maximum /.#host]
+                                [maximum /.#host_module_extension]
+                                [maximum /.#artifact_extension]
+                                [1 /.#target]
+                                ))))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/export.lux b/stdlib/source/test/lux/meta/compiler/meta/export.lux
new file mode 100644
index 000000000..d9fb14ace
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/export.lux
@@ -0,0 +1,120 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    [concurrency
+     ["[0]" async]]]
+   [data
+    ["[0]" product]
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    [format
+     ["[0]" tar]]
+    ["[0]" binary (.only Binary) (.use "[1]#[0]" equivalence)
+     ["<[1]>" \\parser]]
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format (.only format)]
+     [encoding
+      ["[0]" utf8]]]
+    [collection
+     ["[0]" sequence]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" / (.only)
+   [//
+    ["[0]" io
+     ["[1]" context]]]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (do [! random.monad]
+        [.let [/ .module_separator]
+         source/0 (random.lower_case 1)
+         source/1 (random.lower_case 2)
+         target (random.lower_case 3)
+
+         .let [random_file (is (Random file.Path)
+                               (at ! each (text.suffix io.lux_extension) (random.lower_case 4)))]
+         file/0' random_file
+         .let [file/0 (format source/0 / file/0')]
+         
+         dir/0 (random.lower_case 5)
+         file/1' (at ! each (|>> (format dir/0 /)) random_file)
+         .let [file/1 (format source/1 / file/1')]
+         
+         .let [random_content (is (Random Binary)
+                                  (at ! each (|>> %.nat (at utf8.codec encoded)) random.nat))]
+         content/0 random_content
+         content/1 random_content]
+        (all _.and
+             (in (do [! async.monad]
+                   [it (do (try.with !)
+                         [.let [fs (file.mock /)]
+                          _ (at fs make_directory source/0)
+                          _ (at fs write file/0 content/0)
+                          
+                          _ (at fs make_directory source/1)
+                          _ (at fs make_directory (format source/1 / dir/0))
+                          _ (at fs write file/1 content/1)
+
+                          _ (at fs make_directory target)
+                          library_tar (/.library fs (list source/0 source/1))
+                          _ (/.export fs [(list source/0 source/1) target])
+                          export_tar (at fs read (format target / /.file))
+                          export_tar (at ! in (.result tar.parser export_tar))]
+                         (in [library_tar export_tar]))]
+                   (all _.and'
+                        (_.coverage' [/.library /.mode /.ownership]
+                          (|> it
+                              (try#each (|>> product.left
+                                             sequence.list
+                                             (pipe.case
+                                               (list {tar.#Normal [actual_path/0 when/0 mode/0 ownership/0 actual_content/0]}
+                                                     {tar.#Normal [actual_path/1 when/1 mode/1 ownership/1 actual_content/1]})
+                                               (with_expansions [ (and (and (text#= file/0' (tar.from_path actual_path/0))
+                                                                                  (same? /.mode mode/0)
+                                                                                  (same? /.ownership ownership/0)
+                                                                                  (binary#= content/0 (tar.data actual_content/0)))
+                                                                             (and (text#= file/1' (tar.from_path actual_path/1))
+                                                                                  (same? /.mode mode/1)
+                                                                                  (same? /.ownership ownership/1)
+                                                                                  (binary#= content/1 (tar.data actual_content/1))))]
+                                                 (or 
+                                                     (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+                                                           [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+                                                       )))
+                                               
+                                               _
+                                               false)))
+                              (try.else false)))
+                        (_.coverage' [/.export /.file]
+                          (|> it
+                              (try#each (|>> product.right
+                                             sequence.list
+                                             (pipe.case
+                                               (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
+                                                     {tar.#Normal [actual_path/1 _ _ _ actual_content/1]})
+                                               (with_expansions [ (and (and (text#= file/0' (tar.from_path actual_path/0))
+                                                                                  (binary#= content/0 (tar.data actual_content/0)))
+                                                                             (and (text#= file/1' (tar.from_path actual_path/1))
+                                                                                  (binary#= content/1 (tar.data actual_content/1))))]
+                                                 (or 
+                                                     (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+                                                           [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+                                                       )))
+                                               
+                                               _
+                                               false)))
+                              (try.else false)))
+                        )))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/meta/import.lux b/stdlib/source/test/lux/meta/compiler/meta/import.lux
new file mode 100644
index 000000000..fc2e79616
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/meta/import.lux
@@ -0,0 +1,156 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [control
+    ["[0]" maybe (.use "[1]#[0]" functor)]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception]
+    [concurrency
+     ["[0]" async]]]
+   [data
+    ["[0]" product]
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" binary (.only Binary) (.use "[1]#[0]" equivalence)
+     ["[0]" \\format]
+     ["<[1]>" \\parser]]
+    ["[0]" format
+     ["[0]" tar (.only Tar)]]
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format (.only format)]
+     [encoding
+      ["[0]" utf8]]]
+    [collection
+     ["[0]" sequence]
+     ["[0]" dictionary]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [world
+    ["[0]" file]]]]
+ [\\library
+  ["[0]" / (.only)
+   [//
+    ["[0]" export]
+    ["[0]" io
+     ["[1]" context]]]]])
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Import])
+      (do [! random.monad]
+        [library/0 (random.lower_case 1)
+         library/1 (random.lower_case 2)
+         
+         .let [/ .module_separator
+               random_file (is (Random file.Path)
+                               (at ! each (text.suffix io.lux_extension) (random.lower_case 3)))]
+         file/0 random_file
+         
+         dir/0 (random.lower_case 4)
+         file/1 (at ! each (|>> (format dir/0 /)) random_file)
+         
+         .let [random_content (is (Random Binary)
+                                  (at ! each (|>> %.nat (at utf8.codec encoded)) random.nat))]
+         now random.instant
+         content/0 random_content
+         content/1 random_content
+         .let [library_content (|> (do try.monad
+                                     [file/0 (tar.path file/0)
+                                      file/1 (tar.path file/1)
+                                      content/0 (tar.content content/0)
+                                      content/1 (tar.content content/1)]
+                                     (in (|> (sequence.sequence {tar.#Normal [file/0 now export.mode export.ownership content/0]}
+                                                                {tar.#Normal [file/1 now export.mode export.ownership content/1]})
+                                             (\\format.result tar.format))))
+                                   (try.else (binary.empty 0)))
+               library_content/0 (|> (do try.monad
+                                       [file/0 (tar.path file/0)
+                                        content/0 (tar.content content/0)]
+                                       (in (|> (sequence.sequence {tar.#Normal [file/0 now export.mode export.ownership content/0]})
+                                               (\\format.result tar.format))))
+                                     (try.else (binary.empty 0)))
+               library_content/1 (|> (do try.monad
+                                       [file/1 (tar.path file/1)
+                                        content/1 (tar.content content/1)]
+                                       (in (|> (sequence.sequence {tar.#Normal [file/1 now export.mode export.ownership content/1]})
+                                               (\\format.result tar.format))))
+                                     (try.else (binary.empty 0)))
+               library_content/-0 (|> (do try.monad
+                                        [file/0 (tar.path file/0)
+                                         content/0 (tar.content content/0)]
+                                        (in (|> (sequence.sequence {tar.#Contiguous [file/0 now export.mode export.ownership content/0]})
+                                                (\\format.result tar.format))))
+                                      (try.else (binary.empty 0)))
+               library_content/-1 (|> (do try.monad
+                                        [file/0 (tar.path file/0)]
+                                        (in (|> (sequence.sequence {tar.#Symbolic_Link file/0})
+                                                (\\format.result tar.format))))
+                                      (try.else (binary.empty 0)))
+               library_content/-2 (|> (do try.monad
+                                        [file/0 (tar.path file/0)]
+                                        (in (|> (sequence.sequence {tar.#Directory file/0})
+                                                (\\format.result tar.format))))
+                                      (try.else (binary.empty 0)))
+               imported? (is (-> /.Import Bit)
+                             (function (_ it)
+                               (and (n.= 2 (dictionary.size it))
+                                    (|> it
+                                        (dictionary.value file/0)
+                                        (maybe#each (binary#= content/0))
+                                        (maybe.else false))
+                                    (|> it
+                                        (dictionary.value file/1)
+                                        (maybe#each (binary#= content/1))
+                                        (maybe.else false)))))]]
+        (all _.and
+             (in (do [! async.monad]
+                   [it/0 (do (try.with !)
+                           [.let [fs (file.mock /)]
+                            _ (at fs write library/0 library_content)]
+                           (/.import fs (list library/0)))
+                    it/1 (do (try.with !)
+                           [.let [fs (file.mock /)]
+                            _ (at fs write library/0 library_content/0)
+                            _ (at fs write library/1 library_content/1)]
+                           (/.import fs (list library/0 library/1)))]
+                   (_.coverage' [/.import]
+                     (and (|> it/0
+                              (try#each imported?)
+                              (try.else false))
+                          (|> it/1
+                              (try#each imported?)
+                              (try.else false))))))
+             (in (do [! async.monad]
+                   [it (do (try.with !)
+                         [.let [fs (file.mock /)]
+                          _ (at fs write library/0 library_content)
+                          _ (/.import fs (list library/0 library/0))]
+                         (in false))]
+                   (_.coverage' [/.duplicate]
+                     (exception.otherwise (exception.match? /.duplicate) it))))
+             (in (do [! async.monad]
+                   [it/0 (do (try.with !)
+                           [.let [fs (file.mock /)]
+                            _ (at fs write library/0 library_content/-0)
+                            _ (/.import fs (list library/0))]
+                           (in false))
+                    it/1 (do (try.with !)
+                           [.let [fs (file.mock /)]
+                            _ (at fs write library/0 library_content/-1)
+                            _ (/.import fs (list library/0))]
+                           (in false))
+                    it/2 (do (try.with !)
+                           [.let [fs (file.mock /)]
+                            _ (at fs write library/0 library_content/-2)
+                            _ (/.import fs (list library/0))]
+                           (in false))]
+                   (_.coverage' [/.useless_tar_entry]
+                     (and (exception.otherwise (exception.match? /.useless_tar_entry) it/0)
+                          (exception.otherwise (exception.match? /.useless_tar_entry) it/1)
+                          (exception.otherwise (exception.match? /.useless_tar_entry) it/2)))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/phase.lux b/stdlib/source/test/lux/meta/compiler/phase.lux
new file mode 100644
index 000000000..39ee0604b
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/phase.lux
@@ -0,0 +1,206 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" functor (.only Injection Comparison)]
+     ["$[0]" monad]]]
+   [control
+    ["[0]" pipe]
+    ["[0]" try (.use "[1]#[0]" functor)]
+    ["[0]" exception (.only exception)]]
+   [data
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format (.only format)]]]
+   [math
+    ["[0]" random]
+    [number
+     ["n" nat]
+     ["i" int]]]]]
+ [\\library
+  ["[0]" / (.only)
+   [//
+    [meta
+     ["[0]" archive]]]]])
+
+(def (injection value)
+  (All (_ s) (Injection (/.Operation s)))
+  (function (_ state)
+    {try.#Success [state value]}))
+
+(def (comparison init)
+  (All (_ s) (-> s (Comparison (/.Operation s))))
+  (function (_ == left right)
+    (case [(/.result init left)
+           (/.result init right)]
+      [{try.#Success left}
+       {try.#Success right}]
+      (== left right)
+
+      _
+      false)))
+
+(exception oops)
+
+(def test|error
+  Test
+  (do [! random.monad]
+    [state random.nat
+     expected random.int
+     expected_error (random.lower_case 1)]
+    (all _.and
+         (_.coverage [/.failure]
+           (|> (/.failure expected_error)
+               (/.result state)
+               (pipe.case {try.#Failure actual_error}
+                 (same? expected_error actual_error)
+
+                 _
+                 false)))
+         (_.coverage [/.lifted]
+           (and (|> (/.lifted {try.#Failure expected_error})
+                    (/.result state)
+                    (pipe.case {try.#Failure actual_error}
+                      (same? expected_error actual_error)
+
+                      _
+                      false))
+                (|> (/.lifted {try.#Success expected})
+                    (at /.functor each (same? expected))
+                    (/.result state)
+                    (try.else false))))
+         (_.coverage [/.except]
+           (|> (/.except ..oops [])
+               (/.result state)
+               (pipe.case {try.#Failure error}
+                 (exception.match? ..oops error)
+
+                 _
+                 false)))
+         (_.coverage [/.assertion]
+           (and (|> (/.assertion ..oops [] false)
+                    (/.result state)
+                    (pipe.case {try.#Failure error}
+                      (exception.match? ..oops error)
+
+                      _
+                      false))
+                (|> (/.assertion ..oops [] true)
+                    (/.result state)
+                    (pipe.case {try.#Success _}
+                      true
+
+                      _
+                      false))))
+         )))
+
+(def test|state
+  Test
+  (do [! random.monad]
+    [state random.nat
+     dummy random.nat
+     expected random.int]
+    (all _.and
+         (_.coverage [/.state]
+           (|> /.state
+               (at /.functor each (same? state))
+               (/.result state)
+               (try.else false)))
+         (_.coverage [/.with]
+           (|> (do /.monad
+                 [_ (/.with state)]
+                 /.state)
+               (at /.functor each (same? state))
+               (/.result dummy)
+               (try.else false)))
+         (_.coverage [/.sub]
+           (|> (/.sub [(at n.hex encoded)
+                       (function (_ new old)
+                         (|> new (at n.hex decoded) (try.else dummy)))]
+                      (do /.monad
+                        [state/hex /.state]
+                        (in (|> state
+                                (at n.hex encoded)
+                                (text#= state/hex)))))
+               (/.result' state)
+               (pipe.case {try.#Success [state' verdict]}
+                 (and verdict
+                      (n.= state state'))
+
+                 _
+                 false)))
+         )))
+
+(def test|operation
+  Test
+  (do [! random.monad]
+    [state random.nat
+     expected random.int]
+    (all _.and
+         (_.for [/.functor]
+                ($functor.spec ..injection (..comparison state) /.functor))
+         (_.for [/.monad]
+                ($monad.spec ..injection (..comparison state) /.monad))
+
+         (_.coverage [/.result]
+           (|> (at /.monad in expected)
+               (/.result state)
+               (pipe.case {try.#Success actual}
+                 (same? expected actual)
+
+                 _
+                 false)))
+         (_.coverage [/.result']
+           (|> (at /.monad in expected)
+               (/.result' state)
+               (pipe.case {try.#Success [state' actual]}
+                 (and (same? state state')
+                      (same? expected actual))
+
+                 _
+                 false)))
+         ..test|state
+         ..test|error
+         )))
+
+(def test|phase
+  Test
+  (do [! random.monad]
+    [state/0 random.nat
+     state/1 random.rev
+     expected random.int]
+    (all _.and
+         (_.coverage [/.identity]
+           (|> (/.identity archive.empty expected)
+               (/.result state/0)
+               (try#each (same? expected))
+               (try.else false)))
+         (_.coverage [/.composite]
+           (let [phase (/.composite (is (/.Phase Nat Int Frac)
+                                        (function (_ archive input)
+                                          (at /.monad in (i.frac input))))
+                                    (is (/.Phase Rev Frac Text)
+                                        (function (_ archive input)
+                                          (at /.monad in (%.frac input)))))]
+             (|> (phase archive.empty expected)
+                 (/.result' [state/0 state/1])
+                 (pipe.case {try.#Success [[state/0' state/1'] actual]}
+                   (and (text#= (%.frac (i.frac expected)) actual)
+                        (same? state/0 state/0')
+                        (same? state/1 state/1'))
+
+                   _
+                   false))))
+         )))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (all _.and
+           (_.for [/.Operation]
+                  ..test|operation)
+           (_.for [/.Phase]
+                  ..test|phase)
+           )))
diff --git a/stdlib/source/test/lux/meta/compiler/reference.lux b/stdlib/source/test/lux/meta/compiler/reference.lux
new file mode 100644
index 000000000..6f247179c
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/reference.lux
@@ -0,0 +1,95 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]
+   [meta
+    ["[0]" symbol (.use "[1]#[0]" equivalence)]]]]
+ [\\library
+  ["[0]" / (.only)
+   ["[0]" variable (.only Register)]]]
+ ["[0]" /
+  ["[1][0]" variable]])
+
+(def constant
+  (Random /.Constant)
+  (all random.and
+       (random.upper_case 5)
+       (random.lower_case 5)
+       ))
+
+(def .public random
+  (Random /.Reference)
+  (all random.or
+       /variable.random
+       ..constant
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Reference /.Constant])
+      (do random.monad
+        [expected_register random.nat
+         expected_constant ..constant])
+      (`` (all _.and
+               (_.for [/.equivalence]
+                      ($equivalence.spec /.equivalence ..random))
+               (_.for [/.hash]
+                      ($hash.spec /.hash ..random))
+
+               (,, (with_template []
+                     [(_.coverage []
+                        (case ( expected_register)
+                          ( actual_register)
+                          (n.= expected_register actual_register)
+
+                          _
+                          false))]
+
+                     [/.local]
+                     [/.foreign]
+                     ))
+
+               (_.coverage [/.variable /.self]
+                 (and (at /.equivalence = (/.self) (/.variable (variable.self)))
+                      (case (/.self)
+                        (/.self)
+                        true
+                        
+                        _
+                        false)
+                      (case (/.variable (variable.self))
+                        (/.self)
+                        true
+                        
+                        _
+                        false)))
+               (_.coverage [/.constant]
+                 (case (/.constant expected_constant)
+                   (/.constant actual_constant)
+                   (symbol#= expected_constant actual_constant)
+
+                   _
+                   false))
+               (_.coverage [/.format]
+                 (and (text#= (/.format (/.local expected_register))
+                              (variable.format {variable.#Local expected_register}))
+                      (text#= (/.format (/.foreign expected_register))
+                              (variable.format {variable.#Foreign expected_register}))
+                      (text#= (/.format (/.constant expected_constant))
+                              (%.symbol expected_constant))))
+               
+               /variable.test
+               ))))
diff --git a/stdlib/source/test/lux/meta/compiler/reference/variable.lux b/stdlib/source/test/lux/meta/compiler/reference/variable.lux
new file mode 100644
index 000000000..f2b219b86
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/reference/variable.lux
@@ -0,0 +1,45 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]
+    [\\specification
+     ["$[0]" equivalence]
+     ["$[0]" hash]]]
+   [data
+    ["[0]" text (.use "[1]#[0]" equivalence)]]
+   [math
+    ["[0]" random (.only Random)]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Variable)
+  (all random.or
+       random.nat
+       random.nat
+       ))
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Variable])
+      (do [! random.monad]
+        [register random.nat]
+        (all _.and
+             (_.for [/.equivalence]
+                    ($equivalence.spec /.equivalence ..random))
+             (_.for [/.hash]
+                    ($hash.spec /.hash ..random))
+             (_.coverage [/.self]
+               (case (/.self)
+                 (/.self) true
+                 _ false))
+             (_.coverage [/.self?]
+               (/.self? (/.self)))
+             (_.for [/.Register]
+                    (_.coverage [/.format]
+                      (not (text#= (/.format {/.#Local register})
+                                   (/.format {/.#Foreign register})))))
+             ))))
diff --git a/stdlib/source/test/lux/meta/compiler/version.lux b/stdlib/source/test/lux/meta/compiler/version.lux
new file mode 100644
index 000000000..24e40bd56
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/version.lux
@@ -0,0 +1,41 @@
+(.require
+ [library
+  [lux (.except)
+   ["_" test (.only Test)]
+   [abstract
+    [monad (.only do)]]
+   [data
+    ["[0]" bit (.use "[1]#[0]" equivalence)]
+    ["[0]" text (.use "[1]#[0]" equivalence)
+     ["%" \\format (.only format)]]]
+   [math
+    ["[0]" random (.only Random)]
+    [number
+     ["n" nat]]]]]
+ [\\library
+  ["[0]" /]])
+
+(def .public random
+  (Random /.Version)
+  random.nat)
+
+(def .public test
+  Test
+  (<| (_.covering /._)
+      (_.for [/.Version])
+      (do [! random.monad]
+        [this ..random
+         that ..random]
+        (`` (all _.and
+                 (_.coverage [/.format]
+                   (bit#= (n.= this that)
+                          (text#= (/.format this) (/.format that))))
+                 (,, (with_template []
+                       [(_.coverage []
+                          (text.contains? (%.nat ( this))
+                                          (/.format this)))]
+
+                       [/.patch]
+                       [/.minor]
+                       [/.major]))
+                 )))))
diff --git a/stdlib/source/test/lux/meta/target/ruby.lux b/stdlib/source/test/lux/meta/target/ruby.lux
index d8c7d1605..627303a41 100644
--- a/stdlib/source/test/lux/meta/target/ruby.lux
+++ b/stdlib/source/test/lux/meta/target/ruby.lux
@@ -27,7 +27,7 @@
      ["i" int]
      ["f" frac]
      ["[0]" i64]]]
-   [tool
+   [meta
     [compiler
      [meta
       ["[0]" packager
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
deleted file mode 100644
index 8f0d06503..000000000
--- a/stdlib/source/test/lux/tool.lux
+++ /dev/null
@@ -1,49 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]]]
- ["[0]" /
-  [compiler
-   ["[1][0]" arity]
-   ["[1][0]" version]
-   ["[1][0]" reference]
-   ["[1][0]" phase]
-   [language
-    [lux
-     ... ["[1][0]" syntax]
-     ["[1][0]" analysis]
-     ["[1][0]" synthesis]
-     ["[1][0]" phase
-      ["[1]/[0]" extension]
-      ["[1]/[0]" analysis]
-      ... ["[1]/[0]" synthesis]
-      ]]]
-   ["[1][0]" meta
-    ["[1]/[0]" archive]
-    ["[1]/[0]" cli]
-    ["[1]/[0]" export]
-    ["[1]/[0]" import]
-    ["[1]/[0]" context]
-    ["[1]/[0]" cache]]
-   ]])
-
-(def .public test
-  Test
-  (all _.and
-       /arity.test
-       /version.test
-       /reference.test
-       /phase.test
-       /analysis.test
-       /synthesis.test
-       /meta/archive.test
-       /meta/cli.test
-       /meta/export.test
-       /meta/import.test
-       /meta/context.test
-       /meta/cache.test
-       /phase/extension.test
-       /phase/analysis.test
-       ... /syntax.test
-       ... /synthesis.test
-       ))
diff --git a/stdlib/source/test/lux/tool/compiler/arity.lux b/stdlib/source/test/lux/tool/compiler/arity.lux
deleted file mode 100644
index ffff0f3e6..000000000
--- a/stdlib/source/test/lux/tool/compiler/arity.lux
+++ /dev/null
@@ -1,29 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Arity])
-      (do [! random.monad]
-        [arity (at ! each (n.% 3) random.nat)]
-        (all _.and
-             (_.coverage [/.nullary?]
-               (bit#= (n.= 0 arity) (/.nullary? arity)))
-             (_.coverage [/.unary?]
-               (bit#= (n.= 1 arity) (/.unary? arity)))
-             (_.coverage [/.multiary?]
-               (bit#= (n.>= 2 arity) (/.multiary? arity)))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
deleted file mode 100644
index a42a76432..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
+++ /dev/null
@@ -1,628 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   ["[0]" static]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["<>" parser]
-    ["[0]" pipe]
-    ["[0]" try]
-    ["[0]" exception (.only exception)]
-    ["[0]" function]
-    ["[0]" maybe]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]
-    [collection
-     ["[0]" list]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat]
-     ["i" int]
-     ["f" frac]
-     ["r" rev]]]
-   [meta
-    ["[0]" symbol (.use "[1]#[0]" equivalence)]
-    [macro
-     ["[0]" template]]
-    ["[0]" configuration
-     ["$[1]" \\test]]]
-   [tool
-    [compiler
-     [reference (.only Constant)
-      [variable (.only)]]]]]]
- ["[0]" \\parser]
- [\\library
-  ["[0]" / (.only)
-   [//
-    [phase
-     ["[0]" extension]]
-    [///
-     ["[0]" phase]
-     ["[0]" version]]]]]
- ["[0]" /
-  ["[1][0]" complex]
-  ["[1][0]" inference]
-  ["[1][0]" macro]
-  ["[1][0]" module]
-  ["[1][0]" pattern]
-  ["[1][0]" scope]
-  ["[1][0]" simple]
-  ["[1][0]" type]
-  ["[1][0]" coverage]
-  [////
-   ["[1][0]" reference (.only)
-    ["[2][0]" variable]]
-   [///
-    [meta
-     ["[1][0]" symbol]
-     ["[0]" location
-      ["[2][1]" /]
-      ["[1]" \\library (.use "[1]#[0]" equivalence)]]]]]])
-
-(def !expect
-  (template (_  )
-    [(case 
-       
-       true
-
-       _
-       false)]))
-
-(def constant
-  (Random Constant)
-  (random.and (random.unicode 10)
-              (random.unicode 10)))
-
-(def \\parser
-  Test
-  (<| (_.covering \\parser._)
-      (_.for [\\parser.Parser])
-      (do [! random.monad]
-        []
-        (`` (all _.and
-                 (do [! random.monad]
-                   [expected (at ! each (|>> /.bit) random.bit)]
-                   (_.coverage [\\parser.result \\parser.any]
-                     (|> (list expected)
-                         (\\parser.result \\parser.any)
-                         (pipe.case
-                           {try.#Success actual}
-                           (at /.equivalence = expected actual)
-
-                           {try.#Failure _}
-                           false))))
-                 (,, (with_template [    <=>]
-                       [(do [! random.monad]
-                          [expected ]
-                          (_.coverage []
-                            (|> (list ( expected))
-                                (\\parser.result )
-                                (pipe.case
-                                  {try.#Success actual}
-                                  (<=> expected actual)
-
-                                  {try.#Failure _}
-                                  false))))
-                        (do [! random.monad]
-                          [expected ]
-                          (_.coverage []
-                            (|> (list ( expected))
-                                (\\parser.result ( expected))
-                                (!expect {try.#Success _}))))]
-                       
-                       [\\parser.bit \\parser.this_bit random.bit /.bit bit#=]
-                       [\\parser.nat \\parser.this_nat random.nat /.nat n.=]
-                       [\\parser.int \\parser.this_int random.int /.int i.=]
-                       [\\parser.frac \\parser.this_frac random.safe_frac /.frac f.=]
-                       [\\parser.rev \\parser.this_rev random.rev /.rev r.=]
-                       [\\parser.text \\parser.this_text (random.unicode 10) /.text text#=]
-                       [\\parser.local \\parser.this_local random.nat /.local n.=]
-                       [\\parser.foreign \\parser.this_foreign random.nat /.foreign n.=]
-                       [\\parser.constant \\parser.this_constant ..constant /.constant symbol#=]
-                       ))
-                 (do [! random.monad]
-                   [expected random.bit]
-                   (_.coverage [\\parser.tuple]
-                     (|> (list (/.tuple (list (/.bit expected))))
-                         (\\parser.result (\\parser.tuple \\parser.bit))
-                         (pipe.case
-                           {try.#Success actual}
-                           (bit#= expected actual)
-
-                           {try.#Failure _}
-                           false))))
-                 (do [! random.monad]
-                   [dummy random.bit]
-                   (_.coverage [\\parser.end?]
-                     (and (|> (\\parser.result \\parser.end? (list))
-                              (!expect {try.#Success #1}))
-                          (|> (\\parser.result (do <>.monad
-                                                 [verdict \\parser.end?
-                                                  _ \\parser.bit]
-                                                 (in verdict))
-                                               (list (/.bit dummy)))
-                              (!expect {try.#Success #0})))))
-                 (do [! random.monad]
-                   [dummy random.bit]
-                   (_.coverage [\\parser.end]
-                     (and (|> (\\parser.result \\parser.end (list))
-                              (!expect {try.#Success _}))
-                          (|> (\\parser.result \\parser.end (list (/.bit dummy)))
-                              (!expect {try.#Failure _})))))
-                 (do [! random.monad]
-                   [expected random.bit]
-                   (_.coverage [\\parser.cannot_parse]
-                     (and (|> (list (/.bit expected))
-                              (\\parser.result \\parser.nat)
-                              (pipe.case
-                                {try.#Success _}
-                                false
-
-                                {try.#Failure error}
-                                (exception.match? \\parser.cannot_parse error)))
-                          (|> (list)
-                              (\\parser.result \\parser.bit)
-                              (pipe.case
-                                {try.#Success _}
-                                false
-
-                                {try.#Failure error}
-                                (exception.match? \\parser.cannot_parse error))))))
-                 (do [! random.monad]
-                   [expected random.bit]
-                   (_.coverage [\\parser.unconsumed_input]
-                     (|> (list (/.bit expected) (/.bit expected))
-                         (\\parser.result \\parser.bit)
-                         (pipe.case
-                           {try.#Success _}
-                           false
-
-                           {try.#Failure error}
-                           (exception.match? \\parser.unconsumed_input error)))))
-                 )))))
-
-(def (random_branch random)
-  (All (_ a) (-> (Random a) (Random (/.Branch' a))))
-  (all random.and
-       /pattern.random
-       random
-       ))
-
-(def (random_match multiplicity random)
-  (All (_ a) (-> Nat (Random a) (Random (/.Match' a))))
-  (all random.and
-       (..random_branch random)
-       (random.list multiplicity (..random_branch random))
-       ))
-
-(def .public (random multiplicity)
-  (-> Nat (Random /.Analysis))
-  (<| random.rec
-      (function (_ random))
-      (let [random|case (all random.and
-                             random
-                             (..random_match multiplicity random)
-                             )
-            random|function (all random.and
-                                 (random.list multiplicity random)
-                                 random
-                                 )
-            random|apply (all random.and
-                              random
-                              random
-                              )
-            random|extension (all random.and
-                                  (random.lower_case 1)
-                                  (random.list multiplicity random)
-                                  )])
-      (all random.or
-           /simple.random
-           (/complex.random multiplicity random)
-           /reference.random
-           random|case
-           random|function
-           random|apply
-           random|extension
-           )))
-
-(def test|simple
-  Test
-  (do random.monad
-    [bit random.bit
-     nat random.nat
-     int random.int
-     rev random.rev
-     frac random.frac
-     text (random.lower_case 1)]
-    (`` (all _.and
-             (_.coverage [/.unit]
-               (case (/.unit)
-                 (/.unit)
-                 true
-                 
-                 _
-                 false))
-             (,, (with_template [ ]
-                   [(_.coverage []
-                      (case ( )
-                        ( actual)
-                        (same?  actual)
-                        
-                        _
-                        false))]
-
-                   [/.bit bit]
-                   [/.nat nat]
-                   [/.int int]
-                   [/.rev rev]
-                   [/.frac frac]
-                   [/.text text]))
-             ))))
-
-(def test|complex
-  Test
-  (do random.monad
-    [expected_left (..random 2)
-     expected_right (..random 2)
-     expected_lefts random.nat
-     expected_right? random.bit]
-    (all _.and
-         (_.coverage [/.variant]
-           (let [expected (if expected_right?
-                            expected_right
-                            expected_left)]
-             (case (/.variant [expected_lefts expected_right? expected])
-               (/.variant [actual_lefts actual_right? actual])
-               (and (same? expected_lefts actual_lefts)
-                    (same? expected_right? actual_right?)
-                    (same? expected actual))
-
-               _
-               false)))
-         (_.coverage [/.tuple]
-           (case (/.tuple (list expected_left expected_right))
-             (/.tuple (list actual_left actual_right))
-             (and (same? expected_left actual_left)
-                  (same? expected_right actual_right))
-
-             _
-             false))
-         )))
-
-(def test|reference
-  Test
-  (do random.monad
-    [expected_register random.nat
-     expected_constant (/symbol.random 1 1)
-     expected_variable /variable.random]
-    (`` (all _.and
-             (,, (with_template [ ]
-                   [(_.coverage []
-                      (case ( )
-                        ( actual)
-                        (same?  actual)
-
-                        _
-                        false))]
-
-                   [/.local expected_register]
-                   [/.foreign expected_register]
-                   [/.constant expected_constant]
-                   [/.variable expected_variable]
-                   ))
-             ))))
-
-(def tagged?
-  (template (_  )
-    [(case 
-       { _}
-       true
-
-       _
-       false)]))
-
-(def test|reification
-  Test
-  (do random.monad
-    [expected_abstraction (random.only (|>> (..tagged? /.#Apply) not)
-                                       (..random 2))
-     expected_parameter/0 (..random 2)
-     expected_parameter/1 (..random 2)]
-    (all _.and
-         (_.coverage [/.reified /.reification]
-           (case (|> [expected_abstraction (list expected_parameter/0 expected_parameter/1)]
-                     /.reified
-                     /.reification)
-             [actual_abstraction (list actual_parameter/0 actual_parameter/1)]
-             (and (same? expected_abstraction actual_abstraction)
-                  (same? expected_parameter/0 actual_parameter/0)
-                  (same? expected_parameter/1 actual_parameter/1))
-
-             _
-             false))
-         (_.coverage [/.no_op]
-           (case (/.no_op expected_parameter/0)
-             (/.no_op actual)
-             (same? expected_parameter/0 actual)
-
-             _
-             false))
-         )))
-
-(def test|case
-  Test
-  (do random.monad
-    [expected_input (..random 2)
-     expected_match (random_match 2 (..random 2))]
-    (all _.and
-         (_.coverage [/.case]
-           (case (/.case [expected_input expected_match])
-             (/.case [actual_input actual_match])
-             (and (same? expected_input actual_input)
-                  (same? expected_match actual_match))
-
-             _
-             false))
-         )))
-
-(with_expansions [ (static.random_nat)
-                   (template.symbol ["exception_" ])]
-  (exception )
-
-  (def test|phase
-    Test
-    (do random.monad
-      [version/0 random.nat
-       host/0 (random.lower_case 5)
-       version/1 random.nat
-       host/1 (random.lower_case 5)
-       expected_error (random.lower_case 10)
-       location/0 /location.random
-       location/1 /location.random
-       configuration ($configuration.random 5)
-       .let [state/0 (has .#location location/0
-                          (/.state (/.info version/0 host/0 configuration)))
-             state/1 (has .#location location/1
-                          (/.state (/.info version/1 host/1 configuration)))]]
-      (all _.and
-           (_.coverage [/.set_state]
-             (|> (do phase.monad
-                   [pre (extension.read function.identity)
-                    _ (/.set_state state/1)
-                    post (extension.read function.identity)]
-                   (in (and (same? state/0 pre)
-                            (same? state/1 post))))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state/0])
-                 (try.else false)))
-           (_.coverage [/.failure]
-             (|> (/.failure expected_error)
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state/0])
-                 (pipe.case
-                   {try.#Failure actual_error}
-                   (and (text.contains? expected_error actual_error)
-                        (text.contains? (location.format location/0) actual_error))
-
-                   _
-                   false)))
-           (_.coverage [/.except]
-             (|> (/.except  [])
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state/0])
-                 (pipe.case
-                   {try.#Failure actual_error}
-                   (and (text.contains? (exception.error  []) actual_error)
-                        (text.contains? (location.format location/0) actual_error))
-
-                   _
-                   false)))
-           (_.coverage [/.with_exception]
-             (|> (/.failure expected_error)
-                 (/.with_exception  [])
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state/0])
-                 (pipe.case
-                   {try.#Failure actual_error}
-                   (and (text.contains? expected_error actual_error)
-                        (text.contains? (exception.error  []) actual_error)
-                        (text.contains? (location.format location/0) actual_error))
-
-                   _
-                   false)))
-           (_.coverage [/.assertion]
-             (and (|> (/.assertion  [] false)
-                      (phase.result [extension.#bundle extension.empty
-                                     extension.#state state/0])
-                      (pipe.case
-                        {try.#Failure actual_error}
-                        (and (text.contains? (exception.error  []) actual_error)
-                             (text.contains? (location.format location/0) actual_error))
-
-                        _
-                        false))
-                  (|> (/.assertion  [] true)
-                      (phase.result [extension.#bundle extension.empty
-                                     extension.#state state/0])
-                      (pipe.case
-                        {try.#Success _}
-                        true
-
-                        _
-                        false))))
-           ))))
-
-(def test|state
-  Test
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 5)
-
-     expected_module (random.lower_case 10)
-     dummy_module (random.lower_case 11)
-
-     location /location.random
-     
-     expected_file (random.lower_case 12)
-     expected_code (random.lower_case 13)
-
-     configuration ($configuration.random 5)
-     .let [state (has .#location location
-                      (/.state (/.info version host configuration)))]]
-    (all _.and
-         (_.coverage [/.info]
-           (let [it (/.info version host configuration)]
-             (and (text#= (version.format version)
-                          (the .#version it))
-                  (same? host
-                         (the .#target it))
-                  (..tagged? .#Build (the .#mode it))
-                  (same? configuration (the .#configuration it)))))
-         (_.coverage [/.state]
-           (let [info (/.info version host configuration)
-                 it (/.state info)]
-             (and (same? info
-                         (the .#info it))
-                  (same? location.dummy
-                         (the .#location it))
-                  (..tagged? .#None (the .#current_module it))
-                  (..tagged? .#None (the .#expected it))
-                  (list.empty? (the .#modules it))
-                  (list.empty? (the .#scopes it))
-                  (list.empty? (the [.#type_context .#var_bindings] it))
-                  (case (the .#source it)
-                    [location 0 ""]
-                    (same? location.dummy location)
-
-                    _
-                    false))))
-         (_.coverage [/.set_current_module]
-           (|> (do phase.monad
-                 [_ (/.set_current_module expected_module)]
-                 (extension.read (|>> (the .#current_module) (maybe.else ""))))
-               (phase.result [extension.#bundle extension.empty
-                              extension.#state state])
-               (pipe.case
-                 {try.#Success actual}
-                 (same? expected_module actual)
-
-                 _
-                 false)))
-         (_.coverage [/.with_current_module]
-           (let [current_module (extension.read (|>> (the .#current_module) (maybe.else "")))]
-             (|> (do phase.monad
-                   [_ (/.set_current_module expected_module)
-                    pre current_module
-                    mid (/.with_current_module dummy_module
-                          current_module)
-                    post current_module]
-                   (in (and (same? expected_module pre)
-                            (same? dummy_module mid)
-                            (same? expected_module post))))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state])
-                 (try.else false))))
-         (_.coverage [/.location /.set_location]
-           (let [expected (/.location expected_file)]
-             (|> (do phase.monad
-                   [_ (/.set_location expected)]
-                   (extension.read (the .#location)))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state])
-                 (pipe.case
-                   {try.#Success actual}
-                   (same? expected actual)
-
-                   _
-                   false))))
-         (_.coverage [/.with_location]
-           (let [expected (/.location expected_file)
-                 dummy (/.location expected_code)
-                 location (extension.read (the .#location))]
-             (|> (do phase.monad
-                   [_ (/.set_location expected)
-                    pre location
-                    mid (/.with_location dummy
-                          location)
-                    post location]
-                   (in (and (same? expected pre)
-                            (same? dummy mid)
-                            (same? expected post))))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state])
-                 (try.else false))))
-         (_.coverage [/.source /.set_source_code]
-           (let [expected (/.source expected_file expected_code)]
-             (|> (do phase.monad
-                   [_ (/.set_source_code expected)]
-                   (extension.read (the .#source)))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state])
-                 (pipe.case
-                   {try.#Success actual}
-                   (same? expected actual)
-
-                   _
-                   false))))
-         (_.coverage [/.with_source_code]
-           (let [expected (/.source expected_file expected_code)
-                 dummy (/.source expected_code expected_file)
-                 source (extension.read (the .#source))]
-             (|> (do phase.monad
-                   [_ (/.set_source_code expected)
-                    pre source
-                    mid (/.with_source_code dummy
-                          source)
-                    post source]
-                   (in (and (same? expected pre)
-                            (same? dummy mid)
-                            (same? expected post))))
-                 (phase.result [extension.#bundle extension.empty
-                                extension.#state state])
-                 (try.else false))))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Analysis])
-      (do random.monad
-        [left (..random 2)
-         right (..random 2)]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence (..random 2)))
-             
-             ..test|simple
-             ..test|complex
-             ..test|reference
-             (_.for [/.Reification]
-                    ..test|reification)
-             (_.for [/.Branch /.Branch' /.Match /.Match']
-                    ..test|case)
-             (_.for [/.Operation /.Phase /.Handler /.Bundle]
-                    ..test|phase)
-             (_.for [/.State+]
-                    ..test|state)
-             (_.coverage [/.format]
-               (bit#= (at /.equivalence = left right)
-                      (text#= (/.format left) (/.format right))))
-
-             /complex.test
-             /inference.test
-             /macro.test
-             /module.test
-             /pattern.test
-             /scope.test
-             /simple.test
-             /type.test
-             /coverage.test
-
-             ..\\parser
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux
deleted file mode 100644
index 069b07187..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux
+++ /dev/null
@@ -1,76 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" /]])
-
-(def test|tag
-  Test
-  (do [! random.monad]
-    [multiplicity (at ! each (n.max 2) random.nat)
-     tag (at ! each (n.% multiplicity) random.nat)
-     lefts random.nat
-     right? random.bit]
-    (all _.and
-         (_.coverage [/.tag /.lefts]
-           (and (|> lefts
-                    (/.tag right?)
-                    (/.lefts right?)
-                    (n.= lefts))
-                (|> tag
-                    (/.lefts right?)
-                    (/.tag right?)
-                    (n.= tag))))
-         (_.coverage [/.choice]
-           (let [[lefts right?] (/.choice multiplicity tag)]
-             (if right?
-               (n.= (-- tag) lefts)
-               (n.= tag lefts))))
-         )))
-
-(def .public (random multiplicity it)
-  (All (_ a)
-    (-> Nat (Random a) (Random (/.Complex a))))
-  (all random.or
-       (all random.and
-            (random#each (n.% (-- multiplicity)) random.nat)
-            random.bit
-            it)
-       (random.list multiplicity it)
-       ))
-
-(def .public test
-  Test
-  (let [random (..random 3 random.nat)]
-    (<| (_.covering /._)
-        (_.for [/.Complex /.Variant /.Tuple])
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec (/.equivalence n.equivalence) random))
-             (_.for [/.hash]
-                    ($hash.spec (/.hash n.hash) random))
-
-             (_.for [/.Tag]
-                    ..test|tag)
-             
-             (do random.monad
-               [left random
-                right random]
-               (_.coverage [/.format]
-                 (bit#= (at (/.equivalence n.equivalence) = left right)
-                        (text#= (/.format %.nat left) (/.format %.nat right)))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux
deleted file mode 100644
index 417413fb0..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux
+++ /dev/null
@@ -1,468 +0,0 @@
-(.require
- [library
-  [lux (.except Pattern)
-   ["_" test (.only Test)]
-   [abstract
-    ["[0]" monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
-    ["[0]" exception (.only Exception)]
-    [function
-     ["[0]" predicate]]]
-   [data
-    ["[0]" product]
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format]]
-    [collection
-     ["[0]" set]
-     ["[0]" dictionary]
-     ["[0]" list (.use "[1]#[0]" functor mix)]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat (.use "[1]#[0]" interval)]
-     ["i" int]
-     ["r" rev]
-     ["f" frac]]]
-   [meta
-    [macro
-     ["^" pattern]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" //
-    ["[1][0]" simple]
-    ["[1][0]" complex]
-    ["[1][0]" pattern (.only Pattern)]]]])
-
-(def spread 16)
-
-(def random_tag
-  (Random Nat)
-  (random#each (n.% ..spread) random.nat))
-
-(def .public random
-  (Random /.Coverage)
-  (<| random.rec
-      (function (_ again))
-      (all random.or
-           (random#in [])
-           random.bit
-           (random.set n.hash ..spread random.nat)
-           (random.set i.hash ..spread random.int)
-           (random.set r.hash ..spread random.rev)
-           (random.set f.hash ..spread random.frac)
-           (random.set text.hash ..spread (random.unicode 1))
-           (all random.and
-                (random.maybe (random#in ..spread))
-                (do [! random.monad]
-                  [cases ..random_tag
-                   cases (random.set n.hash cases ..random_tag)]
-                  (|> cases
-                      set.list
-                      (monad.each ! (function (_ case) (at ! each (|>> [case]) again)))
-                      (at ! each (dictionary.of_list n.hash))))
-                )
-           (random.and again again)
-           (random.and again again)
-           )))
-
-(def (ranged min range)
-  (-> Nat Nat (Random Nat))
-  (random#each (|>> (n.% (++ range)) (n.+ min))
-               random.nat))
-
-(def random_pattern
-  (Random [/.Coverage Pattern])
-  (<| random.rec
-      (function (_ again))
-      (`` (all random.either
-               (random#in [{/.#Exhaustive}
-                           {//pattern.#Simple {//simple.#Unit}}])
-               (do random.monad
-                 [it random.bit]
-                 (in [{/.#Bit it}
-                      {//pattern.#Simple {//simple.#Bit it}}]))
-               (,, (with_template [   ]
-                     [(do random.monad
-                        [it ]
-                        (in [{ (set.of_list  (list it))}
-                             {//pattern.#Simple { it}}]))]
-
-                     [random.nat n.hash /.#Nat //simple.#Nat]
-                     [random.int i.hash /.#Int //simple.#Int]
-                     [random.rev r.hash /.#Rev //simple.#Rev]
-                     [random.frac f.hash /.#Frac //simple.#Frac]
-                     [(random.unicode 1) text.hash /.#Text //simple.#Text]
-                     ))
-               
-               (do [! random.monad]
-                 [tag (at ! each ++ ..random_tag)
-                  right? random.bit
-                  .let [lefts (//complex.lefts right? tag)]
-                  [sub_coverage sub_pattern] again]
-                 (in [{/.#Variant (if right? {.#Some tag} {.#None})
-                                  (dictionary.of_list n.hash (list [tag sub_coverage]))}
-                      {//pattern.#Complex
-                       {//complex.#Variant
-                        [//complex.#lefts lefts
-                         //complex.#right? right?
-                         //complex.#value sub_pattern]}}]))
-               
-               (do [! random.monad]
-                 [arity (..ranged 2 (n.- 2 ..spread))
-                  it (random.list arity again)
-                  .let [coverages (list#each product.left it)
-                        patterns (list#each product.right it)]]
-                 (in [(|> coverages
-                          (list.only (|>> /.exhaustive? not))
-                          list.reversed
-                          (pipe.case
-                            {.#End}
-                            {/.#Exhaustive}
-                            
-                            {.#Item last prevs}
-                            (list#mix (function (_ left right)
-                                        {/.#Seq left right})
-                                      last
-                                      prevs)))
-                      {//pattern.#Complex {//complex.#Tuple patterns}}]))
-               
-               (do random.monad
-                 [register random.nat]
-                 (in [{/.#Exhaustive}
-                      {//pattern.#Bind register}]))
-               ))))
-
-(def (failure? exception it)
-  (All (_ a) (-> (Exception a) (Try /.Coverage) Bit))
-  (case it
-    {try.#Failure error}
-    (exception.match? exception error)
-
-    _
-    false))
-
-(def test|value
-  Test
-  (<| (let [(open "/#[0]") /.equivalence])
-      (do [! random.monad]
-        [left ..random
-         right ..random]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-
-             (_.coverage [/.exhaustive?]
-               (bit#= (/#= {/.#Exhaustive} left)
-                      (/.exhaustive? left)))
-             (_.coverage [/.format]
-               (bit#= (/#= left right)
-                      (text#= (/.format left) (/.format right))))
-             ))))
-
-(def test|coverage
-  Test
-  (<| (let [(open "/#[0]") /.equivalence])
-      (do [! random.monad]
-        [[expected pattern] ..random_pattern]
-        (all _.and
-             (_.coverage [/.coverage]
-               (|> pattern
-                   /.coverage
-                   (try#each (/#= expected))
-                   (try.else false)))
-             (_.coverage [/.invalid_tuple]
-               (let [invalid? (..failure? /.invalid_tuple)]
-                 (and (|> (list)
-                          {//complex.#Tuple}
-                          {//pattern.#Complex}
-                          /.coverage
-                          invalid?)
-                      (|> (list pattern)
-                          {//complex.#Tuple}
-                          {//pattern.#Complex}
-                          /.coverage
-                          invalid?)
-                      (|> (list pattern pattern)
-                          {//complex.#Tuple}
-                          {//pattern.#Complex}
-                          /.coverage
-                          invalid?
-                          not))))
-             ))))
-
-(def random_partial_pattern
-  (Random [/.Coverage Pattern])
-  (random.only (|>> product.left /.exhaustive? not)
-               ..random_pattern))
-
-(def test|variant
-  Test
-  (<| (let [(open "/#[0]") /.equivalence])
-      (do [! random.monad]
-        [[expected/0 pattern/0] ..random_partial_pattern
-         [expected/1 pattern/1] (random.only (|>> product.left (/#= expected/0) not)
-                                             ..random_partial_pattern)
-         expected_maximum (at ! each (n.+ 2) ..random_tag)
-         .let [random_tag (random#each (n.% expected_maximum) random.nat)]
-         tag/0 random_tag
-         tag/1 (random.only (|>> (n.= tag/0) not) random_tag)
-         .let [cases (dictionary.of_list n.hash (list [tag/0 expected/0]
-                                                      [tag/1 expected/1]))
-               expected_minimum (++ (n.max tag/0 tag/1))]]
-        (all _.and
-             (_.coverage [/.minimum]
-               (and (n.= expected_minimum (/.minimum [{.#None} cases]))
-                    (n.= expected_maximum (/.minimum [{.#Some expected_maximum} cases]))))
-             (_.coverage [/.maximum]
-               (and (n.= n#top (/.maximum [{.#None} cases]))
-                    (n.= expected_maximum (/.maximum [{.#Some expected_maximum} cases]))))
-             ))))
-
-(def random_value_pattern
-  (Random [/.Coverage Pattern])
-  (random.only (function (_ [coverage pattern])
-                 (case coverage
-                   (^.or {/.#Alt _} {/.#Seq _})
-                   false
-
-                   _
-                   true))
-               ..random_partial_pattern))
-
-(def test|composite
-  Test
-  (<| (let [(open "/#[0]") /.equivalence])
-      (do [! random.monad]
-        [[expected/0 pattern/0] ..random_value_pattern
-         [expected/1 pattern/1] (random.only (|>> product.left (/#= expected/0) not)
-                                             ..random_value_pattern)
-         [expected/2 pattern/2] (random.only (all predicate.and
-                                                  (|>> product.left (/#= expected/0) not)
-                                                  (|>> product.left (/#= expected/1) not)
-                                                  (|>> product.left (pipe.case {/.#Variant _} false _ true)))
-                                             ..random_value_pattern)
-
-         bit random.bit
-         nat random.nat
-         int random.int
-         rev random.rev
-         frac random.frac
-         text (random.unicode 1)
-         
-         arity (at ! each (n.+ 2) ..random_tag)
-         .let [random_tag (random#each (n.% arity) random.nat)]
-         tag/0 random_tag
-         tag/1 (random.only (|>> (n.= tag/0) not) random_tag)]
-        (all _.and
-             (_.coverage [/.composite]
-               (let [composes_simples!
-                     (`` (and (|> (/.composite {/.#Bit bit} {/.#Bit (not bit)})
-                                  (try#each (/#= {/.#Exhaustive}))
-                                  (try.else false))
-                              (|> {/.#Bit bit}
-                                  (/.composite {/.#Exhaustive})
-                                  (try#each (/#= {/.#Exhaustive}))
-                                  (try.else false))
-                              (,, (with_template [   ]
-                                    [(|> (/.composite { (set.of_list  (list ))}
-                                                      { (set.of_list  (list (|>  )))})
-                                         (try#each (/#= { (set.of_list  (list  (|>  )))}))
-                                         (try.else false))
-                                     (|> { (set.of_list  (list ))}
-                                         (/.composite {/.#Exhaustive})
-                                         (try#each (/#= {/.#Exhaustive}))
-                                         (try.else false))]
-
-                                    [/.#Nat n.hash nat ++]
-                                    [/.#Int i.hash int ++]
-                                    [/.#Rev r.hash rev ++]
-                                    [/.#Frac f.hash frac (f.+ frac)]
-                                    [/.#Text text.hash text (%.format text)]
-                                    ))))
-
-                     composes_variants!
-                     (let [composes_different_variants!
-                           (let [composes? (is (-> (Maybe Nat) (Maybe Nat) (Maybe Nat) Bit)
-                                               (function (_ left right both)
-                                                 (|> (/.composite {/.#Variant left (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                                  {/.#Variant right (dictionary.of_list n.hash (list [tag/1 expected/1]))})
-                                                     (try#each (/#= {/.#Variant both (dictionary.of_list n.hash (list [tag/0 expected/0]
-                                                                                                                      [tag/1 expected/1]))}))
-                                                     (try.else false))))]
-                             (and (composes? {.#None} {.#None} {.#None})
-                                  (composes? {.#Some arity} {.#None} {.#Some arity})
-                                  (composes? {.#None} {.#Some arity} {.#Some arity})
-                                  (composes? {.#Some arity} {.#Some arity} {.#Some arity})))
-
-                           composes_same_variants!
-                           (let [composes? (is (-> (Maybe Nat) (Maybe Nat) (Maybe Nat) Bit)
-                                               (function (_ left right both)
-                                                 (|> (do try.monad
-                                                       [variant (/.composite {/.#Variant left (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                                             {/.#Variant right (dictionary.of_list n.hash (list [tag/0 expected/1]))})
-                                                        expected (/.composite expected/0 expected/1)]
-                                                       (in (/#= {/.#Variant both (dictionary.of_list n.hash (list [tag/0 expected]))}
-                                                                variant)))
-                                                     (try.else false))))]
-                             (and (composes? {.#None} {.#None} {.#None})
-                                  (composes? {.#Some arity} {.#None} {.#Some arity})
-                                  (composes? {.#None} {.#Some arity} {.#Some arity})
-                                  (composes? {.#Some arity} {.#Some arity} {.#Some arity})))]
-                       (and composes_different_variants!
-                            composes_same_variants!
-                            (and (|> {/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                     (/.composite {/.#Exhaustive})
-                                     (try#each (/#= {/.#Exhaustive}))
-                                     (try.else false))
-                                 (|> {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                     (/.composite {/.#Exhaustive})
-                                     (try#each (/#= {/.#Exhaustive}))
-                                     (try.else false)))))
-
-                     composes_sequences!
-                     (and (|> (/.composite {/.#Seq expected/0 expected/1}
-                                           {/.#Seq expected/1 expected/0})
-                              (try#each (/#= {/.#Alt {/.#Seq expected/0 expected/1}
-                                                     {/.#Seq expected/1 expected/0}}))
-                              (try.else false))
-                          (|> (do try.monad
-                                [seq (/.composite {/.#Seq expected/0 expected/0}
-                                                  {/.#Seq expected/0 expected/1})
-                                 expected (/.composite expected/0 expected/1)]
-                                (in (/#= (if (/.exhaustive? expected)
-                                           expected/0
-                                           {/.#Seq expected/0 expected})
-                                         seq)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [seq (/.composite {/.#Seq expected/0 expected/0}
-                                                  {/.#Seq expected/1 expected/0})
-                                 expected (/.composite expected/0 expected/1)]
-                                (in (/#= {/.#Seq expected expected/0}
-                                         seq)))
-                              (try.else false))
-                          (|> (/.composite {/.#Seq expected/0 expected/1}
-                                           expected/1)
-                              (try#each (/#= {/.#Alt {/.#Seq expected/0 expected/1}
-                                                     expected/1}))
-                              (try.else false))
-                          (|> (/.composite expected/1
-                                           {/.#Seq expected/0 expected/1})
-                              (try#each (/#= {/.#Alt expected/1
-                                                     {/.#Seq expected/0 expected/1}}))
-                              (try.else false))
-                          (|> (/.composite expected/0
-                                           {/.#Seq expected/0 expected/1})
-                              (try#each (/#= expected/0))
-                              (try.else false)))
-
-                     composes_alts!
-                     (and (|> (do try.monad
-                                [alt (/.composite {/.#Exhaustive}
-                                                  {/.#Alt expected/0
-                                                          expected/1})]
-                                (in (/#= {/.#Exhaustive}
-                                         alt)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))}
-                                                  {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                          {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/1]))}})]
-                                (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))}
-                                         alt)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]))}
-                                                  {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                          {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}})]
-                                (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 {/.#Exhaustive}]
-                                                                                                     [tag/1 expected/1]))}
-                                         alt)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/2]))}
-                                                  {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                          {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}})
-                                 expected (/.composite expected/2 expected/0)]
-                                (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected]
-                                                                                                     [tag/1 expected/1]))}
-                                         alt)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/2]))}
-                                                  {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                          {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}})
-                                 expected (/.composite expected/2 expected/1)]
-                                (in (/#= {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]
-                                                                                                     [tag/1 expected]))}
-                                         alt)))
-                              (try.else false))
-                          (|> (do try.monad
-                                [alt (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}
-                                                  {/.#Alt {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                          expected/2})]
-                                (in (/#= {/.#Alt expected/2
-                                                 {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]
-                                                                                                             [tag/1 expected/1]))}}
-                                         alt)))
-                              (try.else false)))]
-                 (and composes_simples!
-                      composes_variants!
-                      composes_sequences!
-                      composes_alts!)))
-             (_.coverage [/.redundancy]
-               (let [redundant? (..failure? /.redundancy)]
-                 (`` (and (redundant? (/.composite {/.#Exhaustive} {/.#Exhaustive}))
-                          (,, (with_template []
-                                [(redundant? (/.composite  ))
-                                 (redundant? (/.composite  {/.#Exhaustive}))]
-                                
-                                [{/.#Bit bit}]
-                                [{/.#Nat (set.of_list n.hash (list nat))}]
-                                [{/.#Int (set.of_list i.hash (list int))}]
-                                [{/.#Rev (set.of_list r.hash (list rev))}]
-                                [{/.#Frac (set.of_list f.hash (list frac))}]
-                                [{/.#Text (set.of_list text.hash (list text))}]
-                                [{/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))}]
-                                [{/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}]
-                                [{/.#Seq expected/0 expected/1}]))
-                          (redundant? (/.composite {/.#Seq expected/0 expected/1} expected/0))))))
-             (_.coverage [/.variant_mismatch]
-               (let [mismatch? (..failure? /.variant_mismatch)]
-                 (and (not (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                   {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})))
-                      
-                      (mismatch? (/.composite {/.#Variant {.#Some (++ arity)} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                              {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))
-                      (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                              {/.#Variant {.#Some (++ arity)} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))
-                      
-                      (mismatch? (/.composite {/.#Variant {.#Some (-- arity)} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                              {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))
-                      (mismatch? (/.composite {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                              {/.#Variant {.#Some (-- arity)} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))
-                      
-                      (not (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [tag/0 expected/0]))}
-                                                   {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})))
-                      (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [arity expected/0]))}
-                                              {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))
-                      (not (mismatch? (/.composite {/.#Variant {.#None} (dictionary.of_list n.hash (list [(-- arity) expected/0]))}
-                                                   {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))}))))))
-             ))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Coverage])
-      (all _.and
-           ..test|value
-           ..test|coverage
-           (_.for [/.Variant]
-                  ..test|variant)
-           ..test|composite
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux
deleted file mode 100644
index 24433b8d0..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux
+++ /dev/null
@@ -1,423 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
-    ["[0]" exception (.only Exception)]]
-   [data
-    ["[0]" product]
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text]
-    [collection
-     ["[0]" list (.use "[1]#[0]" monad)]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" code]
-    ["[0]" macro]
-    ["[0]" symbol
-     ["$[1]" \\test]]
-    ["[0]" configuration
-     ["$[1]" \\test]]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["[0]" check (.only Check)]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [evaluation (.only Eval)]
-    ["[1][0]" macro]
-    ["[1][0]" type]
-    ["[1][0]" module]
-    ["[1][0]" complex]
-    [//
-     [phase
-      ["[2][0]" analysis]
-      ["[2][0]" extension (.only)
-       ["[1]/[0]" analysis
-        ["[1]" lux]]]]
-     [///
-      ["[2][0]" phase (.use "[1]#[0]" monad)]
-      [meta
-       ["[0]" archive]]]]]]])
-
-(def (eval archive type term)
-  Eval
-  (/phase#in []))
-
-(def (expander macro inputs state)
-  //macro.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def random_state
-  (Random Lux)
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 1)
-     configuration ($configuration.random 5)]
-    (in (//.state (//.info version host configuration)))))
-
-(def primitive
-  (Random Type)
-  (do random.monad
-    [name (random.lower_case 1)]
-    (in {.#Primitive name (list)})))
-
-(def analysis
-  //.Phase
-  (/analysis.phase ..expander))
-
-(def (fails? exception try)
-  (All (_ e a) (-> (Exception e) (Try a) Bit))
-  (case try
-    {try.#Success _}
-    false
-    
-    {try.#Failure error}
-    (text.contains? (the exception.#label exception) error)))
-
-(def .public simple_parameter
-  (Random [Type Code])
-  (`` (all random.either
-           (,, (with_template [  ]
-                 [(random#each (|>>  []) )]
-
-                 [.Bit random.bit code.bit]
-                 [.Nat random.nat code.nat]
-                 [.Int random.int code.int]
-                 [.Rev random.rev code.rev]
-                 [.Frac random.frac code.frac]
-                 [.Text (random.lower_case 1) code.text]
-                 ))
-           )))
-
-(def test|general
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle (/extension/analysis.bundle ..eval)
-                  /extension.#state lux]]
-     expected ..primitive
-     name ($symbol.random 1 1)
-     [type/0 term/0] ..simple_parameter
-     arity (at ! each (n.% 10) random.nat)
-     nats (random.list arity random.nat)]
-    (all _.and
-         (_.coverage [/.general]
-           (and (|> (/.general archive.empty ..analysis expected (list))
-                    (//type.expecting expected)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase.result state)
-                    (try#each (|>> product.left (type#= expected)))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type.function (list.repeated arity .Nat) expected)
-                               (list#each code.nat nats))
-                    (//type.expecting expected)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase.result state)
-                    (try#each (function (_ [actual analysis/*])
-                                (and (type#= expected actual)
-                                     (at (list.equivalence //.equivalence) =
-                                         (list#each (|>> //.nat) nats)
-                                         analysis/*))))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type_literal (-> type/0 expected))
-                               (list term/0))
-                    (//type.expecting expected)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase.result state)
-                    (try#each (|>> product.left (type#= expected)))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type_literal {.#Named name (-> type/0 expected)})
-                               (list term/0))
-                    (//type.expecting expected)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase.result state)
-                    (try#each (|>> product.left (type#= expected)))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type_literal (All (_ a) (-> a a)))
-                               (list term/0))
-                    (//type.expecting type/0)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase#each (|>> product.left (check.clean (list)) //type.check))
-                    /phase#conjoint
-                    (/phase.result state)
-                    (try#each (type#= type/0))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type_literal ((All (_ a) (-> a a)) type/0))
-                               (list term/0))
-                    (//type.expecting type/0)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase.result state)
-                    (try#each (|>> product.left (type#= type/0)))
-                    (try.else false))
-                (|> (do /phase.monad
-                      [[@var varT] (//type.check check.var)
-                       _ (//type.check (check.check varT (type_literal (-> type/0 expected))))]
-                      (/.general archive.empty ..analysis varT (list term/0)))
-                    (//type.expecting expected)
-                    (//module.with 0 (product.left name))
-                    (/phase#each product.right)
-                    (/phase#each (|>> product.left (check.clean (list)) //type.check))
-                    /phase#conjoint
-                    (/phase.result state)
-                    (try#each (type#= expected))
-                    (try.else false))
-                (|> (/.general archive.empty ..analysis
-                               (type_literal (Ex (_ a) (-> a a)))
-                               (list (` ("lux io error" ""))))
-                    //type.inferring
-                    (//module.with 0 (product.left name))
-                    (/phase#each (|>> product.right product.left (check.clean (list)) //type.check))
-                    /phase#conjoint
-                    (/phase.result state)
-                    (try#each //type.existential?)
-                    (try.else false))
-                ))
-         (_.coverage [/.cannot_infer]
-           (and (|> (/.general archive.empty ..analysis expected (list term/0))
-                    (//type.expecting expected)
-                    (/phase.result state)
-                    (..fails? /.cannot_infer))
-                (|> (do /phase.monad
-                      [[@var varT] (//type.check check.var)]
-                      (/.general archive.empty ..analysis varT (list term/0)))
-                    (//type.expecting expected)
-                    (/phase.result state)
-                    (..fails? /.cannot_infer))))
-         (_.coverage [/.cannot_infer_argument]
-           (|> (/.general archive.empty ..analysis
-                          (type_literal (-> expected expected))
-                          (list term/0))
-               (//type.expecting expected)
-               (//module.with 0 (product.left name))
-               (/phase.result state)
-               (..fails? /.cannot_infer_argument)))
-         )))
-
-(def test|variant
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle (/extension/analysis.bundle ..eval)
-                  /extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     [type/0 term/0] ..simple_parameter
-     [type/1 term/1] (random.only (|>> product.left (same? type/0) not)
-                                  ..simple_parameter)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     tag (at ! each (n.% arity) random.nat)
-     .let [[lefts right?] (//complex.choice arity tag)]
-     arbitrary_right? random.bit]
-    (all _.and
-         (_.coverage [/.variant]
-           (let [variantT (type.variant (list#each product.left types/*,terms/*))
-                 [tagT tagC] (|> types/*,terms/*
-                                 (list.item tag)
-                                 (maybe.else [Any (' [])]))
-                 variant?' (is (-> Type (Maybe Type) Nat Bit Code Bit)
-                               (function (_ variant inferred lefts right? term)
-                                 (|> (do /phase.monad
-                                       [inferT (/.variant lefts right? variant)
-                                        [_ [it _]] (|> (/.general archive.empty ..analysis inferT (list term))
-                                                       //type.inferring)]
-                                       (case inferred
-                                         {.#Some inferred}
-                                         (//type.check
-                                          (do check.monad
-                                            [_ (check.check inferred it)
-                                             _ (check.check it inferred)]
-                                            (in true)))
-                                         
-                                         {.#None}
-                                         (in true)))
-                                     (//module.with 0 (product.left name))
-                                     (/phase#each product.right)
-                                     (/phase.result state)
-                                     (try.else false))))
-                 variant? (is (-> Type Nat Bit Code Bit)
-                              (function (_ type lefts right? term)
-                                (variant?' type {.#Some type} lefts right? term)))
-
-                 can_match_case!
-                 (variant? variantT lefts right? tagC)
-
-                 names_do_not_matter!
-                 (variant? {.#Named name variantT} lefts right? tagC)
-
-                 cases_independent_of_parameters_conform_to_anything!
-                 (variant? (type_literal (Maybe type/0)) 0 #0 (' []))
-
-                 cases_dependent_on_parameters_are_tettered_to_those_parameters!
-                 (and (variant? (type_literal (Maybe type/0)) 0 #1 term/0)
-                      (not (variant? (type_literal (Maybe type/0)) 0 #1 term/1)))
-
-                 only_bottom_conforms_to_tags_outside_of_range!
-                 (`` (and (,, (with_template [ ]
-                                [(bit#=  (variant? variantT arity arbitrary_right? ))]
-
-                                [#0 term/0]
-                                [#1 (` ("lux io error" ""))]))))
-
-                 can_handle_universal_quantification!
-                 (and (variant?' (type_literal (All (_ a) (Maybe a)))
-                                 {.#Some Maybe}
-                                 0 #0 (' []))
-                      (variant?' (type_literal (All (_ a) (Maybe a)))
-                                 {.#Some (type_literal (Maybe type/0))}
-                                 0 #1 term/0)
-                      (not (variant?' (type_literal (All (_ a) (Maybe a)))
-                                      {.#Some Maybe}
-                                      0 #1 term/0)))
-
-                 existential_types_do_not_affect_independent_cases!
-                 (variant?' (type_literal (Ex (_ a) (Maybe a)))
-                            {.#None}
-                            0 #0 (' []))
-
-                 existential_types_affect_dependent_cases!
-                 (`` (and (,, (with_template [ ]
-                                [(bit#=  (variant?' (type_literal (Ex (_ a) (Maybe a))) {.#None} 0 #1 ))]
-
-                                [#0 term/0]
-                                [#1 (` ("lux io error" ""))]))))]
-             (and can_match_case!
-                  names_do_not_matter!
-
-                  cases_independent_of_parameters_conform_to_anything!
-                  cases_dependent_on_parameters_are_tettered_to_those_parameters!
-
-                  only_bottom_conforms_to_tags_outside_of_range!
-
-                  can_handle_universal_quantification!
-
-                  existential_types_do_not_affect_independent_cases!
-                  existential_types_affect_dependent_cases!
-                  )))
-         (_.coverage [/.not_a_variant]
-           (let [[tagT tagC] (|> types/*,terms/*
-                                 (list.item tag)
-                                 (maybe.else [Any (' [])]))]
-             (|> (/.variant lefts right? tagT)
-                 (/phase.result state)
-                 (..fails? /.not_a_variant))))
-         )))
-
-(def test|record
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle (/extension/analysis.bundle ..eval)
-                  /extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     [type/0 term/0] ..simple_parameter
-     [type/1 term/1] (random.only (|>> product.left (same? type/0) not)
-                                  ..simple_parameter)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     .let [record? (is (-> Type (Maybe Type) Nat (List Code) Bit)
-                       (function (_ record expected arity terms)
-                         (|> (do /phase.monad
-                               [inference (/.record arity record)
-                                [_ [it _]] (|> (/.general archive.empty ..analysis inference terms)
-                                               //type.inferring)]
-                               (case expected
-                                 {.#Some expected}
-                                 (//type.check
-                                  (do check.monad
-                                    [_ (check.check expected it)
-                                     _ (check.check it expected)]
-                                    (in true)))
-                                 
-                                 {.#None}
-                                 (in true)))
-                             (//module.with 0 (product.left name))
-                             (/phase#each product.right)
-                             (/phase.result state)
-                             (try.else false))))
-           record (type.tuple (list#each product.left types/*,terms/*))
-           terms (list#each product.right types/*,terms/*)]]
-    (all _.and
-         (_.coverage [/.record]
-           (let [can_infer_record!
-                 (record? record {.#None} arity terms)
-
-                 names_do_not_matter!
-                 (record? {.#Named name record} {.#None} arity terms)
-
-                 can_handle_universal_quantification!
-                 (and (record? (All (_ a) (Tuple type/0 a))
-                               {.#Some (Tuple type/0 type/1)}
-                               2 (list term/0 term/1))
-                      (record? (All (_ a) (Tuple a type/0))
-                               {.#Some (Tuple type/1 type/0)}
-                               2 (list term/1 term/0)))
-
-                 can_handle_existential_quantification!
-                 (and (not (record? (Ex (_ a) (Tuple type/0 a))
-                                    {.#Some (Tuple type/0 type/1)}
-                                    2 (list term/0 term/1)))
-                      (record? (Ex (_ a) (Tuple type/0 a))
-                               {.#None}
-                               2 (list term/0 (` ("lux io error" ""))))
-                      (not (record? (Ex (_ a) (Tuple a type/0))
-                                    {.#Some (Tuple type/1 type/0)}
-                                    2 (list term/1 term/0)))
-                      (record? (Ex (_ a) (Tuple a type/0))
-                               {.#None}
-                               2 (list (` ("lux io error" "")) term/0)))]
-             (and can_infer_record!
-                  names_do_not_matter!
-                  can_handle_universal_quantification!
-                  can_handle_existential_quantification!
-                  )))
-         (_.coverage [/.not_a_record]
-           (|> (/.record arity type/0)
-               (/phase.result state)
-               (..fails? /.not_a_record)))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux ..random_state
-         .let [state [/extension.#bundle (/extension/analysis.bundle ..eval)
-                      /extension.#state lux]]
-         [type/0 term/0] ..simple_parameter
-         [type/1 term/1] (random.only (|>> product.left (same? type/0) not)
-                                      ..simple_parameter)
-         lefts (at ! each (n.% 10) random.nat)
-         right? random.bit]
-        (all _.and
-             ..test|general
-             ..test|variant
-             ..test|record
-             (_.coverage [/.invalid_type_application]
-               (and (|> (/.general archive.empty ..analysis (type_literal (type/0 type/1)) (list term/0))
-                        (/phase.result state)
-                        (..fails? /.invalid_type_application))
-                    (|> (/.variant lefts right? (type_literal (type/0 type/1)))
-                        (/phase.result state)
-                        (..fails? /.invalid_type_application))
-                    (|> (/.record lefts (type_literal (type/0 type/1)))
-                        (/phase.result state)
-                        (..fails? /.invalid_type_application))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux
deleted file mode 100644
index 19c701bef..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux
+++ /dev/null
@@ -1,110 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["[0]" pipe]
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]
-    [collection
-     ["[0]" list (.use "[1]#[0]" monad)]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat]]]
-   ["[0]" meta (.only)
-    ["[0]" code (.use "[1]#[0]" equivalence)]
-    ["[0]" macro]
-    ["[0]" configuration
-     ["$[1]" \\test]]]]]
- ["$" ///////
-  [meta
-   ["[1][0]" symbol]
-   ["[1][0]" code]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" //]]])
-
-(def random_state
-  (Random Lux)
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 1)
-     configuration ($configuration.random 5)]
-    (in (//.state (//.info version host configuration)))))
-
-(def (expander macro inputs state)
-  /.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Expander])
-      (do [! random.monad]
-        [multiplicity (at ! each (|>> (n.% 8) (n.+ 2))
-                          random.nat)
-         choice (at ! each (n.% multiplicity)
-                    random.nat)
-         expected_error (random.upper_case 5)
-
-         name ($symbol.random 2 2)
-         mono $code.random
-         poly (random.list multiplicity $code.random)
-
-         lux ..random_state
-         .let [singular (<| (as Macro)
-                            (is Macro')
-                            (function (_ inputs state)
-                              (case (list.item choice inputs)
-                                {.#Some it}
-                                {try.#Success [state (list it)]}
-
-                                {.#None}
-                                {try.#Failure expected_error})))
-               multiple (<| (as Macro)
-                            (is Macro')
-                            (function (_ inputs state)
-                              {try.#Success [state (|> inputs
-                                                       (list.repeated multiplicity)
-                                                       list#conjoint)]}))]])
-      (all _.and
-           (_.coverage [/.expansion]
-             (|> (/.expansion ..expander name multiple (list mono))
-                 (meta.result lux)
-                 (try#each (at (list.equivalence code.equivalence) =
-                               (list.repeated multiplicity mono)))
-                 (try.else false)))
-           (_.coverage [/.expansion_failed]
-             (|> (/.expansion ..expander name singular (list))
-                 (meta.result lux)
-                 (pipe.case
-                   {try.#Failure it}
-                   (and (text.contains? expected_error it)
-                        (text.contains? (the exception.#label /.expansion_failed) it))
-
-                   _
-                   false)))
-           (_.coverage [/.single_expansion]
-             (|> (/.single_expansion ..expander name singular poly)
-                 (meta.result lux)
-                 (try#each (code#= (|> poly (list.item choice) maybe.trusted)))
-                 (try.else false)))
-           (_.coverage [/.must_have_single_expansion]
-             (|> (/.single_expansion ..expander name multiple (list mono))
-                 (meta.result lux)
-                 (pipe.case
-                   {try.#Failure it}
-                   (text.contains? (the exception.#label /.must_have_single_expansion) it)
-
-                   _
-                   false)))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux
deleted file mode 100644
index 7a68264d7..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux
+++ /dev/null
@@ -1,354 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    ["[0]" monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]
-    [collection
-     ["[0]" list]
-     ["[0]" set]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   ["[0]" meta (.only)
-    ["[0]" configuration
-     ["$[1]" \\test]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [//
-     [phase
-      ["[2][0]" extension]]
-     [///
-      ["[2][0]" phase]]]]]])
-
-(def random_state
-  (Random Lux)
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 1)
-     configuration ($configuration.random 5)]
-    (in (//.state (//.info version host configuration)))))
-
-(def primitive
-  (Random Type)
-  (do random.monad
-    [name (random.lower_case 1)]
-    (in {.#Primitive name (list)})))
-
-(def (new? hash it)
-  (-> Nat .Module Bit)
-  (and (same? hash (the .#module_hash it))
-       (list.empty? (the .#module_aliases it))
-       (list.empty? (the .#definitions it))
-       (list.empty? (the .#imports it))
-       (case (the .#module_state it)
-         {.#Active}
-         true
-         
-         _
-         false)))
-
-(def test|module
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle /extension.empty
-                  /extension.#state lux]]
-     name (random.lower_case 1)
-     hash random.nat
-     expected_import (random.lower_case 2)
-     expected_alias (random.lower_case 3)]
-    (all _.and
-         (_.coverage [/.empty]
-           (..new? hash (/.empty hash)))
-         (_.coverage [/.create]
-           (|> (do /phase.monad
-                 [_ (/.create hash name)]
-                 (/extension.lifted (meta.module name)))
-               (/phase.result state)
-               (try#each (..new? hash))
-               (try.else false)))
-         (_.coverage [/.exists?]
-           (|> (do /phase.monad
-                 [pre (/.exists? name)
-                  _ (/.create hash name)
-                  post (/.exists? name)]
-                 (in (and (not pre) post)))
-               (/phase.result state)
-               (try.else false)))
-         (_.coverage [/.with]
-           (|> (do /phase.monad
-                 [[it _] (/.with hash name
-                           (in []))]
-                 (in it))
-               (/phase.result state)
-               (try#each (..new? hash))
-               (try.else false)))
-         (_.coverage [/.import]
-           (`` (and (,, (with_template []
-                          [(|> (do [! /phase.monad]
-                                 [_ (/.create hash expected_import)
-                                  [it ?] (/.with hash name
-                                           (do !
-                                             [_ (if 
-                                                  (/.import expected_import)
-                                                  (in []))]
-                                             (/extension.lifted
-                                              (meta.imported? expected_import))))]
-                                 (in ?))
-                               (/phase.result state)
-                               (try#each (bit#= ))
-                               (try.else false))]
-
-                          [false]
-                          [true])))))
-         (_.coverage [/.alias]
-           (|> (do [! /phase.monad]
-                 [_ (/.create hash expected_import)
-                  [it _] (/.with hash name
-                           (do !
-                             [_ (/.import expected_import)]
-                             (/.alias expected_alias expected_import)))]
-                 (in it))
-               (/phase.result state)
-               (try#each (|>> (the .#module_aliases)
-                              (pipe.case
-                                (list [actual_alias actual_import])
-                                (and (same? expected_alias actual_alias)
-                                     (same? expected_import actual_import))
-
-                                _
-                                false)))
-               (try.else false)))
-         )))
-
-(def test|state
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle /extension.empty
-                  /extension.#state lux]]
-     name (random.lower_case 1)
-     hash random.nat]
-    (`` (all _.and
-             (,, (with_template [   ]
-                   [(_.coverage [ ]
-                      (|> (do [! /phase.monad]
-                            [[it ?] (/.with hash name
-                                      (do !
-                                        [_ ( name)
-                                         ? ( name)
-                                         ~0 ( name)
-                                         ~1 ( name)]
-                                        (in (and ? (not ~0) (not ~1)))))]
-                            (in ?))
-                          (/phase.result state)
-                          (try.else false)))]
-
-                   [/.set_active   /.active?   /.compiled? /.cached?]
-                   [/.set_compiled /.compiled? /.cached?   /.active?]
-                   [/.set_cached   /.cached?   /.active?   /.compiled?]
-                   ))
-             (_.coverage [/.can_only_change_state_of_active_module]
-               (and (,, (with_template [
 ]
-                          [(|> (/.with hash name
-                                 (do /phase.monad
-                                   [_ (
 name)]
-                                   ( name)))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _}
-                                 false
-                                 
-                                 {try.#Failure error}
-                                 (text.contains? (the exception.#label /.can_only_change_state_of_active_module) error)))]
-
-                          [/.set_compiled /.set_active]
-                          [/.set_compiled /.set_compiled]
-                          [/.set_compiled /.set_cached]
-                          [/.set_cached /.set_active]
-                          [/.set_cached /.set_compiled]
-                          [/.set_cached /.set_cached]
-                          ))))
-             (_.coverage [/.unknown_module]
-               (and (,, (with_template []
-                          [(|> ( name)
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _}
-                                 false
-                                 
-                                 {try.#Failure error}
-                                 (text.contains? (the exception.#label /.unknown_module) error)))]
-
-                          [/.set_active]
-                          [/.set_compiled]
-                          [/.set_cached]
-                          ))))
-             ))))
-
-(def test|definition
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle /extension.empty
-                  /extension.#state lux]]
-     module_name (random.lower_case 1)
-     hash random.nat
-     def_name (random.lower_case 2)
-     alias_name (random.lower_case 3)
-
-     public? random.bit
-     def_type ..primitive
-     arity (at ! each (|>> (n.% 10) ++) random.nat)
-     labels|head (random.lower_case 1)
-     labels|tail (|> (random.lower_case 1)
-                     (random.only (|>> (text#= labels|head) not))
-                     (random.set text.hash (-- arity))
-                     (at ! each set.list))
-     index (at ! each (n.% arity) random.nat)
-     .let [definition {.#Definition [public? def_type []]}
-           alias {.#Alias [module_name def_name]}]]
-    (all _.and
-         (_.coverage [/.define]
-           (`` (and (,, (with_template []
-                          [(|> (/.with hash module_name
-                                 (/.define def_name ))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _} true
-                                 {try.#Failure _} false))]
-
-                          [definition]
-                          [{.#Type [public? def_type {.#Left [labels|head labels|tail]}]}]
-                          [{.#Type [public? def_type {.#Right [labels|head labels|tail]}]}]
-                          [{.#Tag [public? def_type (list.partial labels|head labels|tail) index]}]
-                          [{.#Slot [public? def_type (list.partial labels|head labels|tail) index]}]))
-                    (|> (/.with hash module_name
-                          (do /phase.monad
-                            [_ (/.define def_name definition)]
-                            (/.define alias_name alias)))
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} true
-                          {try.#Failure _} false)))))
-         (_.coverage [/.cannot_define_more_than_once]
-           (`` (and (,, (with_template []
-                          [(|> (/.with hash module_name
-                                 (do /phase.monad
-                                   [_ (/.define def_name )]
-                                   (/.define def_name )))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _} false
-                                 {try.#Failure _} true))]
-
-                          [{.#Definition [public? def_type []]}]
-                          [{.#Type [public? def_type {.#Left [labels|head labels|tail]}]}]
-                          [{.#Type [public? def_type {.#Right [labels|head labels|tail]}]}]
-                          [{.#Tag [public? def_type (list.partial labels|head labels|tail) index]}]
-                          [{.#Slot [public? def_type (list.partial labels|head labels|tail) index]}]))
-                    (|> (/.with hash module_name
-                          (do /phase.monad
-                            [_ (/.define def_name definition)
-                             _ (/.define alias_name alias)]
-                            (/.define alias_name alias)))
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} false
-                          {try.#Failure _} true)))))
-         )))
-
-(def test|label
-  Test
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [/extension.#bundle /extension.empty
-                  /extension.#state lux]]
-     module_name (random.lower_case 1)
-     hash random.nat
-     def_name (random.lower_case 2)
-     foreign_module (random.lower_case 3)
-
-     public? random.bit
-     def_type ..primitive
-     arity (at ! each (|>> (n.% 10) ++) random.nat)
-     labels|head (random.lower_case 1)
-     labels|tail (|> (random.lower_case 1)
-                     (random.only (|>> (text#= labels|head) not))
-                     (random.set text.hash (-- arity))
-                     (at ! each set.list))]
-    (all _.and
-         (_.coverage [/.declare_labels]
-           (`` (and (,, (with_template [   ]
-                          [(|> (/.with hash module_name
-                                 (do [! /phase.monad]
-                                   [.let [it {.#Named [module_name def_name] def_type}]
-                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})
-                                    _ (/.declare_labels  (list.partial labels|head labels|tail) public? it)]
-                                   (monad.each ! (|>> [module_name]  /extension.lifted)
-                                               (list.partial labels|head labels|tail))))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _} 
-                                 {try.#Failure _} (not )))]
-
-                          [.#Left false meta.tag true]
-                          [.#Left false meta.slot false]
-                          [.#Right true meta.slot true]
-                          [.#Right true meta.tag false])))))
-         (_.coverage [/.cannot_declare_labels_for_anonymous_type]
-           (`` (and (,, (with_template [ ]
-                          [(|> (/.with hash module_name
-                                 (do [! /phase.monad]
-                                   [.let [it def_type]
-                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})]
-                                   (/.declare_labels  (list.partial labels|head labels|tail) public? it)))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _}
-                                 false
-                                 
-                                 {try.#Failure error}
-                                 (text.contains? (the exception.#label /.cannot_declare_labels_for_anonymous_type) error)))]
-
-                          [.#Left false]
-                          [.#Right true])))))
-         (_.coverage [/.cannot_declare_labels_for_foreign_type]
-           (`` (and (,, (with_template [ ]
-                          [(|> (/.with hash module_name
-                                 (do [! /phase.monad]
-                                   [.let [it {.#Named [foreign_module def_name] def_type}]
-                                    _ (/.define def_name {.#Type [public? it { [labels|head labels|tail]}]})]
-                                   (/.declare_labels  (list.partial labels|head labels|tail) public? it)))
-                               (/phase.result state)
-                               (pipe.case
-                                 {try.#Success _}
-                                 false
-                                 
-                                 {try.#Failure error}
-                                 (text.contains? (the exception.#label /.cannot_declare_labels_for_foreign_type) error)))]
-
-                          [.#Left false]
-                          [.#Right true])))))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           ..test|module
-           ..test|state
-           ..test|definition
-           (_.for [/.Label]
-                  ..test|label)
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux
deleted file mode 100644
index e3034f93c..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux
+++ /dev/null
@@ -1,112 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["f" frac]]]]]
- [\\library
-  ["[0]" /]]
- ["[0]" //
-  ["[1][0]" simple]
-  ["[1][0]" complex]])
-
-(def .public random
-  (Random /.Pattern)
-  (random.rec
-   (function (_ random)
-     (all random.or
-          //simple.random
-          (//complex.random 4 random)
-          random.nat
-          ))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Pattern])
-      (do random.monad
-        [expected_register random.nat
-         expected_bit random.bit
-         expected_nat random.nat
-         expected_int random.int
-         expected_rev random.rev
-         expected_frac random.frac
-         expected_text (random.lower_case 2)
-
-         expected_lefts random.nat
-         expected_right? random.bit
-
-         left ..random
-         right ..random])
-      (`` (all _.and
-               (_.for [/.equivalence]
-                      ($equivalence.spec /.equivalence ..random))
-               
-               (_.coverage [/.format]
-                 (bit#= (at /.equivalence = left right)
-                        (text#= (/.format left) (/.format right))))
-               (_.coverage [/.unit]
-                 (case (/.unit)
-                   (/.unit)
-                   true
-
-                   _
-                   false))
-               (,, (with_template [ ]
-                     [(_.coverage []
-                        (case ( )
-                          ( actual)
-                          (same?  actual)
-
-                          _
-                          false))]
-
-                     [/.bind expected_register]
-                     [/.bit expected_bit]
-                     [/.nat expected_nat]
-                     [/.int expected_int]
-                     [/.rev expected_rev]
-                     [/.frac expected_frac]
-                     [/.text expected_text]
-                     ))
-               (_.coverage [/.variant]
-                 (case (/.variant [expected_lefts expected_right? (/.text expected_text)])
-                   (/.variant [actual_lefts actual_right? (/.text actual_text)])
-                   (and (same? expected_lefts actual_lefts)
-                        (same? expected_right? actual_right?)
-                        (same? expected_text actual_text))
-
-                   _
-                   false))
-               (_.coverage [/.tuple]
-                 (case (/.tuple (list (/.bit expected_bit)
-                                      (/.nat expected_nat)
-                                      (/.int expected_int)
-                                      (/.rev expected_rev)
-                                      (/.frac expected_frac)
-                                      (/.text expected_text)))
-                   (/.tuple (list (/.bit actual_bit)
-                                  (/.nat actual_nat)
-                                  (/.int actual_int)
-                                  (/.rev actual_rev)
-                                  (/.frac actual_frac)
-                                  (/.text actual_text)))
-                   (and (same? expected_bit actual_bit)
-                        (same? expected_nat actual_nat)
-                        (same? expected_int actual_int)
-                        (same? expected_rev actual_rev)
-                        (same? expected_frac actual_frac)
-                        (same? expected_text actual_text))
-
-                   _
-                   false))
-               ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux
deleted file mode 100644
index 5fb2ad044..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux
+++ /dev/null
@@ -1,205 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    [collection
-     ["[0]" list]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" type
-     ["$[1]" \\test]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [//
-     [phase
-      ["[1][0]" extension]]
-     [///
-      ["[1][0]" phase (.use "[1]#[0]" monad)]
-      [reference
-       ["[1][0]" variable (.only Register Variable)]]]]]]]
- ["$[0]" //
-  ["[1][0]" type]])
-
-(with_template [ ]
-  [(def ( expected_type expected_register [actual_type actual_var])
-     (-> Type Register [Type Variable] Bit)
-     (and (same? expected_type actual_type)
-          (case actual_var
-            { actual_register}
-            (n.= expected_register actual_register)
-            
-            _
-            false)))]
-
-  [local? //variable.#Local]
-  [foreign? //variable.#Foreign]
-  )
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux $//type.random_state
-         .let [state [//extension.#bundle //extension.empty
-                      //extension.#state lux]]
-         name/0 (random.lower_case 1)
-         name/1 (random.lower_case 2)
-         type/0 ($type.random 0)
-         type/1 ($type.random 0)]
-        (all _.and
-             (_.coverage [/.variable]
-               (|> (/.variable name/0)
-                   /.with
-                   (//phase.result state)
-                   (try#each (|>> product.right
-                                  (pipe.case
-                                    {.#None} true
-                                    {.#Some _} false)))
-                   (try.else false)))
-             (_.coverage [/.with_local]
-               (|> (/.with_local [name/0 type/0]
-                     (/.variable name/0))
-                   /.with
-                   (//phase.result state)
-                   (try#each (|>> product.right
-                                  (maybe#each (..local? type/0 0))
-                                  (maybe.else false)))
-                   (try.else false)))
-             (_.coverage [/.next]
-               (|> (<| (do [! //phase.monad]
-                         [register/0 /.next])
-                       (/.with_local [name/0 type/0])
-                       (do !
-                         [var/0 (/.variable name/0)])
-                       (do !
-                         [register/1 /.next])
-                       (/.with_local [name/1 type/1])
-                       (do !
-                         [var/1 (/.variable name/1)])
-                       (in (do maybe.monad
-                             [var/0 var/0
-                              var/1 var/1]
-                             (in [[register/0 var/0] [register/1 var/1]]))))
-                   /.with
-                   (//phase.result state)
-                   (try#each (|>> product.right
-                                  (maybe#each (function (_ [[register/0 var/0] [register/1 var/1]])
-                                                (and (..local? type/0 register/0 var/0)
-                                                     (..local? type/1 register/1 var/1))))
-                                  (maybe.else false)))
-                   (try.else false)))
-             (_.coverage [/.no_scope]
-               (and (|> (/.with_local [name/0 type/0]
-                          (//phase#in false))
-                        (//phase.result state)
-                        (exception.otherwise (exception.match? /.no_scope)))
-                    (|> (do //phase.monad
-                          [_ /.next]
-                          (in false))
-                        (//phase.result state)
-                        (exception.otherwise (exception.match? /.no_scope)))))
-             (_.coverage [/.reset]
-               (and (|> /.next
-                        (/.with_local [name/0 type/0])
-                        /.with
-                        (//phase.result state)
-                        (try#each (|>> product.right
-                                       (n.= 1)))
-                        (try.else false))
-                    (|> /.next
-                        /.reset
-                        (/.with_local [name/0 type/0])
-                        /.with
-                        (//phase.result state)
-                        (try#each (|>> product.right
-                                       (n.= 0)))
-                        (try.else false))))
-             (_.coverage [/.drained]
-               (|> (function (_ [bundle state])
-                     {try.#Success [[bundle (has .#scopes (list) state)]
-                                    false]})
-                   (/.with_local [name/0 type/0])
-                   /.with
-                   (//phase#each product.right)
-                   (//phase.result state)
-                   (exception.otherwise (exception.match? /.drained))))
-             (_.coverage [/.with]
-               (|> (<| /.with
-                       (/.with_local [name/0 type/0])
-                       (do //phase.monad
-                         [var/0' (/.variable name/0)
-                          [scope/1 var/0''] (/.with (/.variable name/0))]
-                         (<| //phase.lifted
-                             try.of_maybe
-                             (do maybe.monad
-                               [var/0' var/0'
-                                var/0'' var/0'']
-                               (in [var/0' scope/1 var/0''])))))
-                   (//phase.result state)
-                   (try#each (function (_ [scope/0 var/0' scope/1 var/0''])
-                               (and (local? type/0 0 var/0')
-                                    (n.= 0 (list.size (the [.#locals .#mappings] scope/0)))
-                                    (n.= 0 (list.size (the [.#captured .#mappings] scope/0)))
-
-                                    (foreign? type/0 0 var/0'')
-                                    (n.= 0 (list.size (the [.#locals .#mappings] scope/1)))
-                                    (n.= 1 (list.size (the [.#captured .#mappings] scope/1))))))
-                   (try.else false)))
-             (_.coverage [/.environment]
-               (let [(open "list#[0]") (list.equivalence //variable.equivalence)]
-                 (and (|> (<| /.with
-                              (/.with_local [name/0 type/0])
-                              (/.with_local [name/1 type/1])
-                              (do //phase.monad
-                                [[scope/1 _] (/.with (in []))]
-                                (in (/.environment scope/1))))
-                          (//phase.result state)
-                          (try#each (|>> product.right
-                                         (list#= (list))))
-                          (try.else false))
-                      (|> (<| /.with
-                              (do [! //phase.monad]
-                                [register/0 /.next])
-                              (/.with_local [name/0 type/0])
-                              (/.with_local [name/1 type/1])
-                              (do !
-                                [[scope/1 _] (/.with (/.variable name/0))]
-                                (in [register/0 (/.environment scope/1)])))
-                          (//phase.result state)
-                          (try#each (function (_ [_ [register/0 environment]])
-                                      (list#= (list {//variable.#Local register/0})
-                                              environment)))
-                          (try.else false))
-                      (|> (<| /.with
-                              (do [! //phase.monad]
-                                [register/0 /.next])
-                              (/.with_local [name/0 type/0])
-                              (do [! //phase.monad]
-                                [register/1 /.next])
-                              (/.with_local [name/1 type/1])
-                              (do [! //phase.monad]
-                                [[scope/1 _] (/.with (do !
-                                                       [_ (/.variable name/1)
-                                                        _ (/.variable name/0)]
-                                                       (in [])))]
-                                (in [register/0 register/1 (/.environment scope/1)])))
-                          (//phase.result state)
-                          (try#each (function (_ [_ [register/0 register/1 environment]])
-                                      (list#= (list {//variable.#Local register/1}
-                                                    {//variable.#Local register/0})
-                                              environment)))
-                          (try.else false)))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux
deleted file mode 100644
index b029f6add..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux
+++ /dev/null
@@ -1,45 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["f" frac]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Simple)
-  (all random.or
-       (random#in [])
-       random.bit
-       random.nat
-       random.int
-       random.rev
-       (random.only (|>> f.not_a_number? not) random.frac)
-       (random.lower_case 5)
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Simple])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence ..random))
-           
-           (do random.monad
-             [left ..random
-              right ..random]
-             (_.coverage [/.format]
-               (bit#= (at /.equivalence = left right)
-                      (text#= (/.format left) (/.format right)))))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux
deleted file mode 100644
index 805939c68..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux
+++ /dev/null
@@ -1,135 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" product]]
-   [math
-    ["[0]" random (.only Random)]]
-   [meta
-    ["[0]" configuration
-     ["$[1]" \\test]]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["[0]" check]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    ["[2][0]" module]
-    [//
-     [phase
-      ["[2][0]" extension]]
-     [///
-      ["[2][0]" phase (.use "[1]#[0]" functor)]]]]]])
-
-(def .public random_state
-  (Random Lux)
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 1)
-     configuration ($configuration.random 5)]
-    (in (//.state (//.info version host configuration)))))
-
-(def primitive
-  (Random Type)
-  (do random.monad
-    [name (random.lower_case 1)]
-    (in {.#Primitive name (list)})))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux ..random_state
-         .let [state [/extension.#bundle /extension.empty
-                      /extension.#state lux]]
-         expected ..primitive
-         dummy (random.only (|>> (type#= expected) not)
-                            ..primitive)
-         module (random.lower_case 1)]
-        (all _.and
-             (_.coverage [/.expecting /.inference]
-               (and (|> (/.inference expected)
-                        (/.expecting expected)
-                        (/module.with 0 module)
-                        (/phase#each product.right)
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} true
-                          {try.#Failure _} false))
-                    (|> (/.inference dummy)
-                        (/.expecting expected)
-                        (/module.with 0 module)
-                        (/phase#each product.right)
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} false
-                          {try.#Failure _} true))
-                    (|> (/.inference expected)
-                        (/.expecting dummy)
-                        (/module.with 0 module)
-                        (/phase#each product.right)
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} false
-                          {try.#Failure _} true))))
-             (_.coverage [/.inferring]
-               (|> (/.inference expected)
-                   /.inferring
-                   (/module.with 0 module)
-                   (/phase#each product.right)
-                   (/phase.result state)
-                   (try#each (|>> product.left (type#= expected)))
-                   (try.else false)))
-             (_.coverage [/.check]
-               (|> (do /phase.monad
-                     [exT (/.check (do check.monad
-                                     [[id type] check.existential]
-                                     (in type)))]
-                     (|> (/.inference exT)
-                         (/.expecting exT)))
-                   (/module.with 0 module)
-                   (/phase#each product.right)
-                   (/phase.result state)
-                   (pipe.case
-                     {try.#Success _} true
-                     {try.#Failure _} false)))
-             (_.coverage [/.existential /.existential?]
-               (|> (do /phase.monad
-                     [:it: /.existential]
-                     (in (/.existential? :it:)))
-                   (/module.with 0 module)
-                   (/phase#each product.right)
-                   (/phase.result state)
-                   (try.else false)))
-             (_.coverage [/.fresh]
-               (and (|> (do /phase.monad
-                          [varT (/.check (do check.monad
-                                           [[id type] check.var]
-                                           (in type)))]
-                          (|> (/.inference expected)
-                              (/.expecting varT)))
-                        (/module.with 0 module)
-                        (/phase#each product.right)
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} true
-                          {try.#Failure _} false))
-                    (|> (do /phase.monad
-                          [varT (/.check (do check.monad
-                                           [[id type] check.var]
-                                           (in type)))]
-                          (|> (/.inference expected)
-                              (/.expecting varT)
-                              /.fresh))
-                        (/module.with 0 module)
-                        (/phase#each product.right)
-                        (/phase.result state)
-                        (pipe.case
-                          {try.#Success _} false
-                          {try.#Failure _} true))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux
deleted file mode 100644
index 91614f4b2..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux
+++ /dev/null
@@ -1,967 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    ["[0]" text]
-    [collection
-     ["[0]" list]]]
-   [math
-    ["[0]" random]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" code]
-    ["[0]" macro]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["[0]" check]]]]]
- [\\library
-  ["[0]" / (.only)
-   [//
-    ["[0]" extension (.only)
-     ["[1]/[0]" analysis
-      ["[1]" lux]]]
-    [//
-     ["/[1]" analysis (.only Analysis Operation)
-      [evaluation (.only Eval)]
-      ["[1][0]" macro]
-      ["[1][0]" scope]
-      ["[1][0]" module]
-      ["[1][0]" pattern]
-      ["[1][0]" type (.only)
-       ["$[1]" \\test]]]
-     [///
-      ["[0]" phase (.use "[1]#[0]" monad)]
-      [meta
-       ["[0]" archive]]]]]]]
- ["[0]" /
-  ["[1][0]" simple]
-  ["[1][0]" complex]
-  ["[1][0]" reference]
-  ["[1][0]" function]
-  ["[1][0]" case]])
-
-(def (eval archive type term)
-  Eval
-  (phase#in []))
-
-(def (expander macro inputs state)
-  //macro.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def (can_analyse_unit! lux module/0)
-  (-> Lux Text Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]]
-    (|> (do phase.monad
-          [[:it: it] (|> (' [])
-                         (/.phase ..expander archive.empty)
-                         //type.inferring)]
-          (in (and (type#= .Any :it:)
-                   (case it
-                     (//.unit)
-                     true
-
-                     _
-                     false))))
-        //scope.with
-        (//module.with 0 module/0)
-        (phase#each (|>> product.right product.right))
-        (phase.result state)
-        (try.else false))))
-
-(def (can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-  (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]]
-    (`` (and (,, (with_template [   ]
-                   [(|> (do phase.monad
-                          [[:it: it] (|> 
-                                         
-                                         (/.phase ..expander archive.empty)
-                                         //type.inferring)]
-                          (in (and (type#=  :it:)
-                                   (case it
-                                     ( it)
-                                     (same?  it)
-
-                                     _
-                                     false))))
-                        //scope.with
-                        (//module.with 0 module/0)
-                        (phase#each (|>> product.right product.right))
-                        (phase.result state)
-                        (try.else false))]
-                   
-                   [bit/0 code.bit .Bit //.bit]
-                   [nat/0 code.nat .Nat //.nat]
-                   [int/0 code.int .Int //.int]
-                   [rev/0 code.rev .Rev //.rev]
-                   [frac/0 code.frac .Frac //.frac]
-                   [text/0 code.text .Text //.text]
-
-                   ... Singleton tuple
-                   [bit/0 (<| code.tuple list code.bit) .Bit //.bit]
-                   [nat/0 (<| code.tuple list code.nat) .Nat //.nat]
-                   [int/0 (<| code.tuple list code.int) .Int //.int]
-                   [rev/0 (<| code.tuple list code.rev) .Rev //.rev]
-                   [frac/0 (<| code.tuple list code.frac) .Frac //.frac]
-                   [text/0 (<| code.tuple list code.text) .Text //.text]
-                   ))
-             ))))
-
-(def (can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
-  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-        :record: (And .Any .Bit .Nat .Int .Rev .Frac .Text)
-        :variant: (Or .Any .Bit .Nat .Int .Rev .Frac .Text)
-
-        can_analyse_unary!
-        (`` (and (|> (do phase.monad
-                       [it (|> (code.variant (list (code.nat 0) (code.bit #0) (` [])))
-                               (/.phase ..expander archive.empty)
-                               (//type.expecting :variant:))]
-                       (in (case it
-                             (//.variant [0 #0 (//.unit)])
-                             true
-
-                             _
-                             false)))
-                     //scope.with
-                     (//module.with 0 module/0)
-                     (phase#each (|>> product.right product.right))
-                     (phase.result state)
-                     (try.else false))
-                 (,, (with_template [     ]
-                       [(|> (do phase.monad
-                              [it (|> (code.variant (list (code.nat ) (code.bit ) ( )))
-                                      (/.phase ..expander archive.empty)
-                                      (//type.expecting :variant:))]
-                              (in (case it
-                                    (//.variant [  ( actual)])
-                                    (same?  actual)
-
-                                    _
-                                    false)))
-                            //scope.with
-                            (//module.with 0 module/0)
-                            (phase#each (|>> product.right product.right))
-                            (phase.result state)
-                            (try.else false))]
-
-                       [1 #0 bit/0 @bit code.bit //.bit]
-                       [2 #0 nat/0 @nat code.nat //.nat]
-                       [3 #0 int/0 @int code.int //.int]
-                       [4 #0 rev/0 @rev code.rev //.rev]
-                       [5 #0 frac/0 @frac code.frac //.frac]
-                       [5 #1 text/0 @text code.text //.text]
-                       ))))
-
-        can_analyse_nullary!
-        (|> (do phase.monad
-              [.let [:either: (Or .Any :record:)]
-               it (|> (code.variant (list (code.nat 0) (code.bit #0)))
-                      (/.phase ..expander archive.empty)
-                      (//type.expecting :either:))]
-              (in (case it
-                    (//.variant [0 #0 (//.unit)])
-                    true
-
-                    _
-                    false)))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        can_analyse_multiary!
-        (|> (do phase.monad
-              [.let [:either: (Or .Any :record:)]
-               it (|> (code.variant (list (code.nat 0)
-                                          (code.bit #1)
-                                          (` [])
-                                          (code.bit bit/0)
-                                          (code.nat nat/0)
-                                          (code.int int/0)
-                                          (code.rev rev/0)
-                                          (code.frac frac/0)
-                                          (code.text text/0)))
-                      (/.phase ..expander archive.empty)
-                      (//type.expecting :either:))]
-              (in (case it
-                    (//.variant [0 #1 (//.tuple (list (//.unit)
-                                                      (//.bit bit/?)
-                                                      (//.nat nat/?)
-                                                      (//.int int/?)
-                                                      (//.rev rev/?)
-                                                      (//.frac frac/?)
-                                                      (//.text text/?)))])
-                    (and (same? bit/0 bit/?)
-                         (same? nat/0 nat/?)
-                         (same? int/0 int/?)
-                         (same? rev/0 rev/?)
-                         (same? frac/0 frac/?)
-                         (same? text/0 text/?))
-
-                    _
-                    false)))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))]
-    (and can_analyse_unary!
-         can_analyse_nullary!
-         can_analyse_multiary!
-         )))
-
-(def (can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
-  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-        :record: {.#Named [module/0 @text]
-                          (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])}
-        slots/* (list @any @bit @nat @int @rev @frac @text)
-        :variant: {.#Named [module/0 @text]
-                           (type_literal (Or .Any .Bit .Nat .Int .Rev .Frac .Text))}
-        tags/* (list @any @bit @nat @int @rev @frac @text)
-
-        can_analyse_unary!
-        (`` (and (|> (do phase.monad
-                       [_ (//module.declare_labels false tags/* false :variant:)
-                        [:it: it] (|> (code.variant (list (code.local @any) (` [])))
-                                      (/.phase ..expander archive.empty)
-                                      //type.inferring)]
-                       (in (and (type#= :variant:
-                                        :it:)
-                                (case it
-                                  (//.variant [0 #0 (//.unit)])
-                                  true
-
-                                  _
-                                  false))))
-                     //scope.with
-                     (//module.with 0 module/0)
-                     (phase#each (|>> product.right product.right))
-                     (phase.result state)
-                     (try.else false))
-                 (,, (with_template [     ]
-                       [(|> (do phase.monad
-                              [_ (//module.declare_labels false tags/* false :variant:)
-                               [:it: it] (|> (code.variant (list (code.local ) ( )))
-                                             (/.phase ..expander archive.empty)
-                                             //type.inferring)]
-                              (in (and (type#= :variant:
-                                               :it:)
-                                       (case it
-                                         (//.variant [  ( actual)])
-                                         (same?  actual)
-
-                                         _
-                                         false))))
-                            //scope.with
-                            (//module.with 0 module/0)
-                            (phase#each (|>> product.right product.right))
-                            (phase.result state)
-                            (try.else false))]
-
-                       [1 #0 bit/0 @bit code.bit //.bit]
-                       [2 #0 nat/0 @nat code.nat //.nat]
-                       [3 #0 int/0 @int code.int //.int]
-                       [4 #0 rev/0 @rev code.rev //.rev]
-                       [5 #0 frac/0 @frac code.frac //.frac]
-                       [5 #1 text/0 @text code.text //.text]
-                       ))))
-
-        can_analyse_nullary!
-        (|> (do phase.monad
-              [_ (//module.declare_labels true slots/* false :record:)
-               .let [:either: {.#Named [module/0 module/0]
-                                       (type_literal (Or .Any :record:))}]
-               _ (//module.declare_labels false (list @left @right) false :either:)
-               [:it: it] (|> (code.variant (list (code.local @left)))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= :either:
-                               :it:)
-                       (case it
-                         (//.variant [0 #0 (//.unit)])
-                         true
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        can_analyse_multiary!
-        (|> (do phase.monad
-              [_ (//module.declare_labels true slots/* false :record:)
-               .let [:either: {.#Named [module/0 module/0]
-                                       (type_literal (Or .Any :record:))}]
-               _ (//module.declare_labels false (list @left @right) false :either:)
-               [:it: it] (|> (code.variant (list (code.local @right)
-                                                 (` [])
-                                                 (code.bit bit/0)
-                                                 (code.nat nat/0)
-                                                 (code.int int/0)
-                                                 (code.rev rev/0)
-                                                 (code.frac frac/0)
-                                                 (code.text text/0)))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= :either:
-                               :it:)
-                       (case it
-                         (//.variant [0 #1 (//.tuple (list (//.unit)
-                                                           (//.bit bit/?)
-                                                           (//.nat nat/?)
-                                                           (//.int int/?)
-                                                           (//.rev rev/?)
-                                                           (//.frac frac/?)
-                                                           (//.text text/?)))])
-                         (and (same? bit/0 bit/?)
-                              (same? nat/0 nat/?)
-                              (same? int/0 int/?)
-                              (same? rev/0 rev/?)
-                              (same? frac/0 frac/?)
-                              (same? text/0 text/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))]
-    (and can_analyse_unary!
-         can_analyse_nullary!
-         can_analyse_multiary!)))
-
-(def (can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-  (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]]
-    (|> (do phase.monad
-          [[:it: it] (|> (code.tuple (list (` [])
-                                           (code.bit bit/0)
-                                           (code.nat nat/0)
-                                           (code.int int/0)
-                                           (code.rev rev/0)
-                                           (code.frac frac/0)
-                                           (code.text text/0)))
-                         (/.phase ..expander archive.empty)
-                         //type.inferring)]
-          (in (and (type#= (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])
-                           :it:)
-                   (case it
-                     (//.tuple (list (//.unit)
-                                     (//.bit bit/?)
-                                     (//.nat nat/?)
-                                     (//.int int/?)
-                                     (//.rev rev/?)
-                                     (//.frac frac/?)
-                                     (//.text text/?)))
-                     (and (same? bit/0 bit/?)
-                          (same? nat/0 nat/?)
-                          (same? int/0 int/?)
-                          (same? rev/0 rev/?)
-                          (same? frac/0 frac/?)
-                          (same? text/0 text/?))
-
-                     _
-                     false))))
-        //scope.with
-        (//module.with 0 module/0)
-        (phase#each (|>> product.right product.right))
-        (phase.result state)
-        (try.else false))))
-
-(def (can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-        :record: {.#Named [module/0 @text]
-                          (type_literal [.Any .Bit .Nat .Int .Rev .Frac .Text])}
-        slots/* (list @any @bit @nat @int @rev @frac @text)]
-    (|> (do phase.monad
-          [_ (//module.declare_labels true slots/* false :record:)
-           [:it: it] (|> (code.tuple (list (code.local @text) (code.text text/0)
-                                           (code.local @bit) (code.bit bit/0)
-                                           (code.local @rev) (code.rev rev/0)
-                                           (code.local @int) (code.int int/0)
-                                           (code.local @nat) (code.nat nat/0)
-                                           (code.local @frac) (code.frac frac/0)
-                                           (code.local @any) (` [])))
-                         (/.phase ..expander archive.empty)
-                         //type.inferring)]
-          (in (and (type#= :record:
-                           :it:)
-                   (case it
-                     (//.tuple (list (//.unit)
-                                     (//.bit bit/?)
-                                     (//.nat nat/?)
-                                     (//.int int/?)
-                                     (//.rev rev/?)
-                                     (//.frac frac/?)
-                                     (//.text text/?)))
-                     (and (same? bit/0 bit/?)
-                          (same? nat/0 nat/?)
-                          (same? int/0 int/?)
-                          (same? rev/0 rev/?)
-                          (same? frac/0 frac/?)
-                          (same? text/0 text/?))
-
-                     _
-                     false))))
-        //scope.with
-        (//module.with 0 module/0)
-        (phase#each (|>> product.right product.right))
-        (phase.result state)
-        (try.else false))))
-
-(def (can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
-  (-> Lux Text Nat [Code Code Code Code] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-
-        can_make_abstraction!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)] (, (code.nat nat/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= (All (_ a) (-> a .Nat))
-                               :it:)
-                       (case it
-                         {//.#Function (list) (//.nat nat/?)}
-                         (same? nat/0 nat/?)
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        can_nest_abstraction!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
-                                 ([(, $abstraction/1) (, $parameter/1)]
-                                  (, (code.nat nat/0)))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= (All (_ a) (-> a (All (_ b) (-> b .Nat))))
-                               :it:)
-                       (case it
-                         {//.#Function (list) {//.#Function (list) (//.nat nat/?)}}
-                         (same? nat/0 nat/?)
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        can_refer_to_parameter!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
-                                 ([(, $abstraction/1) (, $parameter/1)]
-                                  (, $parameter/1))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= (All (_ a) (-> a (All (_ b) (-> b b))))
-                               :it:)
-                       (case it
-                         {//.#Function (list) {//.#Function (list) (//.local 1)}}
-                         true
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        can_refer_to_closure!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
-                                 ([(, $abstraction/1) (, $parameter/1)]
-                                  (, $parameter/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (case it
-                         {//.#Function (list) {//.#Function (list (//.local 1)) (//.foreign 0)}}
-                         true
-
-                         _
-                         false)
-                       ... TODO: Un-comment
-                       ... (type#= (All (_ a) (-> a (All (_ b) (-> b a))))
-                       ...         :it:)
-                       )))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))]
-    (and can_make_abstraction!
-         can_nest_abstraction!
-         can_refer_to_parameter!
-         can_refer_to_closure!
-         ... TODO: Un-comment
-         ... (|> (do phase.monad
-         ...       [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
-         ...                          ([(, $abstraction/1) (, $parameter/1)]
-         ...                           (, $abstraction/1))))
-         ...                      (/.phase ..expander archive.empty)
-         ...                      //type.inferring)]
-         ...       (in (case it
-         ...             {//.#Function (list) {//.#Function (list) (//.local 0)}}
-         ...             true
-
-         ...             _
-         ...             false)))
-         ...     //scope.with
-         ...     (//module.with 0 module/0)
-         ...     (phase#each (|>> product.right product.right))
-         ...     (phase.result state)
-         ...     (try.else false))
-         ... TODO: Un-comment
-         ... (|> (do phase.monad
-         ...       [[:it: it] (|> (` ([(, $abstraction/0) (, $parameter/0)]
-         ...                          ([(, $abstraction/1) (, $parameter/1)]
-         ...                           (, $abstraction/0))))
-         ...                      (/.phase ..expander archive.empty)
-         ...                      //type.inferring)]
-         ...       (in (case it
-         ...             {//.#Function (list) {//.#Function (list (//.local 0)) (//.foreign 0)}}
-         ...             true
-
-         ...             _
-         ...             false)))
-         ...     //scope.with
-         ...     (//module.with 0 module/0)
-         ...     (phase#each (|>> product.right product.right))
-         ...     (phase.result state)
-         ...     (try.else false))
-         )))
-
-(def (can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
-  (-> Lux Text Bit Nat [Code Code Code Code] Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-
-        constant!
-        (|> (do phase.monad
-              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)] (, (code.bit bit/0)))
-                                 (, (code.nat nat/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= .Bit :it:)
-                       (case it
-                         {//.#Apply (//.nat nat/?)
-                                    {//.#Function (list) (//.bit bit/?)}}
-                         (and (same? bit/0 bit/?)
-                              (same? nat/0 nat/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        variable!
-        (|> (do phase.monad
-              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)] (, $parameter/0))
-                                 (, (code.nat nat/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= .Nat :it:)
-                       (case it
-                         {//.#Apply (//.nat nat/?)
-                                    {//.#Function (list) (//.local 1)}}
-                         (same? nat/0 nat/?)
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        partial!
-        (|> (do phase.monad
-              [[:it: it] (|> (` (([(, $abstraction/0) (, $parameter/0)]
-                                  ([(, $abstraction/1) (, $parameter/1)]
-                                   (, (code.bit bit/0))))
-                                 (, (code.nat nat/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (check.subsumes? (All (_ a) (-> a Bit)) :it:)
-                       (case it
-                         {//.#Apply (//.nat nat/?)
-                                    {//.#Function (list)
-                                                  {//.#Function (list) (//.bit bit/?)}}}
-                         (and (same? bit/0 bit/?)
-                              (same? nat/0 nat/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))]
-    (and constant!
-         variable!
-         partial!)))
-
-(def (can_analyse_extension! lux module/0 text/0)
-  (-> Lux Text Text Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]]
-    (|> (do phase.monad
-          [[:it: it] (|> (` ("lux text concat" (, (code.text text/0)) (, (code.text text/0))))
-                         (/.phase ..expander archive.empty)
-                         //type.inferring)]
-          (in (and (type#= .Text :it:)
-                   (case it
-                     {//.#Extension "lux text concat" (list (//.text left) (//.text right))}
-                     (and (same? text/0 left)
-                          (same? text/0 right))
-
-                     _
-                     false))))
-        //scope.with
-        (//module.with 0 module/0)
-        (phase#each (|>> product.right product.right))
-        (phase.result state)
-        (try.else false))))
-
-(def (can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0)
-  (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Code Bit)
-  (let [state [extension.#bundle (extension/analysis.bundle ..eval)
-               extension.#state lux]
-        
-        :variant: {.#Named [module/0 module/0]
-                           (type_literal (Or .Any .Bit .Nat .Int .Rev .Frac .Text))}
-        tags/* (list @any @bit @nat @int @rev @frac @text)
-
-        :record: {.#Named [module/0 module/0]
-                          (type_literal (And .Any .Bit .Nat .Int .Rev .Frac .Text))}
-        slots/* (list @any @bit @nat @int @rev @frac @text)
-
-        simple!
-        (`` (and (,, (with_template [   ]
-                       [(|> (do phase.monad
-                              [[:it: it] (|> (` ({(, $parameter/0) (, (code.frac frac/0))} (, ( ))))
-                                             (/.phase ..expander archive.empty)
-                                             //type.inferring)]
-                              (in (and (type#= .Frac :it:)
-                                       (case it
-                                         {//.#Case ( input/?)
-                                                   [[//.#when (//pattern.bind 0)
-                                                     //.#then (//.frac frac/?)]
-                                                    (list)]}
-                                         (and (same?  input/?)
-                                              (same? frac/0 frac/?))
-
-                                         _
-                                         false))))
-                            //scope.with
-                            (//module.with 0 module/0)
-                            (phase#each (|>> product.right product.right))
-                            (phase.result state)
-                            (try.else false))
-                        (|> (do phase.monad
-                              [[:it: it] (|> (` ({(, ( ))
-                                                  (, (code.frac frac/0))
-
-                                                  (, $parameter/0)
-                                                  (, (code.frac frac/0))}
-                                                 (, ( ))))
-                                             (/.phase ..expander archive.empty)
-                                             //type.inferring)]
-                              (in (and (type#= .Frac :it:)
-                                       (case it
-                                         {//.#Case ( input/?)
-                                                   [[//.#when ( pattern/?)
-                                                     //.#then (//.frac frac/?)]
-                                                    (list [//.#when (//pattern.bind 0)
-                                                           //.#then (//.frac frac/?)])]}
-                                         (and (same?  input/?)
-                                              (same?  pattern/?)
-                                              (same? frac/0 frac/?))
-
-                                         _
-                                         false))))
-                            //scope.with
-                            (//module.with 0 module/0)
-                            (phase#each (|>> product.right product.right))
-                            (phase.result state)
-                            (try.else false))]
-
-                       [bit/0 code.bit //.bit //pattern.bit]
-                       [nat/0 code.nat //.nat //pattern.nat]
-                       [int/0 code.int //.int //pattern.int]
-                       [rev/0 code.rev //.rev //pattern.rev]
-                       [frac/0 code.frac //.frac //pattern.frac]
-                       [text/0 code.text //.text //pattern.text]
-                       ))))
-
-        bit!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ({#0
-                                  (, (code.frac frac/0))
-
-                                  #1
-                                  (, (code.frac frac/0))}
-                                 (, (code.bit bit/0))))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= .Frac :it:)
-                       (case it
-                         {//.#Case (//.bit bit/?)
-                                   [[//.#when (//pattern.bit #0)
-                                     //.#then (//.frac false/?)]
-                                    (list [//.#when (//pattern.bit #1)
-                                           //.#then (//.frac true/?)])]}
-                         (and (same? bit/0 bit/?)
-                              (same? frac/0 false/?)
-                              (same? frac/0 true/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        variant!
-        (`` (and (,, (with_template [      ]
-                       [(|> (do phase.monad
-                              [_ (//module.declare_labels false tags/* false :variant:)
-                               [:it: it] (|> (` ({{(, (code.local )) (, ( ))}
-                                                  (, (code.frac frac/0))
-
-                                                  (, $parameter/0)
-                                                  (, (code.frac frac/0))}
-                                                 {(, (code.local )) (, ( ))}))
-                                             (/.phase ..expander archive.empty)
-                                             //type.inferring)]
-                              (in (and (type#= .Frac :it:)
-                                       (case it
-                                         {//.#Case (//.variant [  ( analysis/?)])
-                                                   [[//.#when (//pattern.variant [  ( pattern/?)])
-                                                     //.#then (//.frac match/?)]
-                                                    (list [//.#when (//pattern.bind 0)
-                                                           //.#then (//.frac mismatch/?)])]}
-                                         (and (same?  analysis/?)
-                                              (same?  pattern/?)
-                                              (same? frac/0 match/?)
-                                              (same? frac/0 mismatch/?))
-
-                                         _
-                                         false))))
-                            //scope.with
-                            (//module.with 0 module/0)
-                            (phase#each (|>> product.right product.right))
-                            (phase.result state)
-                            (try.else false))]
-
-                       [1 #0 bit/0 @bit code.bit //.bit //pattern.bit]
-                       [2 #0 nat/0 @nat code.nat //.nat //pattern.nat]
-                       [3 #0 int/0 @int code.int //.int //pattern.int]
-                       [4 #0 rev/0 @rev code.rev //.rev //pattern.rev]
-                       [5 #0 frac/0 @frac code.frac //.frac //pattern.frac]
-                       [5 #1 text/0 @text code.text //.text //pattern.text]
-                       ))))
-
-        tuple!
-        (|> (do phase.monad
-              [[:it: it] (|> (` ({[#0 (, $parameter/0)]
-                                  (, (code.frac frac/0))
-
-                                  [#1 (, $parameter/0)]
-                                  (, (code.frac frac/0))}
-                                 [(, (code.bit bit/0))
-                                  (, (code.nat nat/0))]))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= .Frac :it:)
-                       (case it
-                         {//.#Case (//.tuple (list (//.bit bit/?) (//.nat nat/?)))
-                                   [[//.#when (//pattern.tuple (list (//pattern.bit #0) (//pattern.bind 0)))
-                                     //.#then (//.frac false/?)]
-                                    (list [//.#when (//pattern.tuple (list (//pattern.bit #1) (//pattern.bind 0)))
-                                           //.#then (//.frac true/?)])]}
-                         (and (same? bit/0 bit/?)
-                              (same? nat/0 nat/?)
-                              (same? frac/0 false/?)
-                              (same? frac/0 true/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))
-
-        record!
-        (|> (do phase.monad
-              [_ (//module.declare_labels true slots/* false :record:)
-               [:it: it] (|> (` ({[(, (code.symbol [module/0 @any])) []
-                                   (, (code.symbol [module/0 @bit])) (, (code.bit bit/0))
-                                   (, (code.symbol [module/0 @nat])) (, (code.nat nat/0))
-                                   (, (code.symbol [module/0 @int])) (, (code.int int/0))
-                                   (, (code.symbol [module/0 @rev])) (, (code.rev rev/0))
-                                   (, (code.symbol [module/0 @frac])) (, (code.frac frac/0))
-                                   (, (code.symbol [module/0 @text])) (, (code.text text/0))]
-                                  (, (code.frac frac/0))
-
-                                  (, $parameter/0)
-                                  (, (code.frac frac/0))}
-                                 [(, (code.local @any)) []
-                                  (, (code.local @bit)) (, (code.bit bit/0))
-                                  (, (code.local @nat)) (, (code.nat nat/0))
-                                  (, (code.local @int)) (, (code.int int/0))
-                                  (, (code.local @rev)) (, (code.rev rev/0))
-                                  (, (code.local @frac)) (, (code.frac frac/0))
-                                  (, (code.local @text)) (, (code.text text/0))]))
-                             (/.phase ..expander archive.empty)
-                             //type.inferring)]
-              (in (and (type#= .Frac :it:)
-                       (case it
-                         {//.#Case (//.tuple (list (//.unit)
-                                                   (//.bit bit/?)
-                                                   (//.nat nat/?)
-                                                   (//.int int/?)
-                                                   (//.rev rev/?)
-                                                   (//.frac frac/?)
-                                                   (//.text text/?)))
-                                   [[//.#when (//pattern.tuple (list (//pattern.unit)
-                                                                     (//pattern.bit bit/?')
-                                                                     (//pattern.nat nat/?')
-                                                                     (//pattern.int int/?')
-                                                                     (//pattern.rev rev/?')
-                                                                     (//pattern.frac frac/?')
-                                                                     (//pattern.text text/?')))
-                                     //.#then (//.frac match/?)]
-                                    (list [//.#when (//pattern.bind 0)
-                                           //.#then (//.frac mismatch/?)])]}
-                         (and (same? bit/0 bit/?) (same? bit/0 bit/?')
-                              (same? nat/0 nat/?) (same? nat/0 nat/?')
-                              (same? int/0 int/?) (same? int/0 int/?')
-                              (same? rev/0 rev/?) (same? rev/0 rev/?')
-                              (same? frac/0 frac/?) (same? frac/0 frac/?')
-                              (same? text/0 text/?) (same? text/0 text/?')
-                              (same? frac/0 match/?)
-                              (same? frac/0 mismatch/?))
-
-                         _
-                         false))))
-            //scope.with
-            (//module.with 0 module/0)
-            (phase#each (|>> product.right product.right))
-            (phase.result state)
-            (try.else false))]
-    (and simple!
-         bit!
-         variant!
-         tuple!
-         record!)))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux $//type.random_state
-         .let [state [extension.#bundle (extension/analysis.bundle ..eval)
-                      extension.#state lux]]
-
-         .let [[module/0 _] (symbol ._)]
-         
-         bit/0 random.bit
-         nat/0 random.nat
-         int/0 random.int
-         rev/0 random.rev
-         frac/0 random.frac
-         text/0 (random.lower_case 1)
-
-         @any (random.lower_case 2)
-         @bit (random.lower_case 3)
-         @nat (random.lower_case 4)
-         @int (random.lower_case 5)
-         @rev (random.lower_case 6)
-         @frac (random.lower_case 7)
-         @text (random.lower_case 8)
-
-         @left (random.lower_case 9)
-         @right (random.lower_case 10)
-
-         $abstraction/0 (at ! each code.local (random.lower_case 11))
-         $parameter/0 (at ! each code.local (random.lower_case 12))
-         $abstraction/1 (at ! each code.local (random.lower_case 13))
-         $parameter/1 (at ! each code.local (random.lower_case 14))])
-      (all _.and
-           (_.coverage [/.phase]
-             (and (..can_analyse_unit! lux module/0)
-                  (..can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-                  (..can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
-                  (..can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right])
-                  (..can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-                  (..can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0])
-                  (..can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
-                  (..can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1])
-                  (..can_analyse_extension! lux module/0 text/0)
-                  (..can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0)
-                  ))
-           (_.coverage [/.invalid]
-             (`` (and (,, (with_template []
-                            [(|> (do phase.monad
-                                   [_ (|> 
-                                          (/.phase ..expander archive.empty)
-                                          (//type.expecting .Any))]
-                                   (in false))
-                                 //scope.with
-                                 (//module.with 0 module/0)
-                                 (phase#each (|>> product.right product.right))
-                                 (phase.result state)
-                                 (exception.otherwise (text.contains? (the exception.#label /.invalid))))]
-
-                            [(` ({#0} (, (code.bit bit/0))))]
-                            [(` ({#0 [] #1} (, (code.bit bit/0))))]
-                            [(` {(, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0))})]
-                            [(` {(, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0))})]
-                            [(` {(, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0))})]
-                            [(` {(, (code.rev rev/0)) (, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0))})]
-                            [(` {(, (code.frac frac/0)) (, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0))})]
-                            [(` {(, (code.text text/0)) (, (code.bit bit/0)) (, (code.nat nat/0)) (, (code.int int/0)) (, (code.rev rev/0)) (, (code.frac frac/0))})]
-                            ))
-                      )))
-           
-           /simple.test
-           /complex.test
-           /reference.test
-           /function.test
-           /case.test
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux
deleted file mode 100644
index 5c1752fe3..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux
+++ /dev/null
@@ -1,636 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    ["[0]" text (.only)
-     ["%" \\format]]]
-   [math
-    ["[0]" random]]
-   [meta
-    ["[0]" code]
-    ["[0]" macro]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["[0]" check]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [//
-     ["[1][0]" extension (.only)
-      ["[1]/[0]" analysis
-       ["[1]" lux]]]
-     [//
-      ["[1][0]" analysis (.only)
-       [evaluation (.only Eval)]
-       ["[2][0]" macro]
-       ["[2][0]" scope]
-       ["[2][0]" module]
-       ["[2][0]" coverage]
-       ["[2][0]" type (.only)
-        ["$[1]" \\test]]
-       ["[2][0]" inference
-        ["$[1]" \\test]]]
-      [///
-       ["[1][0]" phase (.use "[1]#[0]" monad)]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def (eval archive type term)
-  Eval
-  (//phase#in []))
-
-(def (expander macro inputs state)
-  //macro.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def analysis
-  //analysis.Phase
-  (//.phase ..expander))
-
-(def test|tuple
-  Test
-  (do [! random.monad]
-    [lux $//type.random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     module/0 (random.lower_case 1)
-     name/0 (at ! each (|>> [module/0]) (random.lower_case 2))
-     [input/0 simple/0] $//inference.simple_parameter
-     [input/1 simple/1] $//inference.simple_parameter
-     [input/2 simple/2] $//inference.simple_parameter
-     $binding/0 (at ! each code.local (random.lower_case 3))
-     $binding/1 (at ! each code.local (random.lower_case 4))
-     $binding/2 (at ! each code.local (random.lower_case 5))]
-    (all _.and
-         (_.coverage [/.tuple]
-           (let [tuple? (is (-> Type Type Bit)
-                            (function (_ :input: :expected:)
-                              (and (|> :input:
-                                       /.tuple
-                                       (check.result check.fresh_context)
-                                       (try#each (|>> product.right (type#= :expected:)))
-                                       (try.else false))
-                                   (|> (do check.monad
-                                         [[@var :var:] check.var
-                                          _ (check.check :var: :input:)]
-                                         (/.tuple :var:))
-                                       (check.result check.fresh_context)
-                                       (try#each (|>> product.right (type#= :expected:)))
-                                       (try.else false)))))]
-             (and (tuple? input/0
-                          (type.anonymous input/0))
-                  (tuple? (Tuple input/0 input/1 input/2)
-                          (Tuple input/0 input/1 input/2))
-                  (tuple? {.#Named name/0 (Tuple input/0 input/1 input/2)}
-                          (Tuple input/0 input/1 input/2))
-                  (tuple? (All (_ a b c) (Tuple input/0 input/1 input/2))
-                          (Tuple (All (_ a b c) input/0)
-                                 (All (_ a b c) input/1)
-                                 (All (_ a b c) input/2)))
-                  (tuple? (type_literal ((All (_ a b c) (Tuple a b c)) input/0 input/1 input/2))
-                          (Tuple input/0 input/1 input/2))
-                  (|> (do check.monad
-                        [[@var :var:] check.var
-                         _ (check.bind (All (_ a b c) (Tuple a b c)) @var)]
-                        (/.tuple (type_literal (:var: input/0 input/1 input/2))))
-                      (check.result check.fresh_context)
-                      (try#each (|>> product.right (type#= (Tuple input/0 input/1 input/2))))
-                      (try.else false))
-                  (|> (do check.monad
-                        [[@0 :0:] check.existential
-                         [@1 :1:] check.existential
-                         [_ :tuple:] (/.tuple (Ex (_ a b c) (Tuple a input/1 c)))
-                         context check.context
-                         _ (check.with context)
-                         _ (check.check (Tuple :0: input/1 :1:) :tuple:)
-                         _ (check.with context)
-                         _ (check.check :tuple: (Tuple :0: input/1 :1:))]
-                        (in true))
-                      (check.result check.fresh_context)
-                      (try.else false)))))
-         (_.coverage [/.non_tuple]
-           (and (|> (do check.monad
-                      [[@var :var:] check.var
-                       _ (/.tuple :var:)]
-                      (in false))
-                    (check.result check.fresh_context)
-                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
-                (|> (do check.monad
-                      [[@var :var:] check.var
-                       _ (/.tuple (type_literal (:var: input/0 input/1 input/2)))]
-                      (in false))
-                    (check.result check.fresh_context)
-                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
-                (|> (do check.monad
-                      [_ (/.tuple (type_literal (input/0 input/1 input/2)))]
-                      (in false))
-                    (check.result check.fresh_context)
-                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))
-                (|> (do check.monad
-                      [[@var :var:] check.var
-                       _ (check.bind input/0 @var)
-                       _ (/.tuple (type_literal (:var: input/1 input/2)))]
-                      (in false))
-                    (check.result check.fresh_context)
-                    (exception.otherwise (text.contains? (the exception.#label /.non_tuple))))))
-         )))
-
-(def (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
-  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
-  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-               //extension.#state lux]
-        case? (is (-> Code (List [Code Code]) Bit)
-                  (function (_ input branches)
-                    (|> (do //phase.monad
-                          [analysis (|> (/.case ..analysis branches archive.empty input)
-                                        (//type.expecting output/0))]
-                          (in true))
-                        //scope.with
-                        (//module.with 0 module/0)
-                        (//phase#each (|>> product.right product.right))
-                        (//phase.result state)
-                        (try.else false))))
-
-        body_types_mismatch!
-        (and (not (case? (code.bit bit/0) (list [(` #0) body/1]
-                                                [(` #1) body/1])))
-             (not (case? (code.bit bit/0) (list [(` #0) body/0]
-                                                [(` #1) body/1]))))
-
-        input_types_mismatch!
-        (and (not (case? (code.nat nat/0) (list [(` #0) body/0]
-                                                [(` #1) body/0])))
-             (not (case? (code.bit bit/0) (list [(code.nat nat/0) body/0]
-                                                [$binding/0 body/0]))))
-
-        handles_singletons!
-        (and (case? simple/0 (list [(` [(, $binding/0)]) body/0]))
-             (case? simple/0 (list [(` [(, simple/0)]) body/0]
-                                   [(` [(, $binding/0)]) body/0]))
-             (case? (code.bit bit/0) (list [(` [#0]) body/0]
-                                           [(` [#1]) body/0])))
-
-        can_infer_body!
-        (|> (do //phase.monad
-              [[:actual: analysis] (|> (code.bit bit/0)
-                                       (/.case ..analysis
-                                         (list [(` #0) body/0]
-                                               [(` #1) body/0])
-                                         archive.empty)
-                                       //type.inferring)]
-              (in (type#= output/0 :actual:)))
-            //scope.with
-            (//module.with 0 module/0)
-            (//phase#each (|>> product.right product.right))
-            (//phase.result state)
-            (try.else false))
-
-        ensures_consistent_bodies!
-        (|> (do //phase.monad
-              [[:actual: analysis] (|> (code.bit bit/0)
-                                       (/.case ..analysis
-                                         (list [(` #0) body/0]
-                                               [(` #1) body/1])
-                                         archive.empty)
-                                       //type.inferring)]
-              (in false))
-            //scope.with
-            (//module.with 0 module/0)
-            (//phase#each (|>> product.right product.right))
-            (//phase.result state)
-            (try.else true))]
-    (and body_types_mismatch!
-         input_types_mismatch!
-         handles_singletons!
-         can_infer_body!
-         ensures_consistent_bodies!
-
-         (case? (` [])
-                (list [(` []) body/0]))
-         (case? (` [])
-                (list [$binding/0 body/0]))
-
-         (case? (code.bit bit/0) (list [(` #0) body/0]
-                                       [(` #1) body/0]))
-         (case? (code.bit bit/0) (list [(` #1) body/0]
-                                       [(` #0) body/0]))
-
-         (case? simple/0 (list [$binding/0 body/0]))
-         (case? simple/0 (list [simple/0 body/0]
-                               [$binding/0 body/0]))
-         
-         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
-                (list [$binding/0 body/0]))
-         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
-                (list [(` [(, $binding/0) (, $binding/1)]) body/0]))
-         (case? (` [(, simple/0) (, simple/1) (, simple/2)])
-                (list [(` [(, simple/0) (, simple/1) (, simple/2)]) body/0]
-                      ... 000
-                      [(` [(, $binding/0) (, simple/1) (, simple/2)]) body/0]
-                      ... 001
-                      [(` [(, simple/0) (, $binding/1) (, simple/2)]) body/0]
-                      ... 010
-                      [(` [(, $binding/0) (, $binding/1) (, simple/2)]) body/0]
-                      ... 011
-                      [(` [(, simple/0) (, simple/1) (, $binding/2)]) body/0]
-                      ... 100
-                      [(` [(, $binding/0) (, simple/1) (, $binding/2)]) body/0]
-                      ... 101
-                      [(` [(, simple/0) (, $binding/1) (, $binding/2)]) body/0]
-                      ... 110
-                      [(` [(, $binding/0) (, $binding/1) (, $binding/2)]) body/0]
-                      ... 111
-                      )))))
-
-(def (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] bit/0)
-  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] Bit Bit)
-  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-               //extension.#state lux]
-        redundant? (is (-> Code (List [Code Code]) Bit)
-                       (function (_ input branches)
-                         (|> (do //phase.monad
-                               [analysis (|> (/.case ..analysis branches archive.empty input)
-                                             (//type.expecting output/0))]
-                               (in true))
-                             //scope.with
-                             (//module.with 0 module/0)
-                             (//phase#each (|>> product.right product.right))
-                             (//phase.result state)
-                             (exception.otherwise (text.contains? (the exception.#label //coverage.redundancy))))))]
-    (and (redundant? (` [])
-                     (list [(` []) body/0]
-                           [(` []) body/0]))
-         (redundant? (` [])
-                     (list [$binding/0 body/0]
-                           [$binding/0 body/0]))
-         (redundant? (code.bit bit/0) (list [(` #0) body/0]
-                                            [(` #1) body/0]
-                                            [(` #0) body/0]))
-         (redundant? (code.bit bit/0) (list [(` #0) body/0]
-                                            [(` #1) body/0]
-                                            [(` #1) body/0]))
-         (redundant? (code.bit bit/0) (list [(` #0) body/0]
-                                            [(` #1) body/0]
-                                            [$binding/0 body/0]))
-         (redundant? simple/0 (list [$binding/0 body/0]
-                                    [$binding/0 body/0]))
-         (redundant? simple/0 (list [simple/0 body/0]
-                                    [$binding/0 body/0]
-                                    [$binding/0 body/0]))
-         (redundant? simple/0 (list [$binding/0 body/0]
-                                    [simple/0 body/0]))
-         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
-                     (list [$binding/0 body/0]
-                           [$binding/0 body/0]))
-         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
-                     (list [(` [(, $binding/0) (, $binding/1)]) body/0]
-                           [(` [(, $binding/0) (, $binding/1)]) body/0]))
-         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
-                     (list [(` [(, $binding/0) (, $binding/1)]) body/0]
-                           [$binding/0 body/0]))
-         (redundant? (` [(, simple/0) (, simple/1) (, simple/2)])
-                     (list [$binding/0 body/0]
-                           [(` [(, $binding/0) (, $binding/1)]) body/0])))))
-
-(def (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
-  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
-  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-               //extension.#state lux]
-        
-        tag/0 (%.code $binding/0)
-        tag/1 (%.code $binding/1)
-        tag/2 (%.code $binding/2)
-
-        tags/* (list tag/0 tag/1 tag/2)
-        :variant: {.#Named [module/0 name/0] (type.variant (list input/0 input/1 input/2))}
-
-        tag/0 (code.symbol [module/0 tag/0])
-        tag/1 (code.symbol [module/0 tag/1])
-        tag/2 (code.symbol [module/0 tag/2])
-        
-        variant? (is (-> Code (List [Code Code]) Bit)
-                     (function (_ input branches)
-                       (|> (do //phase.monad
-                             [_ (//module.declare_labels false tags/* false :variant:)
-                              analysis (|> (/.case ..analysis branches archive.empty input)
-                                           (//type.expecting output/0))]
-                             (in true))
-                           //scope.with
-                           (//module.with 0 module/0)
-                           (//phase#each (|>> product.right product.right))
-                           (//phase.result state)
-                           (try.else false))))
-
-        can_bind!
-        (and (variant? (` {(, tag/0) (, simple/0)})
-                       (list [$binding/0 body/0]))
-             (variant? (` {(, tag/1) (, simple/1)})
-                       (list [$binding/0 body/0]))
-             (variant? (` {(, tag/2) (, simple/2)})
-                       (list [$binding/0 body/0])))
-
-        can_bind_variant!
-        (variant? (` {(, tag/0) (, simple/0)})
-                  (list [(` {(, tag/0) (, $binding/0)}) body/0]
-                        [(` {(, tag/1) (, $binding/1)}) body/0]
-                        [(` {(, tag/2) (, $binding/2)}) body/0]))
-
-        can_bind_sum!
-        (variant? (` {(, tag/0) (, simple/0)})
-                  (list [(` {0 #0 (, $binding/0)}) body/0]
-                        [(` {1 #0 (, $binding/1)}) body/0]
-                        [(` {1 #1 (, $binding/2)}) body/0]))
-
-        can_check_exhaustiveness!
-        (variant? (` {(, tag/0) (, simple/0)})
-                  (list [(` {(, tag/0) (, simple/0)}) body/0]
-                        [(` {(, tag/0) (, $binding/0)}) body/0]
-
-                        [(` {(, tag/1) (, simple/1)}) body/0]
-                        [(` {(, tag/1) (, $binding/1)}) body/0]
-
-                        [(` {(, tag/2) (, simple/2)}) body/0]
-                        [(` {(, tag/2) (, $binding/2)}) body/0]))
-
-        can_bind_partial_variant!
-        (variant? (` {(, tag/0) (, simple/0)})
-                  (list [(` {(, tag/0) (, $binding/0)}) body/0]
-                        [(` {0 #1 (, $binding/1)}) body/0]))]
-    (and can_bind!
-         can_bind_variant!
-         can_bind_sum!
-         can_check_exhaustiveness!
-         can_bind_partial_variant!
-         )))
-
-(def (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
-  (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit)
-  (let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-               //extension.#state lux]
-        
-        slot/0 (%.code $binding/0)
-        slot/1 (%.code $binding/1)
-        slot/2 (%.code $binding/2)
-
-        slots/* (list slot/0 slot/1 slot/2)
-        :record: {.#Named [module/0 name/0] (type.tuple (list input/0 input/1 input/2))}
-
-        slot/0 (code.symbol [module/0 slot/0])
-        slot/1 (code.symbol [module/0 slot/1])
-        slot/2 (code.symbol [module/0 slot/2])
-        
-        record? (is (-> Code (List [Code Code]) Bit)
-                    (function (_ input branches)
-                      (|> (do //phase.monad
-                            [_ (//module.declare_labels true slots/* false :record:)
-                             analysis (|> (/.case ..analysis branches archive.empty input)
-                                          (//type.expecting output/0))]
-                            (in true))
-                          //scope.with
-                          (//module.with 0 module/0)
-                          (//phase#each (|>> product.right product.right))
-                          (//phase.result state)
-                          (try.else false))))
-
-        can_bind!
-        (record? (` [(, slot/0) (, simple/0)
-                     (, slot/1) (, simple/1)
-                     (, slot/2) (, simple/2)])
-                 (list [$binding/0 body/0]))
-
-        can_bind_record!
-        (record? (` [(, slot/0) (, simple/0)
-                     (, slot/1) (, simple/1)
-                     (, slot/2) (, simple/2)])
-                 (list [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, $binding/2)]) body/0]))
-
-        can_bind_tuple!
-        (record? (` [(, slot/0) (, simple/0)
-                     (, slot/1) (, simple/1)
-                     (, slot/2) (, simple/2)])
-                 (list [(` [(, $binding/0) (, $binding/1) (, $binding/2)]) body/0]))
-
-        can_deduce_record!
-        (record? (` [(, simple/0)
-                     (, simple/1)
-                     (, simple/2)])
-                 (list [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, $binding/2)]) body/0]))
-
-        can_check_exhaustiveness!
-        (record? (` [(, slot/0) (, simple/0)
-                     (, slot/1) (, simple/1)
-                     (, slot/2) (, simple/2)])
-                 (list [(` [(, slot/0) (, simple/0)
-                            (, slot/1) (, simple/1)
-                            (, slot/2) (, simple/2)]) body/0]
-                       ... 000
-                       [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, simple/1)
-                            (, slot/2) (, simple/2)]) body/0]
-                       ... 001
-                       [(` [(, slot/0) (, simple/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, simple/2)]) body/0]
-                       ... 010
-                       [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, simple/2)]) body/0]
-                       ... 011
-                       [(` [(, slot/0) (, simple/0)
-                            (, slot/1) (, simple/1)
-                            (, slot/2) (, $binding/2)]) body/0]
-                       ... 100
-                       [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, simple/1)
-                            (, slot/2) (, $binding/2)]) body/0]
-                       ... 101
-                       [(` [(, slot/0) (, simple/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, $binding/2)]) body/0]
-                       ... 110
-                       [(` [(, slot/0) (, $binding/0)
-                            (, slot/1) (, $binding/1)
-                            (, slot/2) (, $binding/2)]) body/0]
-                       ... 111
-                       ))
-
-        cannot_repeat_slot!
-        (not (record? (` [(, slot/0) (, simple/0)
-                          (, slot/1) (, simple/1)
-                          (, slot/2) (, simple/2)])
-                      (list [(` [(, slot/0) (, $binding/0)
-                                 (, slot/1) (, $binding/1)
-                                 (, slot/2) (, $binding/2)
-                                 (, slot/2) (, $binding/2)]) body/0])))
-
-        cannot_omit_slot!
-        (not (record? (` [(, slot/0) (, simple/0)
-                          (, slot/1) (, simple/1)
-                          (, slot/2) (, simple/2)])
-                      (list [(` [(, slot/0) (, $binding/0)
-                                 (, slot/1) (, $binding/1)]) body/0])))
-
-        can_bind_partial_tuple!
-        (record? (` [(, slot/0) (, simple/0)
-                     (, slot/1) (, simple/1)
-                     (, slot/2) (, simple/2)])
-                 (list [(` [(, $binding/0) (, $binding/1)]) body/0]))]
-    (and can_bind!
-         can_bind_record!
-         can_bind_tuple!
-         can_deduce_record!
-         can_check_exhaustiveness!
-         cannot_repeat_slot!
-         cannot_omit_slot!
-         can_bind_partial_tuple!)))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux $//type.random_state
-         .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                      //extension.#state lux]]
-         module/0 (random.lower_case 1)
-         name/0 (random.lower_case 2)
-         [input/0 simple/0] $//inference.simple_parameter
-         [input/1 simple/1] $//inference.simple_parameter
-         [input/2 simple/2] $//inference.simple_parameter
-         [output/0 body/0] $//inference.simple_parameter
-         [output/1 body/1] (random.only (|>> product.left (same? output/0) not)
-                                        $//inference.simple_parameter)
-         $binding/0 (at ! each code.local (random.lower_case 3))
-         $binding/1 (at ! each code.local (random.lower_case 4))
-         $binding/2 (at ! each code.local (random.lower_case 5))
-         extension/0 (at ! each code.text (random.lower_case 6))
-         bit/0 random.bit
-         nat/0 random.nat]
-        (all _.and
-             (_.coverage [/.case]
-               (and (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
-                    (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/1] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [bit/0])
-                    (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])
-                    (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0])))
-             (_.coverage [/.empty_branches]
-               (|> (do //phase.monad
-                     [analysis (|> (/.case ..analysis (list) archive.empty simple/0)
-                                   (//type.expecting output/0))]
-                     (in false))
-                   //scope.with
-                   (//module.with 0 module/0)
-                   (//phase#each (|>> product.right product.right))
-                   (//phase.result state)
-                   (exception.otherwise (text.contains? (the exception.#label /.empty_branches)))))
-             (_.coverage [/.non_exhaustive]
-               (let [non_exhaustive? (is (-> (List [Code Code]) Bit)
-                                         (function (_ branches)
-                                           (|> (do //phase.monad
-                                                 [analysis (|> (/.case ..analysis branches archive.empty simple/0)
-                                                               (//type.expecting output/0))]
-                                                 (in false))
-                                               //scope.with
-                                               (//module.with 0 module/0)
-                                               (//phase#each (|>> product.right product.right))
-                                               (//phase.result state)
-                                               (exception.otherwise (text.contains? (the exception.#label /.non_exhaustive))))))]
-                 (and (non_exhaustive? (list [simple/0 body/0]))
-                      (not (non_exhaustive? (list [simple/0 body/0]
-                                                  [$binding/0 body/0]))))))
-             (_.coverage [/.invalid]
-               (let [invalid? (is (-> (List [Code Code]) Bit)
-                                  (function (_ branches)
-                                    (|> (do //phase.monad
-                                          [analysis (|> (/.case ..analysis branches archive.empty simple/0)
-                                                        (//type.expecting output/0))]
-                                          (in false))
-                                        //scope.with
-                                        (//module.with 0 module/0)
-                                        (//phase#each (|>> product.right product.right))
-                                        (//phase.result state)
-                                        (exception.otherwise (text.contains? (the exception.#label /.invalid))))))]
-                 (and (invalid? (list [(` ((, extension/0) (, $binding/0) (, $binding/1) (, $binding/2)))
-                                       body/0]))
-                      (invalid? (list [(` {(, extension/0) (, $binding/0) (, $binding/1) (, $binding/2)})
-                                       body/0]))
-                      (invalid? (list [(` {[] (, $binding/0) (, $binding/1) (, $binding/2)})
-                                       body/0])))))
-             (_.coverage [/.sum_has_no_case]
-               (let [tag/0 (%.code $binding/0)
-                     tag/1 (%.code $binding/1)
-                     tag/2 (%.code $binding/2)
-
-                     tags/* (list tag/0 tag/1 tag/2)
-                     :variant: {.#Named [module/0 name/0] (type.variant (list input/0 input/1 input/2))}
-
-                     tag/0 (code.symbol [module/0 tag/0])
-                     tag/1 (code.symbol [module/0 tag/1])
-                     tag/2 (code.symbol [module/0 tag/2])]
-                 (|> (do //phase.monad
-                       [_ (//module.declare_labels false tags/* false :variant:)
-                        analysis (|> (` {(, tag/0) (, simple/0)})
-                                     (/.case ..analysis
-                                       (list [(` {0 #0 (, $binding/0)}) body/0]
-                                             [(` {1 #0 (, $binding/1)}) body/0]
-                                             [(` {2 #0 (, $binding/2)}) body/0]
-                                             [(` {2 #1 (, $binding/2)}) body/0])
-                                       archive.empty)
-                                     (//type.expecting output/0))]
-                       (in false))
-                     //scope.with
-                     (//module.with 0 module/0)
-                     (//phase#each (|>> product.right product.right))
-                     (//phase.result state)
-                     (exception.otherwise (text.contains? (the exception.#label /.sum_has_no_case))))))
-             (_.coverage [/.mismatch]
-               (let [slot/0 (%.code $binding/0)
-                     slot/1 (%.code $binding/1)
-                     slot/2 (%.code $binding/2)
-
-                     slots/* (list slot/0 slot/1 slot/2)
-                     :record: {.#Named [module/0 name/0] (type.tuple (list input/0 input/1 input/2))}
-
-                     slot/0 (code.symbol [module/0 slot/0])
-                     slot/1 (code.symbol [module/0 slot/1])
-                     slot/2 (code.symbol [module/0 slot/2])]
-                 (and (|> (do //phase.monad
-                            [analysis (|> (` (, simple/0))
-                                          (/.case ..analysis
-                                            (list [(` {0 #0 (, $binding/0)}) body/0]
-                                                  [(` {1 #0 (, $binding/1)}) body/0]
-                                                  [(` {1 #1 (, $binding/2)}) body/0])
-                                            archive.empty)
-                                          (//type.expecting output/0))]
-                            (in false))
-                          //scope.with
-                          (//module.with 0 module/0)
-                          (//phase#each (|>> product.right product.right))
-                          (//phase.result state)
-                          (exception.otherwise (text.contains? (the exception.#label /.mismatch))))
-                      (|> (do //phase.monad
-                            [_ (//module.declare_labels true slots/* false :record:)
-                             analysis (|> (` (, simple/0))
-                                          (/.case ..analysis
-                                            (list [(` [(, slot/0) (, $binding/0)
-                                                       (, slot/1) (, $binding/1)
-                                                       (, slot/2) (, $binding/2)]) body/0])
-                                            archive.empty)
-                                          (//type.expecting output/0))]
-                            (in false))
-                          //scope.with
-                          (//module.with 0 module/0)
-                          (//phase#each (|>> product.right product.right))
-                          (//phase.result state)
-                          (exception.otherwise (text.contains? (the exception.#label /.mismatch)))))))
-             
-             ..test|tuple
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux
deleted file mode 100644
index 46232997f..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux
+++ /dev/null
@@ -1,659 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
-    ["[0]" exception (.only Exception)]]
-   [data
-    ["[0]" product]
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.only)
-     ["%" \\format (.only format)]]
-    [collection
-     ["[0]" list (.use "[1]#[0]" monad monoid)]
-     ["[0]" set]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
-    [number
-     ["n" nat]
-     ["f" frac]]]
-   [meta
-    ["[0]" code]
-    ["[0]" macro (.only)
-     ["^" pattern]]
-    ["[0]" symbol (.only)
-     ["$[1]" \\test]]
-    ["[0]" configuration
-     ["$[1]" \\test]]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["[0]" check]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [//
-     ["[1][0]" extension (.only)
-      ["[1]/[0]" analysis
-       ["[1]" lux]]]
-     [//
-      ["[1][0]" analysis (.only Analysis)
-       [evaluation (.only Eval)]
-       ["[2][0]" macro]
-       ["[2][0]" type]
-       ["[2][0]" module]
-       ["[2][0]" complex]
-       ["[2][0]" scope]]
-      [///
-       ["[1][0]" phase (.use "[1]#[0]" monad)]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def (eval archive type term)
-  Eval
-  (//phase#in []))
-
-(def (expander macro inputs state)
-  //macro.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def random_state
-  (Random Lux)
-  (do random.monad
-    [version random.nat
-     host (random.lower_case 1)
-     configuration ($configuration.random 5)]
-    (in (//analysis.state (//analysis.info version host configuration)))))
-
-(def primitive
-  (Random Type)
-  (do random.monad
-    [name (random.lower_case 1)]
-    (in {.#Primitive name (list)})))
-
-(def analysis
-  //analysis.Phase
-  (//.phase ..expander))
-
-(def (failure? exception try)
-  (All (_ e a) (-> (Exception e) (Try a) Bit))
-  (case try
-    {try.#Success _}
-    false
-    
-    {try.#Failure error}
-    (text.contains? (the exception.#label exception) error)))
-
-(def simple_parameter
-  (Random [Type Code])
-  (`` (all random.either
-           (,, (with_template [  ]
-                 [(random#each (|>>  []) )]
-
-                 [.Bit random.bit code.bit]
-                 [.Nat random.nat code.nat]
-                 [.Int random.int code.int]
-                 [.Rev random.rev code.rev]
-                 [.Frac (random.only (|>> f.not_a_number? not) random.frac) code.frac]
-                 [.Text (random.lower_case 1) code.text]
-                 ))
-           )))
-
-(def (analysed? expected actual)
-  (-> Code Analysis Bit)
-  (case [expected actual]
-    [[_ {.#Tuple (list)}] (//analysis.unit)]
-    true
-
-    [[_ {.#Tuple expected}] (//analysis.tuple actual)]
-    (and (n.= (list.size expected)
-              (list.size actual))
-         (list.every? (function (_ [expected actual])
-                        (analysed? expected actual))
-                      (list.zipped_2 expected actual)))
-    
-    (^.with_template [ ]
-      [[[_ { expected}] ( actual)]
-       (same? expected actual)])
-    ([.#Bit //analysis.bit]
-     [.#Nat //analysis.nat]
-     [.#Int //analysis.int]
-     [.#Rev //analysis.rev]
-     [.#Frac //analysis.frac]
-     [.#Text //analysis.text])
-
-    _
-    false))
-
-(def test|sum
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     tag (at ! each (n.% arity) random.nat)
-     .let [[lefts right?] (//complex.choice arity tag)
-           [tagT tagC] (|> types/*,terms/*
-                           (list.item tag)
-                           (maybe.else [Any (' [])]))]]
-    (all _.and
-         (_.coverage [/.sum]
-           (let [variantT (type.variant (list#each product.left types/*,terms/*))
-                 sum? (is (-> Type Nat Bit Code Bit)
-                          (function (_ type lefts right? code)
-                            (|> (do //phase.monad
-                                  [analysis (|> (/.sum ..analysis lefts right? archive.empty code)
-                                                (//type.expecting type))]
-                                  (in (case analysis
-                                        (//analysis.variant [lefts' right?' analysis])
-                                        (and (n.= lefts lefts')
-                                             (bit#= right? right?')
-                                             (..analysed? code analysis))
-
-                                        _
-                                        false)))
-                                (//module.with 0 (product.left name))
-                                (//phase#each product.right)
-                                (//phase.result state)
-                                (try.else false))))]
-             (and (sum? variantT lefts right? tagC)
-                  (sum? {.#Named name variantT} lefts right? tagC)
-                  (|> (do //phase.monad
-                        [[@var varT] (//type.check check.var)
-                         _ (//type.check (check.check varT variantT))
-                         analysis (|> (/.sum ..analysis lefts right? archive.empty tagC)
-                                      (//type.expecting varT))]
-                        (in (case analysis
-                              (//analysis.variant [lefts' right?' it])
-                              (and (n.= lefts lefts')
-                                   (bit#= right? right?')
-                                   (..analysed? tagC it))
-
-                              _
-                              false)))
-                      (//module.with 0 (product.left name))
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false))
-                  (and (sum? (type_literal (Maybe tagT)) 0 #0 (` []))
-                       (sum? (type_literal (Maybe tagT)) 0 #1 tagC))
-                  (and (sum? (type_literal (All (_ a) (Maybe a))) 0 #0 (` []))
-                       (not (sum? (type_literal (All (_ a) (Maybe a))) 0 #1 tagC)))
-                  (and (sum? (type_literal (Ex (_ a) (Maybe a))) 0 #0 (` []))
-                       (sum? (type_literal (Ex (_ a) (Maybe a))) 0 #1 tagC)))))
-         (_.for [/.cannot_analyse_variant]
-                (let [failure? (is (All (_ a) (-> (Exception a) (//analysis.Operation Any) Bit))
-                                   (function (_ exception analysis)
-                                     (let [it (//phase.result state analysis)]
-                                       (and (..failure? /.cannot_analyse_variant it)
-                                            (..failure? exception it)))))]
-                  (all _.and
-                       (_.coverage [/.invalid_variant_type]
-                         (and (|> (/.sum ..analysis lefts right? archive.empty tagC)
-                                  (//type.expecting tagT)
-                                  (failure? /.invalid_variant_type))
-                              (|> (do //phase.monad
-                                    [[@var varT] (//type.check check.var)]
-                                    (|> (/.sum ..analysis lefts right? archive.empty tagC)
-                                        (//type.expecting (type_literal (varT tagT)))))
-                                  (failure? /.invalid_variant_type))))
-                       (_.coverage [/.cannot_infer_sum]
-                         (|> (do //phase.monad
-                               [[@var varT] (//type.check check.var)]
-                               (|> (/.sum ..analysis lefts right? archive.empty tagC)
-                                   (//type.expecting varT)))
-                             (failure? /.cannot_infer_sum)))
-                       )))
-         )))
-
-(def test|variant
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     tag (at ! each (n.% arity) random.nat)
-     .let [[lefts right?] (//complex.choice arity tag)]
-     tags (|> (random.lower_case 1)
-              (random.set text.hash arity)
-              (at ! each set.list))
-     .let [module (product.left name)
-           sumT (type.variant (list#each product.left types/*,terms/*))
-           variantT {.#Named name sumT}
-           [tagT tagC] (|> types/*,terms/*
-                           (list.item tag)
-                           (maybe.else [Any (' [])]))
-           tag (|> tags
-                   (list.item tag)
-                   (maybe.else ""))]]
-    (all _.and
-         (_.coverage [/.variant]
-           (let [expected_variant? (is (-> Symbol Bit)
-                                       (function (_ tag)
-                                         (|> (do //phase.monad
-                                               [_ (//module.declare_labels false tags false variantT)
-                                                analysis (|> (/.variant ..analysis tag archive.empty tagC)
-                                                             (//type.expecting variantT))]
-                                               (in (case analysis
-                                                     (//analysis.variant [lefts' right?' analysis])
-                                                     (and (n.= lefts lefts')
-                                                          (bit#= right? right?')
-                                                          (..analysed? tagC analysis))
-
-                                                     _
-                                                     false)))
-                                             (//module.with 0 module)
-                                             (//phase#each product.right)
-                                             (//phase.result state)
-                                             (try.else false))))
-                 inferred_variant? (is (-> Symbol Bit)
-                                       (function (_ tag)
-                                         (|> (do //phase.monad
-                                               [_ (//module.declare_labels false tags false variantT)
-                                                [actualT analysis] (|> (/.variant ..analysis tag archive.empty tagC)
-                                                                       //type.inferring)]
-                                               (in (case analysis
-                                                     (//analysis.variant [lefts' right?' analysis])
-                                                     (and (n.= lefts lefts')
-                                                          (bit#= right? right?')
-                                                          (..analysed? tagC analysis)
-                                                          (type#= variantT actualT))
-
-                                                     _
-                                                     false)))
-                                             (//module.with 0 module)
-                                             (//phase#each product.right)
-                                             (//phase.result state)
-                                             (try.else false))))]
-             (and (expected_variant? [module tag])
-                  (expected_variant? ["" tag])
-                  (inferred_variant? [module tag])
-                  (inferred_variant? ["" tag])
-
-                  ... TODO: Test what happens when tags are shadowed by local bindings.
-                  )))
-         )))
-
-(type (Triple a)
-  [a a a])
-
-(def test|product
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     [type/0 term/0] ..simple_parameter
-     [type/1 term/1] ..simple_parameter
-     [type/2 term/2] ..simple_parameter
-     .let [module (product.left name)
-           productT (type.tuple (list#each product.left types/*,terms/*))
-           expected (list#each product.right types/*,terms/*)]]
-    (all _.and
-         (_.coverage [/.product]
-           (let [product? (is (-> Type (List Code) Bit)
-                              (function (_ type expected)
-                                (|> (do //phase.monad
-                                      [analysis (|> expected
-                                                    (/.product ..analysis archive.empty)
-                                                    (//type.expecting type))]
-                                      (in (case analysis
-                                            (//analysis.tuple actual)
-                                            (and (n.= (list.size expected)
-                                                      (list.size actual))
-                                                 (list.every? (function (_ [expected actual])
-                                                                (..analysed? expected actual))
-                                                              (list.zipped_2 expected actual)))
-
-                                            _
-                                            false)))
-                                    (//module.with 0 module)
-                                    (//phase#each product.right)
-                                    (//phase.result state)
-                                    (try.else false))))]
-             (and (product? productT expected)
-                  (product? {.#Named name productT} expected)
-                  (product? (type_literal (Ex (_ a) [a a])) (list term/0 term/0))
-                  (not (product? (type_literal (All (_ a) [a a])) (list term/0 term/0)))
-                  (product? (type_literal (Triple type/0)) (list term/0 term/0 term/0))
-                  (|> (do //phase.monad
-                        [[@var varT] (//type.check check.var)
-                         _ (//type.check (check.check varT productT))
-                         analysis (|> expected
-                                      (/.product ..analysis archive.empty)
-                                      (//type.expecting varT))]
-                        (in (case analysis
-                              (//analysis.tuple actual)
-                              (and (n.= (list.size expected)
-                                        (list.size actual))
-                                   (list.every? (function (_ [expected actual])
-                                                  (..analysed? expected actual))
-                                                (list.zipped_2 expected actual)))
-
-                              _
-                              false)))
-                      (//module.with 0 module)
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false))
-                  (|> (do //phase.monad
-                        [[:inferred: analysis] (|> expected
-                                                   (/.product ..analysis archive.empty)
-                                                   //type.inferring)]
-                        (in (case analysis
-                              (//analysis.tuple actual)
-                              (and (n.= (list.size expected)
-                                        (list.size actual))
-                                   (list.every? (function (_ [expected actual])
-                                                  (..analysed? expected actual))
-                                                (list.zipped_2 expected actual))
-                                   (type#= productT :inferred:))
-
-                              _
-                              false)))
-                      (//module.with 0 module)
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false))
-                  (|> (do [! //phase.monad]
-                        [[@var varT] (//type.check check.var)
-                         [:inferred: analysis] (//type.inferring
-                                                (do !
-                                                  [_ (//type.inference (Tuple type/0 type/1 varT))]
-                                                  (/.product ..analysis archive.empty
-                                                             (list term/0 term/1 term/2 term/2 term/2))))
-                         :inferred: (//type.check (check.clean (list @var) :inferred:))]
-                        (in (case analysis
-                              (//analysis.tuple (list analysis/0 analysis/1 (//analysis.tuple (list analysis/2 analysis/3 analysis/4))))
-                              (and (type#= (Tuple type/0 type/1 type/2 type/2 type/2)
-                                           :inferred:)
-                                   (..analysed? term/0 analysis/0)
-                                   (..analysed? term/1 analysis/1)
-                                   (..analysed? term/2 analysis/2)
-                                   (..analysed? term/2 analysis/3)
-                                   (..analysed? term/2 analysis/4))
-
-                              _
-                              false)))
-                      (//module.with 0 module)
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false))
-                  (|> (do [! //phase.monad]
-                        [analysis (|> (list term/0 term/1 (code.tuple (list term/2 term/2 term/2)))
-                                      (/.product ..analysis archive.empty)
-                                      (//type.expecting (Tuple type/0 type/1 type/2 type/2 type/2)))]
-                        (in (case analysis
-                              (//analysis.tuple (list analysis/0 analysis/1 (//analysis.tuple (list analysis/2 analysis/3 analysis/4))))
-                              (and (..analysed? term/0 analysis/0)
-                                   (..analysed? term/1 analysis/1)
-                                   (..analysed? term/2 analysis/2)
-                                   (..analysed? term/2 analysis/3)
-                                   (..analysed? term/2 analysis/4))
-
-                              _
-                              false)))
-                      (//module.with 0 module)
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false)))))
-         (_.for [/.cannot_analyse_tuple]
-                (_.coverage [/.invalid_tuple_type]
-                  (let [failure? (is (All (_ a) (-> (Exception a) (//analysis.Operation Any) Bit))
-                                     (function (_ exception operation)
-                                       (let [it (//phase.result state operation)]
-                                         (and (..failure? /.cannot_analyse_tuple it)
-                                              (..failure? exception it)))))]
-                    (and (|> expected
-                             (/.product ..analysis archive.empty)
-                             (//type.expecting (|> types/*,terms/*
-                                                   list.head
-                                                   (maybe#each product.left)
-                                                   (maybe.else .Any)))
-                             (failure? /.invalid_tuple_type))
-                         (|> (do //phase.monad
-                               [[@var varT] (//type.check check.var)]
-                               (|> expected
-                                   (/.product ..analysis archive.empty)
-                                   (//type.expecting (type_literal (varT type/0)))))
-                             (failure? /.invalid_tuple_type))))))
-         )))
-
-(def test|record
-  (do [! random.monad]
-    [lux ..random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     name ($symbol.random 1 1)
-     arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-     slice (at ! each (|>> (n.% (-- arity)) ++) random.nat)
-     [type/0 term/0] ..simple_parameter
-     slot/0 (random.lower_case 1)
-     types/*,terms/* (random.list arity ..simple_parameter)
-     slots/0 (|> (random.lower_case 1)
-                 (random.set text.hash arity))
-     slots/1 (|> (random.lower_case 1)
-                 (random.only (|>> (set.member? slots/0) not))
-                 (random.set text.hash arity))
-     .let [slots/0 (set.list slots/0)
-           slots/1 (set.list slots/1)
-           module (product.left name)
-           :record: {.#Named name (type.tuple (list#each product.left types/*,terms/*))}
-           tuple (list#each product.right types/*,terms/*)
-           local_record (|> tuple
-                            (list.zipped_2 (list#each (|>> [""] code.symbol) slots/0))
-                            (list#each (function (_ [slot value])
-                                         (list slot value)))
-                            list#conjoint)
-           global_record (|> tuple
-                             (list.zipped_2 (list#each (|>> [module] code.symbol) slots/0))
-                             (list#each (function (_ [slot value])
-                                          (list slot value)))
-                             list#conjoint)
-           expected_record (list.zipped_2 (list#each (|>> [module]) slots/0)
-                                          tuple)
-           head_slot/0 (|> slots/0 list.head maybe.trusted)
-           head_term/0 (|> types/*,terms/* list.head maybe.trusted product.right)
-           head_slot/1 (|> slots/1 list.head maybe.trusted)
-           slots/01 (case slots/1
-                      {.#Item _ tail}
-                      {.#Item head_slot/0 tail}
-
-                      _
-                      slots/0)]]
-    (all _.and
-         (_.coverage [/.normal]
-           (let [normal? (is (-> (List [Symbol Code]) (List Code) Bit)
-                             (function (_ expected input)
-                               (|> (do //phase.monad
-                                     [_ (//module.declare_labels true slots/0 false :record:)]
-                                     (/.normal false input))
-                                   (//module.with 0 module)
-                                   (//phase#each product.right)
-                                   (//phase.result state)
-                                   (pipe.case
-                                     {try.#Success {.#Some actual}}
-                                     (let [(open "list#[0]") (list.equivalence (product.equivalence symbol.equivalence code.equivalence))]
-                                       (list#= expected (list.reversed actual)))
-                                     
-                                     _
-                                     false))))]
-             (and (normal? (list) (list))
-                  (normal? expected_record global_record)
-                  (normal? expected_record local_record)
-                  (|> (/.normal false tuple)
-                      (//phase.result state)
-                      (pipe.case
-                        {try.#Success {.#None}}
-                        true
-                        
-                        _
-                        false)))))
-         (_.coverage [/.order]
-           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/0) tuple)
-                 global_record (list.zipped_2 (list#each (|>> [module]) slots/0) tuple)
-                 ordered? (is (-> Bit (List [Symbol Code]) Bit)
-                              (function (_ pattern_matching? input)
-                                (|> (do //phase.monad
-                                      [_ (//module.declare_labels true slots/0 false :record:)]
-                                      (/.order pattern_matching? input))
-                                    //scope.with
-                                    (//module.with 0 module)
-                                    (//phase#each (|>> product.right product.right))
-                                    (//phase.result state)
-                                    (pipe.case
-                                      {try.#Success {.#Some [actual_arity actual_tuple actual_type]}}
-                                      (and (n.= arity actual_arity)
-                                           (at code.equivalence = (code.tuple tuple) (code.tuple actual_tuple))
-                                           (type#= :record: actual_type))
-
-                                      _
-                                      false))))
-                 unit? (is (-> Bit Bit)
-                           (function (_ pattern_matching?)
-                             (|> (/.order false (list))
-                                 (//phase.result state)
-                                 (pipe.case
-                                   {try.#Success {.#Some [0 (list) actual_type]}}
-                                   (same? .Any actual_type)
-
-                                   _
-                                   false))))]
-             (and (ordered? false global_record)
-                  (ordered? false (list.reversed global_record))
-                  (ordered? false local_record)
-                  (ordered? false (list.reversed local_record))
-
-                  (ordered? true global_record)
-                  (ordered? true (list.reversed global_record))
-                  (not (ordered? true local_record))
-                  (not (ordered? true (list.reversed local_record)))
-
-                  (unit? false)
-                  (unit? true)
-
-                  ... TODO: Test what happens when slots are shadowed by local bindings.
-                  )))
-         (_.coverage [/.cannot_repeat_slot]
-           (let [repeated? (is (-> Bit Bit)
-                               (function (_ pattern_matching?)
-                                 (|> (do //phase.monad
-                                       [_ (//module.declare_labels true slots/0 false :record:)]
-                                       (/.order pattern_matching? (list.repeated arity [[module head_slot/0] head_term/0])))
-                                     (//module.with 0 module)
-                                     (//phase#each product.right)
-                                     (//phase.result state)
-                                     (..failure? /.cannot_repeat_slot))))]
-             (and (repeated? false)
-                  (repeated? true))))
-         (_.coverage [/.record_size_mismatch]
-           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/0) tuple)
-                 global_record (list.zipped_2 (list#each (|>> [module]) slots/0) tuple)
-                 mismatched? (is (-> Bit (List [Symbol Code]) Bit)
-                                 (function (_ pattern_matching? input)
-                                   (|> (do //phase.monad
-                                         [_ (//module.declare_labels true slots/0 false :record:)]
-                                         (/.order pattern_matching? input))
-                                       //scope.with
-                                       (//module.with 0 module)
-                                       (//phase.result state)
-                                       (..failure? /.record_size_mismatch))))]
-             (and (mismatched? false (list.first slice local_record))
-                  (mismatched? false (list#composite local_record (list.first slice local_record)))
-
-                  (mismatched? false (list.first slice global_record))
-                  (mismatched? true (list.first slice global_record))
-                  (mismatched? false (list#composite global_record (list.first slice global_record)))
-                  (mismatched? true (list#composite global_record (list.first slice global_record))))))
-         (_.coverage [/.slot_does_not_belong_to_record]
-           (let [local_record (list.zipped_2 (list#each (|>> [""]) slots/01) tuple)
-                 global_record (list.zipped_2 (list#each (|>> [module]) slots/01) tuple)
-                 mismatched? (is (-> Bit (List [Symbol Code]) Bit)
-                                 (function (_ pattern_matching? input)
-                                   (|> (do //phase.monad
-                                         [_ (//module.declare_labels true slots/0 false :record:)
-                                          _ (//module.declare_labels true slots/1 false :record:)]
-                                         (/.order pattern_matching? input))
-                                       //scope.with
-                                       (//module.with 0 module)
-                                       (//phase.result state)
-                                       (..failure? /.slot_does_not_belong_to_record))))]
-             (and (mismatched? false local_record)
-
-                  (mismatched? false global_record)
-                  (mismatched? true global_record))))
-         (_.coverage [/.record]
-           (let [record? (is (-> Type (List Text) (List Code) Code Bit)
-                             (function (_ type slots tuple expected)
-                               (|> (do //phase.monad
-                                     [_ (//module.declare_labels true slots false type)]
-                                     (/.record ..analysis archive.empty tuple))
-                                   (//type.expecting type)
-                                   //scope.with
-                                   (//module.with 0 module)
-                                   (//phase#each (|>> product.right product.right))
-                                   (//phase.result state)
-                                   (try#each (analysed? expected))
-                                   (try.else false))))
-                 inferred? (is (-> (List Code) Bit)
-                               (function (_ record)
-                                 (|> (do //phase.monad
-                                       [_ (//module.declare_labels true slots/0 false :record:)]
-                                       (//type.inferring
-                                        (/.record ..analysis archive.empty record)))
-                                     //scope.with
-                                     (//module.with 0 module)
-                                     (//phase#each (|>> product.right product.right))
-                                     (//phase.result state)
-                                     (try#each (function (_ [actual_type actual_term])
-                                                 (and (same? :record: actual_type)
-                                                      (analysed? (code.tuple tuple) actual_term))))
-                                     (try.else false))))]
-             (and (record? {.#Named name .Any} (list) (list) (' []))
-                  (record? {.#Named name type/0} (list) (list term/0) term/0)
-                  (record? {.#Named name type/0} (list slot/0) (list term/0) term/0)
-                  (record? :record: slots/0 tuple (code.tuple tuple))
-                  (record? :record: slots/0 local_record (code.tuple tuple))
-                  (record? :record: slots/0 global_record (code.tuple tuple))
-                  (inferred? local_record)
-                  (inferred? global_record))))
-         )))
-
-(def .public test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux ..random_state
-         .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                      //extension.#state lux]]
-         arity (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-         types/*,terms/* (random.list arity ..simple_parameter)
-         [type/0 term/0] ..simple_parameter
-         [type/1 term/1] ..simple_parameter
-         tag (at ! each (n.% arity) random.nat)
-         .let [[lefts right?] (//complex.choice arity tag)]]
-        (all _.and
-             ..test|sum
-             ..test|variant
-             ..test|product
-             ..test|record
-             (_.coverage [/.not_a_quantified_type]
-               (and (|> (/.sum ..analysis lefts right? archive.empty term/0)
-                        (//type.expecting (type_literal (type/0 type/1)))
-                        (//phase.result state)
-                        (..failure? /.not_a_quantified_type))
-                    (|> types/*,terms/*
-                        (list#each product.right)
-                        (/.product ..analysis archive.empty)
-                        (//type.expecting (type_literal (type/0 type/1)))
-                        (//phase.result state)
-                        (..failure? /.not_a_quantified_type))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux
deleted file mode 100644
index efd22de9a..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux
+++ /dev/null
@@ -1,258 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" function]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    ["[0]" text (.only)
-     ["%" \\format]]
-    [collection
-     ["[0]" list]]]
-   [math
-    ["[0]" random]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" code]
-    ["[0]" macro]
-    ["[0]" symbol
-     ["$[1]" \\test]]
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["$[1]" \\test]
-     ["[0]" check]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    [//
-     ["[1][0]" extension (.only)
-      ["[1]/[0]" analysis
-       ["[1]" lux]]]
-     [//
-      ["[1][0]" analysis (.only Analysis)
-       [evaluation (.only Eval)]
-       ["[2][0]" macro]
-       ["[2][0]" module]
-       ["[2][0]" type (.only)
-        ["$[1]" \\test]]
-       ["[2][0]" inference
-        ["$[1]" \\test]]]
-      [///
-       ["[1][0]" phase (.use "[1]#[0]" monad)]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def (eval archive type term)
-  Eval
-  (//phase#in []))
-
-(def (expander macro inputs state)
-  //macro.Expander
-  {try.#Success ((macro.function macro) inputs state)})
-
-(def analysis
-  //analysis.Phase
-  (//.phase ..expander))
-
-(def test|function
-  Test
-  (do [! random.monad]
-    [lux $//type.random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     input/0 ($type.random 0)
-     input/1 ($type.random 0)
-     function/0 (random.lower_case 1)
-     function/1 (random.lower_case 2)
-     argument/0 (random.lower_case 3)
-     argument/1 (random.lower_case 4)
-     module/0 (random.lower_case 5)
-     [output/0 term/0] $//inference.simple_parameter
-     [output/1 term/1] (random.only (|>> product.left (same? output/0) not)
-                                    $//inference.simple_parameter)
-     name/0 ($symbol.random 1 1)
-     .let [$function/0 (code.local function/0)
-           $function/1 (code.local function/1)
-           $argument/0 (code.local argument/0)
-           $argument/1 (code.local argument/1)]]
-    (all _.and
-         (_.coverage [/.function]
-           (let [function?' (is (-> Type Code (-> [(List Analysis) Analysis] Bit) Bit)
-                                (function (_ function_type output_term ?)
-                                  (|> (do //phase.monad
-                                        [analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
-                                                        output_term)
-                                                      (//type.expecting function_type))]
-                                        (in (case analysis
-                                              {//analysis.#Function it}
-                                              (? it)
-
-                                              _
-                                              false)))
-                                      (//module.with 0 module/0)
-                                      (//phase#each product.right)
-                                      (//phase.result state)
-                                      (try.else false))))
-                 function? (is (-> Type Code Bit)
-                               (function (_ function_type output_term)
-                                 (function?' function_type output_term (function.constant true))))
-                 inferring? (is (-> Type Code Bit)
-                                (function (_ :expected: term)
-                                  (|> (do //phase.monad
-                                        [[:actual: analysis] (|> (/.function ..analysis function/0 argument/0 archive.empty
-                                                                   term)
-                                                                 //type.inferring)]
-                                        (in (case analysis
-                                              {//analysis.#Function [actual_env actual_body]}
-                                              (type#= :expected: :actual:)
-
-                                              _
-                                              false)))
-                                      (//module.with 0 module/0)
-                                      (//phase#each product.right)
-                                      (//phase.result state)
-                                      (try.else false))))]
-             (and (function? (-> input/0 output/0) term/0)
-                  (function? (-> input/0 input/0) $argument/0)
-
-                  (function? {.#Named name/0 (-> input/0 output/0)} term/0)
-                  
-                  (function? (All (_ a) (-> a a)) $argument/0)
-                  (function? (Ex (_ a) (-> a a)) $argument/0)
-                  (function? (Ex (_ a) (-> input/0 a)) term/0)
-                  (function? (Ex (_ a) (-> a a)) term/0)
-                  (function? (Rec self (-> input/0 self)) $function/0)
-
-                  (function? (type_literal ((All (_ a) (-> a a)) output/0)) term/0)
-                  (not (function? (type_literal ((All (_ a) (-> a a)) output/1)) term/0))
-
-                  (function? (type_literal ((Ex (_ a) (-> a a)) output/0)) term/0)
-                  (not (function? (type_literal ((Ex (_ a) (-> a a)) output/1)) term/0))
-
-                  (function?' (-> input/0 input/1 input/0) (` ([(, $function/1) (, $argument/1)] (, $argument/0)))
-                              (function (_ [outer body])
-                                (and (list.empty? outer)
-                                     (case body
-                                       {//analysis.#Function [inner body]}
-                                       (n.= 1 (list.size inner))
-
-                                       _
-                                       false))))
-                  (function?' (-> input/0 input/1 input/1) (` ([(, $function/1) (, $argument/1)] (, $argument/1)))
-                              (function (_ [outer body])
-                                (and (list.empty? outer)
-                                     (case body
-                                       {//analysis.#Function [inner body]}
-                                       (n.= 0 (list.size inner))
-
-                                       _
-                                       false))))
-
-                  (|> (do //phase.monad
-                        [[@var :var:] (//type.check check.var)
-                         _ (//type.check (check.check :var: (-> input/0 output/0)))
-                         analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
-                                        term/0)
-                                      (//type.expecting :var:))]
-                        (in (case analysis
-                              {//analysis.#Function [actual_env actual_body]}
-                              true
-
-                              _
-                              false)))
-                      (//module.with 0 module/0)
-                      (//phase#each product.right)
-                      (//phase.result state)
-                      (try.else false))
-                  
-                  (inferring? (All (_ a) (-> a output/0)) term/0)
-                  (inferring? (All (_ a) (-> a a)) $argument/0)
-                  (inferring? (All (_ @0) (-> @0 @0 (And .Bit @0)))
-                              (` ([(, $function/1) (, $argument/1)]
-                                  [("lux is" (, $argument/0) (, $argument/1))
-                                   (, $argument/1)]))))))
-         (_.coverage [/.cannot_analyse]
-           (|> (do //phase.monad
-                 [analysis (|> (/.function ..analysis function/0 argument/0 archive.empty
-                                 term/1)
-                               (//type.expecting (-> input/0 output/0)))]
-                 (in (case analysis
-                       {//analysis.#Function [actual_env actual_body]}
-                       true
-
-                       _
-                       false)))
-               (//module.with 0 module/0)
-               (//phase#each product.right)
-               (//phase.result state)
-               (exception.otherwise (text.contains? (the exception.#label /.cannot_analyse)))))
-         )))
-
-(def test|apply
-  Test
-  (do [! random.monad]
-    [lux $//type.random_state
-     .let [state [//extension.#bundle (//extension/analysis.bundle ..eval)
-                  //extension.#state lux]]
-     [input/0 term/0] $//inference.simple_parameter
-     [input/1 term/1] (random.only (|>> product.left (same? input/0) not)
-                                   $//inference.simple_parameter)
-     output/0 ($type.random 0)
-     module/0 (random.lower_case 1)]
-    (all _.and
-         (_.coverage [/.apply]
-           (let [reification? (is (-> Type (List Code) Type Bit)
-                                  (function (_ :abstraction: terms :expected:)
-                                    (|> (do //phase.monad
-                                          [[:actual: analysis] (|> (/.apply ..analysis terms
-                                                                            :abstraction:
-                                                                            (//analysis.unit)
-                                                                            archive.empty
-                                                                            (' []))
-                                                                   //type.inferring)]
-                                          (in (and (check.subsumes? :expected: :actual:)
-                                                   (case analysis
-                                                     {//analysis.#Apply _}
-                                                     true
-
-                                                     _
-                                                     false))))
-                                        (//module.with 0 module/0)
-                                        (//phase#each product.right)
-                                        (//phase.result state)
-                                        (try.else false))))]
-             (and (reification? (-> input/0 input/1 output/0) (list term/0 term/1) output/0)
-                  (reification? (-> input/0 input/1 output/0) (list term/0) (-> input/1 output/0))
-                  (reification? (All (_ a) (-> a a)) (list term/0) input/0)
-                  (reification? (All (_ a) (-> a a a)) (list term/0) (-> input/0 input/0))
-                  (reification? (All (_ a) (-> input/0 a)) (list term/0) .Nothing)
-                  (reification? (All (_ a b) (-> a b a)) (list term/0) (All (_ b) (-> b input/0)))
-                  (reification? (Ex (_ a) (-> a input/0)) (list (` ("lux io error" ""))) input/0)
-                  (reification? (Ex (_ a) (-> input/0 a)) (list term/0) .Any))))
-         (_.coverage [/.cannot_apply]
-           (|> (do //phase.monad
-                 [_ (|> (/.apply ..analysis (list term/1 term/0)
-                                 (-> input/0 input/1 output/0)
-                                 (//analysis.unit)
-                                 archive.empty
-                                 (' []))
-                        (//type.expecting output/0))]
-                 (in false))
-               (//module.with 0 module/0)
-               (//phase#each product.right)
-               (//phase.result state)
-               (exception.otherwise (text.contains? (the exception.#label /.cannot_apply)))))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           ..test|function
-           ..test|apply
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux
deleted file mode 100644
index e88482764..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux
+++ /dev/null
@@ -1,224 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    ["[0]" text]]
-   [math
-    ["[0]" random]]
-   [meta
-    ["[0]" type (.use "[1]#[0]" equivalence)
-     ["$[1]" \\test]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" //
-    [//
-     ["[1][0]" extension]
-     [//
-      ["[1][0]" analysis (.only)
-       ["[2][0]" scope]
-       ["[2][0]" module]
-       ["[2][0]" type (.only)
-        ["$[1]" \\test]]]
-      [///
-       ["[1][0]" phase (.use "[1]#[0]" monad)]]]]]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [lux $//type.random_state
-         .let [state [//extension.#bundle //extension.empty
-                      //extension.#state lux]]
-         expected_name (random.lower_case 1)
-         expected_type ($type.random 0)
-         expected_module (random.lower_case 2)
-         import (random.lower_case 3)
-         expected_label (random.lower_case 4)
-         record? random.bit]
-        (all _.and
-             (_.coverage [/.reference]
-               (let [can_find_local_variable!
-                     (|> (/.reference ["" expected_name])
-                         (//scope.with_local [expected_name expected_type])
-                         //type.inferring
-                         //scope.with
-                         (//module.with 0 expected_module)
-                         (//phase#each product.right)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.local 0)]
-                                          (type#= expected_type actual_type)
-
-                                          _
-                                          false)))
-                         (try.else false))
-
-                     can_find_foreign_variable!
-                     (|> (/.reference ["" expected_name])
-                         //type.inferring
-                         //scope.with
-                         (//scope.with_local [expected_name expected_type])
-                         //scope.with
-                         (//module.with 0 expected_module)
-                         (//phase#each product.right)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.foreign 0)]
-                                          (type#= expected_type actual_type)
-
-                                          _
-                                          false)))
-                         (try.else false))
-
-                     can_find_local_definition!
-                     (|> (do //phase.monad
-                           [_ (//module.define expected_name {.#Definition [#0 expected_type []]})]
-                           (/.reference ["" expected_name]))
-                         //type.inferring
-                         (//module.with 0 expected_module)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.constant [actual_module actual_name])]
-                                          (and (type#= expected_type actual_type)
-                                               (same? expected_module actual_module)
-                                               (same? expected_name actual_name))
-
-                                          _
-                                          false)))
-                         (try.else false))
-
-                     can_find_foreign_definition!
-                     (|> (do //phase.monad
-                           [_ (//module.with 0 import
-                                (//module.define expected_name {.#Definition [#1 expected_type []]}))
-                            _ (//module.import import)]
-                           (/.reference [import expected_name]))
-                         //type.inferring
-                         (//module.with 0 expected_module)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.constant [actual_module actual_name])]
-                                          (and (type#= expected_type actual_type)
-                                               (same? import actual_module)
-                                               (same? expected_name actual_name))
-
-                                          _
-                                          false)))
-                         (try.else false))
-
-                     can_find_alias!
-                     (|> (do //phase.monad
-                           [_ (//module.with 0 import
-                                (//module.define expected_name {.#Definition [#1 expected_type []]}))
-                            _ (//module.import import)
-                            _ (//module.define expected_name {.#Alias [import expected_name]})]
-                           (/.reference [expected_module expected_name]))
-                         //type.inferring
-                         (//module.with 0 expected_module)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.constant [actual_module actual_name])]
-                                          (and (type#= expected_type actual_type)
-                                               (same? import actual_module)
-                                               (same? expected_name actual_name))
-
-                                          _
-                                          false)))
-                         (try.else false))
-
-                     can_find_type!
-                     (|> (do //phase.monad
-                           [_ (//module.define expected_name {.#Type [#0 expected_type
-                                                                      (if record?
-                                                                        {.#Right [expected_label (list)]}
-                                                                        {.#Left [expected_label (list)]})]})]
-                           (/.reference [expected_module expected_name]))
-                         //type.inferring
-                         (//module.with 0 expected_module)
-                         (//phase.result state)
-                         (try#each (|>> product.right
-                                        (pipe.case
-                                          [actual_type (//analysis.constant [actual_module actual_name])]
-                                          (and (type#= .Type actual_type)
-                                               (same? expected_module actual_module)
-                                               (same? expected_name actual_name))
-
-                                          _
-                                          false)))
-                         (try.else false))]
-                 (and can_find_local_variable!
-                      can_find_foreign_variable!
-                      
-                      can_find_local_definition!
-                      can_find_foreign_definition!
-
-                      can_find_alias!
-                      can_find_type!)))
-             (_.coverage [/.foreign_module_has_not_been_imported]
-               (let [scenario (is (-> Type Global Bit)
-                                  (function (_ expected_type it)
-                                    (|> (do //phase.monad
-                                          [_ (//module.with 0 import
-                                               (//module.define expected_name it))
-                                           _ (/.reference [import expected_name])]
-                                          (in false))
-                                        (//type.expecting expected_type)
-                                        (//module.with 0 expected_module)
-                                        (//phase#each product.right)
-                                        (//phase.result state)
-                                        (exception.otherwise (text.contains? (the exception.#label /.foreign_module_has_not_been_imported)))
-                                        )))]
-                 (and (scenario expected_type {.#Definition [#1 expected_type []]})
-                      (scenario .Type {.#Type [#1 expected_type
-                                               (if record?
-                                                 {.#Right [expected_label (list)]}
-                                                 {.#Left [expected_label (list)]})]}))))
-             (_.coverage [/.definition_has_not_been_exported]
-               (let [scenario (is (-> Type Global Bit)
-                                  (function (_ expected_type it)
-                                    (|> (do //phase.monad
-                                          [_ (//module.with 0 import
-                                               (//module.define expected_name it))
-                                           _ (/.reference [import expected_name])]
-                                          (in false))
-                                        (//type.expecting expected_type)
-                                        (//module.with 0 expected_module)
-                                        (//phase#each product.right)
-                                        (//phase.result state)
-                                        (exception.otherwise (text.contains? (the exception.#label /.definition_has_not_been_exported)))
-                                        )))]
-                 (and (scenario expected_type {.#Definition [#0 expected_type []]})
-                      (scenario .Type {.#Type [#0 expected_type
-                                               (if record?
-                                                 {.#Right [expected_label (list)]}
-                                                 {.#Left [expected_label (list)]})]}))))
-             (_.coverage [/.labels_are_not_definitions]
-               (let [scenario (is (-> Type Global Bit)
-                                  (function (_ expected_type it)
-                                    (|> (do //phase.monad
-                                          [_ (//module.with 0 import
-                                               (//module.define expected_label it))
-                                           _ (/.reference [import expected_label])]
-                                          (in false))
-                                        (//type.expecting expected_type)
-                                        (//module.with 0 expected_module)
-                                        (//phase#each product.right)
-                                        (//phase.result state)
-                                        (exception.otherwise (text.contains? (the exception.#label /.labels_are_not_definitions))))))]
-                 (and (scenario expected_type {.#Tag [#1 expected_type (list) 0]})
-                      (scenario expected_type {.#Slot [#1 expected_type (list) 0]}))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux
deleted file mode 100644
index bceb035c6..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux
+++ /dev/null
@@ -1,111 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try]]
-   [data
-    ["[0]" product]]
-   [math
-    ["[0]" random]]
-   [meta
-    ["[0]" type (.use "[1]#[0]" equivalence)]
-    ["[0]" configuration
-     ["$[1]" \\test]]]]]
- [\\library
-  ["[0]" / (.only)
-   [///
-    ["[1][0]" extension]
-    [//
-     ["[1][0]" analysis (.only Analysis Operation)
-      ["[2][0]" type]
-      ["[2][0]" module]]
-     [///
-      ["[1][0]" phase (.use "[1]#[0]" functor)]]]]]])
-
-(def (analysis state module type it ?)
-  (-> Lux Text Type (Operation Analysis) (-> Analysis Bit) Bit)
-  (and (|> it
-           (/type.expecting type)
-           (/module.with 0 module)
-           (/phase#each product.right)
-           (/phase.result [/extension.#bundle /extension.empty
-                           /extension.#state state])
-           (pipe.case
-             {try.#Success analysis}
-             (? analysis)
-
-             _
-             false))
-       (|> it
-           (/type.expecting .Nothing)
-           (/module.with 0 module)
-           (/phase#each product.right)
-           (/phase.result [/extension.#bundle /extension.empty
-                           /extension.#state state])
-           (pipe.case
-             {try.#Failure error}
-             true
-
-             _
-             false))
-       (|> it
-           /type.inferring
-           (/module.with 0 module)
-           (/phase#each product.right)
-           (/phase.result [/extension.#bundle /extension.empty
-                           /extension.#state state])
-           (pipe.case
-             {try.#Success [inferred analysis]}
-             (and (type#= type inferred)
-                  (? analysis))
-
-             _
-             false))))
-
-(def analysis?
-  (template (_  )
-    [(is (->  Analysis Bit)
-         (function (_ expected)
-           (|>> (pipe.case
-                  ( actual)
-                  (same? expected actual)
-
-                  _
-                  false))))]))
-
-(def .public test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [version random.nat
-         host (random.lower_case 1)
-         module (random.lower_case 2)
-         configuration ($configuration.random 5)
-         .let [state (/analysis.state (/analysis.info version host configuration))]]
-        (`` (all _.and
-                 (_.coverage [/.unit]
-                   (..analysis state module .Any /.unit
-                     (|>> (pipe.case
-                            (/analysis.unit)
-                            true
-                            
-                            _
-                            false))))
-                 (,, (with_template [   ]
-                       [(do !
-                          [sample ]
-                          (_.coverage []
-                            (..analysis state module  ( sample)
-                              ((..analysis?  ) sample))))]
-
-                       [/.bit .Bit random.bit /analysis.bit]
-                       [/.nat .Nat random.nat /analysis.nat]
-                       [/.int .Int random.int /analysis.int]
-                       [/.rev .Rev random.rev /analysis.rev]
-                       [/.frac .Frac random.frac /analysis.frac]
-                       [/.text .Text (random.unicode 1) /analysis.text]
-                       ))
-                 )))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux
deleted file mode 100644
index 08e310f54..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux
+++ /dev/null
@@ -1,280 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    ["[0]" monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try]
-    ["[0]" exception]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]]
-    [collection
-     ["[0]" dictionary]
-     ["[0]" list (.use "[1]#[0]" mix)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]
-     ["i" int]]]]]
- [\\library
-  ["[0]" / (.only)
-   [/////
-    ["[0]" phase]
-    [meta
-     ["[0]" archive]]]]])
-
-(def .public random
-  (Random (/.Extension Nat))
-  (all random.and
-       (random.lower_case 5)
-       (random.list 2 random.nat)
-       ))
-
-(def test|state
-  Test
-  (do [! random.monad]
-    [state random.int
-     dummy (random.only (|>> (i.= state) not)
-                        random.int)]
-    (all _.and
-         (_.coverage [/.read]
-           (|> (is (/.Operation Int Nat Nat Text)
-                   (/.read %.int))
-               (at phase.functor each (text#= (%.int state)))
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (try.else false)))
-         (_.coverage [/.update]
-           (|> (is (/.Operation Int Nat Nat Text)
-                   (do phase.monad
-                     [_ (/.update ++)]
-                     (/.read %.int)))
-               (at phase.functor each (text#= (%.int (++ state))))
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (try.else false)))
-         (_.coverage [/.temporary]
-           (|> (is (/.Operation Int Nat Nat Text)
-                   (do phase.monad
-                     [|state'| (/.temporary ++ (/.read %.int))
-                      |state| (/.read %.int)]
-                     (in (format |state'| " " |state|))))
-               (at phase.functor each (text#= (format (%.int (++ state)) " " (%.int state))))
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (try.else false)))
-         (_.coverage [/.with_state]
-           (|> (is (/.Operation Int Nat Nat Text)
-                   (/.with_state state
-                     (/.read %.int)))
-               (at phase.functor each (text#= (%.int state)))
-               (phase.result [/.#bundle /.empty
-                              /.#state dummy])
-               (try.else false)))
-         (_.coverage [/.localized]
-           (|> (is (/.Operation Int Nat Nat Text)
-                   (do phase.monad
-                     [|state| (/.localized %.int
-                                           (function (_ _ old) (++ old))
-                                           (text.enclosed ["<" ">"])
-                                           (/.read %.int))
-                      |state'| (/.read %.int)]
-                     (in (format |state'| " " |state|))))
-               (at phase.functor each (text#= (format (%.int (i.+ +2 state))
-                                                      " " (%.int (i.+ +1 state)))))
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (try.else false))))
-    ))
-
-(def extender
-  /.Extender
-  (|>> as_expected))
-
-(def handler/0
-  (/.Handler Int Nat Nat)
-  (function (_ @self phase archive inputs)
-    (at phase.monad in (list#mix n.+ 0 inputs))))
-
-(def handler/1
-  (/.Handler Int Nat Nat)
-  (function (_ @self phase archive inputs)
-    (at phase.monad in (list#mix n.* 1 inputs))))
-
-(def test|name
-  Test
-  (do [! random.monad]
-    [state random.int
-     extension (random.lower_case 1)
-     left random.nat
-     right random.nat]
-    (all _.and
-         (_.coverage [/.cannot_overwrite]
-           (|> (do phase.monad
-                 [_ (/.install extender extension handler/0)]
-                 (/.install extender extension handler/1))
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (pipe.case
-                 {try.#Failure error}
-                 (exception.match? /.cannot_overwrite error)
-
-                 _
-                 false)))
-         (_.coverage [/.unknown]
-           (|> (/.apply archive.empty (function (_ archive input)
-                                        (at phase.monad in (++ input)))
-                        [extension (list left right)])
-               (phase.result [/.#bundle /.empty
-                              /.#state state])
-               (pipe.case
-                 {try.#Failure error}
-                 (exception.match? /.unknown error)
-
-                 _
-                 false)))
-         )))
-
-(def test|bundle
-  Test
-  (let [phase (is (/.Phase Int Nat Nat)
-                  (function (_ archive input)
-                    (at phase.monad in (++ input))))]
-    (do [! random.monad]
-      [state random.int
-
-       extension (random.lower_case 1)
-       left random.nat
-       right random.nat]
-      (all _.and
-           (_.coverage [/.empty]
-             (dictionary.empty? /.empty))
-           (<| (_.for [/.Extender /.Handler])
-               (all _.and
-                    (_.coverage [/.install /.apply]
-                      (|> (do phase.monad
-                            [_ (/.install extender extension handler/0)]
-                            (/.apply archive.empty phase [extension (list left right)]))
-                          (at phase.functor each (n.= (n.+ left right)))
-                          (phase.result [/.#bundle /.empty
-                                         /.#state state])
-                          (try.else false)))
-                    (_.coverage [/.Phase]
-                      (let [handler (is (/.Handler Int Nat Nat)
-                                        (function (_ @self phase archive inputs)
-                                          (let [! phase.monad]
-                                            (|> inputs
-                                                (monad.each ! (phase archive))
-                                                (at ! each (list#mix n.+ 0))))))]
-                        (|> (do phase.monad
-                              [_ (/.install extender extension handler)]
-                              (/.apply archive.empty phase [extension (list left right)]))
-                            (at phase.functor each (n.= (n.+ (++ left) (++ right))))
-                            (phase.result [/.#bundle /.empty
-                                           /.#state state])
-                            (try.else false))))
-                    (_.coverage [/.with]
-                      (|> (do phase.monad
-                            [_ (/.with extender (dictionary.of_list text.hash (list [extension handler/1])))]
-                            (/.apply archive.empty (function (_ archive input)
-                                                     (at phase.monad in (++ input)))
-                                     [extension (list left right)]))
-                          (at phase.functor each (n.= (n.* left right)))
-                          (phase.result [/.#bundle /.empty
-                                         /.#state state])
-                          (try.else false)))
-                    (_.coverage [/.incorrect_arity]
-                      (let [handler (is (/.Handler Int Nat Nat)
-                                        (function (_ @self phase archive inputs)
-                                          (phase.except /.incorrect_arity [@self 2 (list.size inputs)])))]
-                        (|> (do phase.monad
-                              [_ (/.install extender extension handler)]
-                              (/.apply archive.empty phase [extension (list)]))
-                            (phase.result [/.#bundle /.empty
-                                           /.#state state])
-                            (pipe.case
-                              {try.#Failure error}
-                              (exception.match? /.incorrect_arity error)
-
-                              _
-                              false))))
-                    (_.coverage [/.invalid_syntax]
-                      (let [handler (is (/.Handler Int Nat Nat)
-                                        (function (_ @self phase archive inputs)
-                                          (phase.except /.invalid_syntax [@self %.nat inputs])))]
-                        (|> (do phase.monad
-                              [_ (/.install extender extension handler)]
-                              (/.apply archive.empty phase [extension (list left right)]))
-                            (phase.result [/.#bundle /.empty
-                                           /.#state state])
-                            (pipe.case
-                              {try.#Failure error}
-                              (exception.match? /.invalid_syntax error)
-
-                              _
-                              false))))
-                    (_.for [/.Name]
-                           ..test|name)
-                    ))
-           ))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Extension])
-      (do [! random.monad]
-        [state random.int
-         dummy (random.only (|>> (i.= state) not)
-                            random.int)
-         expected random.nat
-         expected_error (random.lower_case 1)]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec (/.equivalence n.equivalence) ..random))
-             (_.for [/.hash]
-                    ($hash.spec (/.hash n.hash) ..random))
-             
-             (<| (_.for [/.Operation])
-                 (all _.and
-                      (_.coverage [/.lifted]
-                        (and (|> (is (/.Operation Int Nat Nat Nat)
-                                     (/.lifted (do phase.monad
-                                                 []
-                                                 (in expected))))
-                                 (at phase.functor each (same? expected))
-                                 (phase.result [/.#bundle /.empty
-                                                /.#state state])
-                                 (try.else false))
-                             (|> (is (/.Operation Int Nat Nat Nat)
-                                     (/.lifted (phase.lifted {try.#Failure expected_error})))
-                                 (phase.result [/.#bundle /.empty
-                                                /.#state state])
-                                 (pipe.case
-                                   {try.#Failure actual_error}
-                                   (same? expected_error actual_error)
-
-                                   _
-                                   false))))
-                      (_.coverage [/.up]
-                        (|> (do phase.monad
-                              []
-                              (in expected))
-                            (is (/.Operation Int Nat Nat Nat))
-                            /.up
-                            (is (phase.Operation Int Nat))
-                            (at phase.functor each (same? expected))
-                            (phase.result state)
-                            (try.else false)))
-                      ))
-             (_.for [/.State]
-                    ..test|state)
-             (_.for [/.Bundle]
-                    ..test|bundle)
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux
deleted file mode 100644
index 4876aa0be..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux
+++ /dev/null
@@ -1,205 +0,0 @@
-(.require
- [lux (.except i64 int primitive)
-  [abstract
-   ["[0]" monad (.only do)]]
-  [data
-   ["%" text/format (.only format)]]
-  ["r" math/random (.only Random)]
-  ["_" test (.only Test)]
-  [control
-   [io (.only IO)]
-   ["[0]" pipe]
-   ["[0]" try]
-   [concurrency
-    ["[0]" atom]]]
-  [data
-   ["[0]" product]]
-  [meta
-   ["[0]" code]
-   ["[0]" symbol]
-   ["[0]" type (.use "[1]#[0]" equivalence)]]]
- [////
-  [analysis
-   ["_[0]" primitive]]]
- [\\
-  ["[0]" / (.only)
-   ["///[1]" ////
-    [analysis
-     ["[1][0]" scope]
-     ["[1][0]" type]]
-    [////
-     ["[0]" phase]
-     [meta
-      ["[0]" archive]]]]]])
-
-(with_template [  ]
-  [(def ( procedure params output_type)
-     (-> Text (List Code) Type Bit)
-     (|> (////scope.with_scope ""
-           (////type.with_type output_type
-             (_primitive.phase archive.empty (` ((, (code.text procedure)) (,* params))))))
-         (phase.result _primitive.state)
-         (pipe.case
-           {try.#Success _}
-           
-
-           {try.#Failure _}
-           )))]
-
-  [check_success+ true false]
-  [check_failure+ false true]
-  )
-
-(def primitive
-  (Random [Type Code])
-  (r.only (|>> product.left (same? Any) not) _primitive.primitive))
-
-(def lux
-  Test
-  (do r.monad
-    [[primT primC] ..primitive
-     [antiT antiC] (|> ..primitive
-                       (r.only (|>> product.left (type#= primT) not)))]
-    (all _.and
-         (_.property "Can test for reference equality."
-           (check_success+ "lux is" (list primC primC) Bit))
-         (_.property "Reference equality must be done with elements of the same type."
-           (check_failure+ "lux is" (list primC antiC) Bit))
-         (_.property "Can 'try' risky IO computations."
-           (check_success+ "lux try"
-                           (list (` ("lux io error" "YOLO")))
-                           (type_literal (Either Text primT))))
-         )))
-
-(def i64
-  Test
-  (do [! r.monad]
-    [subjectC (|> r.nat (at ! each code.nat))
-     signedC (|> r.int (at ! each code.int))
-     paramC (|> r.nat (at ! each code.nat))]
-    (all _.and
-         (_.property "i64 'and'."
-           (check_success+ "lux i64 and" (list paramC subjectC) Nat))
-         (_.property "i64 'or'."
-           (check_success+ "lux i64 or" (list paramC subjectC) Nat))
-         (_.property "i64 'xor'."
-           (check_success+ "lux i64 xor" (list paramC subjectC) Nat))
-         (_.property "i64 left-shift."
-           (check_success+ "lux i64 left-shift" (list paramC subjectC) Nat))
-         (_.property "i64 logical-right-shift."
-           (check_success+ "lux i64 logical-right-shift" (list paramC subjectC) Nat))
-         (_.property "i64 arithmetic-right-shift."
-           (check_success+ "lux i64 arithmetic-right-shift" (list paramC signedC) Int))
-         (_.property "i64 equivalence."
-           (check_success+ "lux i64 =" (list paramC subjectC) Bit))
-         (_.property "i64 addition."
-           (check_success+ "lux i64 +" (list paramC subjectC) Int))
-         (_.property "i64 subtraction."
-           (check_success+ "lux i64 -" (list paramC subjectC) Int))
-         )))
-
-(def int
-  Test
-  (do [! r.monad]
-    [subjectC (|> r.int (at ! each code.int))
-     paramC (|> r.int (at ! each code.int))]
-    (all _.and
-         (_.property "Can multiply integers."
-           (check_success+ "lux i64 *" (list paramC subjectC) Int))
-         (_.property "Can divide integers."
-           (check_success+ "lux i64 /" (list paramC subjectC) Int))
-         (_.property "Can calculate remainder of integers."
-           (check_success+ "lux i64 %" (list paramC subjectC) Int))
-         (_.property "Can compare integers."
-           (check_success+ "lux i64 <" (list paramC subjectC) Bit))
-         (_.property "Can convert integer to text."
-           (check_success+ "lux i64 char" (list subjectC) Text))
-         (_.property "Can convert integer to fraction."
-           (check_success+ "lux i64 f64" (list subjectC) Frac))
-         )))
-
-(def frac
-  Test
-  (do [! r.monad]
-    [subjectC (|> r.safe_frac (at ! each code.frac))
-     paramC (|> r.safe_frac (at ! each code.frac))
-     encodedC (|> r.safe_frac (at ! each (|>> %.frac code.text)))]
-    (all _.and
-         (_.property "Can add frac numbers."
-           (check_success+ "lux f64 +" (list paramC subjectC) Frac))
-         (_.property "Can subtract frac numbers."
-           (check_success+ "lux f64 -" (list paramC subjectC) Frac))
-         (_.property "Can multiply frac numbers."
-           (check_success+ "lux f64 *" (list paramC subjectC) Frac))
-         (_.property "Can divide frac numbers."
-           (check_success+ "lux f64 /" (list paramC subjectC) Frac))
-         (_.property "Can calculate remainder of frac numbers."
-           (check_success+ "lux f64 %" (list paramC subjectC) Frac))
-         (_.property "Can test equivalence of frac numbers."
-           (check_success+ "lux f64 =" (list paramC subjectC) Bit))
-         (_.property "Can compare frac numbers."
-           (check_success+ "lux f64 <" (list paramC subjectC) Bit))
-         (_.property "Can obtain minimum frac number."
-           (check_success+ "lux f64 min" (list) Frac))
-         (_.property "Can obtain maximum frac number."
-           (check_success+ "lux f64 max" (list) Frac))
-         (_.property "Can obtain smallest frac number."
-           (check_success+ "lux f64 smallest" (list) Frac))
-         (_.property "Can convert frac number to integer."
-           (check_success+ "lux f64 i64" (list subjectC) Int))
-         (_.property "Can convert frac number to text."
-           (check_success+ "lux f64 encode" (list subjectC) Text))
-         (_.property "Can convert text to frac number."
-           (check_success+ "lux f64 decode" (list encodedC) (type_literal (Maybe Frac))))
-         )))
-
-(def text
-  Test
-  (do [! r.monad]
-    [subjectC (|> (r.unicode 5) (at ! each code.text))
-     paramC (|> (r.unicode 5) (at ! each code.text))
-     replacementC (|> (r.unicode 5) (at ! each code.text))
-     fromC (|> r.nat (at ! each code.nat))
-     toC (|> r.nat (at ! each code.nat))]
-    (all _.and
-         (_.property "Can test text equivalence."
-           (check_success+ "lux text =" (list paramC subjectC) Bit))
-         (_.property "Compare texts in lexicographical order."
-           (check_success+ "lux text <" (list paramC subjectC) Bit))
-         (_.property "Can concatenate one text to another."
-           (check_success+ "lux text concat" (list subjectC paramC) Text))
-         (_.property "Can find the index of a piece of text inside a larger one that (may) contain it."
-           (check_success+ "lux text index" (list fromC paramC subjectC) (type_literal (Maybe Nat))))
-         (_.property "Can query the size/length of a text."
-           (check_success+ "lux text size" (list subjectC) Nat))
-         (_.property "Can obtain the character code of a text at a given index."
-           (check_success+ "lux text char" (list fromC subjectC) Nat))
-         (_.property "Can clip a piece of text between 2 indices."
-           (check_success+ "lux text clip" (list fromC toC subjectC) Text))
-         )))
-
-(def io
-  Test
-  (do [! r.monad]
-    [logC (|> (r.unicode 5) (at ! each code.text))
-     exitC (|> r.int (at ! each code.int))]
-    (all _.and
-         (_.property "Can log messages to standard output."
-           (check_success+ "lux io log" (list logC) Any))
-         (_.property "Can throw a run-time error."
-           (check_success+ "lux io error" (list logC) Nothing))
-         (_.property "Can query the current time (as milliseconds since epoch)."
-           (check_success+ "lux io current-time" (list) Int))
-         )))
-
-(def .public test
-  Test
-  (<| (_.context (symbol.module (symbol /._)))
-      (all _.and
-           ..lux
-           ..i64
-           ..int
-           ..frac
-           ..text
-           ..io
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux
deleted file mode 100644
index e4a2814b4..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux
+++ /dev/null
@@ -1,21 +0,0 @@
-(.require
- [lux (.except)
-  ["_" test (.only Test)]]
- ["[0]" /
-  ["[1][0]" primitive]
-  ["[1][0]" structure]
-  ["[1][0]" case]
-  ["[1][0]" function]
-  ["[1][0]" loop]
-  ["[1][0]" variable]])
-
-(def .public test
-  Test
-  (all _.and
-       /primitive.test
-       /structure.test
-       /case.test
-       /function.test
-       /loop.test
-       /variable.test
-       ))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux
deleted file mode 100644
index 7f348e194..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux
+++ /dev/null
@@ -1,358 +0,0 @@
-(.require
- [lux (.except)
-  ["_" test (.only Test)]
-  [abstract
-   [hash (.only Hash)]
-   ["[0]" monad (.only do)]]
-  [control
-   ["[0]" pipe]
-   ["[0]" try (.use "[1]#[0]" functor)]]
-  [data
-   ["[0]" sum]
-   ["[0]" text (.only)
-    ["%" \\format (.only format)]]
-   [number
-    ["n" nat]
-    ["[0]" int]
-    ["[0]" rev]
-    ["[0]" frac]]
-   [collection
-    ["[0]" list (.use "[1]#[0]" functor mix monoid)]
-    ["[0]" set]]]
-  [math
-   ["[0]" random (.only Random)]]]
- ["[0]" //
-  ["[1][0]" primitive]]
- [\\
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    ["/[1]" //
-     [extension
-      ["[1][0]" bundle]]
-     ["/[1]" // (.only)
-      ["[0]" analysis (.only Branch Match Analysis)]
-      ["[0]" synthesis (.only Path Synthesis)]
-      [///
-       ["[1][0]" reference (.only)
-        [variable (.only Register)]]
-       ["[0]" phase]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def masking_test
-  Test
-  (do [! random.monad]
-    [maskedA //primitive.primitive
-     temp (|> random.nat (at ! each (n.% 100)))
-     .let [maskA (analysis.case
-                   [maskedA
-                    [[{analysis.#Bind temp}
-                      {analysis.#Reference (////reference.local temp)}]
-                     (list)]])]]
-    (_.coverage [/.synthesize_masking]
-      (|> maskA
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty synthesis.init])
-          (try#each (//primitive.corresponds? maskedA))
-          (try.default false)))))
-
-(def let_test
-  Test
-  (do random.monad
-    [registerA random.nat
-     inputA //primitive.primitive
-     outputA //primitive.primitive
-     .let [letA (analysis.case
-                  [inputA
-                   [[{analysis.#Bind registerA}
-                     outputA]
-                    (list)]])]]
-    (_.coverage [/.synthesize_let]
-      (|> letA
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty synthesis.init])
-          (pipe.case
-            {try.#Success (synthesis.branch/let [inputS registerS outputS])}
-            (and (n.= registerA registerS)
-                 (//primitive.corresponds? inputA inputS)
-                 (//primitive.corresponds? outputA outputS))
-
-            _
-            false)))))
-
-(def if_test
-  Test
-  (do random.monad
-    [then|else random.bit
-     inputA //primitive.primitive
-     thenA //primitive.primitive
-     elseA //primitive.primitive
-     .let [thenB (is Branch
-                     [{analysis.#Simple {analysis.#Bit true}}
-                      thenA])
-           elseB (is Branch
-                     [{analysis.#Simple {analysis.#Bit false}}
-                      elseA])
-           ifA (if then|else
-                 (analysis.case [inputA [thenB (list elseB)]])
-                 (analysis.case [inputA [elseB (list thenB)]]))]]
-    (_.coverage [/.synthesize_if]
-      (|> ifA
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty synthesis.init])
-          (pipe.case
-            {try.#Success (synthesis.branch/if [inputS thenS elseS])}
-            (and (//primitive.corresponds? inputA inputS)
-                 (//primitive.corresponds? thenA thenS)
-                 (//primitive.corresponds? elseA elseS))
-
-            _
-            false)))))
-
-(def random_member
-  (Random synthesis.Member)
-  (do [! random.monad]
-    [lefts (|> random.nat (at ! each (n.% 10)))
-     right? random.bit]
-    (in (if right?
-          {.#Right lefts}
-          {.#Left lefts}))))
-
-(def random_path
-  (Random (analysis.Tuple synthesis.Member))
-  (do [! random.monad]
-    [size_1 (|> random.nat (at ! each (|>> (n.% 10) ++)))]
-    (random.list size_1 ..random_member)))
-
-(def (get_pattern path)
-  (-> (analysis.Tuple synthesis.Member)
-      (Random [analysis.Pattern Register]))
-  (do random.monad
-    [@member random.nat]
-    (in [(list#mix (function (_ member inner)
-                     (case member
-                       {.#Left lefts}
-                       (analysis.pattern/tuple
-                        (list#composite (list.repeated lefts (analysis.pattern/unit))
-                                        (list inner (analysis.pattern/unit))))
-                       
-                       {.#Right lefts}
-                       (analysis.pattern/tuple
-                        (list#composite (list.repeated (++ lefts) (analysis.pattern/unit))
-                                        (list inner)))))
-                   {analysis.#Bind @member}
-                   (list.reversed path))
-         @member])))
-
-(def get_test
-  Test
-  (do [! random.monad]
-    [recordA (|> random.nat
-                 (at ! each (|>> analysis.nat))
-                 (random.list 10)
-                 (at ! each (|>> analysis.tuple)))
-     pathA ..random_path
-     [pattern @member] (get_pattern pathA)
-     .let [getA (analysis.case [recordA [[pattern
-                                          {analysis.#Reference (////reference.local @member)}]
-                                         (list)]])]]
-    (_.coverage [/.synthesize_get]
-      (|> getA
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty synthesis.init])
-          (pipe.case
-            {try.#Success (synthesis.branch/get [pathS recordS])}
-            (and (at (list.equivalence (sum.equivalence n.= n.=)) = pathA pathS)
-                 (//primitive.corresponds? recordA recordS))
-
-            _
-            false)))))
-
-(def random_bit
-  (Random [Path Match])
-  (do [! random.monad]
-    [test random.bit
-     then random.nat
-     else random.nat]
-    (in [{synthesis.#Alt {synthesis.#Seq (synthesis.path/bit test)
-                                         {synthesis.#Then (synthesis.i64 (.i64 then))}}
-                         {synthesis.#Seq (synthesis.path/bit (not test))
-                                         {synthesis.#Then (synthesis.i64 (.i64 else))}}}
-         [[analysis.#when (analysis.pattern/bit test)
-           analysis.#then (analysis.nat then)]
-          (list [analysis.#when (analysis.pattern/bit (not test))
-                 analysis.#then (analysis.nat else)])]])))
-
-(def (random_five hash random_element)
-  (All (_ a) (-> (Hash a) (Random a) (Random [a a a a a])))
-  (|> random_element
-      (random.set hash 5)
-      (at random.monad each (|>> set.list
-                                 (pipe.case
-                                   (list s0 s1 s2 s3 s4)
-                                   [s0 s1 s2 s3 s4]
-
-                                   _
-                                   (undefined))))))
-
-(with_template [      ]
-  [(def 
-     (Random [Path Match])
-     (do [! random.monad]
-       [[test/0 test/1 test/2 test/3 test/4] (random_five  )
-        [body/0 body/1 body/2 body/3 body/4] (random_five  )]
-       (in [(all {synthesis.#Alt}
-                 {synthesis.#Seq ( test/0) {synthesis.#Then ( body/0)}}
-                 {synthesis.#Seq ( test/1) {synthesis.#Then ( body/1)}}
-                 {synthesis.#Seq ( test/2) {synthesis.#Then ( body/2)}}
-                 {synthesis.#Seq ( test/3) {synthesis.#Then ( body/3)}}
-                 {synthesis.#Seq ( test/4) {synthesis.#Then ( body/4)}})
-            [[analysis.#when ( test/0) analysis.#then ( body/0)]
-             (list [analysis.#when ( test/1) analysis.#then ( body/1)]
-                   [analysis.#when ( test/2) analysis.#then ( body/2)]
-                   [analysis.#when ( test/3) analysis.#then ( body/3)]
-                   [analysis.#when ( test/4) analysis.#then ( body/4)])]])))]
-
-  [random_nat n.hash random.nat (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/nat analysis.nat]
-  [random_int int.hash random.int (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/int analysis.int]
-  [random_rev rev.hash random.rev (|>> .i64 synthesis.path/i64) (|>> .i64 synthesis.i64) analysis.pattern/rev analysis.rev]
-  [random_frac frac.hash random.frac synthesis.path/f64 synthesis.f64 analysis.pattern/frac analysis.frac]
-  [random_text text.hash (random.unicode 1) synthesis.path/text synthesis.text analysis.pattern/text analysis.text]
-  )
-
-(def random_simple
-  (all random.either
-       ..random_bit
-       ..random_nat
-       ..random_int
-       ..random_rev
-       ..random_frac
-       ..random_text
-       ))
-
-(def random_variant
-  (Random [Path Match])
-  (do [! random.monad]
-    [[lefts/0 lefts/1 lefts/2 lefts/3 lefts/4] (random_five n.hash random.nat)
-     [value/0 value/1 value/2 value/3 value/4] (random_five text.hash (random.unicode 1))
-     last_is_right? random.bit
-     [body/0 body/1 body/2 body/3 body/4] (random_five frac.hash random.frac)
-     .let [path (is (-> Nat Bit Text Frac Path)
-                    (function (_ lefts right? value body)
-                      (all {synthesis.#Seq}
-                           (synthesis.path/side (if right?
-                                                  {.#Right lefts}
-                                                  {.#Left lefts}))
-                           (synthesis.path/text value)
-                           {synthesis.#Then (synthesis.f64 body)})))
-           branch (is (-> Nat Bit Text Frac Branch)
-                      (function (_ lefts right? value body)
-                        [analysis.#when (analysis.pattern/variant [analysis.#lefts lefts
-                                                                   analysis.#right? right?
-                                                                   analysis.#value (analysis.pattern/text value)])
-                         analysis.#then (analysis.frac body)]))]]
-    (in [(all {synthesis.#Alt}
-              (path lefts/0 false value/0 body/0)
-              (path lefts/1 false value/1 body/1)
-              (path lefts/2 false value/2 body/2)
-              (path lefts/3 false value/3 body/3)
-              (path lefts/4 last_is_right? value/4 body/4))
-         [(branch lefts/0 false value/0 body/0)
-          (list (branch lefts/1 false value/1 body/1)
-                (branch lefts/2 false value/2 body/2)
-                (branch lefts/3 false value/3 body/3)
-                (branch lefts/4 last_is_right? value/4 body/4))]])))
-
-(def random_tuple
-  (Random [Path Match])
-  (do [! random.monad]
-    [mid_size (at ! each (n.% 4) random.nat)
-
-     value/first (random.unicode 1)
-     value/mid (random.list mid_size (random.unicode 1))
-     value/last (random.unicode 1)
-
-     body/first random.frac
-     body/mid (random.list mid_size random.frac)
-     body/last random.frac
-     .let [path (is (-> Nat Bit Text Frac Path)
-                    (function (_ lefts right? value body)
-                      (if right?
-                        (all {synthesis.#Seq}
-                             (synthesis.path/member (if right?
-                                                      {.#Right lefts}
-                                                      {.#Left lefts}))
-                             (synthesis.path/text value)
-                             {synthesis.#Then (synthesis.f64 body)})
-                        (all {synthesis.#Seq}
-                             (synthesis.path/member (if right?
-                                                      {.#Right lefts}
-                                                      {.#Left lefts}))
-                             (synthesis.path/text value)
-                             {synthesis.#Pop}
-                             {synthesis.#Then (synthesis.f64 body)}))))
-           branch (is (-> Nat Bit Text Frac Branch)
-                      (function (_ lefts right? value body)
-                        [analysis.#when (if right?
-                                          (analysis.pattern/tuple (list#composite (list.repeated (++ lefts) (analysis.pattern/unit))
-                                                                                  (list (analysis.pattern/text value))))
-                                          (analysis.pattern/tuple (all list#composite
-                                                                       (list.repeated lefts (analysis.pattern/unit))
-                                                                       (list (analysis.pattern/text value)
-                                                                             (analysis.pattern/unit)))))
-                         analysis.#then (analysis.frac body)]))]]
-    (in [(list#mix (function (_ left right)
-                     {synthesis.#Alt left right})
-                   (path (++ mid_size) true value/last body/last)
-                   (|> (list.zipped_2 value/mid body/mid)
-                       {.#Item [value/first body/first]}
-                       list.enumeration
-                       (list#each (function (_ [lefts' [value body]])
-                                    (path lefts' false value body)))
-                       list.reversed))
-         [(branch 0 false value/first body/first)
-          (list#composite (|> (list.zipped_2 value/mid body/mid)
-                              list.enumeration
-                              (list#each (function (_ [lefts' [value body]])
-                                           (branch (++ lefts') false value body))))
-                          (list (branch (++ mid_size) true value/last body/last)))]])))
-
-(def random_complex
-  (all random.either
-       ..random_variant
-       ..random_tuple
-       ))
-
-(def random_case
-  (all random.either
-       ..random_simple
-       ..random_complex
-       ))
-
-(def case_test
-  Test
-  (do [! random.monad]
-    [expected_input (at ! each (|>> .i64 synthesis.i64) random.nat)
-     [expected_path match] ..random_case]
-    (_.coverage [/.synthesize_case]
-      (|> (/.synthesize_case //.phase archive.empty expected_input match)
-          (phase.result [///bundle.empty synthesis.init])
-          (pipe.case
-            {try.#Success (synthesis.branch/case [actual_input actual_path])}
-            (and (at synthesis.equivalence = expected_input actual_input)
-                 (at synthesis.path_equivalence = expected_path actual_path))
-
-            _
-            false)))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.synthesize])
-      (all _.and
-           ..masking_test
-           ..let_test
-           ..if_test
-           ..get_test
-           ..case_test
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux
deleted file mode 100644
index 579f52354..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux
+++ /dev/null
@@ -1,468 +0,0 @@
-(.require
- [lux (.except)
-  ["_" test (.only Test)]
-  [abstract
-   ["[0]" monad (.only do)]]
-  [control
-   ["[0]" try]]
-  [data
-   ["[0]" product]
-   ["[0]" text (.only)
-    ["%" \\format (.only format)]]
-   [number
-    ["n" nat]]
-   [collection
-    ["[0]" list (.use "[1]#[0]" functor mix monoid)]
-    ["[0]" dictionary (.only Dictionary)]
-    ["[0]" set]]]
-  [math
-   ["[0]" random (.only Random)]]
-  [meta
-   [macro
-    ["^" pattern]]]]
- ["[0]" //
-  ["[1][0]" primitive]]
- [\\
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    ["/[1]" //
-     [extension
-      ["[1][0]" bundle]]
-     ["/[1]" // (.only)
-      ["[0]" analysis (.only Analysis)]
-      ["[0]" synthesis (.only Synthesis)]
-      [///
-       [arity (.only Arity)]
-       ["[0]" reference (.only)
-        ["[0]" variable (.only Variable)]]
-       ["[0]" phase]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def (n_function loop? arity body)
-  (-> Bit Arity Synthesis Synthesis)
-  (synthesis.function/abstraction
-   [synthesis.#environment (list)
-    synthesis.#arity arity
-    synthesis.#body (if loop?
-                      (synthesis.loop/scope
-                       [synthesis.#start 1
-                        synthesis.#inits (list)
-                        synthesis.#iteration body])
-                      body)]))
-
-(def (n_abstraction arity body)
-  (-> Arity Analysis Analysis)
-  (list#mix (function (_ arity_1 body)
-              (case arity_1
-                0 {analysis.#Function (list) body}
-                _ {analysis.#Function (all list#composite
-                                           (list#each (|>> {variable.#Foreign})
-                                                      (list.indices arity_1))
-                                           (list {variable.#Local 1}))
-                                      body}))
-            body
-            (list.reversed (list.indices arity))))
-
-(def !expect
-  (template (_  )
-    (case 
-      
-      true
-      
-      _
-      false)))
-
-(type Circumstance
-  (Record
-   [#loop? Bit
-    #expectation Synthesis
-    #reality Analysis]))
-
-(type Scenario
-  (-> Bit (Random Circumstance)))
-
-(def (random_unit output?)
-  Scenario
-  (at random.monad in
-      [true
-       (synthesis.text synthesis.unit)
-       (analysis.unit)]))
-
-(with_template [   ]
-  [(def ( output?)
-     Scenario
-     (do [! random.monad]
-       [value ]
-       (in [true
-            ( value)
-            ( value)])))]
-
-  [random_bit random.bit synthesis.bit analysis.bit]
-  [random_nat random.nat (|>> .i64 synthesis.i64) analysis.nat]
-  [random_int random.int (|>> .i64 synthesis.i64) analysis.int]
-  [random_rev random.rev (|>> .i64 synthesis.i64) analysis.rev]
-  [random_frac random.frac synthesis.f64 analysis.frac]
-  [random_text (random.unicode 1) synthesis.text analysis.text]
-  )
-
-(def (random_primitive output?)
-  Scenario
-  (random.either (random.either (..random_unit output?)
-                                (random.either (..random_bit output?)
-                                               (..random_nat output?)))
-                 (random.either (random.either (..random_int output?)
-                                               (..random_rev output?))
-                                (random.either (..random_frac output?)
-                                               (..random_text output?)))))
-
-(def (random_variant random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [lefts random.nat
-     right? random.bit
-     [loop? expected_value actual_value] (random_value false)]
-    (in [loop?
-         (synthesis.variant
-          [analysis.#lefts lefts
-           analysis.#right? right?
-           analysis.#value expected_value])
-         (analysis.variant
-          [analysis.#lefts lefts
-           analysis.#right? right?
-           analysis.#value actual_value])])))
-
-(def (random_tuple random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [[loop?_left expected_left actual_left] (random_value false)
-     [loop?_right expected_right actual_right] (random_value false)]
-    (in [(and loop?_left
-              loop?_right)
-         (synthesis.tuple (list expected_left expected_right))
-         (analysis.tuple (list actual_left actual_right))])))
-
-(def (random_structure random_value output?)
-  (-> Scenario Scenario)
-  (all random.either
-       (..random_variant random_value output?)
-       (..random_tuple random_value output?)))
-
-(def (random_variable arity output?)
-  (-> Arity Scenario)
-  (do [! random.monad]
-    [register (at ! each (|>> (n.% arity) ++) random.nat)]
-    (in [(not (n.= 0 register))
-         (synthesis.variable/local register)
-         (if (n.= arity register)
-           {analysis.#Reference (reference.local 1)}
-           {analysis.#Reference (reference.foreign register)})])))
-
-(def (random_constant output?)
-  Scenario
-  (do [! random.monad]
-    [module (random.unicode 1)
-     short (random.unicode 1)]
-    (in [true
-         (synthesis.constant [module short])
-         {analysis.#Reference (reference.constant [module short])}])))
-
-(def (random_reference arity output?)
-  (-> Arity Scenario)
-  (random.either (..random_variable arity output?)
-                 (..random_constant output?)))
-
-(def (random_case arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (do [! random.monad]
-    [bit_test random.bit
-     i64_test random.nat
-     f64_test random.frac
-     text_test (random.unicode 1)
-     [loop?_input expected_input actual_input] (random_value false)
-     [loop?_output expected_output actual_output] (random_value output?)
-     lefts (|> random.nat (at ! each (n.% 10)))
-     right? random.bit
-     .let [side|member (if right?
-                         {.#Right lefts}
-                         {.#Left lefts})]]
-    (in [(and loop?_input
-              loop?_output)
-         (synthesis.branch/case [expected_input
-                                 (all synthesis.path/alt
-                                      (synthesis.path/then expected_output)
-                                      (synthesis.path/seq (synthesis.path/bit bit_test)
-                                                          (synthesis.path/then expected_output))
-                                      (synthesis.path/seq (synthesis.path/i64 (.i64 i64_test))
-                                                          (synthesis.path/then expected_output))
-                                      (synthesis.path/seq (synthesis.path/f64 f64_test)
-                                                          (synthesis.path/then expected_output))
-                                      (synthesis.path/seq (synthesis.path/text text_test)
-                                                          (synthesis.path/then expected_output))
-                                      (synthesis.path/seq (synthesis.path/bind (++ arity))
-                                                          (synthesis.path/then expected_output))
-                                      (all synthesis.path/seq
-                                           (synthesis.path/side side|member)
-                                           (synthesis.path/bind (++ arity))
-                                           (synthesis.path/then expected_output))
-                                      (if right?
-                                        (all synthesis.path/seq
-                                             (synthesis.path/member side|member)
-                                             (synthesis.path/bind (++ arity))
-                                             (synthesis.path/then expected_output)) 
-                                        (all synthesis.path/seq
-                                             (synthesis.path/member side|member)
-                                             (synthesis.path/bind (++ arity))
-                                             synthesis.path/pop
-                                             (synthesis.path/then expected_output))))])
-         {analysis.#Case actual_input
-                         [[analysis.#when (analysis.pattern/unit)
-                           analysis.#then actual_output]
-                          (list [analysis.#when (analysis.pattern/bit bit_test)
-                                 analysis.#then actual_output]
-                                [analysis.#when (analysis.pattern/nat (.nat i64_test))
-                                 analysis.#then actual_output]
-                                [analysis.#when (analysis.pattern/frac f64_test)
-                                 analysis.#then actual_output]
-                                [analysis.#when (analysis.pattern/text text_test)
-                                 analysis.#then actual_output]
-                                [analysis.#when {analysis.#Bind 2}
-                                 analysis.#then actual_output]
-                                [analysis.#when (analysis.pattern/variant
-                                                 [analysis.#lefts lefts
-                                                  analysis.#right? right?
-                                                  analysis.#value {analysis.#Bind 2}])
-                                 analysis.#then actual_output]
-                                [analysis.#when (analysis.pattern/tuple
-                                                 (list#composite (list.repeated lefts (analysis.pattern/unit))
-                                                                 (if right?
-                                                                   (list (analysis.pattern/unit) {analysis.#Bind 2})
-                                                                   (list {analysis.#Bind 2} (analysis.pattern/unit)))))
-                                 analysis.#then actual_output])]}])))
-
-(def (random_let arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (do [! random.monad]
-    [[loop?_input expected_input actual_input] (random_value false)
-     [loop?_output expected_output actual_output] (random_value output?)]
-    (in [(and loop?_input
-              loop?_output)
-         (synthesis.branch/let [expected_input
-                                (++ arity)
-                                expected_output])
-         {analysis.#Case actual_input
-                         [[analysis.#when {analysis.#Bind 2}
-                           analysis.#then actual_output]
-                          (list)]}])))
-
-(def (random_if random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [[loop?_test expected_test actual_test] (random_value false)
-     [loop?_then expected_then actual_then] (random_value output?)
-     [loop?_else expected_else actual_else] (random_value output?)
-     flip? random.bit]
-    (in [(and loop?_test
-              loop?_then
-              loop?_else)
-         (synthesis.branch/if [expected_test
-                               expected_then
-                               expected_else])
-         (if flip?
-           {analysis.#Case actual_test
-                           [[analysis.#when (analysis.pattern/bit false)
-                             analysis.#then actual_else]
-                            (list [analysis.#when (analysis.pattern/bit true)
-                                   analysis.#then actual_then])]}
-           {analysis.#Case actual_test
-                           [[analysis.#when (analysis.pattern/bit true)
-                             analysis.#then actual_then]
-                            (list [analysis.#when (analysis.pattern/bit false)
-                                   analysis.#then actual_else])]})])))
-
-(def (random_get random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [lefts (|> random.nat (at ! each (n.% 10)))
-     right? random.bit
-     [loop?_record expected_record actual_record] (random_value false)]
-    (in [loop?_record
-         (synthesis.branch/get [(list (if right?
-                                        {.#Right lefts}
-                                        {.#Left lefts}))
-                                expected_record])
-         {analysis.#Case actual_record
-                         [[analysis.#when (analysis.pattern/tuple
-                                           (list#composite (list.repeated lefts (analysis.pattern/unit))
-                                                           (if right?
-                                                             (list (analysis.pattern/unit) {analysis.#Bind 2})
-                                                             (list {analysis.#Bind 2} (analysis.pattern/unit)))))
-                           analysis.#then {analysis.#Reference (reference.local 2)}]
-                          (list)]}])))
-
-(def (random_branch arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (random.either (random.either (..random_case arity random_value output?)
-                                (..random_let arity random_value output?))
-                 (random.either (..random_if random_value output?)
-                                (..random_get random_value output?))))
-
-(def (random_again arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (do [! random.monad]
-    [resets (random.list arity (random_value false))]
-    (in [true
-         (synthesis.loop/again (list#each (|>> product.right product.left) resets))
-         (analysis.apply [{analysis.#Reference (case arity
-                                                 1 (reference.local 0)
-                                                 _ (reference.foreign 0))}
-                          (list#each (|>> product.right product.right) resets)])])))
-
-(def (random_scope arity output?)
-  (-> Arity Scenario)
-  (do [! random.monad]
-    [resets (random.list arity (..random_variable arity output?))
-     [_ expected_output actual_output] (..random_nat output?)]
-    (in [(list#mix (function (_ new old)
-                     (and new old))
-                   true
-                   (list#each product.left resets))
-         (synthesis.loop/scope
-          [synthesis.#start (++ arity)
-           synthesis.#inits (list#each (|>> product.right product.left) resets)
-           synthesis.#iteration expected_output])
-         (analysis.apply [(..n_abstraction arity actual_output)
-                          (list#each (|>> product.right product.right) resets)])])))
-
-(def (random_loop arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (if output?
-    (all random.either
-         (..random_again arity random_value output?)
-         (..random_scope arity output?)
-         )
-    (..random_scope arity output?)))
-
-(def (random_abstraction' output?)
-  Scenario
-  (do [! random.monad]
-    [[loop?_output expected_output actual_output] (..random_nat output?)
-     arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
-     .let [environment (all list#composite
-                            (list#each (|>> {variable.#Foreign})
-                                       (list.indices arity))
-                            (list {variable.#Local 1}))]]
-    (in [true
-         (synthesis.function/abstraction
-          [synthesis.#environment environment
-           synthesis.#arity 1
-           synthesis.#body (synthesis.loop/scope
-                            [synthesis.#start 1
-                             synthesis.#inits (list)
-                             synthesis.#iteration expected_output])])
-         {analysis.#Function environment
-                             actual_output}])))
-
-(def (random_apply random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [[loop?_abstraction expected_abstraction actual_abstraction] (..random_nat output?)
-     arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
-     inputs (random.list arity (random_value false))]
-    (in [(list#mix (function (_ new old)
-                     (and new old))
-                   loop?_abstraction
-                   (list#each product.left inputs))
-         (synthesis.function/apply [expected_abstraction
-                                    (list#each (|>> product.right product.left) inputs)])
-         (analysis.apply [actual_abstraction
-                          (list#each (|>> product.right product.right) inputs)])])))
-
-(def (random_function random_value output?)
-  (-> Scenario Scenario)
-  (if output?
-    (..random_apply random_value output?)
-    (all random.either
-         (..random_abstraction' output?)
-         (..random_apply random_value output?)
-         )))
-
-(def (random_control arity random_value output?)
-  (-> Arity Scenario Scenario)
-  (all random.either
-       (..random_branch arity random_value output?)
-       (..random_loop arity random_value output?)
-       (..random_function random_value output?)
-       ))
-
-(def (random_extension random_value output?)
-  (-> Scenario Scenario)
-  (do [! random.monad]
-    [name (random.unicode 1)
-     [loop?_first expected_first actual_first] (random_value false)
-     [loop?_second expected_second actual_second] (random_value false)
-     [loop?_third expected_third actual_third] (random_value false)]
-    (in [(and loop?_first
-              loop?_second
-              loop?_third)
-         {synthesis.#Extension name (list expected_first expected_second expected_third)}
-         {analysis.#Extension name (list actual_first actual_second actual_third)}])))
-
-(def (random_body arity)
-  (-> Arity Scenario)
-  (function (random_value output?)
-    (random.rec
-     (function (_ _)
-       (all random.either
-            (..random_primitive output?)
-            (..random_structure random_value output?)
-            (..random_reference arity output?)
-            (..random_control arity random_value output?)
-            (..random_extension random_value output?))))))
-
-(def random_abstraction
-  (Random [Synthesis Analysis])
-  (do [! random.monad]
-    [arity (|> random.nat (at ! each (|>> (n.% 5) ++)))
-     [loop? expected_body actual_body] (random_body arity true)]
-    (in [(..n_function loop? arity expected_body)
-         (..n_abstraction arity actual_body)])))
-
-(def abstraction
-  Test
-  (do random.monad
-    [[expected input] ..random_abstraction]
-    (_.coverage [/.abstraction]
-      (|> input
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty synthesis.init])
-          (!expect (^.multi {try.#Success actual}
-                            (at synthesis.equivalence = expected actual)))))))
-
-(def application
-  Test
-  (do [! random.monad]
-    [arity (|> random.nat (at ! each (|>> (n.% 10) (n.max 1))))
-     funcA //primitive.primitive
-     argsA (random.list arity //primitive.primitive)]
-    (_.coverage [/.apply]
-      (and (|> (analysis.apply [funcA argsA])
-               (//.phase archive.empty)
-               (phase.result [///bundle.empty synthesis.init])
-               (!expect (^.multi {try.#Success (synthesis.function/apply [funcS argsS])}
-                                 (and (//primitive.corresponds? funcA funcS)
-                                      (list.every? (product.uncurried //primitive.corresponds?)
-                                                   (list.zipped_2 argsA argsS))))))
-           (|> (analysis.apply [funcA (list)])
-               (//.phase archive.empty)
-               (phase.result [///bundle.empty synthesis.init])
-               (!expect (^.multi {try.#Success funcS}
-                                 (//primitive.corresponds? funcA funcS))))))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           ..abstraction
-           ..application
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux
deleted file mode 100644
index 76df6ec77..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux
+++ /dev/null
@@ -1,293 +0,0 @@
-(.require
- [lux (.except structure loop function)
-  ["_" test (.only Test)]
-  [abstract
-   [monad (.only do)]]
-  [control
-   ["[0]" try]
-   ["[0]" exception]]
-  [data
-   [number
-    ["n" nat]]
-   [collection
-    ["[0]" list (.use "[1]#[0]" functor)]]]
-  [math
-   ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]
- [\\
-  ["[0]" /
-   [////
-    ["[0]" analysis (.only Environment)]
-    ["/[1]" synthesis (.only Member Path Synthesis)]
-    [///
-     [arity (.only Arity)]
-     ["[0]" reference (.only Constant)
-      ["[0]" variable (.only Register Variable)]]]]]])
-
-(type (Scenario a)
-  (-> Register Arity Register (Random [Register [a a]])))
-
-(def (primitive offset arity next)
-  (Scenario Synthesis)
-  (`` (all random.either
-           (,, (with_template [ ]
-                 [(do [! random.monad]
-                    [example (at ! each (|>> ) )]
-                    (in [next
-                         [example
-                          example]]))]
-
-                 [//.bit random.bit]
-                 [//.i64 (at ! each .i64 random.nat)]
-                 [//.f64 random.frac]
-                 [//.text (random.unicode 1)]
-                 ))
-           )))
-
-(def (constant offset arity next)
-  (Scenario Constant)
-  (do random.monad
-    [name (random.and (random.unicode 1)
-                      (random.unicode 1))]
-    (in [next
-         [name
-          name]])))
-
-(def (variable offset arity next)
-  (Scenario Variable)
-  (let [local (do [! random.monad]
-                [register (at ! each (|>> (n.% arity) ++) random.nat)]
-                (in [next
-                     [{variable.#Local (/.register_optimization offset register)}
-                      {variable.#Local register}]]))]
-    (case offset
-      0 local
-      _ (all random.either
-             local
-             (do [! random.monad]
-               [foreign (at ! each (n.% offset) random.nat)]
-               (in [next
-                    [{variable.#Local foreign}
-                     {variable.#Foreign foreign}]]))))))
-
-(def (reference offset arity next)
-  (Scenario Synthesis)
-  (`` (all random.either
-           (,, (with_template [ ]
-                 [(do [! random.monad]
-                    [[next [exampleE exampleA]] ( offset arity next)]
-                    (in [next
-                         [( exampleE)
-                          ( exampleA)]]))]
-
-                 [//.constant ..constant]
-                 [//.variable ..variable]
-                 )))))
-
-(def (structure offset arity next)
-  (Scenario Synthesis)
-  (all random.either
-       (do [! random.monad]
-         [lefts random.nat
-          right? random.bit
-          [next [valueE valueA]] (..reference offset arity next)]
-         (in [next
-              [(//.variant
-                [analysis.#lefts lefts
-                 analysis.#right? right?
-                 analysis.#value valueE])
-               (//.variant
-                [analysis.#lefts lefts
-                 analysis.#right? right?
-                 analysis.#value valueA])]]))
-       (do [! random.monad]
-         [[next [leftE leftA]] (..reference offset arity next)
-          [next [rightE rightA]] (..reference offset arity next)]
-         (in [next
-              [(//.tuple (list leftE rightE))
-               (//.tuple (list leftA rightA))]]))
-       ))
-
-(def path
-  (Scenario Path)
-  (let [pattern (is (Scenario Path)
-                    (.function (again offset arity next)
-                      (`` (all random.either
-                               (random#in [next
-                                           [//.path/pop
-                                            //.path/pop]])
-                               (,, (with_template [ ]
-                                     [(do [! random.monad]
-                                        [example (at ! each (|>> ) )]
-                                        (in [next
-                                             [example
-                                              example]]))]
-
-                                     [//.path/bit random.bit]
-                                     [//.path/i64 (at ! each .i64 random.nat)]
-                                     [//.path/f64 random.frac]
-                                     [//.path/text (random.unicode 1)]
-                                     ))
-                               (,, (with_template []
-                                     [(do [! random.monad]
-                                        [example (at ! each (|>> )
-                                                     (random.or random.nat
-                                                                random.nat))]
-                                        (in [next
-                                             [example
-                                              example]]))]
-
-                                     [//.path/side]
-                                     [//.path/member]
-                                     ))
-                               (random#in [(++ next)
-                                           [(//.path/bind (/.register_optimization offset next))
-                                            (//.path/bind next)]])
-                               ))))
-        sequential (is (Scenario Path)
-                       (.function (again offset arity next)
-                         (do random.monad
-                           [[next [patternE patternA]] (pattern offset arity next)
-                            [next [bodyE bodyA]] (..reference offset arity next)]
-                           (in [next
-                                [(//.path/seq patternE (//.path/then bodyE))
-                                 (//.path/seq patternA (//.path/then bodyA))]]))))]
-    (.function (again offset arity next)
-      (do random.monad
-        [[next [leftE leftA]] (sequential offset arity next)
-         [next [rightE rightA]] (sequential offset arity next)]
-        (in [next
-             [(//.path/alt leftE rightE)
-              (//.path/alt leftA rightA)]])))))
-
-(def (branch offset arity next)
-  (Scenario Synthesis)
-  (let [random_member (is (Random Member)
-                          (random.or random.nat
-                                     random.nat))]
-    (all random.either
-         (all random.either
-              (do [! random.monad]
-                [[next [inputE inputA]] (..reference offset arity next)
-                 [next [bodyE bodyA]] (..reference offset arity next)]
-                (in [next
-                     [(//.branch/let [inputE (/.register_optimization offset next) bodyE])
-                      (//.branch/let [inputA next bodyA])]]))
-              (do [! random.monad]
-                [[next [testE testA]] (..reference offset arity next)
-                 [next [thenE thenA]] (..reference offset arity next)
-                 [next [elseE elseA]] (..reference offset arity next)]
-                (in [next
-                     [(//.branch/if [testE thenE elseE])
-                      (//.branch/if [testA thenA elseA])]])))
-         (all random.either
-              (do [! random.monad]
-                [[next [recordE recordA]] (..reference offset arity next)
-                 path_length (at ! each (|>> (n.% 5) ++) random.nat)
-                 path (random.list path_length random_member)]
-                (in [next
-                     [(//.branch/get [path recordE])
-                      (//.branch/get [path recordA])]]))
-              (do [! random.monad]
-                [[next [inputE inputA]] (..reference offset arity next)
-                 [next [pathE pathA]] (..path offset arity next)]
-                (in [next
-                     [(//.branch/case [inputE pathE])
-                      (//.branch/case [inputA pathA])]])))
-         )))
-
-(def (loop offset arity next)
-  (Scenario Synthesis)
-  (all random.either
-       (do random.monad
-         [[next [firstE firstA]] (..reference offset arity next)
-          [next [secondE secondA]] (..reference offset arity next)
-          [next [iterationE iterationA]] (..reference offset arity next)]
-         (in [next
-              [(//.loop/scope
-                [//.#start (/.register_optimization offset next)
-                 //.#inits (list firstE secondE)
-                 //.#iteration iterationE])
-               (//.loop/scope
-                [//.#start next
-                 //.#inits (list firstA secondA)
-                 //.#iteration iterationA])]]))
-       ))
-
-(def (function offset arity next)
-  (Scenario Synthesis)
-  (all random.either
-       (do [! random.monad]
-         [[next [firstE firstA]] (..variable offset arity next)
-          [next [secondE secondA]] (..variable offset arity next)
-          arity (at ! each (n.max 1) random.nat)
-          [next [bodyE bodyA]] (..primitive 0 arity next)]
-         (in [next
-              [(//.function/abstraction
-                [//.#environment (list firstE secondE)
-                 //.#arity arity
-                 //.#body bodyE])
-               (//.function/abstraction
-                [//.#environment (list firstA secondA)
-                 //.#arity arity
-                 //.#body bodyA])]]))
-       ))
-
-(def (control offset arity next)
-  (Scenario Synthesis)
-  (all random.either
-       (..branch offset arity next)
-       (..loop offset arity next)
-       (..function offset arity next)
-       ))
-
-(def (extension offset arity next)
-  (Scenario Synthesis)
-  (do random.monad
-    [name (random.unicode 10)
-     [next [firstE firstA]] (..reference offset arity next)
-     [next [secondE secondA]] (..reference offset arity next)
-     [next [thirdE thirdA]] (..reference offset arity next)]
-    (in [next
-         [{//.#Extension name (list firstE secondE thirdE)}
-          {//.#Extension name (list firstA secondA thirdA)}]])))
-
-(def (scenario offset arity next)
-  (Scenario Synthesis)
-  (all random.either
-       (..primitive offset arity next)
-       (..structure offset arity next)
-       (..reference offset arity next)
-       (..control offset arity next)
-       (..extension offset arity next)
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           (do [! random.monad]
-             [expected_offset (at ! each (|>> (n.% 5) (n.+ 2)) random.nat)
-              arity (at ! each (|>> (n.% 5) ++) random.nat)
-              expected_inits (|> random.nat
-                                 (at ! each (|>> .i64 //.i64))
-                                 (random.list arity))
-              [_ [expected iteration]] (..scenario expected_offset arity 0)]
-             (_.coverage [/.Transform /.optimization /.register_optimization]
-               (case (/.optimization true expected_offset expected_inits
-                                     [//.#environment (|> expected_offset
-                                                          list.indices
-                                                          (list#each (|>> {variable.#Local})))
-                                      //.#arity arity
-                                      //.#body iteration])
-                 {.#Some (//.loop/scope [actual_offset actual_inits
-                                         actual])}
-                 (and (n.= expected_offset
-                           actual_offset)
-                      (at (list.equivalence //.equivalence) =
-                          expected_inits
-                          actual_inits)
-                      (at //.equivalence = expected actual))
-                 
-                 _
-                 false)))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux
deleted file mode 100644
index 07414ac90..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux
+++ /dev/null
@@ -1,98 +0,0 @@
-(.require
- [lux (.except primitive)
-  [abstract ["[0]" monad (.only do)]]
-  [control
-   ["[0]" pipe]
-   ["[0]" try]]
-  [data
-   ["%" text/format (.only format)]
-   [number
-    ["n" nat]]
-   [collection
-    ["[0]" list]]]
-  ["r" math/random (.only Random) (.use "[1]#[0]" monad)]
-  ["_" test (.only Test)]
-  [meta
-   ["[0]" symbol]]]
- [\\
-  ["[0]" /
-   ["/[1]" // (.only)
-    ["/[1]" //
-     [extension
-      ["[1][0]" bundle]]
-     ["/[1]" // (.only)
-      ["[1][0]" analysis (.only Analysis)]
-      ["[1][0]" synthesis (.only Synthesis)]
-      [///
-       ["[0]" phase]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def .public primitive
-  (Random Analysis)
-  (do r.monad
-    [primitive (is (Random ////analysis.Primitive)
-                   (all r.or
-                        (in [])
-                        r.bit
-                        r.nat
-                        r.int
-                        r.rev
-                        r.frac
-                        (r.unicode 5)))]
-    (in {////analysis.#Primitive primitive})))
-
-(def .public (corresponds? analysis synthesis)
-  (-> Analysis Synthesis Bit)
-  (`` (case [analysis synthesis]
-        (,, (with_template [   ]
-              [[{////analysis.#Primitive { expected}}
-                {////synthesis.#Primitive { actual}}]
-               (same? (|> expected )
-                      (|> actual ))]
-
-              [////analysis.#Unit (as Text) ////synthesis.#Text (|>)]
-              [////analysis.#Bit  (|>) ////synthesis.#Bit (|>)]
-              [////analysis.#Nat  .i64 ////synthesis.#I64 .i64]
-              [////analysis.#Int  .i64 ////synthesis.#I64 .i64]
-              [////analysis.#Rev  .i64 ////synthesis.#I64 .i64]
-              [////analysis.#Frac (|>) ////synthesis.#F64 (|>)]
-              [////analysis.#Text (|>) ////synthesis.#Text (|>)]
-              ))
-
-        [(////analysis.tuple expected)
-         (////synthesis.tuple actual)]
-        (and (n.= (list.size expected)
-                  (list.size actual))
-             (list.every? (function (_ [expected actual])
-                            (corresponds? expected actual))
-                          (list.zipped_2 expected actual)))
-        
-        _
-        false)))
-
-(def .public test
-  Test
-  (<| (_.context (%.symbol (symbol ////synthesis.#Primitive)))
-      (`` (all _.and
-               (,, (with_template [  ]
-                     [(do r.monad
-                        [expected ]
-                        (_.property (%.symbol (symbol ))
-                          (|> {////analysis.#Primitive { expected}}
-                              (//.phase archive.empty)
-                              (phase.result [///bundle.empty ////synthesis.init])
-                              (pipe.case
-                                {try.#Success {////synthesis.#Primitive { actual}}}
-                                (same? expected actual)
-
-                                _
-                                false))))]
-
-                     [////analysis.#Unit ////synthesis.#Text (r#in ////synthesis.unit)]
-                     [////analysis.#Bit  ////synthesis.#Bit  r.bit]
-                     [////analysis.#Nat  ////synthesis.#I64  (r#each .i64 r.nat)]
-                     [////analysis.#Int  ////synthesis.#I64  (r#each .i64 r.int)]
-                     [////analysis.#Rev  ////synthesis.#I64  (r#each .i64 r.rev)]
-                     [////analysis.#Frac ////synthesis.#F64  r.frac]
-                     [////analysis.#Text ////synthesis.#Text (r.unicode 5)]))))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux
deleted file mode 100644
index d17044f40..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux
+++ /dev/null
@@ -1,85 +0,0 @@
-(.require
- [lux (.except)
-  [abstract
-   ["[0]" monad (.only do)]]
-  [data
-   ["%" text/format (.only format)]]
-  ["r" math/random (.only Random)]
-  ["_" test (.only Test)]
-  [control
-   ["[0]" pipe]
-   ["[0]" try]]
-  [data
-   ["[0]" bit (.use "[1]#[0]" equivalence)]
-   ["[0]" product]
-   [number
-    ["n" nat]]
-   [collection
-    ["[0]" list]]]
-  [meta
-   ["[0]" symbol]]]
- ["[0]" //
-  ["[1][0]" primitive]]
- [\\
-  ["[0]" /
-   ["/[1]" // (.only)
-    ["/[1]" //
-     [extension
-      ["[1][0]" bundle]]
-     ["/[1]" // (.only)
-      ["[1][0]" analysis (.only Analysis)]
-      ["[1][0]" synthesis (.only Synthesis)]
-      [///
-       ["[0]" phase]
-       [meta
-        ["[0]" archive]]]]]]]])
-
-(def variant
-  Test
-  (do [! r.monad]
-    [size (|> r.nat (at ! each (|>> (n.% 10) (n.+ 2))))
-     tagA (|> r.nat (at ! each (n.% size)))
-     .let [right? (n.= (-- size) tagA)
-           lefts (if right?
-                   (-- tagA)
-                   tagA)]
-     memberA //primitive.primitive]
-    (_.property "Can synthesize variants."
-      (|> (////analysis.variant [lefts right? memberA])
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty ////synthesis.init])
-          (pipe.case
-            {try.#Success (////synthesis.variant [leftsS right?S valueS])}
-            (let [tagS (if right?S (++ leftsS) leftsS)]
-              (and (n.= tagA tagS)
-                   (|> tagS (n.= (-- size)) (bit#= right?S))
-                   (//primitive.corresponds? memberA valueS)))
-            
-            _
-            false)))))
-
-(def tuple
-  Test
-  (do [! r.monad]
-    [size (|> r.nat (at ! each (|>> (n.% 10) (n.max 2))))
-     membersA (r.list size //primitive.primitive)]
-    (_.property "Can synthesize tuple."
-      (|> (////analysis.tuple membersA)
-          (//.phase archive.empty)
-          (phase.result [///bundle.empty ////synthesis.init])
-          (pipe.case
-            {try.#Success (////synthesis.tuple membersS)}
-            (and (n.= size (list.size membersS))
-                 (list.every? (product.uncurried //primitive.corresponds?)
-                              (list.zipped_2 membersA membersS)))
-
-            _
-            false)))))
-
-(def .public test
-  Test
-  (<| (_.context (%.symbol (symbol ////synthesis.#Structure)))
-      (all _.and
-           ..variant
-           ..tuple
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
deleted file mode 100644
index 309ba20ff..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
+++ /dev/null
@@ -1,338 +0,0 @@
-(.require
- [lux (.except)
-  ["_" test (.only Test)]
-  [abstract
-   ["[0]" monad (.only do)]]
-  [control
-   ["[0]" try]]
-  [data
-   ["[0]" product]
-   ["[0]" text
-    ["%" \\format (.only format)]]
-   [number
-    ["n" nat]]
-   [collection
-    ["[0]" list (.use "[1]#[0]" functor mix)]
-    ["[0]" dictionary (.only Dictionary)]]]
-  [math
-   ["[0]" random (.only Random)]]
-  [meta
-   [macro
-    ["^" pattern]]]]
- [\\
-  ["[0]" /
-   [////
-    ["[0]" analysis]
-    ["[0]" synthesis (.only Side Member Path Synthesis)]
-    [///
-     [reference
-      ["[0]" variable]]]]]])
-
-(def !expect
-  (template (_  )
-    (case 
-      
-      true
-      
-      _
-      false)))
-
-(type Context
-  [#redundants Nat
-   #necessary (Dictionary Nat Nat)])
-
-(type (Scenario a)
-  (-> Context (Random [a a])))
-
-(with_template [  ]
-  [(def ( context)
-     (Scenario Synthesis)
-     (do [! random.monad]
-       [value ]
-       (in [( value)
-            ( value)])))]
-
-  [bit_scenario synthesis.bit random.bit]
-  [i64_scenario synthesis.i64 (at ! each .i64 random.nat)]
-  [f64_scenario synthesis.f64 random.frac]
-  [text_scenario synthesis.text (random.unicode 1)]
-  )
-
-(def (primitive_scenario context)
-  (Scenario Synthesis)
-  (random.either (random.either (..bit_scenario context)
-                                (..i64_scenario context))
-                 (random.either (..f64_scenario context)
-                                (..text_scenario context))))
-
-(def (with_redundancy scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [redundant? random.bit]
-    (if redundant?
-      (do !
-        [let? random.bit
-         [expected_input actual_input] (..primitive_scenario context)
-         .let [fake_register (n.+ (the #redundants context)
-                                  (dictionary.size (the #necessary context)))]
-         [expected_output actual_output] (scenario (revised #redundants ++ context))]
-        (in [(synthesis.branch/case [expected_input
-                                     {synthesis.#Seq {synthesis.#Pop}
-                                                     {synthesis.#Then expected_output}}])
-             (if let?
-               (synthesis.branch/let [actual_input fake_register actual_output])
-               (synthesis.branch/case [actual_input
-                                       {synthesis.#Seq {synthesis.#Bind fake_register}
-                                                       {synthesis.#Seq {synthesis.#Pop}
-                                                                       {synthesis.#Then actual_output}}}]))]))
-      (scenario context))))
-
-(def (variant_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [lefts random.nat
-     right? random.bit
-     [expected input] (scenario context)]
-    (in [(synthesis.variant [lefts right? expected])
-         (synthesis.variant [lefts right? input])])))
-
-(def (tuple_scenario context)
-  (Scenario Synthesis)
-  (let [registers (dictionary.entries (the #necessary context))]
-    (at random.monad in
-        [(synthesis.tuple (list#each (|>> product.left synthesis.variable/local) registers))
-         (synthesis.tuple (list#each (|>> product.right synthesis.variable/local) registers))])))
-
-(def (structure_scenario context)
-  (Scenario Synthesis)
-  (random.either (..variant_scenario (..with_redundancy ..tuple_scenario) context)
-                 (..tuple_scenario context)))
-
-(def (let_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do random.monad
-    [_ (in [])
-     [expected_input actual_input] (scenario context)
-     .let [real_register (dictionary.size (the #necessary context))
-           fake_register (n.+ (the #redundants context)
-                              (dictionary.size (the #necessary context)))]
-     [expected_output actual_output] (scenario (revised #necessary (dictionary.has real_register fake_register) context))]
-    (in [(synthesis.branch/let [expected_input real_register expected_output])
-         (synthesis.branch/let [actual_input fake_register actual_output])])))
-
-(def (if_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do random.monad
-    [_ (in [])
-     [expected_test actual_test] (scenario context)
-     [expected_then actual_then] (scenario context)
-     [expected_else actual_else] (scenario context)]
-    (in [(synthesis.branch/if [expected_test
-                               expected_then
-                               expected_else])
-         (synthesis.branch/if [actual_test
-                               actual_then
-                               actual_else])])))
-
-(def random_member
-  (Random Member)
-  (do random.monad
-    [lefts random.nat
-     right? random.bit]
-    (in (if right?
-          {.#Right lefts}
-          {.#Left lefts}))))
-
-(def (get_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [length (at ! each (|>> (n.% 5) ++) random.nat)
-     path (random.list length ..random_member)
-     [expected_record actual_record] (scenario context)]
-    (in [(synthesis.branch/get [path expected_record])
-         (synthesis.branch/get [path actual_record])])))
-
-(def random_side
-  (Random Side)
-  ..random_member)
-
-(def (path_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Path))
-  (`` (all random.either
-           (all random.either
-                (do [! random.monad]
-                  [_ (in [])
-                   [expected_then actual_then] (scenario context)]
-                  (in [{synthesis.#Seq {synthesis.#Pop}
-                                       {synthesis.#Then expected_then}}
-                       {synthesis.#Seq {synthesis.#Pop}
-                                       {synthesis.#Then actual_then}}]))
-                (do [! random.monad]
-                  [_ (in [])
-                   .let [real_register (dictionary.size (the #necessary context))
-                         fake_register (n.+ (the #redundants context)
-                                            (dictionary.size (the #necessary context)))]
-                   [expected_then actual_then] (scenario (revised #necessary (dictionary.has real_register fake_register) context))]
-                  (in [{synthesis.#Seq {synthesis.#Bind real_register}
-                                       {synthesis.#Seq {synthesis.#Pop}
-                                                       {synthesis.#Then expected_then}}}
-                       {synthesis.#Seq {synthesis.#Bind fake_register}
-                                       {synthesis.#Seq {synthesis.#Pop}
-                                                       {synthesis.#Then actual_then}}}])))
-           (all random.either
-                (,, (with_template [ ]
-                      [(do [! random.monad]
-                         [test 
-                          [expected_then actual_then] (scenario context)]
-                         (in [{synthesis.#Seq {synthesis.#Test { test}}
-                                              {synthesis.#Then expected_then}}
-                              {synthesis.#Seq {synthesis.#Test { test}}
-                                              {synthesis.#Then actual_then}}]))]
-
-                      [synthesis.#Bit random.bit]
-                      [synthesis.#I64 (at ! each .i64 random.nat)]
-                      [synthesis.#F64 random.frac]
-                      [synthesis.#Text (random.unicode 1)]
-                      )))
-           (all random.either
-                (do [! random.monad]
-                  [side ..random_side
-                   [expected_next actual_next] (path_scenario scenario context)]
-                  (in [{synthesis.#Seq {synthesis.#Access {synthesis.#Side side}}
-                                       expected_next}
-                       {synthesis.#Seq {synthesis.#Access {synthesis.#Side side}}
-                                       actual_next}]))
-                (do [! random.monad]
-                  [member ..random_member
-                   [expected_next actual_next] (path_scenario scenario context)]
-                  (in [{synthesis.#Seq {synthesis.#Access {synthesis.#Member member}}
-                                       expected_next}
-                       {synthesis.#Seq {synthesis.#Access {synthesis.#Member member}}
-                                       actual_next}])))
-           (do [! random.monad]
-             [_ (in [])
-              [expected_left actual_left] (path_scenario scenario context)
-              [expected_right actual_right] (path_scenario scenario context)]
-             (in [{synthesis.#Alt expected_left expected_right}
-                  {synthesis.#Alt actual_left actual_right}]))
-           )))
-
-(def (case_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [_ (in [])
-     [expected_input actual_input] (scenario context)
-     [expected_path actual_path] (..path_scenario scenario context)]
-    (in [(synthesis.branch/case [expected_input expected_path])
-         (synthesis.branch/case [actual_input actual_path])])))
-
-(def (branch_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (all random.either
-       (..let_scenario scenario context)
-       (..if_scenario scenario context)
-       (..get_scenario scenario context)
-       (..case_scenario scenario context)
-       ))
-
-(def scope_arity 5)
-
-(def (scope_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [_ (in [])
-     .let [real_start (dictionary.size (the #necessary context))
-           fake_start (n.+ (the #redundants context)
-                           real_start)]
-     inits (random.list ..scope_arity (scenario context))
-     [expected_iteration actual_iteration] (scenario (revised #necessary
-                                                              (function (_ necessary)
-                                                                (list#mix (function (_ [idx _] context)
-                                                                            (dictionary.has (n.+ real_start idx)
-                                                                                            (n.+ fake_start idx)
-                                                                                            context))
-                                                                          necessary
-                                                                          (list.enumeration inits)))
-                                                              context))]
-    (in [(synthesis.loop/scope [real_start (list#each product.left inits) expected_iteration])
-         (synthesis.loop/scope [fake_start (list#each product.right inits) actual_iteration])])))
-
-(def (again_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [_ (in [])
-     resets (random.list ..scope_arity (scenario context))]
-    (in [(synthesis.loop/again (list#each product.left resets))
-         (synthesis.loop/again (list#each product.right resets))])))
-
-(def (loop_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (all random.either
-       (..scope_scenario scenario context)
-       (..again_scenario scenario context)
-       ))
-
-(def (abstraction_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [_ (in [])
-     .let [registers (dictionary.entries (the #necessary context))
-           expected_environment (list#each (|>> product.left {variable.#Local}) registers)
-           actual_environment (list#each (|>> product.right {variable.#Local}) registers)]
-     [expected_body actual_body] (..primitive_scenario context)]
-    (in [(synthesis.function/abstraction [expected_environment 1 expected_body])
-         (synthesis.function/abstraction [actual_environment 1 actual_body])])))
-
-(def (apply_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (do [! random.monad]
-    [abstraction (at ! each (|>> synthesis.constant)
-                     (random.and (random.unicode 1)
-                                 (random.unicode 1)))
-     inputs (random.list ..scope_arity (scenario context))]
-    (in [(synthesis.function/apply [abstraction (list#each product.left inputs)])
-         (synthesis.function/apply [abstraction (list#each product.right inputs)])])))
-
-(def (function_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (all random.either
-       (..abstraction_scenario scenario context)
-       (..apply_scenario scenario context)
-       ))
-
-(def (control_scenario scenario context)
-  (-> (Scenario Synthesis) (Scenario Synthesis))
-  (all random.either
-       (..branch_scenario scenario context)
-       (..loop_scenario scenario context)
-       (..function_scenario scenario context)
-       ))
-
-(def (scenario context)
-  (Scenario Synthesis)
-  (all random.either
-       (..primitive_scenario context)
-       (..structure_scenario context)
-       (..control_scenario (..with_redundancy
-                             (..control_scenario
-                              (..with_redundancy
-                                ..structure_scenario)))
-                           context)
-       ))
-
-(def default
-  Context
-  [#redundants 0
-   #necessary (dictionary.empty n.hash)])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           (do random.monad
-             [[expected input] (..scenario ..default)]
-             (_.coverage [/.optimization]
-               (|> (/.optimization input)
-                   (!expect (^.multi {try.#Success actual}
-                                     (at synthesis.equivalence = expected actual))))))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux
deleted file mode 100644
index a87bcbd66..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux
+++ /dev/null
@@ -1,145 +0,0 @@
-(.require
- [lux (.except)
-  [abstract/monad (.only do)]
-  [data
-   ["%" text/format (.only format)]
-   [number
-    ["n" nat]]]
-  ["r" math/random (.only Random) (.use "[1]#[0]" monad)]
-  ["_" test (.only Test)]
-  [control
-   ["[0]" try]
-   [parser
-    ["l" text]]]
-  [data
-   ["[0]" text]
-   [collection
-    ["[0]" list]
-    ["[0]" dictionary (.only Dictionary)]]]
-  [meta
-   ["[0]" code]
-   ["[0]" location]
-   ["[0]" symbol]]]
- [\\
-  ["[0]" /]])
-
-(def symbol_part^
-  (Random Text)
-  (do [! r.monad]
-    [size (|> r.nat (at ! each (|>> (n.% 20) (n.max 1))))]
-    (r.lower_case_alpha size)))
-
-(def symbol^
-  (Random Symbol)
-  (r.and symbol_part^ symbol_part^))
-
-(def code^
-  (Random Code)
-  (let [numeric^ (is (Random Code)
-                     (all r.either
-                          (|> r.bit (r#each code.bit))
-                          (|> r.nat (r#each code.nat))
-                          (|> r.int (r#each code.int))
-                          (|> r.rev (r#each code.rev))
-                          (|> r.safe_frac (r#each code.frac))))
-        textual^ (is (Random Code)
-                     (all r.either
-                          (do r.monad
-                            [size (|> r.nat (r#each (n.% 20)))]
-                            (|> (r.upper_case_alpha size) (r#each code.text)))
-                          (|> symbol^ (r#each code.symbol))
-                          (|> symbol^ (r#each code.tag))))
-        simple^ (is (Random Code)
-                    (all r.either
-                         numeric^
-                         textual^))]
-    (r.rec
-     (function (_ code^)
-       (let [multi^ (do r.monad
-                      [size (|> r.nat (r#each (n.% 3)))]
-                      (r.list size code^))
-             composite^ (is (Random Code)
-                            (all r.either
-                                 (|> multi^ (r#each code.form))
-                                 (|> multi^ (r#each code.tuple))
-                                 (do r.monad
-                                   [size (|> r.nat (r#each (n.% 3)))]
-                                   (|> (r.list size (r.and code^ code^))
-                                       (r#each code.record)))))]
-         (all r.either
-              simple^
-              composite^))))))
-
-(def code
-  Test
-  (do [! r.monad]
-    [sample code^]
-    (all _.and
-         (_.property "Can parse Lux code."
-           (case (let [source_code (%.code sample)]
-                   (/.parse "" (dictionary.empty text.hash) (text.size source_code)
-                            [location.dummy 0 source_code]))
-             {.#Left error}
-             false
-
-             {.#Right [_ parsed]}
-             (at code.equivalence = parsed sample)))
-         (do !
-           [other code^]
-           (_.property "Can parse multiple Lux code nodes."
-             (let [source_code (format (%.code sample) " " (%.code other))
-                   source_code//size (text.size source_code)]
-               (case (/.parse "" (dictionary.empty text.hash) source_code//size
-                              [location.dummy 0 source_code])
-                 {.#Left error}
-                 false
-
-                 {.#Right [remaining =sample]}
-                 (case (/.parse "" (dictionary.empty text.hash) source_code//size
-                                remaining)
-                   {.#Left error}
-                   false
-
-                   {.#Right [_ =other]}
-                   (and (at code.equivalence = sample =sample)
-                        (at code.equivalence = other =other)))))))
-         )))
-
-(def comment_text^
-  (Random Text)
-  (let [char_gen (|> r.nat (r.only (|>> (n.= (`` (char (,, (static text.new_line))))) not)))]
-    (do r.monad
-      [size (|> r.nat (r#each (n.% 20)))]
-      (r.text char_gen size))))
-
-(def comment^
-  (Random Text)
-  (do r.monad
-    [comment comment_text^]
-    (in (format "... " comment text.new_line))))
-
-(def comments
-  Test
-  (do r.monad
-    [sample code^
-     comment comment^]
-    (all _.and
-         (_.property "Can handle comments."
-           (case (let [source_code (format comment (%.code sample))
-                       source_code//size (text.size source_code)]
-                   (/.parse "" (dictionary.empty text.hash) source_code//size
-                            [location.dummy 0 source_code]))
-             {.#Left error}
-             false
-
-             {.#Right [_ parsed]}
-             (at code.equivalence = parsed sample)))
-         )))
-
-(def .public test
-  Test
-  (<| (_.context (symbol.module (symbol /._)))
-      (all _.and
-           ..code
-           ..comments
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux
deleted file mode 100644
index 46ae030bc..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux
+++ /dev/null
@@ -1,216 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    ["[0]" monad (.only do)]]
-   [control
-    ["<>" parser]
-    ["[0]" try]
-    ["[0]" exception]]
-   [data
-    ["[0]" bit]
-    ["[0]" text]
-    [collection
-     ["[0]" list (.use "[1]#[0]" functor)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]
-     ["[0]" i64]
-     ["[0]" frac]]]
-   [meta
-    ["[0]" symbol]
-    [macro
-     ["^" pattern]]]
-   [tool
-    [compiler
-     [reference (.only)
-      ["[0]" variable (.only Variable)]]
-     [language
-      [lux
-       [analysis (.only Environment)]
-       ["[0]" synthesis (.only Synthesis)]]]]]]]
- ["[0]" \\parser]
- ["[0]" /
-  ["[1][0]" simple]
-  ["[1][0]" access]])
-
-(def !expect
-  (template (_  )
-    [(case 
-       
-       true
-       
-       _
-       false)]))
-
-(def random_constant
-  (Random Symbol)
-  (random.and (random.unicode 1)
-              (random.unicode 1)))
-
-(def random_variable
-  (Random Variable)
-  (random.or random.nat
-             random.nat))
-
-(def random_environment
-  (Random (Environment Synthesis))
-  (do [! random.monad]
-    [size (at ! each (n.% 5) random.nat)]
-    (|> ..random_variable
-        (at ! each (|>> synthesis.variable))
-        (random.list size))))
-
-(def simple
-  Test
-  (`` (all _.and
-           (,, (with_template [    ]
-                 [(do [! random.monad]
-                    [expected 
-                     dummy (|>  (random.only (|>> (at  = expected) not)))]
-                    (all _.and
-                         (_.coverage []
-                           (|> (\\parser.result  (list ( expected)))
-                               (!expect (^.multi {try.#Success actual}
-                                                 (at  = expected actual)))))
-                         (_.coverage []
-                           (and (|> (\\parser.result ( expected) (list ( expected)))
-                                    (!expect {try.#Success _}))
-                                (|> (\\parser.result ( expected) (list ( dummy)))
-                                    (!expect (^.multi {try.#Failure error}
-                                                      (exception.match? \\parser.cannot_parse error))))))
-                         ))]
-
-                 [\\parser.bit \\parser.this_bit random.bit synthesis.bit bit.equivalence]
-                 [\\parser.i64 \\parser.this_i64 random.i64 synthesis.i64 i64.equivalence]
-                 [\\parser.f64 \\parser.this_f64 random.safe_frac synthesis.f64 frac.equivalence]
-                 [\\parser.text \\parser.this_text (random.unicode 1) synthesis.text text.equivalence]
-                 [\\parser.local \\parser.this_local random.nat synthesis.variable/local n.equivalence]
-                 [\\parser.foreign \\parser.this_foreign random.nat synthesis.variable/foreign n.equivalence]
-                 [\\parser.constant \\parser.this_constant ..random_constant synthesis.constant symbol.equivalence]
-                 ))
-           )))
-
-(def complex
-  Test
-  (all _.and
-       (do [! random.monad]
-         [expected_bit random.bit
-          expected_i64 random.i64
-          expected_f64 random.safe_frac
-          expected_text (random.unicode 1)]
-         (_.coverage [\\parser.tuple]
-           (and (|> (\\parser.result (\\parser.tuple (all <>.and \\parser.bit \\parser.i64 \\parser.f64 \\parser.text))
-                                     (list (synthesis.tuple (list (synthesis.bit expected_bit)
-                                                                  (synthesis.i64 expected_i64)
-                                                                  (synthesis.f64 expected_f64)
-                                                                  (synthesis.text expected_text)))))
-                    (!expect (^.multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]}
-                                      (and (at bit.equivalence = expected_bit actual_bit)
-                                           (at i64.equivalence = expected_i64 actual_i64)
-                                           (at frac.equivalence = expected_f64 actual_f64)
-                                           (at text.equivalence = expected_text actual_text)))))
-                (|> (\\parser.result (\\parser.tuple (all <>.and \\parser.bit \\parser.i64 \\parser.f64 \\parser.text))
-                                     (list (synthesis.text expected_text)))
-                    (!expect (^.multi {try.#Failure error}
-                                      (exception.match? \\parser.cannot_parse error)))))))
-       (do [! random.monad]
-         [arity random.nat
-          expected_environment ..random_environment
-          expected_body (random.unicode 1)]
-         (_.coverage [\\parser.function]
-           (and (|> (\\parser.result (\\parser.function arity \\parser.text)
-                                     (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
-                    (!expect (^.multi {try.#Success [actual_environment actual_body]}
-                                      (and (at (list.equivalence synthesis.equivalence) =
-                                               expected_environment
-                                               actual_environment)
-                                           (at text.equivalence = expected_body actual_body)))))
-                (|> (\\parser.result (\\parser.function arity \\parser.text)
-                                     (list (synthesis.text expected_body)))
-                    (!expect (^.multi {try.#Failure error}
-                                      (exception.match? \\parser.cannot_parse error)))))))
-       (do [! random.monad]
-         [arity random.nat
-          expected_environment ..random_environment
-          expected_body (random.unicode 1)]
-         (_.coverage [\\parser.wrong_arity]
-           (|> (\\parser.result (\\parser.function (++ arity) \\parser.text)
-                                (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
-               (!expect (^.multi {try.#Failure error}
-                                 (exception.match? \\parser.wrong_arity error))))))
-       (do [! random.monad]
-         [arity (at ! each (|>> (n.% 10) ++) random.nat)
-          expected_offset random.nat
-          expected_inits (random.list arity random.bit)
-          expected_body (random.unicode 1)]
-         (_.coverage [\\parser.loop]
-           (and (|> (\\parser.result (\\parser.loop (<>.many \\parser.bit) \\parser.text)
-                                     (list (synthesis.loop/scope [expected_offset
-                                                                  (list#each (|>> synthesis.bit) expected_inits)
-                                                                  (synthesis.text expected_body)])))
-                    (!expect (^.multi {try.#Success [actual_offset actual_inits actual_body]}
-                                      (and (at n.equivalence = expected_offset actual_offset)
-                                           (at (list.equivalence bit.equivalence) =
-                                               expected_inits
-                                               actual_inits)
-                                           (at text.equivalence = expected_body actual_body)))))
-                (|> (\\parser.result (\\parser.loop (<>.many \\parser.bit) \\parser.text)
-                                     (list (synthesis.text expected_body)))
-                    (!expect (^.multi {try.#Failure error}
-                                      (exception.match? \\parser.cannot_parse error)))))))
-       ))
-
-(def \\parser
-  Test
-  (<| (_.covering \\parser._)
-      (_.for [\\parser.Parser])
-      (all _.and
-           (do [! random.monad]
-             [expected (at ! each (|>> synthesis.i64) random.i64)]
-             (_.coverage [\\parser.result \\parser.any]
-               (|> (\\parser.result \\parser.any (list expected))
-                   (!expect (^.multi {try.#Success actual}
-                                     (at synthesis.equivalence = expected actual))))))
-           (_.coverage [\\parser.empty_input]
-             (|> (\\parser.result \\parser.any (list))
-                 (!expect (^.multi {try.#Failure error}
-                                   (exception.match? \\parser.empty_input error)))))
-           (do [! random.monad]
-             [expected (at ! each (|>> synthesis.i64) random.i64)]
-             (_.coverage [\\parser.unconsumed_input]
-               (|> (\\parser.result \\parser.any (list expected expected))
-                   (!expect (^.multi {try.#Failure error}
-                                     (exception.match? \\parser.unconsumed_input error))))))
-           (do [! random.monad]
-             [dummy (at ! each (|>> synthesis.i64) random.i64)]
-             (_.coverage [\\parser.end \\parser.expected_empty_input]
-               (and (|> (\\parser.result \\parser.end (list))
-                        (!expect {try.#Success _}))
-                    (|> (\\parser.result \\parser.end (list dummy))
-                        (!expect (^.multi {try.#Failure error}
-                                          (exception.match? \\parser.expected_empty_input error)))))))
-           (do [! random.monad]
-             [dummy (at ! each (|>> synthesis.i64) random.i64)]
-             (_.coverage [\\parser.end?]
-               (and (|> (\\parser.result \\parser.end? (list))
-                        (!expect {try.#Success #1}))
-                    (|> (\\parser.result (<>.before \\parser.any \\parser.end?) (list dummy))
-                        (!expect {try.#Success #0})))))
-           (_.for [\\parser.cannot_parse]
-                  (all _.and
-                       ..simple
-                       ..complex
-                       ))
-           )))
-
-(def .public test
-  Test
-  (all _.and
-       ..\\parser
-
-       /simple.test
-       /access.test
-       ))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux
deleted file mode 100644
index 67022657e..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux
+++ /dev/null
@@ -1,14 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]]]
- ["[0]" /
-  ["[1][0]" side]
-  ["[1][0]" member]])
-
-(def .public test
-  Test
-  (all _.and
-       /side.test
-       /member.test
-       ))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux
deleted file mode 100644
index f9a892715..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux
+++ /dev/null
@@ -1,41 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random)]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Member)
-  (all random.and
-       random.nat
-       random.bit
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Member])
-      (do [! random.monad]
-        [left ..random
-         right  ..random]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-             (_.for [/.hash]
-                    ($hash.spec /.hash ..random))
-             
-             (_.coverage [/.format]
-               (bit#= (at /.equivalence = left right)
-                      (text#= (/.format left) (/.format right))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux
deleted file mode 100644
index 236f373e1..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux
+++ /dev/null
@@ -1,41 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random)]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Side)
-  (all random.and
-       random.nat
-       random.bit
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Side])
-      (do [! random.monad]
-        [left ..random
-         right  ..random]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-             (_.for [/.hash]
-                    ($hash.spec /.hash ..random))
-             
-             (_.coverage [/.format]
-               (bit#= (at /.equivalence = left right)
-                      (text#= (/.format left) (/.format right))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux
deleted file mode 100644
index 67cf4f719..000000000
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux
+++ /dev/null
@@ -1,45 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Simple)
-  (all random.or
-       random.bit
-       random.i64
-       random.frac
-       (random.lower_case 1)
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Simple])
-      (do [! random.monad]
-        [left ..random
-         right ..random]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-             (_.for [/.hash]
-                    ($hash.spec /.hash ..random))
-
-             (_.coverage [/.format]
-               (bit#= (text#= (/.format left) (/.format right))
-                      (at /.equivalence = left right)))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive.lux b/stdlib/source/test/lux/tool/compiler/meta/archive.lux
deleted file mode 100644
index 2ada929d2..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive.lux
+++ /dev/null
@@ -1,254 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    ["[0]" exception]]
-   [data
-    ["[0]" product]
-    ["[0]" text (.only)
-     ["%" \\format (.only format)]]
-    [collection
-     ["[0]" list]
-     ["[0]" set (.use "[1]#[0]" equivalence)]
-     ["[0]" sequence]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["[1][0]" key]
-   ["[1][0]" registry]
-   ["[1][0]" signature]
-   ["[1][0]" module (.only)
-    ["[2][0]" document]
-    ["[2][0]" descriptor]]]]
- ["$[0]" /
-  ["[1][0]" signature]
-  ["[1][0]" key]
-  ["[1][0]" artifact]
-  ["[1][0]" registry]
-  ["[1][0]" module]
-  ["[1][0]" unit]])
-
-(def .public (descriptor module hash)
-  (-> /descriptor.Module Nat /descriptor.Descriptor)
-  [/descriptor.#name module
-   /descriptor.#file (format module ".lux")
-   /descriptor.#hash hash
-   /descriptor.#state {.#Active}
-   /descriptor.#references (set.empty text.hash)])
-
-(def test|entry
-  Test
-  (do random.monad
-    [module/0 (random.lower_case 1)
-     module/1 (random.lower_case 2)
-     signature $/signature.random
-     .let [version (the /signature.#version signature)]
-     fake_version (random.only (|>> (n.= version) not) random.nat)
-     content/0 random.nat
-     content/1 (random.only (|>> (n.= content/0) not) random.nat)
-     hash random.nat
-     .let [key (/key.key signature content/0)]]
-    (all _.and
-         (_.coverage [/.has /.find]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  .let [entry [/.#module [/module.#id @module/0
-                                          /module.#descriptor (..descriptor module/0 hash)
-                                          /module.#document (/document.document key content/0)]
-                               /.#output sequence.empty
-                               /.#registry /registry.empty]]
-                  archive (/.has module/0 entry archive)
-                  entry' (/.find module/0 archive)]
-                 (in (same? entry entry')))
-               (try.else false)))
-         (_.coverage [/.module_is_only_reserved]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  entry' (/.find module/0 archive)]
-                 (in false))
-               (exception.otherwise (exception.match? /.module_is_only_reserved))))
-         (_.coverage [/.cannot_replace_document]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  .let [entry/0 [/.#module [/module.#id @module/0
-                                            /module.#descriptor (..descriptor module/0 hash)
-                                            /module.#document (/document.document key content/0)]
-                                 /.#output sequence.empty
-                                 /.#registry /registry.empty]
-                        entry/1 [/.#module [/module.#id @module/0
-                                            /module.#descriptor (..descriptor module/0 hash)
-                                            /module.#document (/document.document key content/1)]
-                                 /.#output sequence.empty
-                                 /.#registry /registry.empty]]
-                  archive (/.has module/0 entry/0 archive)
-                  archive (/.has module/0 entry/1 archive)]
-                 (in false))
-               (exception.otherwise (exception.match? /.cannot_replace_document))))
-         (_.coverage [/.module_must_be_reserved_before_it_can_be_added]
-           (|> (do try.monad
-                 [.let [entry [/.#module [/module.#id 0
-                                          /module.#descriptor (..descriptor module/0 hash)
-                                          /module.#document (/document.document key content/0)]
-                               /.#output sequence.empty
-                               /.#registry /registry.empty]]
-                  archive (/.has module/0 entry /.empty)]
-                 (in false))
-               (exception.otherwise (exception.match? /.module_must_be_reserved_before_it_can_be_added))))
-         (_.coverage [/.archived?]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  .let [pre (/.archived? archive module/0)
-                        entry [/.#module [/module.#id @module/0
-                                          /module.#descriptor (..descriptor module/0 hash)
-                                          /module.#document (/document.document key content/0)]
-                               /.#output sequence.empty
-                               /.#registry /registry.empty]]
-                  archive (/.has module/0 entry archive)
-                  .let [post (/.archived? archive module/0)]]
-                 (in (and (not pre) post)))
-               (try.else false)))
-         (_.coverage [/.unknown_document]
-           (and (|> (do try.monad
-                      [_ (/.id module/0 /.empty)]
-                      (in false))
-                    (exception.otherwise (exception.match? /.unknown_document)))
-                (|> (do try.monad
-                      [_ (/.find module/0 /.empty)]
-                      (in false))
-                    (exception.otherwise (exception.match? /.unknown_document)))))
-         (_.coverage [/.archived]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  .let [pre (/.archived archive)
-                        entry [/.#module [/module.#id @module/0
-                                          /module.#descriptor (..descriptor module/0 hash)
-                                          /module.#document (/document.document key content/0)]
-                               /.#output sequence.empty
-                               /.#registry /registry.empty]]
-                  archive (/.has module/0 entry archive)
-                  .let [post (/.archived archive)
-                        (open "list#[0]") (list.equivalence text.equivalence)]]
-                 (in (and (list#= (list) pre)
-                          (list#= (list module/0) post))))
-               (try.else false)))
-         (_.coverage [/.entries]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  .let [pre (/.entries archive)
-                        entry [/.#module [/module.#id @module/0
-                                          /module.#descriptor (..descriptor module/0 hash)
-                                          /module.#document (/document.document key content/0)]
-                               /.#output sequence.empty
-                               /.#registry /registry.empty]]
-                  archive (/.has module/0 entry archive)]
-                 (in (and (list.empty? pre)
-                          (case (/.entries archive)
-                            (list [module/0' @module/0' entry'])
-                            (and (same? module/0 module/0')
-                                 (same? @module/0 @module/0')
-                                 (same? entry entry'))
-
-                            _
-                            false))))
-               (try.else false)))
-         (_.coverage [/.export /.import]
-           (|> (do try.monad
-                 [[@module/0 archive] (/.reserve module/0 /.empty)
-                  [@module/1 archive] (/.reserve module/1 archive)
-                  .let [entry/0 [/.#module [/module.#id @module/0
-                                            /module.#descriptor (..descriptor module/0 hash)
-                                            /module.#document (/document.document key content/0)]
-                                 /.#output sequence.empty
-                                 /.#registry /registry.empty]
-                        entry/1 [/.#module [/module.#id @module/1
-                                            /module.#descriptor (..descriptor module/1 hash)
-                                            /module.#document (/document.document key content/1)]
-                                 /.#output sequence.empty
-                                 /.#registry /registry.empty]]
-                  archive (/.has module/0 entry/0 archive)
-                  archive (/.has module/1 entry/1 archive)
-                  .let [pre (/.reserved archive)]
-                  archive (|> archive
-                              (/.export version)
-                              (/.import version))
-                  .let [post (/.reserved archive)]]
-                 (in (set#= (set.of_list text.hash pre)
-                            (set.of_list text.hash post))))
-               (try.else false)))
-         (_.coverage [/.version_mismatch]
-           (|> (do try.monad
-                 [archive (|> /.empty
-                              (/.export version)
-                              (/.import fake_version))]
-                 (in false))
-               (exception.otherwise (exception.match? /.version_mismatch))))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Archive])
-      (do random.monad
-        [module/0 (random.lower_case 1)
-         module/1 (random.lower_case 2)
-         signature $/signature.random
-         content/0 random.nat
-         content/1 (random.only (|>> (n.= content/0) not) random.nat)
-         hash random.nat
-         .let [key (/key.key signature content/0)]])
-      (all _.and
-           (_.coverage [/.empty]
-             (list.empty? (/.entries /.empty)))
-           (_.coverage [/.reserve /.id]
-             (|> (do try.monad
-                   [[@module/0 archive] (/.reserve module/0 /.empty)
-                    [@module/1 archive] (/.reserve module/1 archive)
-                    @module/0' (/.id module/0 archive)
-                    @module/1' (/.id module/1 archive)]
-                   (in (and (same? @module/0 @module/0')
-                            (same? @module/1 @module/1'))))
-                 (try.else false)))
-           (_.coverage [/.reserved]
-             (|> (do try.monad
-                   [[@module/0 archive] (/.reserve module/0 /.empty)
-                    [@module/1 archive] (/.reserve module/1 archive)]
-                   (in (set#= (set.of_list text.hash (list module/0 module/1))
-                              (set.of_list text.hash (/.reserved archive)))))
-                 (try.else false)))
-           (_.coverage [/.reservations]
-             (|> (do try.monad
-                   [[@module/0 archive] (/.reserve module/0 /.empty)
-                    [@module/1 archive] (/.reserve module/1 archive)
-                    .let [hash (product.hash text.hash n.hash)]]
-                   (in (set#= (set.of_list hash (list [module/0 @module/0] [module/1 @module/1]))
-                              (set.of_list hash (/.reservations archive)))))
-                 (try.else false)))
-           (_.coverage [/.module_has_already_been_reserved]
-             (|> (do try.monad
-                   [[@module/0 archive] (/.reserve module/0 /.empty)
-                    _ (/.reserve module/0 archive)]
-                   (in false))
-                 (exception.otherwise (exception.match? /.module_has_already_been_reserved))))
-           (_.coverage [/.reserved?]
-             (|> (do try.monad
-                   [[@module/0 archive] (/.reserve module/0 /.empty)]
-                   (in (and (/.reserved? archive module/0)
-                            (not (/.reserved? archive module/1)))))
-                 (try.else false)))
-           (_.for [/.Entry]
-                  ..test|entry)
-
-           $/signature.test
-           $/key.test
-           $/artifact.test
-           $/registry.test
-           $/module.test
-           $/unit.test
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux
deleted file mode 100644
index 4801f7569..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux
+++ /dev/null
@@ -1,32 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [\\specification
-     ["$[0]" equivalence]]]
-   [math
-    ["[0]" random (.only Random)]]]]
- ["[0]" /
-  ["[1][0]" category]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Artifact)
-  (all random.and
-       random.nat
-       /category.random
-       random.bit
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Artifact /.ID])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence ..random))
-
-           /category.test
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux
deleted file mode 100644
index 5eb23ba3e..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux
+++ /dev/null
@@ -1,44 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [\\specification
-     ["$[0]" equivalence]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]]
- [\\library
-  ["[0]" /]])
-
-(def random_definition
-  (Random /.Definition)
-  (all random.and
-       (random.lower_case 1)
-       (random.maybe
-        (all random.and
-             random.nat
-             random.nat
-             random.nat
-             ))
-       ))
-
-(def .public random
-  (Random /.Category)
-  (all random.or
-       (random#in [])
-       ..random_definition
-       (random.lower_case 2)
-       (random.lower_case 3)
-       (random.lower_case 4)
-       (random.lower_case 5)
-       (random.lower_case 6)
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Category])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence ..random))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux
deleted file mode 100644
index fe3230d7c..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux
+++ /dev/null
@@ -1,27 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [math
-    ["[0]" random]]]]
- [\\library
-  ["[0]" /]]
- ["[0]" //
-  ["[1][0]" signature]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Key])
-      (do random.monad
-        [expected //signature.random
-         document random.nat]
-        (all _.and
-             (_.coverage [/.key /.signature]
-               (|> document
-                   (/.key expected)
-                   /.signature
-                   (same? expected)))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux
deleted file mode 100644
index 33aed16e6..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux
+++ /dev/null
@@ -1,43 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" / (.only)
-   ["[0]" document]
-   [//
-    ["[0]" key]
-    ["[0]" signature
-     ["$[1]" \\test]]]]]
- ["[0]" /
-  ["[1][0]" document]
-  ["[1][0]" descriptor]])
-
-(def .public (random it)
-  (All (_ a) (-> (Random a) (Random (/.Module a))))
-  (all random.and
-       random.nat
-       (/descriptor.random 0)
-       (do random.monad
-         [signature $signature.random
-          example it]
-         (in (document.document (key.key signature example)
-                                example)))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Module])
-      (all _.and
-           (_.coverage [/.ID /.runtime]
-             (n.= 0 /.runtime))
-
-           /document.test
-           /descriptor.test
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux
deleted file mode 100644
index fd3103d21..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux
+++ /dev/null
@@ -1,58 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" text (.use "[1]#[0]" equivalence)]
-    ["[0]" binary
-     ["[1]" \\format]
-     ["<[1]>" \\parser]]]
-   [math
-    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]]
- [\\library
-  ["[0]" /]])
-
-(def random_module_state
-  (Random Module_State)
-  (all random.or
-       (random#in [])
-       (random#in [])
-       (random#in [])
-       ))
-
-(def .public (random imports)
-  (-> Nat (Random /.Descriptor))
-  (all random.and
-       (random.lower_case 1)
-       (random.lower_case 1)
-       random.nat
-       ..random_module_state
-       (random.set text.hash imports (random.lower_case 2))
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Descriptor])
-      (do random.monad
-        [expected (..random 5)])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence (..random 1)))
-
-           (_.for [/.Module]
-                  (_.coverage [/.runtime]
-                    (text#= "" /.runtime)))
-           (_.coverage [/.format /.parser]
-             (|> expected
-                 (binary.result /.format)
-                 (.result /.parser)
-                 (try#each (|>> (at /.equivalence = (has /.#state {.#Cached} expected))))
-                 (try.else false)))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux
deleted file mode 100644
index b1ab4c5ec..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux
+++ /dev/null
@@ -1,97 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]]
-   [data
-    ["[0]" binary
-     ["[1]F" \\format]
-     ["<[1]>" \\parser]]]
-   [math
-    ["[0]" random]
-    [number
-     ["[0]" nat]]]]]
- [\\library
-  ["[0]" / (.only)
-   [///
-    ["[1][0]" signature (.use "[1]#[0]" equivalence)]
-    ["[1][0]" key]]]]
- ["[0]" ///
-  ["[1][0]" signature]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Document])
-      (do random.monad
-        [signature/0 ///signature.random
-         signature/1 (random.only (|>> (/signature#= signature/0) not)
-                                  ///signature.random)
-         .let [key/0 (/key.key signature/0 0)
-               key/1 (/key.key signature/1 0)]
-         expected random.nat]
-        (all _.and
-             (_.coverage [/.document /.content]
-               (|> expected
-                   (/.document key/0)
-                   (/.content key/0)
-                   (try#each (same? expected))
-                   (try.else false)))
-             (_.coverage [/.signature]
-               (|> expected
-                   (/.document key/0)
-                   /.signature
-                   (same? signature/0)))
-             (_.coverage [/.marked?]
-               (and (|> expected
-                        (/.document key/0)
-                        (/.marked? key/0)
-                        (pipe.case
-                          {try.#Success it} true
-                          {try.#Failure error} false))
-                    (|> expected
-                        (/.document key/0)
-                        (/.marked? key/1)
-                        (pipe.case
-                          {try.#Success it} false
-                          {try.#Failure error} true))))
-             (_.coverage [/.invalid_signature]
-               (and (|> expected
-                        (/.document key/0)
-                        (/.content key/1)
-                        (pipe.case
-                          {try.#Success it}
-                          false
-                          
-                          {try.#Failure error}
-                          (exception.match? /.invalid_signature error)))
-                    (|> expected
-                        (/.document key/0)
-                        (/.marked? key/1)
-                        (pipe.case
-                          {try.#Success it}
-                          false
-                          
-                          {try.#Failure error}
-                          (exception.match? /.invalid_signature error)))))
-             (_.coverage [/.format /.parser]
-               (|> expected
-                   (/.document key/0)
-                   (binaryF.result (/.format binaryF.nat))
-                   (.result (/.parser key/0 .nat))
-                   (pipe.case
-                     {try.#Success it}
-                     (and (/signature#= signature/0 (/.signature it))
-                          (|> it
-                              (/.content key/0)
-                              (try#each (nat.= expected))
-                              (try.else false)))
-                     
-                     {try.#Failure error}
-                     false)))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux
deleted file mode 100644
index ef21f8b7d..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux
+++ /dev/null
@@ -1,180 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" product]
-    ["[0]" text]
-    ["[0]" binary
-     ["[1]" \\format]
-     ["<[1]>" \\parser]]
-    [collection
-     ["[0]" sequence (.only Sequence)]
-     ["[0]" set (.only Set)]
-     ["[0]" list (.use "[1]#[0]" mix functor)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" / (.only)
-   [//
-    ["[0]" unit]
-    ["[0]" artifact (.only)
-     ["[0]" category]]]]])
-
-(def tagged?
-  (template (_  )
-    [(case 
-       { _}
-       true
-       
-       _
-       false)]))
-
-(def random_dependency
-  (Random unit.ID)
-  (all random.and
-       random.nat
-       random.nat
-       ))
-
-(def (random_dependencies amount)
-  (-> Nat (Random (Set unit.ID)))
-  (random.set unit.hash amount ..random_dependency))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Registry])
-      (do [! random.monad]
-        [expected_name (random.lower_case 5)
-         mandatory? random.bit
-         expected_dependencies (..random_dependencies 5)
-         
-         expected_amount (at ! each (n.% 10) random.nat)
-         expected_names (|> (random.lower_case 1)
-                            (random.set text.hash expected_amount)
-                            (at ! each set.list))]
-        (`` (all _.and
-                 (_.coverage [/.empty]
-                   (|> /.empty
-                       /.artifacts
-                       sequence.size
-                       (n.= 0)))
-                 (_.coverage [/.resource]
-                   (let [[@it registry] (/.resource mandatory? expected_dependencies /.empty)]
-                     (case (sequence.list (/.artifacts registry))
-                       (list [artifact actual_dependencies])
-                       (and (same? @it (the artifact.#id artifact))
-                            (same? mandatory? (the artifact.#mandatory? artifact))
-                            (tagged? category.#Anonymous (the artifact.#category artifact))
-                            (same? expected_dependencies actual_dependencies))
-
-                       _
-                       false)))
-                 (,, (with_template [ '    ']
-                       [(_.coverage [ ]
-                          (let [ '
-                                 ']
-                            (and (let [[@it registry] (  mandatory? expected_dependencies /.empty)]
-                                   (and (case ( registry)
-                                          (list actual_name)
-                                          (same?  actual_name)
-
-                                          _
-                                          false)
-                                        (case (sequence.list (/.artifacts registry))
-                                          (list [artifact actual_dependencies])
-                                          (and (same? @it (the artifact.#id artifact))
-                                               (same? mandatory? (the artifact.#mandatory? artifact))
-                                               (case (the artifact.#category artifact)
-                                                 { actual_name}
-                                                 (same?  actual_name)
-
-                                                 _
-                                                 false)
-                                               (same? expected_dependencies actual_dependencies))
-
-                                          _
-                                          false)))
-                                 (let [[@it registry] (  mandatory? expected_dependencies /.empty)]
-                                   (case ( registry)
-                                     (list)
-                                     true
-
-                                     _
-                                     false)))))]
-
-                       [/.definition (is category.Definition [expected_name {.#None}]) /.definitions category.#Definition /.analyser expected_name]
-                       [/.analyser expected_name /.analysers category.#Analyser /.synthesizer expected_name]
-                       [/.synthesizer expected_name /.synthesizers category.#Synthesizer /.generator expected_name]
-                       [/.generator expected_name /.generators category.#Generator /.declaration expected_name]
-                       [/.declaration expected_name /.declarations category.#Declaration /.custom expected_name]
-                       [/.custom expected_name /.customs category.#Custom /.definition (is category.Definition [expected_name {.#None}])]
-                       ))
-                 (_.coverage [/.id]
-                   (and (,, (with_template [ ' ]
-                              [(let [ '
-                                     [@expected registry] (  mandatory? expected_dependencies /.empty)]
-                                 (|> (/.id ( ) registry)
-                                     (maybe#each (same? @expected))
-                                     (maybe.else false)))]
-
-                              [/.definition (is category.Definition [expected_name {.#None}]) product.left]
-                              [/.analyser expected_name |>]
-                              [/.synthesizer expected_name |>]
-                              [/.generator expected_name |>]
-                              [/.declaration expected_name |>]
-                              [/.custom expected_name |>]
-                              ))))
-                 (_.coverage [/.artifacts]
-                   (and (,, (with_template [   <$>]
-                              [(let [expected/* (list#each <$> expected_names)
-                                     [ids registry] (is [(Sequence artifact.ID) /.Registry]
-                                                        (list#mix (function (_ expected [ids registry])
-                                                                    (let [[@new registry] ( expected mandatory? expected_dependencies registry)]
-                                                                      [(sequence.suffix @new ids) registry]))
-                                                                  [sequence.empty /.empty]
-                                                                  expected/*))
-                                     it (/.artifacts registry)]
-                                 (and (n.= expected_amount (sequence.size it))
-                                      (list.every? (function (_ [@it [it dependencies]])
-                                                     (same? @it (the artifact.#id it)))
-                                                   (list.zipped_2 (sequence.list ids) (sequence.list it)))
-                                      (at (list.equivalence ) = expected/* ( registry))))]
-
-                              [/.definition /.definitions category.definition_equivalence (is (-> Text category.Definition)
-                                                                                              (function (_ it)
-                                                                                                [it {.#None}]))]
-                              [/.analyser /.analysers text.equivalence (|>>)]
-                              [/.synthesizer /.synthesizers text.equivalence (|>>)]
-                              [/.generator /.generators text.equivalence (|>>)]
-                              [/.declaration /.declarations text.equivalence (|>>)]
-                              [/.custom /.customs text.equivalence (|>>)]
-                              ))))
-                 (_.coverage [/.format /.parser]
-                   (and (,, (with_template [ ' ]
-                              [(let [ '
-                                     [@expected before] (  mandatory? expected_dependencies /.empty)]
-                                 (|> before
-                                     (binary.result /.format)
-                                     (.result /.parser)
-                                     (try#each (|>> (/.id ( ))
-                                                    (maybe#each (same? @expected))
-                                                    (maybe.else false)))
-                                     (try.else false)))]
-
-                              [/.definition (is category.Definition [expected_name {.#None}]) product.left]
-                              [/.analyser expected_name |>]
-                              [/.synthesizer expected_name |>]
-                              [/.generator expected_name |>]
-                              [/.declaration expected_name |>]
-                              [/.custom expected_name |>]
-                              ))))
-                 )))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux
deleted file mode 100644
index 2d75deca0..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux
+++ /dev/null
@@ -1,55 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)]
-    ["[0]" binary
-     ["[1]F" \\format]
-     ["<[1]>" \\parser]]]
-   [math
-    ["[0]" random (.only Random)]]]]
- [\\library
-  ["[0]" /]]
- ["[0]" ////
-  ["[1][0]" version]])
-
-(def .public random
-  (Random /.Signature)
-  (all random.and
-       (all random.and
-            (random.upper_case 1)
-            (random.lower_case 1))
-       ////version.random
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Signature])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence ..random))
-           
-           (do random.monad
-             [left ..random
-              right ..random]
-             (_.coverage [/.description]
-               (bit#= (at /.equivalence = left right)
-                      (text#= (/.description left) (/.description right)))))
-           (do random.monad
-             [expected ..random]
-             (_.coverage [/.format /.parser]
-               (|> expected
-                   (binaryF.result /.format)
-                   (.result /.parser)
-                   (try#each (at /.equivalence = expected))
-                   (try.else false))))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux
deleted file mode 100644
index 3bdef20a8..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux
+++ /dev/null
@@ -1,36 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    [collection
-     ["[0]" set]]]
-   [math
-    ["[0]" random (.only Random)]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.ID)
-  (all random.and
-       random.nat
-       random.nat
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.ID])
-      (all _.and
-           (_.for [/.equivalence]
-                  ($equivalence.spec /.equivalence ..random))
-           (_.for [/.hash]
-                  ($hash.spec /.hash ..random))
-           
-           (_.coverage [/.none]
-             (set.empty? /.none))
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache.lux b/stdlib/source/test/lux/tool/compiler/meta/cache.lux
deleted file mode 100644
index 68ba4e7fb..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cache.lux
+++ /dev/null
@@ -1,54 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    [concurrency
-     ["[0]" async]]]
-   [math
-    ["[0]" random]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" /]]
- ["[0]" /
-  ["[1][0]" archive]
-  ["[1][0]" module]
-  ["[1][0]" artifact]
-  ["[1][0]" purge]
-  ["$/[1]" //
-   ["[1][0]" context]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [.let [/ "/"
-               fs (file.mock /)]
-         context $//context.random]
-        (all _.and
-             (in (do [! async.monad]
-                   [pre/0 (at fs directory? (/.path fs context))
-                    pre/1 (/.enabled? fs context)
-                    outcome (/.enable! ! fs context)
-                    post/0 (at fs directory? (/.path fs context))
-                    post/1 (/.enabled? fs context)]
-                   (_.coverage' [/.path /.enabled? /.enable!]
-                     (and (not pre/0)
-                          (not pre/1)
-                          
-                          (case outcome
-                            {try.#Success _} true
-                            {try.#Failure _} false)
-                          
-                          post/0
-                          post/1))))
-
-             /archive.test
-             /module.test
-             /artifact.test
-             /purge.test
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux
deleted file mode 100644
index 09821245e..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux
+++ /dev/null
@@ -1,84 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try (.use "[1]#[0]" functor)]
-    [concurrency
-     ["[0]" async]]]
-   [data
-    ["[0]" binary (.use "[1]#[0]" equivalence)]
-    [collection
-     ["[0]" sequence]]]
-   [math
-    ["[0]" random]
-    [number
-     ["n" nat]]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" // (.only)
-    ["/[1]" // (.only)
-     ["[0]" archive (.only)
-      ["[0]" signature]
-      ["[0]" key]
-      ["[0]" registry]
-      ["[0]" module (.only)
-       ["[0]" document]]]]]]]
- ["$" //
-  [//
-   ["[1][0]" context]
-   ["[1][0]" archive (.only)
-    ["[2][0]" signature]]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [.let [/ "/"
-               fs (file.mock /)]
-         context $context.random
-         module/0 (random.lower_case 1)
-         module/1 (random.lower_case 2)
-         content/0 random.nat
-         content/1 (random.only (|>> (n.= content/0) not) random.nat)
-         hash random.nat
-         signature $signature.random
-         .let [key (key.key signature content/0)
-               [archive expected] (|> (do try.monad
-                                        [[@module/0 archive] (archive.reserve module/0 archive.empty)
-                                         [@module/1 archive] (archive.reserve module/1 archive)
-                                         .let [entry/0 [archive.#module [module.#id @module/0
-                                                                         module.#descriptor ($archive.descriptor module/0 hash)
-                                                                         module.#document (document.document key content/0)]
-                                                        archive.#output sequence.empty
-                                                        archive.#registry registry.empty]
-                                               entry/1 [archive.#module [module.#id @module/1
-                                                                         module.#descriptor ($archive.descriptor module/1 hash)
-                                                                         module.#document (document.document key content/1)]
-                                                        archive.#output sequence.empty
-                                                        archive.#registry registry.empty]]
-                                         archive (archive.has module/0 entry/0 archive)
-                                         archive (archive.has module/1 entry/1 archive)]
-                                        (in [archive (archive.export ///.version archive)]))
-                                      try.trusted)]]
-        (all _.and
-             (in (do [! async.monad]
-                   [pre/0 (at fs file? (/.descriptor fs context))
-                    enabled? (//.enable! ! fs context)
-                    cached? (/.cache! fs context archive)
-                    actual (at fs read (/.descriptor fs context))
-                    post/0 (at fs file? (/.descriptor fs context))]
-                   (_.coverage' [/.descriptor /.cache!]
-                     (and (not pre/0)
-                          (|> (do try.monad
-                                [_ enabled?
-                                 _ cached?]
-                                actual)
-                              (try#each (binary#= expected))
-                              (try.else false))
-                          post/0))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux
deleted file mode 100644
index 7d3fa626d..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux
+++ /dev/null
@@ -1,53 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    [concurrency
-     ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]]
-   [data
-    ["[0]" binary (.use "[1]#[0]" equivalence)
-     ["$[1]" \\test]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" //
-    ["[1][0]" module]]]]
- ["$[0]" ///
-  ["[1][0]" context]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [.let [/ "/"
-               fs (file.mock /)]
-         context $///context.random
-         @module random.nat
-         @artifact random.nat
-         expected ($binary.random 1)]
-        (all _.and
-             (in (do [! async.monad]
-                   [pre (at fs file? (/.path fs context @module @artifact))
-                    _ (//module.enable! ! fs context @module)
-                    write! (/.cache! fs context @module @artifact expected)
-                    post (at fs file? (/.path fs context @module @artifact))
-                    read! (/.cache fs context @module @artifact)]
-                   (_.coverage' [/.path /.cache! /.cache]
-                     (and (not pre)
-                          (case write!
-                            {try.#Success _} true
-                            {try.#Failure _} false)
-                          post
-                          (case read!
-                            {try.#Success actual} (binary#= expected actual)
-                            {try.#Failure _} false)))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
deleted file mode 100644
index bce9082e5..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
+++ /dev/null
@@ -1,94 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    ["[0]" exception]
-    [concurrency
-     ["[0]" async (.only Async) (.use "[1]#[0]" monad)]]]
-   [math
-    ["[0]" random]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" /]]
- ["$[0]" ///
-  ["[1][0]" context]])
-
-(`` (def (bad it)
-      (-> (file.System Async) (file.System Async))
-      (implementation
-       (,, (with_template []
-             [(def 
-                (at it ))]
-
-             [separator]
-             [file?]
-             [directory?]
-             [modify]
-             [write]
-             [append]
-             [move]
-             [directory_files]
-             [sub_directories]
-             [file_size]
-             [last_modified]
-             [can_execute?]
-             [read]
-             [delete]
-             ))
-
-       (def (make_directory path)
-         (async#in {try.#Failure ""}))
-       )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [context $///context.random
-         @module random.nat]
-        (all _.and
-             (in (do [! async.monad]
-                   [.let [/ "/"
-                          fs (file.mock /)]
-                    pre/0 (at fs directory? (/.path fs context @module))
-                    pre/1 (/.enabled? fs context @module)
-                    outcome (/.enable! ! fs context @module)
-                    post/0 (at fs directory? (/.path fs context @module))
-                    post/1 (/.enabled? fs context @module)]
-                   (_.coverage' [/.path /.enabled? /.enable!]
-                     (and (not pre/0)
-                          (not pre/1)
-                          
-                          (case outcome
-                            {try.#Success _} true
-                            {try.#Failure _} false)
-                          
-                          post/0
-                          post/1))))
-             (in (do [! async.monad]
-                   [.let [/ "/"
-                          fs (file.mock /)]
-                    pre/0 (at fs directory? (/.path fs context @module))
-                    pre/1 (/.enabled? fs context @module)
-                    outcome (/.enable! ! (..bad fs) context @module)
-                    post/0 (at fs directory? (/.path fs context @module))
-                    post/1 (/.enabled? fs context @module)]
-                   (_.coverage' [/.cannot_enable]
-                     (and (not pre/0)
-                          (not pre/1)
-                          
-                          (case outcome
-                            {try.#Success _}
-                            false
-                            
-                            {try.#Failure error}
-                            (exception.match? /.cannot_enable error))
-                          
-                          (not post/0)
-                          (not post/1)))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux
deleted file mode 100644
index 02d6402fb..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux
+++ /dev/null
@@ -1,141 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" try]
-    ["[0]" exception]
-    [concurrency
-     ["[0]" async]]]
-   [data
-    ["[0]" text (.only)
-     ["%" \\format]]
-    ["[0]" binary
-     ["$[1]" \\test]]
-    [collection
-     ["[0]" dictionary]
-     ["[0]" sequence]
-     ["[0]" set]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" / (.only)
-   ["/[1]" //
-    ["[1][0]" module]
-    ["[0]" dependency
-     ["[1]" module]]
-    ["/[1]" //
-     ["[0]" context (.only)
-      ["$[1]" \\test]]
-     ["[0]" archive (.only)
-      ["[0]" registry]
-      ["[0]" module (.only)
-       ["$[1]" \\test]
-       ["[0]" descriptor (.only)
-        ["$[1]" \\test]]]]
-     ["/[1]" //]]]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [descriptor ($descriptor.random 0)
-         source_code (random.upper_case 1)
-         name/0 (random.lower_case 1)
-         module/0 ($module.random random.nat)
-         content/0 ($binary.random 1)
-         name/1 (random.lower_case 2)
-         module/1 (|> ($module.random random.nat)
-                      (at ! each (has [module.#descriptor descriptor.#references]
-                                      (set.of_list text.hash (list name/0)))))
-         content/1 ($binary.random 2)
-         .let [id/0 (the module.#id module/0)
-               id/1 (the module.#id module/1)
-               input [////.#module (the descriptor.#name descriptor)
-                      ////.#file (the descriptor.#file descriptor)
-                      ////.#hash (the descriptor.#hash descriptor)
-                      ////.#code source_code]
-               / "/"
-               fs (file.mock /)]
-         context $context.random]
-        (all _.and
-             (_.for [/.Cache]
-                    (all _.and
-                         (_.coverage [/.valid?]
-                           (and (/.valid? descriptor input)
-                                (not (/.valid? descriptor (has ////.#module source_code input)))
-                                (not (/.valid? descriptor (has ////.#file source_code input)))
-                                (not (/.valid? descriptor (revised ////.#hash ++ input)))))
-                         ))
-             (_.for [/.Purge]
-                    (all _.and
-                         (_.coverage [/.purge]
-                           (and (dictionary.empty? (/.purge (list) (list)))
-                                (let [order (is (dependency.Order Nat)
-                                                (list [name/0 id/0
-                                                       [archive.#module module/0
-                                                        archive.#output (sequence.sequence)
-                                                        archive.#registry registry.empty]]))]
-                                  (and (let [cache (is (List /.Cache)
-                                                       (list [#1 name/0 id/0 module/0 registry.empty]))]
-                                         (dictionary.empty? (/.purge cache order)))
-                                       (let [cache (is (List /.Cache)
-                                                       (list [#0 name/0 id/0 module/0 registry.empty]))]
-                                         (dictionary.key? (/.purge cache order) name/0))))
-                                (let [order (is (dependency.Order Nat)
-                                                (list [name/0 id/0
-                                                       [archive.#module module/0
-                                                        archive.#output (sequence.sequence)
-                                                        archive.#registry registry.empty]]
-                                                      [name/1 id/1
-                                                       [archive.#module module/1
-                                                        archive.#output (sequence.sequence)
-                                                        archive.#registry registry.empty]]))]
-                                  (and (let [cache (is (List /.Cache)
-                                                       (list [#1 name/0 id/0 module/0 registry.empty]
-                                                             [#1 name/1 id/1 module/1 registry.empty]))
-                                             purge (/.purge cache order)]
-                                         (dictionary.empty? purge))
-                                       (let [cache (is (List /.Cache)
-                                                       (list [#1 name/0 id/0 module/0 registry.empty]
-                                                             [#0 name/1 id/1 module/1 registry.empty]))
-                                             purge (/.purge cache order)]
-                                         (and (not (dictionary.key? (/.purge cache order) name/0))
-                                              (dictionary.key? (/.purge cache order) name/1)))
-                                       (let [cache (is (List /.Cache)
-                                                       (list [#0 name/0 id/0 module/0 registry.empty]
-                                                             [#1 name/1 id/1 module/1 registry.empty]))
-                                             purge (/.purge cache order)]
-                                         (and (dictionary.key? (/.purge cache order) name/0)
-                                              (dictionary.key? (/.purge cache order) name/1)))))))
-                         (in (do [! async.monad]
-                               [_ (//module.enable! ! fs context id/0)
-                                .let [dir (//module.path fs context id/0)
-                                      file/0 (%.format dir / name/0)
-                                      file/1 (%.format dir / name/1)]
-                                _ (at fs write file/0 content/0)
-                                _ (at fs write file/1 content/1)
-                                pre (at fs directory_files dir)
-                                _ (/.purge! fs context id/0)
-                                post (at fs directory_files dir)]
-                               (_.coverage' [/.purge!]
-                                 (<| (try.else false)
-                                     (do try.monad
-                                       [pre pre]
-                                       (in (and (at set.equivalence =
-                                                    (set.of_list text.hash pre)
-                                                    (set.of_list text.hash (list file/0 file/1)))
-                                                (case post
-                                                  {try.#Failure error}
-                                                  (exception.match? file.cannot_find_directory error)
-
-                                                  success
-                                                  false))))))))
-                         ))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux
deleted file mode 100644
index 28bc83c3b..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cli.lux
+++ /dev/null
@@ -1,143 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["<>" parser]
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" product]
-    ["[0]" text]
-    [collection
-     ["[0]" list (.use "[1]#[0]" monoid monad)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" configuration (.use "[1]#[0]" equivalence)
-     ["$[1]" \\test]]]
-   ["[0]" program
-    ["<[1]>" \\parser]]]]
- [\\library
-  ["[0]" / (.only)
-   ["[1][0]" compiler (.only Compiler)]]]
- ["$[0]" /
-  ["[1][0]" compiler]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Service /.service])
-      (let [(open "list#[0]") (list.equivalence text.equivalence)])
-      (do [! random.monad]
-        [amount (at ! each (|>> (n.% 5) ++) random.nat)
-         sources (random.list amount (random.lower_case 1))
-         host_dependencies (random.list amount (random.lower_case 2))
-         libraries (random.list amount (random.lower_case 3))
-         target (random.lower_case 4)
-         module (random.lower_case 5)
-         compilers (random.list amount $/compiler.random)
-         configuration ($configuration.random 5)
-         .let [compilation' (all list#composite
-                                 (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies))
-                                 (list#conjoint (list#each (|>> (list "--library")) libraries))
-                                 (list#conjoint (list#each (|>> /compiler.format (list "--compiler")) compilers))
-                                 (list#conjoint (list#each (|>> (list "--source")) sources))
-                                 (list "--target" target
-                                       "--module" module
-                                       "--configuration" (configuration.format configuration)))
-               export (all list#composite
-                           (list#conjoint (list#each (|>> (list "--source")) sources))
-                           (list "--target" target))]]
-        (all _.and
-             (_.for [/.Compilation]
-                    (`` (all _.and
-                             (,, (with_template [  ]
-                                   [(_.coverage []
-                                      (|> (list.partial "build" compilation')
-                                          (.result /.service)
-                                          (try#each (|>> (pipe.case
-                                                           {/.#Compilation it}
-                                                           (|> it
-                                                               (the )
-                                                               )
-                                                           
-                                                           _
-                                                           false)))
-                                          (try.else false)))]
-
-                                   [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)]
-                                   [/.Library /.#libraries (list#= libraries)]
-                                   [/compiler.Compiler /.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
-                                   [/.Source /.#sources (list#= sources)]
-                                   [/.Target /.#target (same? target)]
-                                   [/.Module /.#module (same? module)]
-                                   [configuration.Configuration /.#configuration (configuration#= configuration)]
-                                   ))
-                             )))
-             (_.coverage [/.Interpretation]
-               (`` (and (,, (with_template [ ]
-                              [(|> (list.partial "repl" compilation')
-                                   (.result /.service)
-                                   (try#each (|>> (pipe.case
-                                                    {/.#Interpretation it}
-                                                    (|> it
-                                                        (the )
-                                                        )
-                                                    
-                                                    _
-                                                    false)))
-                                   (try.else false))]
-
-                              [/.#host_dependencies (list#= host_dependencies)]
-                              [/.#libraries (list#= libraries)]
-                              [/.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
-                              [/.#sources (list#= sources)]
-                              [/.#target (same? target)]
-                              [/.#module (same? module)]
-                              [/.#configuration (configuration#= configuration)]
-                              )))))
-             (_.coverage [/.Export]
-               (`` (and (,, (with_template [ ]
-                              [(|> (list.partial "export" export)
-                                   (.result /.service)
-                                   (try#each (|>> (pipe.case
-                                                    {/.#Export it}
-                                                    (|> it
-                                                        
-                                                        )
-                                                    
-                                                    _
-                                                    false)))
-                                   (try.else false))]
-
-                              [product.left (list#= sources)]
-                              [product.right (same? target)]
-                              )))))
-             (_.coverage [/.target]
-               (`` (and (,, (with_template []
-                              [(same? target (/.target ))]
-
-                              [{/.#Compilation [/.#host_dependencies host_dependencies
-                                                /.#libraries libraries
-                                                /.#compilers compilers
-                                                /.#sources sources
-                                                /.#target target
-                                                /.#module module
-                                                /.#configuration configuration]}]
-                              [{/.#Interpretation [/.#host_dependencies host_dependencies
-                                                   /.#libraries libraries
-                                                   /.#compilers compilers
-                                                   /.#sources sources
-                                                   /.#target target
-                                                   /.#module module
-                                                   /.#configuration configuration]}]
-                              [{/.#Export [sources target]}]
-                              )))))
-
-             $/compiler.test
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux
deleted file mode 100644
index 66a7997d5..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux
+++ /dev/null
@@ -1,49 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]]]
-   [control
-    ["[0]" try (.use "[1]#[0]" functor)]]
-   [data
-    ["[0]" text
-     ["<[1]>" \\parser]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" symbol
-     ["$[1]" \\test]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Compiler)
-  (do [! random.monad]
-    [definition ($symbol.random 1 1)
-     amount (at ! each (n.% 5) random.nat)
-     parameters (random.list amount (random.lower_case 2))]
-    (in [/.#definition definition
-         /.#parameters parameters])))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Compiler])
-      (do [! random.monad]
-        [expected ..random]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-
-             (_.coverage [/.format /.parser]
-               (|> expected
-                   /.format
-                   (.result /.parser)
-                   (try#each (at /.equivalence = expected))
-                   (try.else false)))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/context.lux b/stdlib/source/test/lux/tool/compiler/meta/context.lux
deleted file mode 100644
index d6ecdceec..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/context.lux
+++ /dev/null
@@ -1,56 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [data
-    ["[0]" text]
-    [collection
-     ["[0]" set]
-     ["[0]" list (.use "[1]#[0]" functor)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Context)
-  (do [! random.monad]
-    [context (all random.either
-                  (in /.js)
-                  (in /.jvm)
-                  (in /.lua)
-                  (in /.python)
-                  (in /.ruby))]
-    (at ! each context (random.lower_case 1))))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Context /.Extension])
-      (do [! random.monad]
-        [target (random.lower_case 1)]
-        (all _.and
-             (_.coverage [/.js /.jvm /.lua /.python /.ruby]
-               (let [contexts (list (/.js target)
-                                    (/.jvm target)
-                                    (/.lua target)
-                                    (/.python target)
-                                    (/.ruby target))
-                     maximum (list.size contexts)]
-                 (`` (and (,, (with_template [ ]
-                                [(|> contexts
-                                     (list#each (the ))
-                                     (set.of_list text.hash)
-                                     set.size
-                                     (n.= ))]
-
-                                [maximum /.#host]
-                                [maximum /.#host_module_extension]
-                                [maximum /.#artifact_extension]
-                                [1 /.#target]
-                                ))))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/export.lux b/stdlib/source/test/lux/tool/compiler/meta/export.lux
deleted file mode 100644
index d9fb14ace..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/export.lux
+++ /dev/null
@@ -1,120 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    [concurrency
-     ["[0]" async]]]
-   [data
-    ["[0]" product]
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    [format
-     ["[0]" tar]]
-    ["[0]" binary (.only Binary) (.use "[1]#[0]" equivalence)
-     ["<[1]>" \\parser]]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]
-     [encoding
-      ["[0]" utf8]]]
-    [collection
-     ["[0]" sequence]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" / (.only)
-   [//
-    ["[0]" io
-     ["[1]" context]]]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (do [! random.monad]
-        [.let [/ .module_separator]
-         source/0 (random.lower_case 1)
-         source/1 (random.lower_case 2)
-         target (random.lower_case 3)
-
-         .let [random_file (is (Random file.Path)
-                               (at ! each (text.suffix io.lux_extension) (random.lower_case 4)))]
-         file/0' random_file
-         .let [file/0 (format source/0 / file/0')]
-         
-         dir/0 (random.lower_case 5)
-         file/1' (at ! each (|>> (format dir/0 /)) random_file)
-         .let [file/1 (format source/1 / file/1')]
-         
-         .let [random_content (is (Random Binary)
-                                  (at ! each (|>> %.nat (at utf8.codec encoded)) random.nat))]
-         content/0 random_content
-         content/1 random_content]
-        (all _.and
-             (in (do [! async.monad]
-                   [it (do (try.with !)
-                         [.let [fs (file.mock /)]
-                          _ (at fs make_directory source/0)
-                          _ (at fs write file/0 content/0)
-                          
-                          _ (at fs make_directory source/1)
-                          _ (at fs make_directory (format source/1 / dir/0))
-                          _ (at fs write file/1 content/1)
-
-                          _ (at fs make_directory target)
-                          library_tar (/.library fs (list source/0 source/1))
-                          _ (/.export fs [(list source/0 source/1) target])
-                          export_tar (at fs read (format target / /.file))
-                          export_tar (at ! in (.result tar.parser export_tar))]
-                         (in [library_tar export_tar]))]
-                   (all _.and'
-                        (_.coverage' [/.library /.mode /.ownership]
-                          (|> it
-                              (try#each (|>> product.left
-                                             sequence.list
-                                             (pipe.case
-                                               (list {tar.#Normal [actual_path/0 when/0 mode/0 ownership/0 actual_content/0]}
-                                                     {tar.#Normal [actual_path/1 when/1 mode/1 ownership/1 actual_content/1]})
-                                               (with_expansions [ (and (and (text#= file/0' (tar.from_path actual_path/0))
-                                                                                  (same? /.mode mode/0)
-                                                                                  (same? /.ownership ownership/0)
-                                                                                  (binary#= content/0 (tar.data actual_content/0)))
-                                                                             (and (text#= file/1' (tar.from_path actual_path/1))
-                                                                                  (same? /.mode mode/1)
-                                                                                  (same? /.ownership ownership/1)
-                                                                                  (binary#= content/1 (tar.data actual_content/1))))]
-                                                 (or 
-                                                     (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
-                                                           [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
-                                                       )))
-                                               
-                                               _
-                                               false)))
-                              (try.else false)))
-                        (_.coverage' [/.export /.file]
-                          (|> it
-                              (try#each (|>> product.right
-                                             sequence.list
-                                             (pipe.case
-                                               (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
-                                                     {tar.#Normal [actual_path/1 _ _ _ actual_content/1]})
-                                               (with_expansions [ (and (and (text#= file/0' (tar.from_path actual_path/0))
-                                                                                  (binary#= content/0 (tar.data actual_content/0)))
-                                                                             (and (text#= file/1' (tar.from_path actual_path/1))
-                                                                                  (binary#= content/1 (tar.data actual_content/1))))]
-                                                 (or 
-                                                     (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
-                                                           [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
-                                                       )))
-                                               
-                                               _
-                                               false)))
-                              (try.else false)))
-                        )))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/import.lux b/stdlib/source/test/lux/tool/compiler/meta/import.lux
deleted file mode 100644
index fc2e79616..000000000
--- a/stdlib/source/test/lux/tool/compiler/meta/import.lux
+++ /dev/null
@@ -1,156 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [control
-    ["[0]" maybe (.use "[1]#[0]" functor)]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception]
-    [concurrency
-     ["[0]" async]]]
-   [data
-    ["[0]" product]
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" binary (.only Binary) (.use "[1]#[0]" equivalence)
-     ["[0]" \\format]
-     ["<[1]>" \\parser]]
-    ["[0]" format
-     ["[0]" tar (.only Tar)]]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]
-     [encoding
-      ["[0]" utf8]]]
-    [collection
-     ["[0]" sequence]
-     ["[0]" dictionary]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [world
-    ["[0]" file]]]]
- [\\library
-  ["[0]" / (.only)
-   [//
-    ["[0]" export]
-    ["[0]" io
-     ["[1]" context]]]]])
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Import])
-      (do [! random.monad]
-        [library/0 (random.lower_case 1)
-         library/1 (random.lower_case 2)
-         
-         .let [/ .module_separator
-               random_file (is (Random file.Path)
-                               (at ! each (text.suffix io.lux_extension) (random.lower_case 3)))]
-         file/0 random_file
-         
-         dir/0 (random.lower_case 4)
-         file/1 (at ! each (|>> (format dir/0 /)) random_file)
-         
-         .let [random_content (is (Random Binary)
-                                  (at ! each (|>> %.nat (at utf8.codec encoded)) random.nat))]
-         now random.instant
-         content/0 random_content
-         content/1 random_content
-         .let [library_content (|> (do try.monad
-                                     [file/0 (tar.path file/0)
-                                      file/1 (tar.path file/1)
-                                      content/0 (tar.content content/0)
-                                      content/1 (tar.content content/1)]
-                                     (in (|> (sequence.sequence {tar.#Normal [file/0 now export.mode export.ownership content/0]}
-                                                                {tar.#Normal [file/1 now export.mode export.ownership content/1]})
-                                             (\\format.result tar.format))))
-                                   (try.else (binary.empty 0)))
-               library_content/0 (|> (do try.monad
-                                       [file/0 (tar.path file/0)
-                                        content/0 (tar.content content/0)]
-                                       (in (|> (sequence.sequence {tar.#Normal [file/0 now export.mode export.ownership content/0]})
-                                               (\\format.result tar.format))))
-                                     (try.else (binary.empty 0)))
-               library_content/1 (|> (do try.monad
-                                       [file/1 (tar.path file/1)
-                                        content/1 (tar.content content/1)]
-                                       (in (|> (sequence.sequence {tar.#Normal [file/1 now export.mode export.ownership content/1]})
-                                               (\\format.result tar.format))))
-                                     (try.else (binary.empty 0)))
-               library_content/-0 (|> (do try.monad
-                                        [file/0 (tar.path file/0)
-                                         content/0 (tar.content content/0)]
-                                        (in (|> (sequence.sequence {tar.#Contiguous [file/0 now export.mode export.ownership content/0]})
-                                                (\\format.result tar.format))))
-                                      (try.else (binary.empty 0)))
-               library_content/-1 (|> (do try.monad
-                                        [file/0 (tar.path file/0)]
-                                        (in (|> (sequence.sequence {tar.#Symbolic_Link file/0})
-                                                (\\format.result tar.format))))
-                                      (try.else (binary.empty 0)))
-               library_content/-2 (|> (do try.monad
-                                        [file/0 (tar.path file/0)]
-                                        (in (|> (sequence.sequence {tar.#Directory file/0})
-                                                (\\format.result tar.format))))
-                                      (try.else (binary.empty 0)))
-               imported? (is (-> /.Import Bit)
-                             (function (_ it)
-                               (and (n.= 2 (dictionary.size it))
-                                    (|> it
-                                        (dictionary.value file/0)
-                                        (maybe#each (binary#= content/0))
-                                        (maybe.else false))
-                                    (|> it
-                                        (dictionary.value file/1)
-                                        (maybe#each (binary#= content/1))
-                                        (maybe.else false)))))]]
-        (all _.and
-             (in (do [! async.monad]
-                   [it/0 (do (try.with !)
-                           [.let [fs (file.mock /)]
-                            _ (at fs write library/0 library_content)]
-                           (/.import fs (list library/0)))
-                    it/1 (do (try.with !)
-                           [.let [fs (file.mock /)]
-                            _ (at fs write library/0 library_content/0)
-                            _ (at fs write library/1 library_content/1)]
-                           (/.import fs (list library/0 library/1)))]
-                   (_.coverage' [/.import]
-                     (and (|> it/0
-                              (try#each imported?)
-                              (try.else false))
-                          (|> it/1
-                              (try#each imported?)
-                              (try.else false))))))
-             (in (do [! async.monad]
-                   [it (do (try.with !)
-                         [.let [fs (file.mock /)]
-                          _ (at fs write library/0 library_content)
-                          _ (/.import fs (list library/0 library/0))]
-                         (in false))]
-                   (_.coverage' [/.duplicate]
-                     (exception.otherwise (exception.match? /.duplicate) it))))
-             (in (do [! async.monad]
-                   [it/0 (do (try.with !)
-                           [.let [fs (file.mock /)]
-                            _ (at fs write library/0 library_content/-0)
-                            _ (/.import fs (list library/0))]
-                           (in false))
-                    it/1 (do (try.with !)
-                           [.let [fs (file.mock /)]
-                            _ (at fs write library/0 library_content/-1)
-                            _ (/.import fs (list library/0))]
-                           (in false))
-                    it/2 (do (try.with !)
-                           [.let [fs (file.mock /)]
-                            _ (at fs write library/0 library_content/-2)
-                            _ (/.import fs (list library/0))]
-                           (in false))]
-                   (_.coverage' [/.useless_tar_entry]
-                     (and (exception.otherwise (exception.match? /.useless_tar_entry) it/0)
-                          (exception.otherwise (exception.match? /.useless_tar_entry) it/1)
-                          (exception.otherwise (exception.match? /.useless_tar_entry) it/2)))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/phase.lux b/stdlib/source/test/lux/tool/compiler/phase.lux
deleted file mode 100644
index 39ee0604b..000000000
--- a/stdlib/source/test/lux/tool/compiler/phase.lux
+++ /dev/null
@@ -1,206 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" functor (.only Injection Comparison)]
-     ["$[0]" monad]]]
-   [control
-    ["[0]" pipe]
-    ["[0]" try (.use "[1]#[0]" functor)]
-    ["[0]" exception (.only exception)]]
-   [data
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]]]
-   [math
-    ["[0]" random]
-    [number
-     ["n" nat]
-     ["i" int]]]]]
- [\\library
-  ["[0]" / (.only)
-   [//
-    [meta
-     ["[0]" archive]]]]])
-
-(def (injection value)
-  (All (_ s) (Injection (/.Operation s)))
-  (function (_ state)
-    {try.#Success [state value]}))
-
-(def (comparison init)
-  (All (_ s) (-> s (Comparison (/.Operation s))))
-  (function (_ == left right)
-    (case [(/.result init left)
-           (/.result init right)]
-      [{try.#Success left}
-       {try.#Success right}]
-      (== left right)
-
-      _
-      false)))
-
-(exception oops)
-
-(def test|error
-  Test
-  (do [! random.monad]
-    [state random.nat
-     expected random.int
-     expected_error (random.lower_case 1)]
-    (all _.and
-         (_.coverage [/.failure]
-           (|> (/.failure expected_error)
-               (/.result state)
-               (pipe.case {try.#Failure actual_error}
-                 (same? expected_error actual_error)
-
-                 _
-                 false)))
-         (_.coverage [/.lifted]
-           (and (|> (/.lifted {try.#Failure expected_error})
-                    (/.result state)
-                    (pipe.case {try.#Failure actual_error}
-                      (same? expected_error actual_error)
-
-                      _
-                      false))
-                (|> (/.lifted {try.#Success expected})
-                    (at /.functor each (same? expected))
-                    (/.result state)
-                    (try.else false))))
-         (_.coverage [/.except]
-           (|> (/.except ..oops [])
-               (/.result state)
-               (pipe.case {try.#Failure error}
-                 (exception.match? ..oops error)
-
-                 _
-                 false)))
-         (_.coverage [/.assertion]
-           (and (|> (/.assertion ..oops [] false)
-                    (/.result state)
-                    (pipe.case {try.#Failure error}
-                      (exception.match? ..oops error)
-
-                      _
-                      false))
-                (|> (/.assertion ..oops [] true)
-                    (/.result state)
-                    (pipe.case {try.#Success _}
-                      true
-
-                      _
-                      false))))
-         )))
-
-(def test|state
-  Test
-  (do [! random.monad]
-    [state random.nat
-     dummy random.nat
-     expected random.int]
-    (all _.and
-         (_.coverage [/.state]
-           (|> /.state
-               (at /.functor each (same? state))
-               (/.result state)
-               (try.else false)))
-         (_.coverage [/.with]
-           (|> (do /.monad
-                 [_ (/.with state)]
-                 /.state)
-               (at /.functor each (same? state))
-               (/.result dummy)
-               (try.else false)))
-         (_.coverage [/.sub]
-           (|> (/.sub [(at n.hex encoded)
-                       (function (_ new old)
-                         (|> new (at n.hex decoded) (try.else dummy)))]
-                      (do /.monad
-                        [state/hex /.state]
-                        (in (|> state
-                                (at n.hex encoded)
-                                (text#= state/hex)))))
-               (/.result' state)
-               (pipe.case {try.#Success [state' verdict]}
-                 (and verdict
-                      (n.= state state'))
-
-                 _
-                 false)))
-         )))
-
-(def test|operation
-  Test
-  (do [! random.monad]
-    [state random.nat
-     expected random.int]
-    (all _.and
-         (_.for [/.functor]
-                ($functor.spec ..injection (..comparison state) /.functor))
-         (_.for [/.monad]
-                ($monad.spec ..injection (..comparison state) /.monad))
-
-         (_.coverage [/.result]
-           (|> (at /.monad in expected)
-               (/.result state)
-               (pipe.case {try.#Success actual}
-                 (same? expected actual)
-
-                 _
-                 false)))
-         (_.coverage [/.result']
-           (|> (at /.monad in expected)
-               (/.result' state)
-               (pipe.case {try.#Success [state' actual]}
-                 (and (same? state state')
-                      (same? expected actual))
-
-                 _
-                 false)))
-         ..test|state
-         ..test|error
-         )))
-
-(def test|phase
-  Test
-  (do [! random.monad]
-    [state/0 random.nat
-     state/1 random.rev
-     expected random.int]
-    (all _.and
-         (_.coverage [/.identity]
-           (|> (/.identity archive.empty expected)
-               (/.result state/0)
-               (try#each (same? expected))
-               (try.else false)))
-         (_.coverage [/.composite]
-           (let [phase (/.composite (is (/.Phase Nat Int Frac)
-                                        (function (_ archive input)
-                                          (at /.monad in (i.frac input))))
-                                    (is (/.Phase Rev Frac Text)
-                                        (function (_ archive input)
-                                          (at /.monad in (%.frac input)))))]
-             (|> (phase archive.empty expected)
-                 (/.result' [state/0 state/1])
-                 (pipe.case {try.#Success [[state/0' state/1'] actual]}
-                   (and (text#= (%.frac (i.frac expected)) actual)
-                        (same? state/0 state/0')
-                        (same? state/1 state/1'))
-
-                   _
-                   false))))
-         )))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (all _.and
-           (_.for [/.Operation]
-                  ..test|operation)
-           (_.for [/.Phase]
-                  ..test|phase)
-           )))
diff --git a/stdlib/source/test/lux/tool/compiler/reference.lux b/stdlib/source/test/lux/tool/compiler/reference.lux
deleted file mode 100644
index 6f247179c..000000000
--- a/stdlib/source/test/lux/tool/compiler/reference.lux
+++ /dev/null
@@ -1,95 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]
-   [meta
-    ["[0]" symbol (.use "[1]#[0]" equivalence)]]]]
- [\\library
-  ["[0]" / (.only)
-   ["[0]" variable (.only Register)]]]
- ["[0]" /
-  ["[1][0]" variable]])
-
-(def constant
-  (Random /.Constant)
-  (all random.and
-       (random.upper_case 5)
-       (random.lower_case 5)
-       ))
-
-(def .public random
-  (Random /.Reference)
-  (all random.or
-       /variable.random
-       ..constant
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Reference /.Constant])
-      (do random.monad
-        [expected_register random.nat
-         expected_constant ..constant])
-      (`` (all _.and
-               (_.for [/.equivalence]
-                      ($equivalence.spec /.equivalence ..random))
-               (_.for [/.hash]
-                      ($hash.spec /.hash ..random))
-
-               (,, (with_template []
-                     [(_.coverage []
-                        (case ( expected_register)
-                          ( actual_register)
-                          (n.= expected_register actual_register)
-
-                          _
-                          false))]
-
-                     [/.local]
-                     [/.foreign]
-                     ))
-
-               (_.coverage [/.variable /.self]
-                 (and (at /.equivalence = (/.self) (/.variable (variable.self)))
-                      (case (/.self)
-                        (/.self)
-                        true
-                        
-                        _
-                        false)
-                      (case (/.variable (variable.self))
-                        (/.self)
-                        true
-                        
-                        _
-                        false)))
-               (_.coverage [/.constant]
-                 (case (/.constant expected_constant)
-                   (/.constant actual_constant)
-                   (symbol#= expected_constant actual_constant)
-
-                   _
-                   false))
-               (_.coverage [/.format]
-                 (and (text#= (/.format (/.local expected_register))
-                              (variable.format {variable.#Local expected_register}))
-                      (text#= (/.format (/.foreign expected_register))
-                              (variable.format {variable.#Foreign expected_register}))
-                      (text#= (/.format (/.constant expected_constant))
-                              (%.symbol expected_constant))))
-               
-               /variable.test
-               ))))
diff --git a/stdlib/source/test/lux/tool/compiler/reference/variable.lux b/stdlib/source/test/lux/tool/compiler/reference/variable.lux
deleted file mode 100644
index f2b219b86..000000000
--- a/stdlib/source/test/lux/tool/compiler/reference/variable.lux
+++ /dev/null
@@ -1,45 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]
-    [\\specification
-     ["$[0]" equivalence]
-     ["$[0]" hash]]]
-   [data
-    ["[0]" text (.use "[1]#[0]" equivalence)]]
-   [math
-    ["[0]" random (.only Random)]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Variable)
-  (all random.or
-       random.nat
-       random.nat
-       ))
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Variable])
-      (do [! random.monad]
-        [register random.nat]
-        (all _.and
-             (_.for [/.equivalence]
-                    ($equivalence.spec /.equivalence ..random))
-             (_.for [/.hash]
-                    ($hash.spec /.hash ..random))
-             (_.coverage [/.self]
-               (case (/.self)
-                 (/.self) true
-                 _ false))
-             (_.coverage [/.self?]
-               (/.self? (/.self)))
-             (_.for [/.Register]
-                    (_.coverage [/.format]
-                      (not (text#= (/.format {/.#Local register})
-                                   (/.format {/.#Foreign register})))))
-             ))))
diff --git a/stdlib/source/test/lux/tool/compiler/version.lux b/stdlib/source/test/lux/tool/compiler/version.lux
deleted file mode 100644
index 24e40bd56..000000000
--- a/stdlib/source/test/lux/tool/compiler/version.lux
+++ /dev/null
@@ -1,41 +0,0 @@
-(.require
- [library
-  [lux (.except)
-   ["_" test (.only Test)]
-   [abstract
-    [monad (.only do)]]
-   [data
-    ["[0]" bit (.use "[1]#[0]" equivalence)]
-    ["[0]" text (.use "[1]#[0]" equivalence)
-     ["%" \\format (.only format)]]]
-   [math
-    ["[0]" random (.only Random)]
-    [number
-     ["n" nat]]]]]
- [\\library
-  ["[0]" /]])
-
-(def .public random
-  (Random /.Version)
-  random.nat)
-
-(def .public test
-  Test
-  (<| (_.covering /._)
-      (_.for [/.Version])
-      (do [! random.monad]
-        [this ..random
-         that ..random]
-        (`` (all _.and
-                 (_.coverage [/.format]
-                   (bit#= (n.= this that)
-                          (text#= (/.format this) (/.format that))))
-                 (,, (with_template []
-                       [(_.coverage []
-                          (text.contains? (%.nat ( this))
-                                          (/.format this)))]
-
-                       [/.patch]
-                       [/.minor]
-                       [/.major]))
-                 )))))
-- 
cgit v1.2.3