From 6862eb56ff91595318a9a30bab61406ec7407314 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 8 Aug 2020 00:56:35 -0400 Subject: Fixed the last set of bugs involved in JS compilation. --- stdlib/source/lux/world/file.lux | 63 +++++++++++++++++++----------------- stdlib/source/program/compositor.lux | 2 +- 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 [ ] - [(def: + [(def: ( _) + (-> [] (Maybe (-> host.String Any))) (host.constant (-> host.String Any) ))] [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 [ ] - [(def: - (:coerce (..require )))] + [(def: ( _) + (-> [] ) + (:coerce (..require [] )))] [node-fs "fs" ..Fs] [node-path "path" ..JsPath] @@ -488,7 +490,7 @@ [(def: (..can-modify (function ( data) - (io.io ( [path (Buffer::from data)] ..node-fs)))))] + (io.io ( [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 ( _) (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 ( [] 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 ( path) (io.io (do try.monad - [stats (Fs::statSync [path] ..node-fs) + [stats (Fs::statSync [path] (..node-fs [])) verdict ( [] stats)] (if verdict (wrap ( path)) @@ -606,14 +610,15 @@ [(def: (..can-open (function ( path) - (io.io (case (Fs::accessSync [path (|> ..node-fs Fs::constants FsConstants::F_OK)] ..node-fs) - (#try.Success _) - (exception.throw [path]) - - (#try.Failure _) - (do try.monad - [_ (|> ..node-fs )] - (wrap ( 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 [path]) + + (#try.Failure _) + (do try.monad + [_ (|> node-fs )] + (wrap ( 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) -- cgit v1.2.3