-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Return Failure early in <*
and *>
too
#190
Conversation
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.
Thanks for your contribution! However, I propose an alternative solution to this problem.
Short-circuiting behaviour of these operators can be tested manually via some unit tests later.
9a7467f
to
11235fb
Compare
I also added a unit test to ensure the short-circuiting works correctly, for all of the |
11235fb
to
0f3dd68
Compare
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.
Thanks! I feel like documentation for the Validation
module can be improved. But I have plans on how to do this and will do it separately 👍
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.
Sorry, I'm slow, but I don't see the point of these changes 🤔 Could you please explain what benefits this PR gives the library?
Consider this code: case thisWillFail *> thisWillTakeALongTime of
Failure _ -> print "It didn't work."
Success _ -> print "It worked!" Since we know that the whole expression will be a |
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.
After thinking more about this PR and discussing it with @vrom911, I now believe that removing code and potentially breaking working code is not a good idea. In general, it's preferable to avoid changing the code in such a considerable way without confidence. And the current example in the documentation is also not helpful. So let's not merge this PR until we have better testing and documentation story for Validation
.
Sure, I do understand that, but I'm talking exactly about this PR. This feels like unchecked breaking change. @chshersh are you sure you would like to take such a risk? I'm personally using |
Am I missing something? How is this a breaking change? |
@vrom911 Agree with you here. I'm also using |
Actually, this is worse than just a performance problem; we're not a valid Applicative:
(emphasis mine) Ours aren't equivalent. If |
0c0f088
to
0bb792e
Compare
Now that #176 is fixed, is this ready to merge? |
@josephcsible Well, since we have tests now, we actually can implement our own more optimised versions of these operators (like it how was done at first). Because now we have more guarantees that they will work. And we won't rely on the inliner too much as a pleasant consequence. |
ad32489
to
22d30b2
Compare
@chshersh Done. |
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.
@josephcsible Thanks for the refactoring, looks good 👍
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.
Thanks, @josephcsible !
@@ -143,6 +145,9 @@ Success 8 | |||
|
|||
>>> liftA2 (+) a c | |||
Failure ["Not correct"] | |||
|
|||
>>> [x | Success x <- [ha <*> e, c <* e, d *> e, liftA2 (+) d e]] |
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.
Heh, I wish these variable names could make a little sense, so the examples could become useful 😢
@chshersh should I create an issue for refactoring this?
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.
@vrom911 Yes, please!
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.
Checklist:
HLint
hlint.dhall
accordingly to my changes (add new rules for the new imports, remove old ones, when they are outdated, etc.)..hlint.yaml
file (see this instructions).General
stylish-haskell
file.[ci skip]
text to the docs-only related commit's name.