diff options
author | Eduardo Julian | 2020-04-22 02:52:57 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-04-22 02:52:57 -0400 |
commit | a419ec66895e07fbb54ecc59f92e154126a10ac5 (patch) | |
tree | 54c282bb5dcdd2bb554dcd30abd71aa6b4bc5810 /stdlib/source/lux/tool/compiler/meta/archive | |
parent | d636f97db32f0ca3aa1705c5290afc07314adc53 (diff) |
Now caching the documents generated after compiling each module.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/meta/archive')
4 files changed, 109 insertions, 11 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux index 2d4559275..7f3e1654d 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux @@ -1,11 +1,19 @@ (.module: [lux #* + [abstract + [monad (#+ do)]] + [control + ["<>" parser + ["<b>" binary (#+ Parser)]]] [data + ["." product] ["." text] [collection - ["." list] + ["." list ("#@." functor fold)] ["." row (#+ Row)] - ["." dictionary (#+ Dictionary)]]] + ["." dictionary (#+ Dictionary)]] + [format + ["." binary (#+ Writer)]]] [type abstract]]) @@ -17,6 +25,7 @@ (abstract: #export Registry {} + {#artifacts (Row Artifact) #resolver (Dictionary Text ID)} @@ -63,4 +72,26 @@ (|> (:representation registry) (get@ #resolver) (dictionary.get name))) + + (def: #export writer + (Writer Registry) + (let [writer|artifacts (binary.list (binary.maybe binary.text))] + (|>> :representation + (get@ #artifacts) + row.to-list + (list@map (get@ #name)) + writer|artifacts))) + + (def: #export parser + (Parser Registry) + (|> (<b>.list (<b>.maybe <b>.text)) + (:: <>.monad map (list@fold (function (_ artifact registry) + (product.right + (case artifact + #.None + (..resource registry) + + (#.Some name) + (..definition name registry)))) + ..empty)))) ) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux index c6e1e7841..24562367a 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux @@ -1,12 +1,18 @@ (.module: [lux (#- Module) + [control + ["<>" parser + ["<b>" binary (#+ Parser)]]] [data + ["." text] [collection - [set (#+ Set)]]] + [set (#+ Set)]] + [format + ["." binary (#+ Writer)]]] [world [file (#+ Path)]]] [// - [artifact (#+ Registry)]]) + ["." artifact (#+ Registry)]]) (type: #export Module Text) @@ -17,3 +23,25 @@ #state Module-State #references (Set Module) #registry Registry}) + +(def: #export writer + (Writer Descriptor) + ($_ binary.and + binary.text + binary.text + binary.nat + binary.any + (binary.set binary.text) + artifact.writer + )) + +(def: #export parser + (Parser Descriptor) + ($_ <>.and + <b>.text + <b>.text + <b>.nat + (:: <>.monad wrap #.Cached) + (<b>.set text.hash <b>.text) + artifact.parser + )) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/lux/tool/compiler/meta/archive/document.lux index e6d5c0dfe..19b8576a1 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive/document.lux @@ -1,11 +1,17 @@ (.module: [lux (#- Module) + [abstract + [monad (#+ do)]] [control ["." try (#+ Try)] - ["ex" exception (#+ exception:)]] + ["." exception (#+ exception:)] + ["<>" parser + ["<b>" binary (#+ Parser)]]] [data [collection - ["." dictionary (#+ Dictionary)]]] + ["." dictionary (#+ Dictionary)]] + [format + ["." binary (#+ Writer)]]] [type (#+ :share) abstract]] [// @@ -14,8 +20,9 @@ [descriptor (#+ Module)]]) (exception: #export (invalid-signature {expected Signature} {actual Signature}) - (ex.report ["Expected" (signature.description expected)] - ["Actual" (signature.description actual)])) + (exception.report + ["Expected" (signature.description expected)] + ["Actual" (signature.description actual)])) (abstract: #export (Document d) {} @@ -34,15 +41,32 @@ key} {e document//content})) - (ex.throw invalid-signature [(key.signature key) - document//signature])))) + (exception.throw ..invalid-signature [(key.signature key) + document//signature])))) (def: #export (write key content) (All [d] (-> (Key d) d (Document d))) (:abstraction {#signature (key.signature key) #content content})) + (def: #export (check key document) + (All [d] (-> (Key d) (Document Any) (Try (Document d)))) + (do try.monad + [_ (..read key document)] + (wrap (:assume document)))) + (def: #export signature (-> (Document Any) Signature) (|>> :representation (get@ #signature))) + + (def: #export (writer content) + (All [d] (-> (Writer d) (Writer (Document d)))) + (let [writer (binary.and signature.writer + content)] + (|>> :representation writer))) + + (def: #export parser + (All [d] (-> (Parser d) (Parser (Document d)))) + (|>> (<>.and signature.parser) + (:: <>.monad map (|>> :abstraction)))) ) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/lux/tool/compiler/meta/archive/signature.lux index 551c54579..3d795ff50 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive/signature.lux @@ -2,10 +2,15 @@ [lux #* [abstract ["." equivalence (#+ Equivalence)]] + [control + ["<>" parser + ["<b>" binary (#+ Parser)]]] [data ["." name] ["." text - ["%" format (#+ format)]]]] + ["%" format (#+ format)]] + [format + ["." binary (#+ Writer)]]]] [//// [version (#+ Version)]]) @@ -20,3 +25,13 @@ (def: #export (description signature) (-> Signature Text) (format (%.name (get@ #name signature)) " " (get@ #version signature))) + +(def: #export writer + (Writer Signature) + (binary.and (binary.and binary.text binary.text) + binary.text)) + +(def: #export parser + (Parser Signature) + (<>.and (<>.and <b>.text <b>.text) + <b>.text)) |