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 or to ApplicativeError #2242

Closed
johnynek opened this issue May 2, 2018 · 7 comments
Closed

Add or to ApplicativeError #2242

johnynek opened this issue May 2, 2018 · 7 comments

Comments

@johnynek
Copy link
Contributor

johnynek commented May 2, 2018

def or(other: IO[A]): IO[A] = io.attempt.flatMap {
    case Right(a) => IO.pure(a)
    case Left(e)  => other
 }

Also, this implies you can make a SemigroupK if you have a MonadError. With an example error, you can make a MonoidK. Or, if you have a MonadError[F, Unit], such as Option, you have an Alternative, I guess.

@johnynek
Copy link
Contributor Author

johnynek commented May 2, 2018

@kailuowang
Copy link
Contributor

we can add this to ApplicativeErrorOps in 1.x.

@johnynek
Copy link
Contributor Author

johnynek commented May 2, 2018

true, handleErrorWith is all that is needed here.

@johnynek johnynek changed the title Add or to MonadError Add or to ApplicativeError May 2, 2018
@barambani
Copy link
Contributor

I could look into this if that's ok

@johnynek
Copy link
Contributor Author

johnynek commented May 2, 2018

@barambani Please!

@johnynek
Copy link
Contributor Author

johnynek commented May 6, 2018

@kailuowang do we have a list of changes that we hacked onto AnyVal classes that we would like to undo?

Side question: should we prefer to keep typeclasses minimal, and have most methods on anyval extensions? It seems that we have almost all methods on the typeclass rather than thinking much about what could plausibly be optimized per type. I guess if binary compatibility was not a problem, and it won't be in 2.12, putting on the trait is strictly better. Maybe we just need to get the community to move to 2.12.

@kailuowang
Copy link
Contributor

@johnynek we don't have a list. I suppose when we move to a 2.12 only version we should review all these AnyVal classes and move the implementations of appropriate ones to the traits along with some "consistency" laws. It's shame that the community couldn't benefit from the better binary compat support from 2.12. Hopefully, now the ScalaCenter is helping, Spark can move over soon.

@johnynek johnynek closed this as completed May 9, 2018
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

3 participants