Skip to content

Commit 1440099

Browse files
committed
Make sure effects aren't performed too early
1 parent 50f59c5 commit 1440099

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Node/ChildProcess.purs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ pid :: ChildProcess -> Pid
100100
pid = _.pid <<< runChildProcess
101101

102102
connected :: forall eff. ChildProcess -> Eff (cp :: CHILD_PROCESS | eff) Boolean
103-
connected = pure <<< _.connected <<< runChildProcess
103+
connected (ChildProcess cp) = mkEff \_ -> cp.connected
104104

105105
send :: forall eff props. { | props } -> Handle -> ChildProcess -> Eff (cp :: CHILD_PROCESS | eff) Boolean
106-
send msg handle (ChildProcess cp) = pure (runFn2 cp.send msg handle)
106+
send msg handle (ChildProcess cp) = mkEff \_ -> runFn2 cp.send msg handle
107107

108108
disconnect :: forall eff. ChildProcess -> Eff (cp :: CHILD_PROCESS | eff) Unit
109109
disconnect = _.disconnect <<< runChildProcess
@@ -112,7 +112,10 @@ disconnect = _.disconnect <<< runChildProcess
112112
-- | that this function is called "kill", as sending a signal to a child
113113
-- | process won't necessarily kill it.
114114
kill :: forall eff. Signal -> ChildProcess -> Eff (cp :: CHILD_PROCESS | eff) Boolean
115-
kill sig (ChildProcess cp) = pure (cp.kill (Signal.toString sig))
115+
kill sig (ChildProcess cp) = mkEff \_ -> cp.kill (Signal.toString sig)
116+
117+
mkEff :: forall eff a. (Unit -> a) -> Eff eff a
118+
mkEff = unsafeCoerce
116119

117120
-- | Specifies how a child process exited; normally (with an exit code), or
118121
-- | due to a signal.

0 commit comments

Comments
 (0)