-
-
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
Add Try instances #1059
Add Try instances #1059
Conversation
PS: I didn't run the tests because when I tried I got some OOM errors, and I figured the CI would need to run anyway. |
Cats doesn't have |
Or you can use |
I saw that, but I'm not sure I agree. I don't see any laws violated if only Can someone clarify this a bit for me? |
I guess the difference with To me, |
👍 for including instances for |
@guersam do we have a demonstration of how the laws are broken? I've usually seen someone trying to show that functor composition is broken when you call fmap with something that isn't even a function, which isn't something that worries me, and I'm not sure there is a difference here in how Xor and Try treat this situation. |
@stew Actually I just naively assumed that @johnynek wasn't aware of alleycats but he already was. I neither am against |
This conversation seems like the most relevant one https://gitter.im/typelevel/cats?at=54d80e750c939ea03d55764a |
I agree that if we have I'm hesitant about the |
Yeah, I'm not 100% about the Throwable thing either. I can move the Eq I guess I prefer requiring Eq[Throwable] to removing all together (but then On Tuesday, May 24, 2016, Cody Allen notifications@github.com wrote:
P. Oscar Boykin, Ph.D. | http://twitter.com/posco | http://pobox.com/~boykin |
It will be, see #589 and non/alleycats#26. Unless this changes anything, I propose I do that ASAP (ie can do now) |
I don't care all that much about the instances for I think Cats absolutely needs to provide |
@ceedubs Correct. But the js versions need to be moved too- And I'll add them both to alleycats |
FWIW, I agree with @travisbrown's position. |
Can anyone succinctly describe an example of something going wrong when using In what kinds of cases can we imagine the Given that all the problems I know about are due to using |
To me it sounds like everyone is pretty much in agreement about keeping around the |
That really raises the question as to whether Alleycats should still exist at all. From gitter chat
|
So, I was writing some tests to see what it would take to beef up our coverage here, and I caught a bug. The I'm still happy to have this PR, but we should at least remove that instance first. |
I think this gives us an opportunity to revisit the separation between Cats and Alleycats ... I'd very much like to see the Alleycats classes and instances rolled into Cats proper ... in a submodule if necessary. |
@milessabin +1 I was thinking something similar. |
@milessabin @non @inthenow let's continue the alleycats discussion on #472. I don't want to block progress on this PR by wrapping it up in a separate (albeit related) discussion. |
I removed the broken |
LGTM 👍 |
implicit def showTry[A](implicit A: Show[A]): Show[Try[A]] = | ||
new Show[Try[A]] { | ||
def show(fa: Try[A]): String = fa match { | ||
case Success(a) => s"Success(${A.show(a)})" | ||
case Failure(e) => s"Failure($e)" | ||
} | ||
} | ||
implicit def eqTry[A](implicit A: Eq[A]): Eq[Try[A]] = | ||
/** | ||
* you may with to do equality by making `implicit val eqT: Eq[Throwable] = Eq.allEqual` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo: with -> wish
Thanks @johnynek this looks great! Sorry, but we've created merge conflicts. Would you be willing to resolve them? We could also have a |
@ceedubs I fixed the merge conflicts but did not yet implement |
Let's merge this now and leave |
suggested a colleague try
sequence
to convertList[Try[T]] => Try[List[T]]
without doingTry(l.map(_.get))
but then didn't see instances for Try.These are mostly based on
Future
, but I addedShow
andEq
.I made the choice that
Eq[Try[T]]
considers allFailures
as equivalent, which seems better that getting into either taking anEq[Throwable]
or using universal equals, but that can be changed as needed.