aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/data/format/tar.lux29
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache/module.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/export.lux2
-rw-r--r--stdlib/source/library/lux/world/file.lux40
6 files changed, 39 insertions, 38 deletions
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux
index 4fb3522a6..debbba560 100644
--- a/stdlib/source/library/lux/data/format/tar.lux
+++ b/stdlib/source/library/lux/data/format/tar.lux
@@ -1,6 +1,7 @@
(.using
[library
[lux {"-" Mode and}
+ [ffi {"+"}]
[abstract
[monad {"+" do}]]
[control
@@ -11,7 +12,8 @@
["<[0]>" binary {"+" Parser}]]]
[data
["[0]" product]
- ["[0]" binary {"+" Binary}]
+ ["[0]" binary {"+" Binary}
+ ["[1]!" \\unsafe]]
["[0]" text {"+" Char}
["%" format {"+" format}]
[encoding
@@ -122,10 +124,11 @@
(Parser Any)
(do <>.monad
[pre_end <binary>.bits_8
- end <binary>.bits_8
_ (let [expected (`` (char (~~ (static ..blank))))]
(<>.assertion (exception.error ..wrong_character [expected pre_end])
(n.= expected pre_end)))
+
+ end <binary>.bits_8
_ (let [expected (`` (char (~~ (static ..null))))]
(<>.assertion (exception.error ..wrong_character [expected end])
(n.= expected end)))]
@@ -230,20 +233,19 @@
(def: .public path_size Size 99)
(def: (un_padded string)
- (-> Binary (Try Binary))
- (case (binary.size string)
- 0 {try.#Success string}
+ (-> Binary Binary)
+ (case (binary!.size string)
+ 0 string
size (loop (again [end (-- size)])
(case end
- 0 {try.#Success (# utf8.codec encoded "")}
- _ (do try.monad
- [last_char (binary.bits_8 end string)]
+ 0 (# utf8.codec encoded "")
+ _ (let [last_char (binary!.bits_8 end string)]
(`` (case (.nat last_char)
(pattern (char (~~ (static ..null))))
(again (-- end))
_
- (binary.slice 0 (++ end) string))))))))
+ (binary!.slice 0 (++ end) string))))))))
(template [<type> <representation> <size> <exception> <in> <out> <writer> <parser> <none>]
[(abstract: .public <type>
@@ -260,7 +262,7 @@
(if (..ascii? value)
(if (|> value
(# utf8.codec encoded)
- binary.size
+ binary!.size
(n.> <size>))
(exception.except <exception> [value])
{try.#Success (abstraction value)})
@@ -289,8 +291,7 @@
(n.= expected end))]
(<>.lifted
(do [! try.monad]
- [ascii (..un_padded string)
- text (# utf8.codec decoded ascii)]
+ [text (# utf8.codec decoded (..un_padded string))]
(<in> text)))))
(def: .public <none>
@@ -533,7 +534,7 @@
(def: .public (content content)
(-> Binary (Try Content))
(do try.monad
- [size (..big (binary.size content))]
+ [size (..big (binary!.size content))]
(in (abstraction [size content]))))
(def: from_content
@@ -735,7 +736,7 @@
(def: .public writer
(Writer Tar)
- (let [end_of_archive (binary.empty ..end_of_archive_size)]
+ (let [end_of_archive (binary!.empty ..end_of_archive_size)]
(function (_ tar)
(format#composite (sequence#mix (function (_ next total)
(format#composite total (..entry_writer next)))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux
index 28abd457a..c31f86f25 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux
@@ -21,4 +21,4 @@
(def: .public (cache! fs context it)
(All (_ !) (-> (file.System !) Context Archive (! (Try Any))))
- (# fs write (archive.export ///.version it) (..descriptor fs context)))
+ (# fs write (..descriptor fs context) (archive.export ///.version it)))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux
index ca2689c18..5917e328b 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux
@@ -36,4 +36,4 @@
(def: .public (cache! fs context @module @artifact content)
(All (_ !)
(-> (file.System !) Context module.ID artifact.ID Binary (! (Try Any))))
- (# fs write content (..path fs context @module @artifact)))
+ (# fs write (..path fs context @module @artifact) content))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
index 869aa2019..426a68589 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
@@ -80,7 +80,7 @@
(def: .public (cache! fs context @module content)
(All (_ !) (-> (file.System !) Context module.ID Binary (! (Try Any))))
- (# fs write content (..descriptor fs context @module)))
+ (# fs write (..descriptor fs context @module) content))
(def: .public (cache fs context @module)
(All (_ !) (-> (file.System !) Context module.ID (! (Try Binary))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/export.lux b/stdlib/source/library/lux/tool/compiler/meta/export.lux
index 7eb36ad62..4fdc63159 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/export.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/export.lux
@@ -71,4 +71,4 @@
(..library fs)
(# ! each (binary.result tar.writer)))
.let [/ (# fs separator)]]
- (# fs write tar (format target / ..file))))
+ (# fs write (format target / ..file) tar)))
diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux
index d04f8c052..820ab92e0 100644
--- a/stdlib/source/library/lux/world/file.lux
+++ b/stdlib/source/library/lux/world/file.lux
@@ -70,7 +70,7 @@
))
(~~ (template [<name> <input>]
- [(is (-> <input> Path (! (Try Any)))
+ [(is (-> Path <input> (! (Try Any)))
<name>)]
[modify Instant]
@@ -131,8 +131,8 @@
[delete]))
(~~ (template [<name>]
- [(def: (<name> input path)
- (async.future (# fs <name> input path)))]
+ [(def: (<name> path input)
+ (async.future (# fs <name> path input)))]
[modify]
[write]
@@ -275,14 +275,14 @@
java/io/File::new
java/io/File::delete))
- (def: (modify time_stamp path)
+ (def: (modify path time_stamp)
(|> path
ffi.as_string
java/io/File::new
(java/io/File::setLastModified (|> time_stamp instant.relative duration.millis ffi.as_long))))
(~~ (template [<flag> <name>]
- [(def: (<name> data path)
+ [(def: (<name> path data)
(do (try.with io.monad)
[stream (java/io/FileOutputStream::new (java/io/File::new (ffi.as_string path)) (ffi.as_boolean <flag>))
_ (java/io/OutputStream::write data stream)
@@ -293,7 +293,7 @@
[#1 append]
))
- (def: (move destination origin)
+ (def: (move origin destination)
(|> origin
ffi.as_string
java/io/File::new
@@ -487,14 +487,14 @@
(Fs::unlink path (..any_callback write!) node_fs)
(Fs::rmdir path (..any_callback write!) node_fs)))))
- (def: (modify time_stamp path)
+ (def: (modify path time_stamp)
(with_async write! (Try Any)
(let [when (|> time_stamp instant.relative duration.millis i.frac)]
(Fs::utimes path when when (..any_callback write!)
node_fs))))
(~~ (template [<name> <method>]
- [(def: (<name> data path)
+ [(def: (<name> path data)
(with_async write! (Try Any)
(<method> path (Buffer::from data) (..any_callback write!)
node_fs)))]
@@ -503,7 +503,7 @@
[append Fs::appendFile]
))
- (def: (move destination origin)
+ (def: (move origin destination)
(with_async write! (Try Any)
(Fs::rename origin destination (..any_callback write!)
node_fs))))))))))
@@ -610,12 +610,12 @@
(os::remove path)
(os::rmdir path))))
- (def: (modify time_stamp path)
+ (def: (modify path time_stamp)
(let [when (|> time_stamp instant.relative duration.millis (i./ +1,000))]
(os::utime path (..tuple [when when]))))
(~~ (template [<name> <mode>]
- [(def: (<name> data path)
+ [(def: (<name> path data)
(do (try.with io.monad)
[file (..open path <mode>)
_ (PyFile::write data file)]
@@ -625,7 +625,7 @@
[append "ab"]
))
- (def: (move destination origin)
+ (def: (move origin destination)
(os::rename origin destination))
)))
@@ -748,7 +748,7 @@
(RubyFile::delete path)
(FileUtils::rmdir path))))
- (def: (modify moment path)
+ (def: (modify path moment)
(let [moment (|> moment
instant.relative
duration.millis
@@ -758,7 +758,7 @@
(RubyFile::utime moment moment path)))
(~~ (template [<mode> <name>]
- [(def: (<name> data path)
+ [(def: (<name> path data)
(do [! (try.with io.monad)]
[file (RubyFile::open path <mode>)
data (RubyFile::write data file)
@@ -770,7 +770,7 @@
["ab" append]
))
- (def: (move destination origin)
+ (def: (move origin destination)
(do (try.with io.monad)
[_ (FileUtils::move origin destination)]
(in [])))
@@ -1240,7 +1240,7 @@
(stm.commit!
(..attempt! (..delete_mock_node! separator path) store)))
- (def: (modify now path)
+ (def: (modify path now)
(stm.commit!
(..attempt! (function (_ |store|)
(do try.monad
@@ -1248,13 +1248,13 @@
(..update_mock_file! separator path now (the #mock_content file) |store|)))
store)))
- (def: (write content path)
+ (def: (write path content)
(do async.monad
[now (async.future instant.now)]
(stm.commit!
(..attempt! (..update_mock_file! separator path now content) store))))
- (def: (append content path)
+ (def: (append path content)
(do async.monad
[now (async.future instant.now)]
(stm.commit!
@@ -1268,7 +1268,7 @@
|store|)))
store))))
- (def: (move destination origin)
+ (def: (move origin destination)
(stm.commit!
(do [! stm.monad]
[|store| (stm.read store)]
@@ -1331,4 +1331,4 @@
[? (# fs file? path)]
(if ?
(in (exception.except ..cannot_make_file [path]))
- (# fs write content path))))
+ (# fs write path content))))