aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/world/file.lux
diff options
context:
space:
mode:
authorEduardo Julian2022-12-18 18:55:32 -0400
committerEduardo Julian2022-12-18 18:55:32 -0400
commitc2830c26e55da02ac628be9a220cd824264cdc9e (patch)
tree40a0208ada85f7a6883b1fb48a7f10adbd22feb6 /stdlib/source/library/lux/world/file.lux
parent549cb9623c560fec165b9e88f112a406614f598e (diff)
Caching compiler artifacts into TAR files, instead of huge directories.
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/world/file.lux61
1 files changed, 44 insertions, 17 deletions
diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux
index 608d9689e..94bea7fad 100644
--- a/stdlib/source/library/lux/world/file.lux
+++ b/stdlib/source/library/lux/world/file.lux
@@ -83,7 +83,9 @@
))
(def (un_rooted fs path)
- (All (_ !) (-> (System !) Path (Maybe [Path Text])))
+ (All (_ !)
+ (-> (System !) Path
+ (Maybe [Path Text])))
(let [/ (of fs separator)]
(when (text.last_index / path)
{.#None}
@@ -96,20 +98,25 @@
(in [parent child])))))
(def .public (parent fs path)
- (All (_ !) (-> (System !) Path (Maybe Path)))
+ (All (_ !)
+ (-> (System !) Path
+ (Maybe Path)))
(|> path
(..un_rooted fs)
(maybe#each product.left)))
(def .public (name fs path)
- (All (_ !) (-> (System !) Path Text))
+ (All (_ !)
+ (-> (System !) Path
+ Text))
(|> path
(..un_rooted fs)
(maybe#each product.right)
(maybe.else path)))
(def .public (async fs)
- (-> (System IO) (System Async))
+ (-> (System IO)
+ (System Async))
(`` (implementation
(def separator
(of fs separator))
@@ -143,7 +150,9 @@
)))
(def .public (rooted fs parent child)
- (All (_ !) (-> (System !) Path Text Path))
+ (All (_ !)
+ (-> (System !) Path Text
+ Path))
(format parent (of fs separator) child))
(with_template [<name>]
@@ -961,7 +970,9 @@
(these)))
(def .public (exists? monad fs path)
- (All (_ !) (-> (Monad !) (System !) Path (! Bit)))
+ (All (_ !)
+ (-> (Monad !) (System !) Path
+ (! Bit)))
(do monad
[verdict (of fs file? path)]
(if verdict
@@ -983,7 +994,8 @@
(dictionary.empty text.hash))
(def (retrieve_mock_file! separator path mock)
- (-> Text Path Mock (Try [Text Mock_File]))
+ (-> Text Path Mock
+ (Try [Text Mock_File]))
(loop (again [directory mock
trail (text.all_split_by separator path)])
(when trail
@@ -1007,7 +1019,8 @@
(exception.except ..cannot_find_file [path]))))
(def (update_mock_file! / path now content mock)
- (-> Text Path Instant Binary Mock (Try Mock))
+ (-> Text Path Instant Binary Mock
+ (Try Mock))
(loop (again [directory mock
trail (text.all_split_by / path)])
(when trail
@@ -1046,7 +1059,8 @@
(exception.except ..cannot_find_file [path]))))
(def (delete_mock_node! / path mock)
- (-> Text Path Mock (Try Mock))
+ (-> Text Path Mock
+ (Try Mock))
(loop (again [directory mock
trail (text.all_split_by / path)])
(when trail
@@ -1081,7 +1095,9 @@
(exception.except ..cannot_delete [path]))))
(def (attempt! transform var)
- (All (_ a) (-> (-> a (Try a)) (Var a) (STM (Try Any))))
+ (All (_ of)
+ (-> (-> of (Try of)) (Var of)
+ (STM (Try Any))))
(do [! stm.monad]
[|var| (stm.read var)]
(when (transform |var|)
@@ -1094,7 +1110,8 @@
(in {try.#Failure error}))))
(def (make_mock_directory! / path mock)
- (-> Text Path Mock (Try Mock))
+ (-> Text Path Mock
+ (Try Mock))
(loop (again [directory mock
trail (text.all_split_by / path)])
(when trail
@@ -1122,7 +1139,8 @@
(exception.except ..cannot_make_directory [path]))))
(def (retrieve_mock_directory! / path mock)
- (-> Text Path Mock (Try Mock))
+ (-> Text Path Mock
+ (Try Mock))
(loop (again [directory mock
trail (text.all_split_by / path)])
(when trail
@@ -1148,7 +1166,8 @@
(again sub_directory tail)))))))
(def .public (mock separator)
- (-> Text (System Async))
+ (-> Text
+ (System Async))
(let [store (stm.var ..empty_mock)]
(`` (implementation
(def separator
@@ -1288,7 +1307,9 @@
))))
(def (check_or_make_directory monad fs path)
- (All (_ !) (-> (Monad !) (System !) Path (! (Try Any))))
+ (All (_ !)
+ (-> (Monad !) (System !) Path
+ (! (Try Any))))
(do monad
[? (of fs directory? path)]
(if ?
@@ -1296,7 +1317,9 @@
(of fs make_directory path))))
(def .public (make_directories monad fs path)
- (All (_ !) (-> (Monad !) (System !) Path (! (Try Any))))
+ (All (_ !)
+ (-> (Monad !) (System !) Path
+ (! (Try Any))))
(let [rooted? (text.starts_with? (of fs separator) path)
segments (text.all_split_by (of fs separator) path)]
(when (if rooted?
@@ -1328,7 +1351,9 @@
(in {try.#Failure error}))))))))
(def .public (make_file monad fs content path)
- (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any))))
+ (All (_ !)
+ (-> (Monad !) (System !) Binary Path
+ (! (Try Any))))
(do monad
[? (of fs file? path)]
(if ?
@@ -1336,7 +1361,9 @@
(of fs write path content))))
(def .public (copy monad fs from to)
- (All (_ !) (-> (Monad !) (System !) Path Path (! (Try Any))))
+ (All (_ !)
+ (-> (Monad !) (System !) Path Path
+ (! (Try Any))))
(do (try.with monad)
[data (of fs read from)]
(of fs write to data)))