@@ -86,15 +86,13 @@ onSignal sig = onSignalImpl (Signal.toString sig)
86
86
nextTick :: Effect Unit -> Effect Unit
87
87
nextTick callback = mkEffect \_ -> process.nextTick callback
88
88
89
- -- | Get an array containing the command line arguments. Be aware
90
- -- | that this can change over the course of the program.
89
+ -- | Get an array containing the command line arguments.
91
90
argv :: Effect (Array String )
92
- argv = mkEffect \_ -> process.argv
91
+ argv = copyArray process.argv
93
92
94
- -- | Node-specific options passed to the `node` executable. Be aware that
95
- -- | this can change over the course of the program.
93
+ -- | Node-specific options passed to the `node` executable.
96
94
execArgv :: Effect (Array String )
97
- execArgv = mkEffect \_ -> process.execArgv
95
+ execArgv = copyArray process.execArgv
98
96
99
97
-- | The absolute pathname of the `node` executable that started the
100
98
-- | process.
@@ -111,11 +109,11 @@ cwd = process.cwd
111
109
112
110
-- | Get a copy of the current environment.
113
111
getEnv :: Effect (FO.Object String )
114
- getEnv = mkEffect \_ -> process.env
112
+ getEnv = copyObject process.env
115
113
116
114
-- | Lookup a particular environment variable.
117
115
lookupEnv :: String -> Effect (Maybe String )
118
- lookupEnv k = FO .lookup k <$> getEnv
116
+ lookupEnv k = lookupMutableObject k process.env
119
117
120
118
-- | Set an environment variable.
121
119
foreign import setEnv :: String -> String -> Effect Unit
@@ -168,3 +166,15 @@ stderrIsTTY = process.stderr.isTTY
168
166
-- | Get the Node.js version.
169
167
version :: String
170
168
version = process.version
169
+
170
+ -- Utils
171
+
172
+ foreign import data MutableArray :: Type -> Type
173
+ foreign import data MutableObject :: Type -> Type
174
+
175
+ foreign import copyArray :: forall a . MutableArray a -> Effect (Array a )
176
+ foreign import copyObject :: forall a . MutableObject a -> Effect (FO.Object a )
177
+
178
+ lookupMutableObject :: forall a . String -> MutableObject a -> Effect (Maybe a )
179
+ lookupMutableObject k o =
180
+ mkEffect \_ -> FO .lookup k (unsafeCoerce o)
0 commit comments