Skip to content

Commit 519bcfd

Browse files
committed
return true from canceling if anything was actually canceling (vs: 'everything' semantic)
1 parent a66a88e commit 519bcfd

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

output/examples.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Control/Monad/Aff.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module Control.Monad.Aff
151151
instance monadPlusAff :: MonadPlus (Aff e)
152152

153153
instance semigroupCanceler :: Semigroup (Canceler e) where
154-
(<>) (Canceler f1) (Canceler f2) = Canceler (\e -> (&&) <$> f1 e <*> f2 e)
154+
(<>) (Canceler f1) (Canceler f2) = Canceler (\e -> (||) <$> f1 e <*> f2 e)
155155

156156
instance monoidCanceler :: Monoid (Canceler e) where
157157
mempty = Canceler (const (pure true))
@@ -164,12 +164,12 @@ module Control.Monad.Aff
164164
return function(e) {
165165
return function(success, error) {
166166
var cancellations = 0;
167-
var result = true;
167+
var result = false;
168168
var errored = false;
169169
170170
var s = function(bool) {
171171
cancellations = cancellations + 1;
172-
result = result && bool;
172+
result = result || bool;
173173
174174
if (cancellations === 2 && !errored) {
175175
try {

src/Control/Monad/Aff/AVar.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module Control.Monad.Aff.AVar
5050
killVar q e = runFn3 _killVar nonCanceler q e
5151

5252
foreign import _makeVar """
53-
function _makeVar(canceler) {
53+
function _makeVar(nonCanceler) {
5454
return function(success, error) {
5555
try {
5656
success({
@@ -62,13 +62,13 @@ module Control.Monad.Aff.AVar
6262
error(e);
6363
}
6464
65-
return canceler;
65+
return nonCanceler;
6666
}
6767
}
6868
""" :: forall e a. Canceler e -> AffAVar e (AVar a)
6969

7070
foreign import _takeVar """
71-
function _takeVar(canceler, avar) {
71+
function _takeVar(nonCanceler, avar) {
7272
return function(success, error) {
7373
if (avar.error !== undefined) {
7474
error(avar.error);
@@ -80,13 +80,13 @@ module Control.Monad.Aff.AVar
8080
avar.consumers.push({success: success, error: error});
8181
}
8282
83-
return canceler;
83+
return nonCanceler;
8484
}
8585
}
8686
""" :: forall e a. Fn2 (Canceler e) (AVar a) (AffAVar e a)
8787

8888
foreign import _putVar """
89-
function _putVar(canceler, avar, a) {
89+
function _putVar(nonCanceler, avar, a) {
9090
return function(success, error) {
9191
if (avar.error !== undefined) {
9292
error(avar.error);
@@ -114,13 +114,13 @@ module Control.Monad.Aff.AVar
114114
success({});
115115
}
116116
117-
return canceler;
117+
return nonCanceler;
118118
}
119119
}
120120
""" :: forall e a. Fn3 (Canceler e) (AVar a) a (AffAVar e Unit)
121121

122122
foreign import _killVar """
123-
function _killVar(canceler, avar, e) {
123+
function _killVar(nonCanceler, avar, e) {
124124
return function(success, error) {
125125
if (avar.error !== undefined) {
126126
error(avar.error);
@@ -143,7 +143,7 @@ module Control.Monad.Aff.AVar
143143
else success({});
144144
}
145145
146-
return canceler;
146+
return nonCanceler;
147147
}
148148
}
149149
""" :: forall e a. Fn3 (Canceler e) (AVar a) Error (AffAVar e Unit)

0 commit comments

Comments
 (0)