aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/world/file.lux63
-rw-r--r--stdlib/source/program/compositor.lux2
2 files changed, 35 insertions, 30 deletions
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 2d41f7d75..88ddeb237 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -454,7 +454,8 @@
(basename [host.String] host.String))
(template [<name> <path>]
- [(def: <name>
+ [(def: (<name> _)
+ (-> [] (Maybe (-> host.String Any)))
(host.constant (-> host.String Any) <path>))]
[normal-require [require]]
@@ -462,9 +463,9 @@
[process-load [global process mainModule constructor _load]]
)
- (def: require
- (-> host.String Any)
- (case [normal-require global-require process-load]
+ (def: (require _)
+ (-> [] (-> host.String Any))
+ (case [(normal-require []) (global-require []) (process-load [])]
(^or [(#.Some require) _ _]
[_ (#.Some require) _]
[_ _ (#.Some require)])
@@ -474,8 +475,9 @@
(undefined)))
(template [<name> <module> <type>]
- [(def: <name>
- (:coerce <type> (..require <module>)))]
+ [(def: (<name> _)
+ (-> [] <type>)
+ (:coerce <type> (..require [] <module>)))]
[node-fs "fs" ..Fs]
[node-path "path" ..JsPath]
@@ -488,7 +490,7 @@
[(def: <name>
(..can-modify
(function (<name> data)
- (io.io (<method> [path (Buffer::from data)] ..node-fs)))))]
+ (io.io (<method> [path (Buffer::from data)] (..node-fs []))))))]
[over-write Fs::writeFileSync]
[append Fs::appendFileSync]
@@ -497,12 +499,12 @@
(def: content
(..can-query
(function (_ _)
- (io.io (Fs::readFileSync [path] ..node-fs)))))
+ (io.io (Fs::readFileSync [path] (..node-fs []))))))
(def: name
(..can-see
(function (_ _)
- (JsPath::basename path ..node-path))))
+ (JsPath::basename path (..node-path [])))))
(def: path
(..can-see
@@ -512,14 +514,14 @@
(def: size
(..can-query
(function (size _)
- (|> (Fs::statSync [path] ..node-fs)
+ (|> (Fs::statSync [path] (..node-fs []))
(:: try.monad map (|>> Stats::size f.nat))
io.io))))
(def: last-modified
(..can-query
(function (last-modified _)
- (|> (Fs::statSync [path] ..node-fs)
+ (|> (Fs::statSync [path] (..node-fs []))
(:: try.monad map (|>> Stats::mtimeMs
f.int
duration.from-millis
@@ -530,8 +532,9 @@
(..can-query
(function (can-execute? _)
(io.io (do try.monad
- [_ (Fs::accessSync [path (|> ..node-fs Fs::constants FsConstants::F_OK)] ..node-fs)]
- (wrap (case (Fs::accessSync [path (|> ..node-fs Fs::constants FsConstants::X_OK)] ..node-fs)
+ [#let [node-fs (..node-fs [])]
+ _ (Fs::accessSync [path (|> node-fs Fs::constants FsConstants::F_OK)] node-fs)]
+ (wrap (case (Fs::accessSync [path (|> node-fs Fs::constants FsConstants::X_OK)] node-fs)
(#try.Success _)
true
@@ -542,19 +545,19 @@
(..can-open
(function (move destination)
(io.io (do try.monad
- [_ (Fs::renameSync [path destination] ..node-fs)]
+ [_ (Fs::renameSync [path destination] (..node-fs []))]
(wrap (file destination)))))))
(def: modify
(..can-modify
(function (modify time-stamp)
(io.io (let [when (|> time-stamp instant.relative duration.to-millis i.frac)]
- (Fs::utimesSync [path when when] ..node-fs))))))
+ (Fs::utimesSync [path when when] (..node-fs [])))))))
(def: delete
(..can-delete
(function (delete _)
- (io.io (Fs::unlink [path] ..node-fs)))))))
+ (io.io (Fs::unlink [path] (..node-fs []))))))))
(`` (structure: (directory path)
(-> Path (Directory IO))
@@ -564,10 +567,11 @@
(..can-query
(function (<name> _)
(io.io (do {@ try.monad}
- [subs (Fs::readdirSync [path] ..node-fs)
+ [#let [node-fs (..node-fs [])]
+ subs (Fs::readdirSync [path] node-fs)
subs (monad.map @ (function (_ sub)
(do @
- [stats (Fs::statSync [sub] ..node-fs)
+ [stats (Fs::statSync [sub] node-fs)
verdict (<method> [] stats)]
(wrap [verdict sub])))
(array.to-list subs))]
@@ -582,7 +586,7 @@
(def: discard
(..can-delete
(function (discard _)
- (io.io (Fs::rmdirSync [path] ..node-fs)))))))
+ (io.io (Fs::rmdirSync [path] (..node-fs []))))))))
(`` (structure: #export system
(System IO)
@@ -592,7 +596,7 @@
(..can-open
(function (<name> path)
(io.io (do try.monad
- [stats (Fs::statSync [path] ..node-fs)
+ [stats (Fs::statSync [path] (..node-fs []))
verdict (<method> [] stats)]
(if verdict
(wrap (<capability> path))
@@ -606,14 +610,15 @@
[(def: <name>
(..can-open
(function (<name> path)
- (io.io (case (Fs::accessSync [path (|> ..node-fs Fs::constants FsConstants::F_OK)] ..node-fs)
- (#try.Success _)
- (exception.throw <exception> [path])
-
- (#try.Failure _)
- (do try.monad
- [_ (|> ..node-fs <prep>)]
- (wrap (<capability> path))))))))]
+ (io.io (let [node-fs (..node-fs [])]
+ (case (Fs::accessSync [path (|> node-fs Fs::constants FsConstants::F_OK)] node-fs)
+ (#try.Success _)
+ (exception.throw <exception> [path])
+
+ (#try.Failure _)
+ (do try.monad
+ [_ (|> node-fs <prep>)]
+ (wrap (<capability> path)))))))))]
[create-file ..file ..cannot-create-file (Fs::appendFileSync [path (Buffer::from (binary.create 0))])]
[create-directory ..directory ..cannot-create-directory (Fs::mkdirSync [path])]
@@ -621,7 +626,7 @@
(def: separator
(if host.on-node-js?
- (JsPath::sep ..node-path)
+ (JsPath::sep (..node-path []))
"/"))
))
)
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index 95ad2c771..d551f61f2 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -94,7 +94,7 @@
(:assume
(: (Promise (Try Any))
(let [monad (:coerce (Monad Promise) monad)
- file-system (:coerce (file.System Promise) monad)
+ file-system (:coerce (file.System Promise) file-system)
packager (:coerce (Packager Promise) packager)]
(do (try.with monad)
[content (packager monad file-system static archive context)