aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/world/file.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/world/file.lux')
-rw-r--r--stdlib/source/library/lux/world/file.lux170
1 files changed, 85 insertions, 85 deletions
diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux
index 66c125a34..82796463c 100644
--- a/stdlib/source/library/lux/world/file.lux
+++ b/stdlib/source/library/lux/world/file.lux
@@ -84,7 +84,7 @@
#.None
#.None
- (#.Some last_separator)
+ {#.Some last_separator}
(do maybe.monad
[[parent temp] (text.split_at last_separator path)
[_ child] (text.split_at (text.size /) temp)]
@@ -230,7 +230,7 @@
(do [! (try.with io.monad)]
[?children (java/io/File::listFiles (java/io/File::new path))]
(case ?children
- (#.Some children)
+ {#.Some children}
(|> children
(array.list #.None)
(monad.only ! (|>> <method>))
@@ -354,8 +354,8 @@
io.run!
write!
(if (ffi.null? error)
- (#try.Success [])
- (#try.Failure (Error::toString [] (:as Error error))))))
+ {#try.Success []}
+ {#try.Failure (Error::toString [] (:as Error error))})))
(def: (value_callback write!)
(All (_ a) (-> (async.Resolver (Try a)) ffi.Function))
@@ -363,8 +363,8 @@
io.run!
write!
(if (ffi.null? error)
- (#try.Success (:expected datum))
- (#try.Failure (Error::toString [] (:as Error error))))))
+ {#try.Success (:expected datum)}
+ {#try.Failure (Error::toString [] (:as Error error))})))
(ffi.import: JsPath
["[1]::[0]"
@@ -383,9 +383,9 @@
(def: (require _)
(-> [] (-> ffi.String Any))
(case [(normal_require []) (global_require []) (process_load [])]
- (^or [(#.Some require) _ _]
- [_ (#.Some require) _]
- [_ _ (#.Some require)])
+ (^or [{#.Some require} _ _]
+ [_ {#.Some require} _]
+ [_ _ {#.Some require}])
require
_
@@ -418,10 +418,10 @@
(Fs::stat [path (..value_callback write!)]
(..node_fs [])))]
(in (case ?stats
- (#try.Success stats)
+ {#try.Success stats}
(<method> [] stats)
- (#try.Failure _)
+ {#try.Failure _}
false))))]
[file? Stats::isFile]
@@ -437,10 +437,10 @@
(..any_callback write!)]
node_fs))]
(case outcome
- (#try.Success _)
+ {#try.Success _}
(in (exception.except ..cannot_make_directory [path]))
- (#try.Failure _)
+ {#try.Failure _}
(with_async write! (Try Any)
(Fs::mkdir [path (..any_callback write!)] node_fs)))))
@@ -487,10 +487,10 @@
(def: (can_execute? path)
(let [node_fs (..node_fs [])]
(\ async.monad each
- (|>> (case> (#try.Success _)
+ (|>> (case> {#try.Success _}
true
- (#try.Failure _)
+ {#try.Failure _}
false)
#try.Success)
(with_async write! (Try Any)
@@ -733,11 +733,11 @@
#.End
(in output)
- (#.Item head tail)
+ {#.Item head tail}
(do !
[verdict (<test> head)]
(recur tail (if verdict
- (#.Item head output)
+ {#.Item head output}
output)))))
_ (RubyDir::close [] self)]
(in output)))]
@@ -928,11 +928,11 @@
... #.End
... (in output)
- ... (#.Item head tail)
+ ... {#.Item head tail}
... (do !
... [verdict (<test> head)]
... (if verdict
- ... (recur tail (#.Item (<constructor> head) output))
+ ... (recur tail {#.Item (<constructor> head) output})
... (recur tail output)))))))]
... [files ..is_file ..file File]
@@ -956,7 +956,7 @@
... [verdict (<test> path)]
... (\ io.monad in
... (if verdict
- ... (#try.Success (<constructor> path))
+ ... {#try.Success (<constructor> path)}
... (exception.except <exception> [path])))))]
... [file ..is_file ..file ..cannot_find_file]
@@ -968,7 +968,7 @@
... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])]
... (\ io.monad in
... (if verdict
- ... (#try.Success (..file path))
+ ... {#try.Success (..file path)}
... (exception.except ..cannot_make_file [path])))))
... (def: (make_directory path)
@@ -976,7 +976,7 @@
... [verdict (..mkdir path)]
... (\ io.monad in
... (if verdict
- ... (#try.Success (..directory path))
+ ... {#try.Success (..directory path)}
... (exception.except ..cannot_make_directory [path])))))
... (def: separator
@@ -1013,17 +1013,17 @@
(loop [directory mock
trail (text.all_split_by separator path)]
(case trail
- (#.Item head tail)
+ {#.Item head tail}
(case (dictionary.value head directory)
#.None
(exception.except ..cannot_find_file [path])
- (#.Some node)
+ {#.Some node}
(case [node tail]
- [(#.Left file) #.End]
- (#try.Success [head file])
+ [{#.Left file} #.End]
+ {#try.Success [head file]}
- [(#.Right sub_directory) (#.Item _)]
+ [{#.Right sub_directory} {#.Item _}]
(recur sub_directory tail)
_
@@ -1037,33 +1037,33 @@
(loop [directory mock
trail (text.all_split_by / path)]
(case trail
- (#.Item head tail)
+ {#.Item head tail}
(case (dictionary.value head directory)
#.None
(case tail
#.End
- (#try.Success (dictionary.has head
- (#.Left [#mock_last_modified now
+ {#try.Success (dictionary.has head
+ {#.Left [#mock_last_modified now
#mock_can_execute false
- #mock_content content])
- directory))
+ #mock_content content]}
+ directory)}
- (#.Item _)
+ {#.Item _}
(exception.except ..cannot_find_file [path]))
- (#.Some node)
+ {#.Some node}
(case [node tail]
- [(#.Left file) #.End]
- (#try.Success (dictionary.has head
- (#.Left (|> file
+ [{#.Left file} #.End]
+ {#try.Success (dictionary.has head
+ {#.Left (|> file
(with@ #mock_last_modified now)
- (with@ #mock_content content)))
- directory))
+ (with@ #mock_content content))}
+ directory)}
- [(#.Right sub_directory) (#.Item _)]
+ [{#.Right sub_directory} {#.Item _}]
(do try.monad
[sub_directory (recur sub_directory tail)]
- (in (dictionary.has head (#.Right sub_directory) directory)))
+ (in (dictionary.has head {#.Right sub_directory} directory)))
_
(exception.except ..cannot_find_file [path])))
@@ -1076,32 +1076,32 @@
(loop [directory mock
trail (text.all_split_by / path)]
(case trail
- (#.Item head tail)
+ {#.Item head tail}
(case (dictionary.value head directory)
#.None
(exception.except ..cannot_delete [path])
- (#.Some node)
+ {#.Some node}
(case tail
#.End
(case node
- (#.Left file)
- (#try.Success (dictionary.lacks head directory))
+ {#.Left file}
+ {#try.Success (dictionary.lacks head directory)}
- (#.Right sub_directory)
+ {#.Right sub_directory}
(if (dictionary.empty? sub_directory)
- (#try.Success (dictionary.lacks head directory))
+ {#try.Success (dictionary.lacks head directory)}
(exception.except ..cannot_delete [path])))
- (#.Item _)
+ {#.Item _}
(case node
- (#.Left file)
+ {#.Left file}
(exception.except ..cannot_delete [path])
- (#.Right sub_directory)
+ {#.Right sub_directory}
(do try.monad
[sub_directory' (recur sub_directory tail)]
- (in (dictionary.has head (#.Right sub_directory') directory))))))
+ (in (dictionary.has head {#.Right sub_directory'} directory))))))
#.End
(exception.except ..cannot_delete [path]))))
@@ -1111,35 +1111,35 @@
(do [! stm.monad]
[|var| (stm.read var)]
(case (transform |var|)
- (#try.Success |var|)
+ {#try.Success |var|}
(do !
[_ (stm.write |var| var)]
- (in (#try.Success [])))
+ (in {#try.Success []}))
- (#try.Failure error)
- (in (#try.Failure error)))))
+ {#try.Failure error}
+ (in {#try.Failure error}))))
(def: (make_mock_directory! / path mock)
(-> Text Path Mock (Try Mock))
(loop [directory mock
trail (text.all_split_by / path)]
(case trail
- (#.Item head tail)
+ {#.Item head tail}
(case (dictionary.value head directory)
#.None
(case tail
#.End
- (#try.Success (dictionary.has head (#.Right ..empty_mock) directory))
+ {#try.Success (dictionary.has head {#.Right ..empty_mock} directory)}
- (#.Item _)
+ {#.Item _}
(exception.except ..cannot_make_directory [path]))
- (#.Some node)
+ {#.Some node}
(case [node tail]
- [(#.Right sub_directory) (#.Item _)]
+ [{#.Right sub_directory} {#.Item _}]
(do try.monad
[sub_directory (recur sub_directory tail)]
- (in (dictionary.has head (#.Right sub_directory) directory)))
+ (in (dictionary.has head {#.Right sub_directory} directory)))
_
(exception.except ..cannot_make_directory [path])))
@@ -1153,24 +1153,24 @@
trail (text.all_split_by / path)]
(case trail
#.End
- (#try.Success directory)
+ {#try.Success directory}
- (#.Item head tail)
+ {#.Item head tail}
(case (dictionary.value head directory)
#.None
(exception.except ..cannot_find_directory [path])
- (#.Some node)
+ {#.Some node}
(case node
- (#.Left _)
+ {#.Left _}
(exception.except ..cannot_find_directory [path])
- (#.Right sub_directory)
+ {#.Right sub_directory}
(case tail
#.End
- (#try.Success sub_directory)
+ {#try.Success sub_directory}
- (#.Item _)
+ {#.Item _}
(recur sub_directory tail)))))))
(def: .public (mock separator)
@@ -1198,13 +1198,13 @@
(do [! stm.monad]
[|store| (stm.read store)]
(case (..make_mock_directory! separator path |store|)
- (#try.Success |store|)
+ {#try.Success |store|}
(do !
[_ (stm.write |store| store)]
- (in (#try.Success [])))
+ (in {#try.Success []}))
- (#try.Failure error)
- (in (#try.Failure error))))))
+ {#try.Failure error}
+ (in {#try.Failure error})))))
(~~ (template [<method> <tag>]
[(def: (<method> path)
@@ -1217,8 +1217,8 @@
dictionary.entries
(list.all (function (_ [node_name node])
(case node
- (<tag> _)
- (#.Some (format path separator node_name))
+ {<tag> _}
+ {#.Some (format path separator node_name)}
_
#.None))))))))))]
@@ -1304,13 +1304,13 @@
[[name file] (..retrieve_mock_file! separator origin |store|)
|store| (..delete_mock_node! separator origin |store|)]
(..update_mock_file! separator destination (value@ #mock_last_modified file) (value@ #mock_content file) |store|))
- (#try.Success |store|)
+ {#try.Success |store|}
(do !
[_ (stm.write |store| store)]
- (in (#try.Success [])))
+ (in {#try.Success []}))
- (#try.Failure error)
- (in (#try.Failure error))))))
+ {#try.Failure error}
+ (in {#try.Failure error})))))
))))
(def: (check_or_make_directory monad fs path)
@@ -1318,7 +1318,7 @@
(do monad
[? (\ fs directory? path)]
(if ?
- (in (#try.Success []))
+ (in {#try.Success []})
(\ fs make_directory path))))
(def: .public (make_directories monad fs path)
@@ -1331,7 +1331,7 @@
#.End
(\ monad in (exception.except ..cannot_make_directory [path]))
- (#.Item head tail)
+ {#.Item head tail}
(case head
"" (\ monad in (exception.except ..cannot_make_directory [path]))
_ (loop [current (if rooted?
@@ -1341,17 +1341,17 @@
(do monad
[? (..check_or_make_directory monad fs current)]
(case ?
- (#try.Success _)
+ {#try.Success _}
(case next
#.End
- (in (#try.Success []))
+ (in {#try.Success []})
- (#.Item head tail)
+ {#.Item head tail}
(recur (format current (\ fs separator) head)
tail))
- (#try.Failure error)
- (in (#try.Failure error)))))))))
+ {#try.Failure error}
+ (in {#try.Failure error}))))))))
(def: .public (make_file monad fs content path)
(All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any))))