diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/archive.lux | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/archive.lux b/stdlib/source/lux/tool/compiler/meta/archive.lux index eb9761ab9..96a6e3b63 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive.lux @@ -24,53 +24,62 @@ ["." document (#+ Document)]]) ## Archive -(exception: #export (unknown-document {name Module}) - (ex.report ["Module" name])) +(exception: #export (unknown-document {module Module}) + (ex.report ["Module" module])) -(exception: #export (cannot-replace-document {name Module} +(exception: #export (cannot-replace-document {module Module} {old (Document Any)} {new (Document Any)}) - (ex.report ["Module" name] + (ex.report ["Module" module] ["Old key" (signature.description (document.signature old))] ["New key" (signature.description (document.signature new))])) (abstract: #export Archive {} - (Dictionary Text [Descriptor (Document Any)]) + (Dictionary Module [Descriptor (Document Any)]) (def: #export empty Archive (:abstraction (dictionary.new text.hash))) - (def: #export (add name [descriptor document] archive) + (def: #export (add module [descriptor document] archive) (-> Module [Descriptor (Document Any)] Archive (Error Archive)) - (case (dictionary.get name (:representation archive)) + (case (dictionary.get module (:representation archive)) (#.Some [existing-descriptor existing-document]) (if (is? document existing-document) (#error.Success archive) - (ex.throw cannot-replace-document [name existing-document document])) + (ex.throw cannot-replace-document [module existing-document document])) #.None (#error.Success (|> archive :representation - (dictionary.put name [descriptor document]) + (dictionary.put module [descriptor document]) :abstraction)))) - (def: #export (find name archive) + (def: #export (find module archive) (-> Module Archive (Error [Descriptor (Document Any)])) - (case (dictionary.get name (:representation archive)) + (case (dictionary.get module (:representation archive)) (#.Some document) (#error.Success document) #.None - (ex.throw unknown-document [name]))) + (ex.throw unknown-document [module]))) + + (def: #export (archived? archive module) + (-> Archive Module Bit) + (case (find module archive) + (#error.Success _) + yes + + (#error.Failure _) + no)) (def: #export (merge additions archive) (-> Archive Archive (Error Archive)) (monad.fold error.monad - (function (_ [name' descriptor+document'] archive') - (..add name' descriptor+document' archive')) + (function (_ [module' descriptor+document'] archive') + (..add module' descriptor+document' archive')) archive (dictionary.entries (:representation additions)))) ) |