aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/file.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-01-09 12:58:50 -0400
committerEduardo Julian2021-01-09 12:58:50 -0400
commit706ce9e4916b65c4df5101bd3cc1b4da3b2057af (patch)
treefe3f3f6b8d6c6bc5b23045a3113a4f93e6f9b04c /stdlib/source/lux/world/file.lux
parent1ce30d50abaa330ab2125b110e245de6deda27c7 (diff)
Turned I64 and variant creation functions into constructors for JS.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/world/file.lux30
1 files changed, 21 insertions, 9 deletions
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 8e60de863..8882270f8 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -626,15 +626,27 @@
(System IO)
(~~ (template [<name> <method> <capability> <exception>]
- [(def: <name>
- (..can_open
- (function (<name> path)
- (do (try.with io.monad)
- [stats (Fs::statSync [path] (..node_fs []))
- verdict (<method> [] stats)]
- (if verdict
- (wrap (<capability> path))
- (\ io.monad wrap (exception.throw <exception> [path])))))))]
+ [(with_expansions [<failure> (exception.throw <exception> [path])]
+ (def: <name>
+ (..can_open
+ (function (<name> path)
+ (do {! io.monad}
+ [?stats (Fs::statSync [path] (..node_fs []))]
+ (case ?stats
+ (#try.Success stats)
+ (do !
+ [?verdict (<method> [] stats)]
+ (wrap (case ?verdict
+ (#try.Success verdict)
+ (if verdict
+ (#try.Success (<capability> path))
+ <failure>)
+
+ (#try.Failure _)
+ <failure>)))
+
+ (#try.Failure _)
+ (wrap <failure>)))))))]
[file Stats::isFile ..file ..cannot_find_file]
[directory Stats::isDirectory ..directory ..cannot_find_directory]