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

Aggregate two options #72

Closed
siroky opened this issue Feb 25, 2021 · 3 comments
Closed

Aggregate two options #72

siroky opened this issue Feb 25, 2021 · 3 comments

Comments

@siroky
Copy link
Contributor

siroky commented Feb 25, 2021

  • Some(x), Some(y), f => Some(f(x, y))
  • Some(x), None, f => Some(x)
  • ...
  • None, None, f => None
@siroky siroky changed the title Combine two options Aggregate two options Feb 25, 2021
@KaliCZ
Copy link
Contributor

KaliCZ commented Feb 25, 2021

Doesn't this result in inconsistent result type?
Assuming that f(x, y) return z, you'd need to either return a coproduct of 3 or 4 types

  • Some z
  • Some x
  • Some y
  • None z (Can be same as first if it would still be an option)

Or you'd need to accept 3 different functions resulting in z

  • one taking x and y
  • one taking x
  • one taking y

Alternatively you would accept a function accepting option of y and option of x as parameters. In which case this method does exactly nothing, because you need to pass the two options and a function, so you might as well just call the function.

@siroky
Copy link
Contributor Author

siroky commented Feb 25, 2021

This will be for options of same type and the function will also return same type.

@siroky
Copy link
Contributor Author

siroky commented May 13, 2021

Duplicates #73

@siroky siroky closed this as completed May 13, 2021
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

2 participants