diff --git a/.travis.yml b/.travis.yml index 78cde3d..f5aa859 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,14 @@ language: node_js dist: trusty sudo: required -node_js: 6 +node_js: 8 +env: + - PATH=$HOME/purescript:$PATH install: + - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') + - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz + - tar -xvf $HOME/purescript.tar.gz -C $HOME/ + - chmod a+x $HOME/purescript - npm install -g bower - npm install - bower install --production diff --git a/bower.json b/bower.json index 0300eb7..7834a29 100644 --- a/bower.json +++ b/bower.json @@ -12,14 +12,12 @@ "output" ], "dependencies": { - "purescript-console": "^3.0.0", - "purescript-exceptions": "^3.0.0", - "purescript-maps": "^3.0.0", - "purescript-maybe": "^3.0.0", - "purescript-node-fs": "^4.0.0", - "purescript-node-streams": "^3.0.0", - "purescript-posix-types": "^3.0.0", - "purescript-unsafe-coerce": "^3.0.0", - "purescript-partial": "^1.2.0" + "purescript-effect": "^2.0.0", + "purescript-foreign-object": "^1.0.0", + "purescript-maybe": "^4.0.0", + "purescript-node-streams": "^4.0.0", + "purescript-posix-types": "^4.0.0", + "purescript-unsafe-coerce": "^4.0.0", + "purescript-prelude": "^4.0.0" } } diff --git a/package.json b/package.json index 2bbc80f..2e21753 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,9 @@ }, "devDependencies": { "jscs": "^3.0.7", - "jshint": "^2.9.4", - "pulp": "^11.0.0", - "purescript-psa": "^0.5.0", - "purescript": "^0.11.1", - "rimraf": "^2.5.4" + "jshint": "^2.9.5", + "pulp": "^12.2.0", + "purescript-psa": "^0.6.0", + "rimraf": "^2.6.2" } } diff --git a/src/Node/Globals.purs b/src/Node/Globals.purs index 815d33e..624bb10 100644 --- a/src/Node/Globals.purs +++ b/src/Node/Globals.purs @@ -2,8 +2,7 @@ -- | documentation](https://nodejs.org/api/globals.html). module Node.Globals where -import Control.Monad.Eff -import Node.FS (FS) +import Effect (Effect) -- | The name of the directory that the currently executing script resides in. -- | @@ -24,4 +23,4 @@ foreign import unsafeRequire :: forall a. String -> a -- | `require.resolve()`. Use the internal `require` machinery to look up the -- | location of a module, but rather than loading the module, just return the -- | resolved filename. -foreign import requireResolve :: forall eff. String -> Eff (fs :: FS | eff) String +foreign import requireResolve :: String -> Effect String diff --git a/src/Node/Process.purs b/src/Node/Process.purs index d980e2c..e8d28d1 100644 --- a/src/Node/Process.purs +++ b/src/Node/Process.purs @@ -1,7 +1,6 @@ -- | Bindings to the global `process` object in Node.js. See also [the Node API documentation](https://nodejs.org/api/process.html) module Node.Process - ( PROCESS - , onBeforeExit + ( onBeforeExit , onExit , onSignal , argv @@ -25,36 +24,29 @@ module Node.Process import Prelude -import Control.Monad.Eff (Eff, kind Effect) -import Control.Monad.Eff.Console (CONSOLE) -import Control.Monad.Eff.Exception (EXCEPTION) +import Effect (Effect) import Data.Maybe (Maybe) import Data.Posix (Pid) import Data.Posix.Signal (Signal) import Data.Posix.Signal as Signal -import Data.StrMap (StrMap) -import Data.StrMap as StrMap - +import Foreign.Object as FO import Node.Platform (Platform) import Node.Platform as Platform import Node.Stream (Readable, Writable) import Unsafe.Coerce (unsafeCoerce) --- | An effect tracking interaction with the global `process` object. -foreign import data PROCESS :: Effect - -- YOLO foreign import process :: forall props. { | props } -mkEff :: forall eff a. (Unit -> a) -> Eff eff a -mkEff = unsafeCoerce +mkEffect :: forall a. (Unit -> a) -> Effect a +mkEffect = unsafeCoerce -- | Register a callback to be performed when the event loop empties, and -- | Node.js is about to exit. Asynchronous calls can be made in the callback, -- | and if any are made, it will cause the process to continue a little longer. -foreign import onBeforeExit :: forall eff. Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit +foreign import onBeforeExit :: Effect Unit -> Effect Unit -- | Register a callback to be performed when the process is about to exit. -- | Any work scheduled via asynchronous calls made here will not be performed @@ -62,52 +54,52 @@ foreign import onBeforeExit :: forall eff. Eff (process :: PROCESS | eff) Unit - -- | -- | The argument to the callback is the exit code which the process is about -- | to exit with. -foreign import onExit :: forall eff. (Int -> Eff (process :: PROCESS | eff) Unit) -> Eff (process :: PROCESS | eff) Unit +foreign import onExit :: (Int -> Effect Unit) -> Effect Unit -foreign import onSignalImpl :: forall eff. String -> Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit +foreign import onSignalImpl :: String -> Effect Unit -> Effect Unit -- | Install a handler for a particular signal. -onSignal :: forall eff. Signal -> Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit +onSignal :: Signal -> Effect Unit -> Effect Unit onSignal sig = onSignalImpl (Signal.toString sig) -- | Register a callback to run as soon as the current event loop runs to -- | completion. -nextTick :: forall eff. Eff eff Unit -> Eff eff Unit -nextTick callback = mkEff \_ -> process.nextTick callback +nextTick :: Effect Unit -> Effect Unit +nextTick callback = mkEffect \_ -> process.nextTick callback -- | Get an array containing the command line arguments. Be aware -- | that this can change over the course of the program. -argv :: forall eff. Eff (process :: PROCESS | eff) (Array String) -argv = mkEff \_ -> process.argv +argv :: Effect (Array String) +argv = mkEffect \_ -> process.argv -- | Node-specific options passed to the `node` executable. Be aware that -- | this can change over the course of the program. -execArgv :: forall eff. Eff (process :: PROCESS | eff) (Array String) -execArgv = mkEff \_ -> process.execArgv +execArgv :: Effect (Array String) +execArgv = mkEffect \_ -> process.execArgv -- | The absolute pathname of the `node` executable that started the -- | process. -execPath :: forall eff. Eff (process :: PROCESS | eff) String -execPath = mkEff \_ -> process.execPath +execPath :: Effect String +execPath = mkEffect \_ -> process.execPath -- | Change the current working directory of the process. If the current -- | directory could not be changed, an exception will be thrown. -foreign import chdir :: forall eff. String -> Eff (exception :: EXCEPTION, process :: PROCESS | eff) Unit +foreign import chdir :: String -> Effect Unit -- | Get the current working directory of the process. -cwd :: forall eff. Eff (process :: PROCESS | eff) String +cwd :: Effect String cwd = process.cwd -- | Get a copy of the current environment. -getEnv :: forall eff. Eff (process :: PROCESS | eff) (StrMap String) -getEnv = mkEff \_ -> process.env +getEnv :: Effect (FO.Object String) +getEnv = mkEffect \_ -> process.env -- | Lookup a particular environment variable. -lookupEnv :: forall eff. String -> Eff (process :: PROCESS | eff) (Maybe String) -lookupEnv k = StrMap.lookup k <$> getEnv +lookupEnv :: String -> Effect (Maybe String) +lookupEnv k = FO.lookup k <$> getEnv -- | Set an environment variable. -foreign import setEnv :: forall eff. String -> String -> Eff (process :: PROCESS | eff) Unit +foreign import setEnv :: String -> String -> Effect Unit pid :: Pid pid = process.pid @@ -121,21 +113,21 @@ platformStr = process.platform -- | Cause the process to exit with the supplied integer code. An exit code -- | of 0 is normally considered successful, and anything else is considered a -- | failure. -foreign import exit :: forall eff a. Int -> Eff (process :: PROCESS | eff) a +foreign import exit :: forall a. Int -> Effect a -- | The standard input stream. Note that this stream will never emit an `end` -- | event, so any handlers attached via `onEnd` will never be called. -stdin :: forall eff. Readable () (console :: CONSOLE | eff) +stdin :: Readable () stdin = process.stdin -- | The standard output stream. Note that this stream cannot be closed; calling -- | `end` will result in an exception being thrown. -stdout :: forall eff. Writable () (console :: CONSOLE, exception :: EXCEPTION | eff) +stdout :: Writable () stdout = process.stdout -- | The standard error stream. Note that this stream cannot be closed; calling -- | `end` will result in an exception being thrown. -stderr :: forall eff. Writable () (console :: CONSOLE, exception :: EXCEPTION | eff) +stderr :: Writable () stderr = process.stderr -- | Check whether the standard output stream appears to be attached to a TTY.