@@ -86,15 +86,13 @@ onSignal sig = onSignalImpl (Signal.toString sig)
8686nextTick :: Effect Unit -> Effect Unit
8787nextTick callback = mkEffect \_ -> process.nextTick callback
8888
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.
9190argv :: Effect (Array String )
92- argv = mkEffect \_ -> process.argv
91+ argv = copyArray process.argv
9392
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.
9694execArgv :: Effect (Array String )
97- execArgv = mkEffect \_ -> process.execArgv
95+ execArgv = copyArray process.execArgv
9896
9997-- | The absolute pathname of the `node` executable that started the
10098-- | process.
@@ -111,11 +109,11 @@ cwd = process.cwd
111109
112110-- | Get a copy of the current environment.
113111getEnv :: Effect (FO.Object String )
114- getEnv = mkEffect \_ -> process.env
112+ getEnv = copyObject process.env
115113
116114-- | Lookup a particular environment variable.
117115lookupEnv :: String -> Effect (Maybe String )
118- lookupEnv k = FO .lookup k <$> getEnv
116+ lookupEnv k = lookupMutableObject k process.env
119117
120118-- | Set an environment variable.
121119foreign import setEnv :: String -> String -> Effect Unit
@@ -168,3 +166,15 @@ stderrIsTTY = process.stderr.isTTY
168166-- | Get the Node.js version.
169167version :: String
170168version = 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