diff options
Diffstat (limited to 'stdlib')
14 files changed, 203 insertions, 139 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 4ae552aba..8bd316fee 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1501,11 +1501,15 @@ (-> Text Text Text) ("lux text concat" x y)) +(def:''' .private symbol_separator + Text + ".") + (def:''' .private (symbol#encoded full_name) (-> Symbol Text) (let' [[module name] full_name] ({"" name - _ ($_ text#composite module "." name)} + _ ($_ text#composite module ..symbol_separator name)} module))) (def:''' .private (global_symbol full_name state) @@ -2197,9 +2201,7 @@ (text#encoded value) [_ {#Symbol [module name]}] - (if (text#= "" module) - name - ($_ text#composite module "." name)) + (symbol#encoded [module name]) [_ {#Form xs}] ($_ text#composite "(" (|> xs diff --git a/stdlib/source/library/lux/meta/symbol.lux b/stdlib/source/library/lux/meta/symbol.lux index 78ce3c3b8..b1848864d 100644 --- a/stdlib/source/library/lux/meta/symbol.lux +++ b/stdlib/source/library/lux/meta/symbol.lux @@ -39,7 +39,7 @@ (# text.order < shortP shortS) (# text.order < moduleP moduleS)))) -(def: separator +(def: .public separator ".") (implementation: .public codec diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 3b4203980..757400c9a 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -263,11 +263,13 @@ 0 ..success_exit_code _ ..failure_exit_code))))) +(def: definition_separator " & ") + (def: (|cover'| coverage condition) (-> (List Symbol) Bit Assertion) (let [message (|> coverage (list#each %.symbol) - (text.interposed " & ")) + (text.interposed ..definition_separator)) coverage (set.of_list symbol.hash coverage)] (|> (..assertion message condition) (async#each (function (_ [tally documentation]) @@ -283,7 +285,7 @@ (-> (List Symbol) Test Test) (let [context (|> coverage (list#each %.symbol) - (text.interposed " & ")) + (text.interposed ..definition_separator)) coverage (set.of_list symbol.hash coverage)] (random#each (async#each (function (_ [tally documentation]) [(revised@ #actual_coverage (set.union coverage) tally) @@ -354,7 +356,15 @@ (|> (..context module test) (random#each (async#each (function (_ [tally documentation]) [(revised@ #expected_coverage (set.union coverage) tally) - documentation])))))) + (`` (|> documentation + (~~ (template [<prefix>] + [(text.replaced (format <prefix> module symbol.separator) <prefix>)] + + [..failure_prefix] + [..success_prefix] + [..definition_separator] + [..context_prefix] + ))))])))))) (syntax: .public (covering [module <code>.symbol test <code>.any]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index bd202b113..1108cfbc4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -43,6 +43,8 @@ ["[0]" dictionary {"+" Dictionary}]]] [macro ["[0]" template]] + [meta + ["[0]" symbol]] [math [number ["n" nat] @@ -143,7 +145,7 @@ ... mark], and the short [after the mark]). ... There are also some extra rules regarding name syntax, ... encoded in the parser. - ["." symbol_separator] + [symbol.separator symbol_separator] ) (exception: .public (end_of_file [module Text]) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index 3c6a9638b..3ff5019f9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -11,42 +11,13 @@ ["[0]" set {"+" Set}]]] [math [number - ["[0]" nat]]]]]) + ["[0]" nat]]]]] + ["[0]" / "_" + ["[1][0]" category {"+" Category}]]) (type: .public ID Nat) -(type: .public Category - (Variant - {#Anonymous} - {#Definition Text} - {#Analyser Text} - {#Synthesizer Text} - {#Generator Text} - {#Directive Text} - {#Custom Text})) - -(implementation: category_equivalence - (Equivalence Category) - - (def: (= left right) - (case [left right] - [{#Anonymous} {#Anonymous}] - true - - (^template [<tag>] - [[{<tag> left} {<tag> right}] - (text#= left right)]) - ([#Definition] - [#Analyser] - [#Synthesizer] - [#Generator] - [#Directive] - [#Custom]) - - _ - false))) - (type: .public Dependency [Nat ID]) @@ -61,14 +32,12 @@ (Record [#id ID #category Category - #mandatory? Bit - #dependencies (Set Dependency)])) + #mandatory? Bit])) (def: .public equivalence (Equivalence Artifact) ($_ product.equivalence nat.equivalence - ..category_equivalence + /category.equivalence bit.equivalence - set.equivalence )) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux new file mode 100644 index 000000000..8286af9a8 --- /dev/null +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux @@ -0,0 +1,38 @@ +(.using + [library + [lux "*" + [abstract + [equivalence {"+" Equivalence}]] + [data + ["[0]" text ("[1]#[0]" equivalence)]]]]) + +(type: .public Category + (Variant + {#Anonymous} + {#Definition Text} + {#Analyser Text} + {#Synthesizer Text} + {#Generator Text} + {#Directive Text} + {#Custom Text})) + +(implementation: .public equivalence + (Equivalence Category) + + (def: (= left right) + (case [left right] + [{#Anonymous} {#Anonymous}] + true + + (^template [<tag>] + [[{<tag> left} {<tag> right}] + (text#= left right)]) + ([#Definition] + [#Analyser] + [#Synthesizer] + [#Generator] + [#Directive] + [#Custom]) + + _ + false))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/dependency.lux index 1e6613015..9d04addde 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/dependency.lux @@ -197,10 +197,10 @@ (value@ descriptor.#registry) registry.artifacts sequence.list - (list#each (function (_ artifact) + (list#each (function (_ [artifact dependencies]) [[module_id (value@ artifact.#id artifact)] (value@ artifact.#mandatory? artifact) - (value@ artifact.#dependencies artifact)]))))) + dependencies]))))) list.together (list#mix (function (_ [artifact_id mandatory? dependencies] [mandatory_dependencies diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux index 3005c2e0d..9b8e1e38a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux @@ -22,11 +22,12 @@ [type abstract]]] ["[0]" // "_" - ["[1]" artifact {"+" Dependency Category Artifact ID}]]) + ["[1]" artifact {"+" Dependency Artifact ID} + ["[2][0]" category {"+" Category}]]]) (abstract: .public Registry (Record - [#artifacts (Sequence Artifact) + [#artifacts (Sequence [Artifact (Set Dependency)]) #resolver (Dictionary Text ID)]) (def: .public empty @@ -35,7 +36,7 @@ #resolver (dictionary.empty text.hash)])) (def: .public artifacts - (-> Registry (Sequence Artifact)) + (-> Registry (Sequence [Artifact (Set Dependency)])) (|>> :representation (value@ #artifacts))) (def: next @@ -48,10 +49,10 @@ [id (|> registry :representation - (revised@ #artifacts (sequence.suffix [//.#id id - //.#category {//.#Anonymous} - //.#mandatory? mandatory? - //.#dependencies dependencies])) + (revised@ #artifacts (sequence.suffix [[//.#id id + //.#category {//category.#Anonymous} + //.#mandatory? mandatory?] + dependencies])) :abstraction)])) (template [<tag> <create> <fetch>] @@ -61,10 +62,10 @@ [id (|> registry :representation - (revised@ #artifacts (sequence.suffix [//.#id id - //.#category {<tag> name} - //.#mandatory? mandatory? - //.#dependencies dependencies])) + (revised@ #artifacts (sequence.suffix [[//.#id id + //.#category {<tag> name} + //.#mandatory? mandatory?] + dependencies])) (revised@ #resolver (dictionary.has name id)) :abstraction)])) @@ -74,16 +75,17 @@ :representation (value@ #artifacts) sequence.list - (list.all (|>> (value@ //.#category) + (list.all (|>> product.left + (value@ //.#category) (case> {<tag> name} {.#Some name} _ {.#None})))))] - [//.#Definition definition definitions] - [//.#Analyser analyser analysers] - [//.#Synthesizer synthesizer synthesizers] - [//.#Generator generator generators] - [//.#Directive directive directives] - [//.#Custom custom customs] + [//category.#Definition definition definitions] + [//category.#Analyser analyser analysers] + [//category.#Synthesizer synthesizer synthesizers] + [//category.#Generator generator generators] + [//category.#Directive directive directives] + [//category.#Custom custom customs] ) (def: .public (remember name registry) @@ -100,13 +102,13 @@ (^template [<nat> <tag> <writer>] [{<tag> value} ((binary.and binary.nat <writer>) [<nat> value])]) - ([0 //.#Anonymous binary.any] - [1 //.#Definition binary.text] - [2 //.#Analyser binary.text] - [3 //.#Synthesizer binary.text] - [4 //.#Generator binary.text] - [5 //.#Directive binary.text] - [6 //.#Custom binary.text])))) + ([0 //category.#Anonymous binary.any] + [1 //category.#Definition binary.text] + [2 //category.#Analyser binary.text] + [3 //category.#Synthesizer binary.text] + [4 //category.#Generator binary.text] + [5 //category.#Directive binary.text] + [6 //category.#Custom binary.text])))) mandatory? binary.bit dependency (: (Writer Dependency) (binary.and binary.nat binary.nat)) @@ -116,10 +118,10 @@ (binary.sequence/64 ($_ binary.and category mandatory? dependencies)))] (|>> :representation (value@ #artifacts) - (sequence#each (function (_ it) + (sequence#each (function (_ [it dependencies]) [(value@ //.#category it) (value@ //.#mandatory? it) - (value@ //.#dependencies it)])) + dependencies])) artifacts))) (exception: .public (invalid_category [tag Nat]) @@ -135,13 +137,13 @@ (^template [<nat> <tag> <parser>] [<nat> (# ! each (|>> {<tag>}) <parser>)]) - ([0 //.#Anonymous <binary>.any] - [1 //.#Definition <binary>.text] - [2 //.#Analyser <binary>.text] - [3 //.#Synthesizer <binary>.text] - [4 //.#Generator <binary>.text] - [5 //.#Directive <binary>.text] - [6 //.#Custom <binary>.text]) + ([0 //category.#Anonymous <binary>.any] + [1 //category.#Definition <binary>.text] + [2 //category.#Analyser <binary>.text] + [3 //category.#Synthesizer <binary>.text] + [4 //category.#Generator <binary>.text] + [5 //category.#Directive <binary>.text] + [6 //category.#Custom <binary>.text]) _ (<>.failure (exception.error ..invalid_category [tag]))))) mandatory? <binary>.bit @@ -153,18 +155,18 @@ (# <>.monad each (sequence#mix (function (_ [category mandatory? dependencies] registry) (product.right (case category - {//.#Anonymous} + {//category.#Anonymous} (..resource mandatory? dependencies registry) (^template [<tag> <create>] [{<tag> name} (<create> name mandatory? dependencies registry)]) - ([//.#Definition ..definition] - [//.#Analyser ..analyser] - [//.#Synthesizer ..synthesizer] - [//.#Generator ..generator] - [//.#Directive ..directive] - [//.#Custom ..custom]) + ([//category.#Definition ..definition] + [//category.#Analyser ..analyser] + [//category.#Synthesizer ..synthesizer] + [//category.#Generator ..generator] + [//category.#Directive ..directive] + [//category.#Custom ..custom]) ))) ..empty))))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 46d3d65cf..b5fae7763 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -22,7 +22,7 @@ ["[0]" list ("[1]#[0]" functor mix)] ["[0]" dictionary {"+" Dictionary}] ["[0]" sequence {"+" Sequence}] - ["[0]" set]]] + ["[0]" set {"+" Set}]]] [math [number ["n" nat]]] @@ -36,10 +36,11 @@ ["[1][0]" context] ["/[1]" // ["[0]" archive {"+" Output Archive} - ["[0]" artifact {"+" Artifact}] ["[0]" registry] ["[0]" descriptor {"+" Module Descriptor}] - ["[0]" document {"+" Document}]] + ["[0]" document {"+" Document}] + ["[0]" artifact {"+" Artifact Dependency} + ["[0]" category {"+" Category}]]] [cache ["[0]" dependency]] ["/[1]" // {"+" Input} @@ -213,7 +214,7 @@ (def: (loaded_document extension host module_id expected actual document) (All (_ expression directive) - (-> Text (generation.Host expression directive) archive.ID (Sequence Artifact) (Dictionary Text Binary) (Document .Module) + (-> Text (generation.Host expression directive) archive.ID (Sequence [Artifact (Set Dependency)]) (Dictionary Text Binary) (Document .Module) (Try [(Document .Module) Bundles Output]))) (do [! try.monad] [[definitions bundles] (: (Try [Definitions Bundles Output]) @@ -224,13 +225,13 @@ output (: Output sequence.empty)] (let [[analysers synthesizers generators directives] bundles] (case input - {.#Item [[artifact_id artifact_category mandatory_artifact? artifact_dependencies] input']} + {.#Item [[[artifact_id artifact_category mandatory_artifact?] artifact_dependencies] input']} (case (do ! [data (try.of_maybe (dictionary.value (format (%.nat artifact_id) extension) actual)) .let [context [module_id artifact_id] directive (# host ingest context data)]] (case artifact_category - {artifact.#Anonymous} + {category.#Anonymous} (do ! [.let [output (sequence.suffix [artifact_id {.#None} data] output)] _ (# host re_learn context {.#None} directive)] @@ -241,7 +242,7 @@ directives] output])) - {artifact.#Definition name} + {category.#Definition name} (let [output (sequence.suffix [artifact_id {.#None} data] output)] (if (text#= $/program.name name) (in [definitions @@ -259,7 +260,7 @@ directives] output])))) - {artifact.#Analyser extension} + {category.#Analyser extension} (do ! [.let [output (sequence.suffix [artifact_id {.#None} data] output)] value (# host re_load context {.#None} directive)] @@ -270,7 +271,7 @@ directives] output])) - {artifact.#Synthesizer extension} + {category.#Synthesizer extension} (do ! [.let [output (sequence.suffix [artifact_id {.#None} data] output)] value (# host re_load context {.#None} directive)] @@ -281,7 +282,7 @@ directives] output])) - {artifact.#Generator extension} + {category.#Generator extension} (do ! [.let [output (sequence.suffix [artifact_id {.#None} data] output)] value (# host re_load context {.#None} directive)] @@ -292,7 +293,7 @@ directives] output])) - {artifact.#Directive extension} + {category.#Directive extension} (do ! [.let [output (sequence.suffix [artifact_id {.#None} data] output)] value (# host re_load context {.#None} directive)] @@ -303,7 +304,7 @@ (dictionary.has extension (:as directive.Handler value) directives)] output])) - {artifact.#Custom name} + {category.#Custom name} (do ! [.let [output (sequence.suffix [artifact_id {.#Some name} data] output)] _ (# host re_learn context {.#Some name} directive)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index b8319015f..d434c4603 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -1,27 +1,28 @@ (.using - [library - [lux "*" - [control - [try {"+" Try}]] - [data - [binary {"+" Binary}] - [collection - [dictionary {"+" Dictionary}] - ["[0]" sequence] - ["[0]" list ("[1]#[0]" functor)]]] - [world - ["[0]" file]]]] + [library + [lux "*" + [control + [try {"+" Try}]] + [data + [binary {"+" Binary}] + ["[0]" product] + [collection + [dictionary {"+" Dictionary}] + ["[0]" sequence] + ["[0]" list ("[1]#[0]" functor)]]] + [world + ["[0]" file]]]] + [// + [cache + ["[0]" dependency]] + ["[0]" archive {"+" Archive} + ["[0]" descriptor] + ["[0]" artifact] + ["[0]" registry]] [// - [cache - ["[0]" dependency]] - ["[0]" archive {"+" Archive} - ["[0]" descriptor] - ["[0]" artifact] - ["[0]" registry]] - [// - [language - [lux - [generation {"+" Context}]]]]]) + [language + [lux + [generation {"+" Context}]]]]]) (type: .public Packager (-> (Dictionary file.Path Binary) @@ -40,5 +41,5 @@ (value@ descriptor.#registry) registry.artifacts sequence.list - (list#each (|>> (value@ artifact.#id))) + (list#each (|>> product.left (value@ artifact.#id))) [module_id])))) 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 index 85a701185..e5eb0c0f5 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -43,11 +43,17 @@ expected_text (random.ascii/lower 2) expected_lefts random.nat - expected_right? random.bit]) + expected_right? random.bit + + left ..random + right ..random]) (`` ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) + (_.cover [/.format] + (bit#= (# /.equivalence = left right) + (text#= (/.format left) (/.format right)))) (_.cover [/.unit] (case (/.unit) (^ (/.unit)) 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 index 517d5eb57..ab2af87eb 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux @@ -257,6 +257,16 @@ _ false)))) + (_.cover [/.up] + (|> (do phase.monad + [] + (in expected)) + (: (/.Operation Int Nat Nat Nat)) + /.up + (: (phase.Operation Int Nat)) + (# phase.functor each (same? expected)) + (phase.result state) + (try.else false))) )) (_.for [/.State] ..test|state) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux index b241b0c46..2bb161796 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux @@ -6,22 +6,12 @@ [\\specification ["$[0]" equivalence]]] [math - ["[0]" random {"+" Random} ("[1]#[0]" monad)]]]] + ["[0]" random {"+" Random}]]]] + ["[0]" / "_" + ["[1][0]" category]] [\\library ["[0]" /]]) -(def: random_category - (Random /.Category) - ($_ random.or - (random#in []) - (random.ascii/lower 1) - (random.ascii/lower 2) - (random.ascii/lower 3) - (random.ascii/lower 4) - (random.ascii/lower 5) - (random.ascii/lower 6) - )) - (def: random_dependency (Random /.Dependency) ($_ random.and @@ -33,9 +23,8 @@ (Random /.Artifact) ($_ random.and random.nat - ..random_category + /category.random random.bit - (random.set /.dependency_hash 5 ..random_dependency) )) (def: .public test @@ -45,4 +34,6 @@ ($_ _.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 new file mode 100644 index 000000000..8f31cca51 --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux @@ -0,0 +1,32 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [\\specification + ["$[0]" equivalence]]] + [math + ["[0]" random {"+" Random} ("[1]#[0]" monad)]]]] + [\\library + ["[0]" /]]) + +(def: .public random + (Random /.Category) + ($_ random.or + (random#in []) + (random.ascii/lower 1) + (random.ascii/lower 2) + (random.ascii/lower 3) + (random.ascii/lower 4) + (random.ascii/lower 5) + (random.ascii/lower 6) + )) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Category]) + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + ))) |