-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
jvm Future instances do not obey laws #589
Comments
Let's move all the unlawful stuff to alleycats (and also put an |
I think there's kind of a lot of subtlety involved with I think the real problem is that everyone uses |
I think we want to mirror Cats' setup in Alleycats, but haven't had the time to do it yet. Specifically, I imagine having |
The JS version of future started out in alleycats so no surprise to me that it's all going there,
|
@inthenow That's a great idea. Let's do it! 🐈 🔬 |
👍 (Sunday) |
@inthenow I see that non/alleycats#21 has been merged. Does that mean that alleycats is ready for this now? |
@ceedubs I think we need non/alleycats#22 in first, but otherwise yes. |
Fixes typelevel#589. If anyone is set on using these, they can be added to alleycats. However, I suspect that few to no people are using these. They all throw exceptions on failed futures, which seems like it would be a show-stopper in most codebases.
Most of the type class instances in https://github.com/non/cats/blob/master/jvm/src/main/scala/cats/jvm/std/future.scala (
Comonad
,Eq
,PartialOrder
,Order
) are not checked against their laws. If we were to check them against their laws they would fail, because they throw exceptions in the case of a failed future.Furthermore, it isn't necessarily obvious how an
Eq[Future[A]]
instance should behave. The current one throws an exception if eitherFuture
fails. Consider the following scenario:This last line throws an exception. One could reasonably expect it to return
true
instead. This does require creating an explicitEq
instance (with a supplied timeout), so it takes a little effort to get yourself into trouble. Still, I think that these instances belong in alleycats or tests but not in cats core. In addition to being unlawful, they aren't especially useful. Other than in tests, you probably always want to get back aFuture[Boolean]
when comparing twoFuture[A]
values instead of blocking the thread waiting for both futures to complete.The text was updated successfully, but these errors were encountered: