Skip to content

Commit 4f04c8a

Browse files
committed
Provide result to bracket completed
1 parent 5320f7e commit 4f04c8a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Control/Monad/Aff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ function runFiber(util, suspended, aff, completeCb) {
511511
} else if (fail !== null) {
512512
step = attempt._1.failed(util.fromLeft(fail))(attempt._2);
513513
} else {
514-
step = attempt._1.completed(attempt._2);
514+
step = attempt._1.completed(util.fromRight(step))(attempt._2);
515515
}
516516
break;
517517

src/Control/Monad/Aff.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ bracket acquire completed =
255255
generalBracket acquire
256256
{ killed: const completed
257257
, failed: const completed
258-
, completed
258+
, completed: const completed
259259
}
260260

261261
foreign import _pure eff a. a Aff eff a
@@ -270,16 +270,16 @@ foreign import _parAffMap ∷ ∀ eff a b. (a → b) → ParAff eff a → ParAff
270270
foreign import _parAffApply eff a b. ParAff eff (a b) ParAff eff a ParAff eff b
271271
foreign import _parAffAlt eff a. ParAff eff a ParAff eff a ParAff eff a
272272

273-
type BracketConditions eff a =
273+
type BracketConditions eff a b =
274274
{ killed Error a Aff eff Unit
275275
, failed Error a Aff eff Unit
276-
, completed a Aff eff Unit
276+
, completed b a Aff eff Unit
277277
}
278278

279279
-- | A general purpose bracket which lets you observe the status of the
280280
-- | bracketed action. The bracketed action may have been killed with an
281281
-- | exception, thrown an exception, or completed successfully.
282-
foreign import generalBracket eff a b. Aff eff a BracketConditions eff a (a Aff eff b) Aff eff b
282+
foreign import generalBracket eff a b. Aff eff a BracketConditions eff a b (a Aff eff b) Aff eff b
283283

284284
-- | Constructs an `Aff` from low-level `Eff` effects using a callback. A
285285
-- | `Canceler` effect should be returned to cancel the pending action. The

test/Test/Main.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ test_general_bracket = assert "bracket/general" do
237237
generalBracket (action s)
238238
{ killed: \error s' → void $ action (s' <> "/kill/" <> message error)
239239
, failed: \error s' → void $ action (s' <> "/throw/" <> message error)
240-
, completed: \s' → void $ action (s' <> "/release")
240+
, completed: \r s' → void $ action (s' <> "/release/" <> r)
241241
}
242242

243243
f1 ← forkAff $ bracketAction "foo" (const (action "a"))
@@ -251,7 +251,7 @@ test_general_bracket = assert "bracket/general" do
251251
r3 ← try $ joinFiber f3
252252

253253
r4 ← readRef ref
254-
pure (isLeft r1 && isLeft r2 && isRight r3 && r4 == "foofoo/kill/zbarbar/throw/bbazcbaz/release")
254+
pure (isLeft r1 && isLeft r2 && isRight r3 && r4 == "foofoo/kill/zbarbar/throw/bbazcbaz/release/c")
255255

256256
test_kill eff. TestAff eff Unit
257257
test_kill = assert "kill" do
@@ -324,7 +324,7 @@ test_kill_child = assert "kill/child" do
324324
(modifyRef ref (_ <> "acquire" <> s))
325325
{ failed: \_ _ → modifyRef ref (_ <> "throw" <> s)
326326
, killed: \_ _ → modifyRef ref (_ <> "kill" <> s)
327-
, completed: \_ → modifyRef ref (_ <> "complete" <> s)
327+
, completed: \_ _ → modifyRef ref (_ <> "complete" <> s)
328328
}
329329
(\_ -> do
330330
delay (Milliseconds 10.0)

0 commit comments

Comments
 (0)