diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/archive/artifact.lux | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux new file mode 100644 index 000000000..222bb2479 --- /dev/null +++ b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux @@ -0,0 +1,48 @@ +(.module: + [lux #* + [data + ["." text] + [collection + ["." row (#+ Row)] + ["." dictionary (#+ Dictionary)]]] + [type + abstract]]) + +(type: #export ID Nat) + +(type: Artifact + (#Resource ID) + (#Definition [ID Text])) + +(abstract: #export Registry + {} + {#next ID + #artifacts (Row Artifact) + #resolver (Dictionary Text ID)} + + (def: #export empty + Registry + (:abstraction {#next 0 + #artifacts row.empty + #resolver (dictionary.new text.hash)})) + + (def: #export (resource registry) + (-> Registry [ID Registry]) + (let [id (get@ #next (:representation registry))] + [id + (|> registry + :representation + (update@ #next inc) + (update@ #artifacts (row.add (#Resource id))) + :abstraction)])) + + (def: #export (definition name registry) + (-> Text Registry [ID Registry]) + (let [id (get@ #next (:representation registry))] + [id + (|> registry + :representation + (update@ #next inc) + (update@ #artifacts (row.add (#Definition id name))) + :abstraction)])) + ) |