aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/compositor
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/compositor')
-rw-r--r--stdlib/source/program/compositor/export.lux22
-rw-r--r--stdlib/source/program/compositor/import.lux50
2 files changed, 35 insertions, 37 deletions
diff --git a/stdlib/source/program/compositor/export.lux b/stdlib/source/program/compositor/export.lux
index 238034534..24ba3492c 100644
--- a/stdlib/source/program/compositor/export.lux
+++ b/stdlib/source/program/compositor/export.lux
@@ -38,16 +38,16 @@
{#tar.user commons
#tar.group commons}))
-(def: #export (library system sources)
+(def: #export (library fs sources)
(-> (file.System Promise) (List Source) (Promise (Try tar.Tar)))
(do (try.with promise.monad)
- [files (io.enumerate system sources)]
+ [files (io.enumerate fs sources)]
(|> (dictionary.entries files)
(monad.map try.monad
(function (_ [path source_code])
(do try.monad
[path (|> path
- (text.replace_all (\ system separator) .module_separator)
+ (text.replace_all (\ fs separator) .module_separator)
tar.path)
source_code (tar.content source_code)]
(wrap (#tar.Normal [path
@@ -61,13 +61,11 @@
(\ try.monad map row.from_list)
(\ promise.monad wrap))))
-(def: #export (export system [sources target])
+(def: #export (export fs [sources target])
(-> (file.System Promise) Export (Promise (Try Any)))
- (do (try.with promise.monad)
- [tar (..library system sources)
- package (: (Promise (Try (file.File Promise)))
- (file.get_file promise.monad system
- (format target (\ system separator) ..file)))]
- (|> tar
- (binary.run tar.writer)
- (\ package over_write))))
+ (do {! (try.with promise.monad)}
+ [tar (\ ! map (binary.run tar.writer)
+ (..library fs sources))]
+ (|> ..file
+ (format target (\ fs separator))
+ (\ fs write tar))))
diff --git a/stdlib/source/program/compositor/import.lux b/stdlib/source/program/compositor/import.lux
index 19a2d7607..f91ad03e7 100644
--- a/stdlib/source/program/compositor/import.lux
+++ b/stdlib/source/program/compositor/import.lux
@@ -8,7 +8,7 @@
[concurrency
["." promise (#+ Promise) ("#\." monad)]]
["<>" parser
- ["<b>" binary]]]
+ ["<.>" binary]]]
[data
[binary (#+ Binary)]
["." text
@@ -24,7 +24,7 @@
[archive
[descriptor (#+ Module)]]]]]
[world
- ["." file (#+ Path File)]]]
+ ["." file]]]
[//
[cli (#+ Library)]])
@@ -39,32 +39,32 @@
["Library" (%.text library)]))
(type: #export Import
- (Dictionary Path Binary))
+ (Dictionary file.Path Binary))
(def: (import_library system library import)
(-> (file.System Promise) Library Import (Action Import))
- (do (try.with promise.monad)
- [file (: (Action (File Promise))
- (\ system file library))
- binary (\ file content [])]
- (promise\wrap
- (do {! try.monad}
- [tar (<b>.run tar.parser binary)]
- (monad.fold ! (function (_ entry import)
- (case entry
- (#tar.Normal [path instant mode ownership content])
- (let [path (tar.from_path path)]
- (case (dictionary.try_put path (tar.data content) import)
- (#try.Success import)
- (wrap import)
-
- (#try.Failure error)
- (exception.throw ..duplicate [library path])))
-
- _
- (exception.throw ..useless_tar_entry [])))
- import
- (row.to_list tar))))))
+ (let [! promise.monad]
+ (|> library
+ (\ system read)
+ (\ ! map (let [! try.monad]
+ (|>> (\ ! map (<binary>.run tar.parser))
+ (\ ! join)
+ (\ ! map (|>> row.to_list
+ (monad.fold ! (function (_ entry import)
+ (case entry
+ (#tar.Normal [path instant mode ownership content])
+ (let [path (tar.from_path path)]
+ (case (dictionary.try_put path (tar.data content) import)
+ (#try.Failure error)
+ (exception.throw ..duplicate [library path])
+
+ import'
+ import'))
+
+ _
+ (exception.throw ..useless_tar_entry [])))
+ import)))
+ (\ ! join)))))))
(def: #export (import system libraries)
(-> (file.System Promise) (List Library) (Action Import))