Skip to content

Commit

Permalink
return true from canceling if anything was actually canceling (vs: 'e…
Browse files Browse the repository at this point in the history
…verything' semantic)
  • Loading branch information
jdegoes committed Apr 18, 2015
1 parent a66a88e commit 519bcfd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
30 changes: 15 additions & 15 deletions output/examples.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Control/Monad/Aff.purs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ module Control.Monad.Aff
instance monadPlusAff :: MonadPlus (Aff e)

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

instance monoidCanceler :: Monoid (Canceler e) where
mempty = Canceler (const (pure true))
Expand All @@ -164,12 +164,12 @@ module Control.Monad.Aff
return function(e) {
return function(success, error) {
var cancellations = 0;
var result = true;
var result = false;
var errored = false;

var s = function(bool) {
cancellations = cancellations + 1;
result = result && bool;
result = result || bool;

if (cancellations === 2 && !errored) {
try {
Expand Down
16 changes: 8 additions & 8 deletions src/Control/Monad/Aff/AVar.purs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module Control.Monad.Aff.AVar
killVar q e = runFn3 _killVar nonCanceler q e

foreign import _makeVar """
function _makeVar(canceler) {
function _makeVar(nonCanceler) {
return function(success, error) {
try {
success({
Expand All @@ -62,13 +62,13 @@ module Control.Monad.Aff.AVar
error(e);
}

return canceler;
return nonCanceler;
}
}
""" :: forall e a. Canceler e -> AffAVar e (AVar a)

foreign import _takeVar """
function _takeVar(canceler, avar) {
function _takeVar(nonCanceler, avar) {
return function(success, error) {
if (avar.error !== undefined) {
error(avar.error);
Expand All @@ -80,13 +80,13 @@ module Control.Monad.Aff.AVar
avar.consumers.push({success: success, error: error});
}

return canceler;
return nonCanceler;
}
}
""" :: forall e a. Fn2 (Canceler e) (AVar a) (AffAVar e a)

foreign import _putVar """
function _putVar(canceler, avar, a) {
function _putVar(nonCanceler, avar, a) {
return function(success, error) {
if (avar.error !== undefined) {
error(avar.error);
Expand Down Expand Up @@ -114,13 +114,13 @@ module Control.Monad.Aff.AVar
success({});
}

return canceler;
return nonCanceler;
}
}
""" :: forall e a. Fn3 (Canceler e) (AVar a) a (AffAVar e Unit)

foreign import _killVar """
function _killVar(canceler, avar, e) {
function _killVar(nonCanceler, avar, e) {
return function(success, error) {
if (avar.error !== undefined) {
error(avar.error);
Expand All @@ -143,7 +143,7 @@ module Control.Monad.Aff.AVar
else success({});
}

return canceler;
return nonCanceler;
}
}
""" :: forall e a. Fn3 (Canceler e) (AVar a) Error (AffAVar e Unit)
Expand Down

0 comments on commit 519bcfd

Please sign in to comment.