Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'initialized' monad blocks #8

Open
tehsenaus opened this issue Mar 12, 2014 · 0 comments
Open

Add 'initialized' monad blocks #8

tehsenaus opened this issue Mar 12, 2014 · 0 comments

Comments

@tehsenaus
Copy link
Owner

It's possible for monad expressions to have an indeterminate type. E.g:

do {
  if ( X ) << Q(...);
  return "DONE";
}

...evaluates to a promise if X is true, but evaluates to a raw value if X is false.

A workaround for this is to start your monad block with an empty promise:

do { << Q();
  if ( X ) << Q(...);
  return "DONE";
}

...now it will always evaluate to a promise.

This enhancement adds sugar for this, like so:

do (Q) {
  if ( X ) << Q(...);
  return "DONE";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant