diff options
author | Eduardo Julian | 2021-07-14 13:59:02 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-07-14 13:59:02 -0400 |
commit | d6c48ae6a8b58f5974133170863a31c70f0123d1 (patch) | |
tree | 008eb88328009e2f3f07002f35c0378a8a137ed0 /stdlib/source/lux/tool/compiler/meta/archive | |
parent | 2431e767a09894c2f685911ba7f1ba0b7de2a165 (diff) |
Normalized the hierarchy of the standard library modules.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/meta/archive')
5 files changed, 0 insertions, 332 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux deleted file mode 100644 index 5592df470..000000000 --- a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux +++ /dev/null @@ -1,154 +0,0 @@ -(.module: - [lux #* - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." exception (#+ exception:)] - ["<>" parser - ["<b>" binary (#+ Parser)]]] - [data - ["." product] - ["." text - ["%" format (#+ format)]] - [collection - ["." list] - ["." row (#+ Row) ("#\." functor fold)] - ["." dictionary (#+ Dictionary)]] - [format - ["." binary (#+ Writer)]]] - [type - abstract]]) - -(type: #export ID - Nat) - -(type: #export Category - #Anonymous - (#Definition Text) - (#Analyser Text) - (#Synthesizer Text) - (#Generator Text) - (#Directive Text)) - -(type: #export Artifact - {#id ID - #category Category}) - -(abstract: #export Registry - {#artifacts (Row Artifact) - #resolver (Dictionary Text ID)} - - (def: #export empty - Registry - (:abstraction {#artifacts row.empty - #resolver (dictionary.new text.hash)})) - - (def: #export artifacts - (-> Registry (Row Artifact)) - (|>> :representation (get@ #artifacts))) - - (def: next - (-> Registry ID) - (|>> ..artifacts row.size)) - - (def: #export (resource registry) - (-> Registry [ID Registry]) - (let [id (..next registry)] - [id - (|> registry - :representation - (update@ #artifacts (row.add {#id id - #category #Anonymous})) - :abstraction)])) - - (template [<tag> <create> <fetch>] - [(def: #export (<create> name registry) - (-> Text Registry [ID Registry]) - (let [id (..next registry)] - [id - (|> registry - :representation - (update@ #artifacts (row.add {#id id - #category (<tag> name)})) - (update@ #resolver (dictionary.put name id)) - :abstraction)])) - - (def: #export (<fetch> registry) - (-> Registry (List Text)) - (|> registry - :representation - (get@ #artifacts) - row.to_list - (list.all (|>> (get@ #category) - (case> (<tag> name) (#.Some name) - _ #.None)))))] - - [#Definition definition definitions] - [#Analyser analyser analysers] - [#Synthesizer synthesizer synthesizers] - [#Generator generator generators] - [#Directive directive directives] - ) - - (def: #export (remember name registry) - (-> Text Registry (Maybe ID)) - (|> (:representation registry) - (get@ #resolver) - (dictionary.get name))) - - (def: #export writer - (Writer Registry) - (let [category (: (Writer Category) - (function (_ value) - (case value - (^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])))) - artifacts (: (Writer (Row Category)) - (binary.row/64 category))] - (|>> :representation - (get@ #artifacts) - (row\map (get@ #category)) - artifacts))) - - (exception: #export (invalid_category {tag Nat}) - (exception.report - ["Tag" (%.nat tag)])) - - (def: #export parser - (Parser Registry) - (let [category (: (Parser Category) - (do {! <>.monad} - [tag <b>.nat] - (case tag - 0 (\ ! map (|>> #Anonymous) <b>.any) - 1 (\ ! map (|>> #Definition) <b>.text) - 2 (\ ! map (|>> #Analyser) <b>.text) - 3 (\ ! map (|>> #Synthesizer) <b>.text) - 4 (\ ! map (|>> #Generator) <b>.text) - 5 (\ ! map (|>> #Directive) <b>.text) - _ (<>.fail (exception.construct ..invalid_category [tag])))))] - (|> (<b>.row/64 category) - (\ <>.monad map (row\fold (function (_ artifact registry) - (product.right - (case artifact - #Anonymous - (..resource registry) - - (^template [<tag> <create>] - [(<tag> name) - (<create> name registry)]) - ([#Definition ..definition] - [#Analyser ..analyser] - [#Synthesizer ..synthesizer] - [#Generator ..generator] - [#Directive ..directive]) - ))) - ..empty))))) - ) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux deleted file mode 100644 index a31f6e793..000000000 --- a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux +++ /dev/null @@ -1,48 +0,0 @@ -(.module: - [lux (#- Module) - [control - ["<>" parser - ["<b>" binary (#+ Parser)]]] - [data - ["." text] - [collection - [set (#+ Set)]] - [format - ["." binary (#+ Writer)]]] - [world - [file (#+ Path)]]] - [// - ["." artifact (#+ Registry)]]) - -(type: #export Module - Text) - -(type: #export Descriptor - {#name Module - #file Path - #hash Nat - #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 deleted file mode 100644 index b60d77246..000000000 --- a/stdlib/source/lux/tool/compiler/meta/archive/document.lux +++ /dev/null @@ -1,71 +0,0 @@ -(.module: - [lux (#- Module) - [abstract - [monad (#+ do)]] - [control - ["." try (#+ Try)] - ["." exception (#+ exception:)] - ["<>" parser - [binary (#+ Parser)]]] - [data - [collection - ["." dictionary (#+ Dictionary)]] - [format - ["." binary (#+ Writer)]]] - [type (#+ :share) - abstract]] - [// - ["." signature (#+ Signature)] - ["." key (#+ Key)] - [descriptor (#+ Module)]]) - -(exception: #export (invalid-signature {expected Signature} {actual Signature}) - (exception.report - ["Expected" (signature.description expected)] - ["Actual" (signature.description actual)])) - -(abstract: #export (Document d) - {#signature Signature - #content d} - - (def: #export (read key document) - (All [d] (-> (Key d) (Document Any) (Try d))) - (let [[document//signature document//content] (:representation document)] - (if (\ signature.equivalence = - (key.signature key) - document//signature) - (#try.Success (:share [e] - (Key e) - key - - e - (:assume document//content))) - (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/key.lux b/stdlib/source/lux/tool/compiler/meta/archive/key.lux deleted file mode 100644 index 1f30e105b..000000000 --- a/stdlib/source/lux/tool/compiler/meta/archive/key.lux +++ /dev/null @@ -1,18 +0,0 @@ -(.module: - [lux #* - [type - abstract]] - [// - [signature (#+ Signature)]]) - -(abstract: #export (Key k) - Signature - - (def: #export signature - (-> (Key Any) Signature) - (|>> :representation)) - - (def: #export (key signature sample) - (All [d] (-> Signature d (Key d))) - (:abstraction signature)) - ) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/lux/tool/compiler/meta/archive/signature.lux deleted file mode 100644 index 8956f99ec..000000000 --- a/stdlib/source/lux/tool/compiler/meta/archive/signature.lux +++ /dev/null @@ -1,41 +0,0 @@ -(.module: - [lux #* - [abstract - [equivalence (#+ Equivalence)]] - [control - ["<>" parser - ["<b>" binary (#+ Parser)]]] - [data - ["." product] - ["." name] - ["." text - ["%" format (#+ format)]] - [format - ["." binary (#+ Writer)]]] - [math - [number - ["." nat]]]] - [//// - [version (#+ Version)]]) - -(type: #export Signature - {#name Name - #version Version}) - -(def: #export equivalence - (Equivalence Signature) - (product.equivalence name.equivalence nat.equivalence)) - -(def: #export (description signature) - (-> Signature Text) - (format (%.name (get@ #name signature)) " " (%.nat (get@ #version signature)))) - -(def: #export writer - (Writer Signature) - (binary.and (binary.and binary.text binary.text) - binary.nat)) - -(def: #export parser - (Parser Signature) - (<>.and (<>.and <b>.text <b>.text) - <b>.nat)) |