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

Should we offer a binding that can bind results of any Error type? #42

Closed
Munzey opened this issue Dec 2, 2020 · 1 comment
Closed

Comments

@Munzey
Copy link
Contributor

Munzey commented Dec 2, 2020

i.e. should we change or offer the following as part of the api:

fun <V> binding(block: ResultBinding.() -> V): Result<V, *>

This would allow 2 things:

  1. no more specifying the types when declaring a binding block:
val result = binding {
  val x = doSomething().bind()
  val y = doSomethingElse().bind()
  x + y
}
  1. doSomething and doSomethingElse can have error types that dont extend from the same type.
    The downside of this is that now the ide will see the type of result in the above example as Result<Int, *>
    But is that so bad?

If we wanted to add this, would it make more sense to replace the current binding with this? or offer a second function. What would they be named? bindingAny? bindingExplicit?

@michaelbull
Copy link
Owner

I'm not a fan of allowing people to shoot themselves in the foot with anonymous types. If they want this behaviour it's fairly trivial for them to write their own extension function with the wildcard types themselves.

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