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

Generalize 'and' and 'or' operators #57

Closed
jckarter opened this issue Dec 14, 2011 · 5 comments
Closed

Generalize 'and' and 'or' operators #57

jckarter opened this issue Dec 14, 2011 · 5 comments
Milestone

Comments

@jckarter
Copy link
Owner

It would be useful to be able to overload and and or for Maybe, Either, and other monadic types:

var x = maybeA() and maybeB() and maybeC(); // short-circuit maybe chaining (aka ">>=")
var y = maybeA() or maybeB(); // maybe alternation (aka "mplus")
var z = maybeA() or 0; // maybe unpack with default
@ghost
Copy link

ghost commented Dec 31, 2011

What's your stance on using 'and', 'or', 'not' keywords instead of the C-like operators (&&,||,!) ? Is this a preference or just a carry over from the Pascal syntax?

@jckarter
Copy link
Owner Author

I kind of like and and or because they're prettier and easier to type than the C operators.

@ghost
Copy link

ghost commented Feb 19, 2012

Could the variadic-op set-up be used for and & or . . .?

@jckarter
Copy link
Owner Author

I'm not sure. I'd like the short-circuit behavior to be inherent in the way and and or desugar, perhaps by having the right-hand side desugar as a lambda.

@jckarter
Copy link
Owner Author

This probably isn't necessary anymore, since you could easily define your own && and || as alias functions that do whatever you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant