aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/compiler/meta/archive.lux52
1 files changed, 29 insertions, 23 deletions
diff --git a/stdlib/source/lux/compiler/meta/archive.lux b/stdlib/source/lux/compiler/meta/archive.lux
index 1e9240f7b..457e3b874 100644
--- a/stdlib/source/lux/compiler/meta/archive.lux
+++ b/stdlib/source/lux/compiler/meta/archive.lux
@@ -98,26 +98,32 @@
["Old document's key" (describe (..signature (get@ #key old)))]
["New document's key" (describe (..signature (get@ #key new)))]))
-(type: #export Archive
- (Dictionary Text (Ex [d] (Document d))))
-
-(def: #export empty Archive (dict.new text.Hash<Text>))
-
-(def: #export (add name document archive)
- (-> Text (Ex [d] (Document d)) Archive (Error Archive))
- (case (dict.get name archive)
- (#.Some existing)
- (if (is? document existing)
- (#error.Success archive)
- (ex.throw cannot-replace-document-in-archive [name existing document]))
-
- #.None
- (#error.Success (dict.put name document archive))))
-
-(def: #export (merge additions archive)
- (-> Archive Archive (Error Archive))
- (monad.fold error.Monad<Error>
- (function (_ [name' document'] archive')
- (..add name' document' archive'))
- archive
- (dict.entries additions)))
+(abstract: #export Archive
+ {}
+
+ (Dictionary Text (Ex [d] (Document d)))
+
+ (def: #export empty
+ Archive
+ (:abstraction (dict.new text.Hash<Text>)))
+
+ (def: #export (add name document archive)
+ (-> Text (Ex [d] (Document d)) Archive (Error Archive))
+ (case (dict.get name (:representation archive))
+ (#.Some existing)
+ (if (is? document existing)
+ (#error.Success archive)
+ (ex.throw cannot-replace-document-in-archive [name existing document]))
+
+ #.None
+ (#error.Success (:abstraction (dict.put name document
+ (:representation archive))))))
+
+ (def: #export (merge additions archive)
+ (-> Archive Archive (Error Archive))
+ (monad.fold error.Monad<Error>
+ (function (_ [name' document'] archive')
+ (..add name' document' archive'))
+ archive
+ (dict.entries (:representation additions))))
+ )