Skip to content

Commit 309963d

Browse files
committed
Updates for 0.12
1 parent 11f78ae commit 309963d

File tree

2 files changed

+30
-39
lines changed

2 files changed

+30
-39
lines changed

src/Node/Globals.purs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
-- | documentation](https://nodejs.org/api/globals.html).
33
module Node.Globals where
44

5-
import Control.Monad.Eff
6-
import Node.FS (FS)
5+
import Effect (Effect)
76

87
-- | The name of the directory that the currently executing script resides in.
98
-- |
@@ -24,4 +23,4 @@ foreign import unsafeRequire :: forall a. String -> a
2423
-- | `require.resolve()`. Use the internal `require` machinery to look up the
2524
-- | location of a module, but rather than loading the module, just return the
2625
-- | resolved filename.
27-
foreign import requireResolve :: forall eff. String -> Eff (fs :: FS | eff) String
26+
foreign import requireResolve :: String -> Effect String

src/Node/Process.purs

+28-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- | Bindings to the global `process` object in Node.js. See also [the Node API documentation](https://nodejs.org/api/process.html)
22
module Node.Process
3-
( PROCESS
4-
, onBeforeExit
3+
( onBeforeExit
54
, onExit
65
, onSignal
76
, argv
@@ -25,89 +24,82 @@ module Node.Process
2524

2625
import Prelude
2726

28-
import Control.Monad.Eff (Eff, kind Effect)
29-
import Control.Monad.Eff.Console (CONSOLE)
30-
import Control.Monad.Eff.Exception (EXCEPTION)
27+
import Effect (Effect)
3128

3229
import Data.Maybe (Maybe)
3330
import Data.Posix (Pid)
3431
import Data.Posix.Signal (Signal)
3532
import Data.Posix.Signal as Signal
36-
import Data.StrMap (StrMap)
37-
import Data.StrMap as StrMap
38-
33+
import Foreign.Object as FO
3934
import Node.Platform (Platform)
4035
import Node.Platform as Platform
4136
import Node.Stream (Readable, Writable)
4237

4338
import Unsafe.Coerce (unsafeCoerce)
4439

45-
-- | An effect tracking interaction with the global `process` object.
46-
foreign import data PROCESS :: Effect
47-
4840
-- YOLO
4941
foreign import process :: forall props. { | props }
5042

51-
mkEff :: forall eff a. (Unit -> a) -> Eff eff a
52-
mkEff = unsafeCoerce
43+
mkEffect :: forall a. (Unit -> a) -> Effect a
44+
mkEffect = unsafeCoerce
5345

5446
-- | Register a callback to be performed when the event loop empties, and
5547
-- | Node.js is about to exit. Asynchronous calls can be made in the callback,
5648
-- | and if any are made, it will cause the process to continue a little longer.
57-
foreign import onBeforeExit :: forall eff. Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit
49+
foreign import onBeforeExit :: Effect Unit -> Effect Unit
5850

5951
-- | Register a callback to be performed when the process is about to exit.
6052
-- | Any work scheduled via asynchronous calls made here will not be performed
6153
-- | in time.
6254
-- |
6355
-- | The argument to the callback is the exit code which the process is about
6456
-- | to exit with.
65-
foreign import onExit :: forall eff. (Int -> Eff (process :: PROCESS | eff) Unit) -> Eff (process :: PROCESS | eff) Unit
57+
foreign import onExit :: (Int -> Effect Unit) -> Effect Unit
6658

67-
foreign import onSignalImpl :: forall eff. String -> Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit
59+
foreign import onSignalImpl :: String -> Effect Unit -> Effect Unit
6860

6961
-- | Install a handler for a particular signal.
70-
onSignal :: forall eff. Signal -> Eff (process :: PROCESS | eff) Unit -> Eff (process :: PROCESS | eff) Unit
62+
onSignal :: Signal -> Effect Unit -> Effect Unit
7163
onSignal sig = onSignalImpl (Signal.toString sig)
7264

7365
-- | Register a callback to run as soon as the current event loop runs to
7466
-- | completion.
75-
nextTick :: forall eff. Eff eff Unit -> Eff eff Unit
76-
nextTick callback = mkEff \_ -> process.nextTick callback
67+
nextTick :: Effect Unit -> Effect Unit
68+
nextTick callback = mkEffect \_ -> process.nextTick callback
7769

7870
-- | Get an array containing the command line arguments. Be aware
7971
-- | that this can change over the course of the program.
80-
argv :: forall eff. Eff (process :: PROCESS | eff) (Array String)
81-
argv = mkEff \_ -> process.argv
72+
argv :: Effect (Array String)
73+
argv = mkEffect \_ -> process.argv
8274

8375
-- | Node-specific options passed to the `node` executable. Be aware that
8476
-- | this can change over the course of the program.
85-
execArgv :: forall eff. Eff (process :: PROCESS | eff) (Array String)
86-
execArgv = mkEff \_ -> process.execArgv
77+
execArgv :: Effect (Array String)
78+
execArgv = mkEffect \_ -> process.execArgv
8779

8880
-- | The absolute pathname of the `node` executable that started the
8981
-- | process.
90-
execPath :: forall eff. Eff (process :: PROCESS | eff) String
91-
execPath = mkEff \_ -> process.execPath
82+
execPath :: Effect String
83+
execPath = mkEffect \_ -> process.execPath
9284

9385
-- | Change the current working directory of the process. If the current
9486
-- | directory could not be changed, an exception will be thrown.
95-
foreign import chdir :: forall eff. String -> Eff (exception :: EXCEPTION, process :: PROCESS | eff) Unit
87+
foreign import chdir :: String -> Effect Unit
9688

9789
-- | Get the current working directory of the process.
98-
cwd :: forall eff. Eff (process :: PROCESS | eff) String
90+
cwd :: Effect String
9991
cwd = process.cwd
10092

10193
-- | Get a copy of the current environment.
102-
getEnv :: forall eff. Eff (process :: PROCESS | eff) (StrMap String)
103-
getEnv = mkEff \_ -> process.env
94+
getEnv :: Effect (FO.Object String)
95+
getEnv = mkEffect \_ -> process.env
10496

10597
-- | Lookup a particular environment variable.
106-
lookupEnv :: forall eff. String -> Eff (process :: PROCESS | eff) (Maybe String)
107-
lookupEnv k = StrMap.lookup k <$> getEnv
98+
lookupEnv :: String -> Effect (Maybe String)
99+
lookupEnv k = FO.lookup k <$> getEnv
108100

109101
-- | Set an environment variable.
110-
foreign import setEnv :: forall eff. String -> String -> Eff (process :: PROCESS | eff) Unit
102+
foreign import setEnv :: String -> String -> Effect Unit
111103

112104
pid :: Pid
113105
pid = process.pid
@@ -121,21 +113,21 @@ platformStr = process.platform
121113
-- | Cause the process to exit with the supplied integer code. An exit code
122114
-- | of 0 is normally considered successful, and anything else is considered a
123115
-- | failure.
124-
foreign import exit :: forall eff a. Int -> Eff (process :: PROCESS | eff) a
116+
foreign import exit :: forall a. Int -> Effect a
125117

126118
-- | The standard input stream. Note that this stream will never emit an `end`
127119
-- | event, so any handlers attached via `onEnd` will never be called.
128-
stdin :: forall eff. Readable () (console :: CONSOLE | eff)
120+
stdin :: Readable ()
129121
stdin = process.stdin
130122

131123
-- | The standard output stream. Note that this stream cannot be closed; calling
132124
-- | `end` will result in an exception being thrown.
133-
stdout :: forall eff. Writable () (console :: CONSOLE, exception :: EXCEPTION | eff)
125+
stdout :: Writable ()
134126
stdout = process.stdout
135127

136128
-- | The standard error stream. Note that this stream cannot be closed; calling
137129
-- | `end` will result in an exception being thrown.
138-
stderr :: forall eff. Writable () (console :: CONSOLE, exception :: EXCEPTION | eff)
130+
stderr :: Writable ()
139131
stderr = process.stderr
140132

141133
-- | Check whether the standard output stream appears to be attached to a TTY.

0 commit comments

Comments
 (0)