Skip to content
New issue

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

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

Already on GitHub? # to your account

Add ||| operator for alternatives forming a shapeless Coproduct #134

Open
sirthias opened this issue Mar 14, 2015 · 0 comments
Open

Add ||| operator for alternatives forming a shapeless Coproduct #134

sirthias opened this issue Mar 14, 2015 · 0 comments
Labels

Comments

@sirthias
Copy link
Owner

The | operator requires that the types of the two rules being "or-ed" are "compatible".
In most cases this is what you want, i.e. (a: Rule1[Int]) | (b: Rule1[String]) shouldn't compile.

Sometimes, however, it'd be convenient if there was a variant of | (e.g. called |||) which automatically created a Coproduct of it's operands, if required:

def a: Rule1[Int] = ...
def b: Rule1[String] = ...
def c = rule { a | b } // doesn't compile
def c: Rule1[Int :+: String :+: CNil] = rule { a ||| b }
def d: Rule1[Int] = rule { a ||| a }
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant