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 MonadError.rethrow #2061

Merged
merged 8 commits into from
Dec 6, 2017
Merged

Conversation

SystemFw
Copy link
Contributor

@SystemFw SystemFw commented Dec 4, 2017

This PR seeks to add rethrow to MonadError, i.e. the inverse of attempt.
The law for it is currently failing on IorT.

@kailuowang kailuowang added this to the 1.0.0 milestone Dec 5, 2017
@kailuowang
Copy link
Contributor

kailuowang commented Dec 5, 2017

still have scala style errors

[error] /home/travis/build/typelevel/cats/core/src/main/scala/cats/MonadError.scala:47:4: Whitespace at end of line
[error] /home/travis/build/typelevel/cats/core/src/main/scala/cats/MonadError.scala:52:4: Whitespace at end of line
[error] /home/travis/build/typelevel/cats/core/src/main/scala/cats/MonadError.scala:56:4: Whitespace at end of line
[error] /home/travis/build/typelevel/cats/core/src/main/scala/cats/MonadError.scala:61:5: Whitespace at end of line

and also need to add mima exceptions to here

Update actually let me do that for you.

@SystemFw
Copy link
Contributor Author

SystemFw commented Dec 5, 2017

@kailuowang you are too kind :)

kailuowang
kailuowang previously approved these changes Dec 5, 2017
@johnynek
Copy link
Contributor

johnynek commented Dec 5, 2017

👍

@codecov-io
Copy link

codecov-io commented Dec 5, 2017

Codecov Report

Merging #2061 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2061      +/-   ##
==========================================
+ Coverage   94.66%   94.66%   +<.01%     
==========================================
  Files         318      318              
  Lines        5380     5383       +3     
  Branches      112      207      +95     
==========================================
+ Hits         5093     5096       +3     
  Misses        287      287
Impacted Files Coverage Δ
core/src/main/scala/cats/data/Ior.scala 100% <ø> (ø) ⬆️
laws/src/main/scala/cats/laws/MonadErrorLaws.scala 100% <100%> (ø) ⬆️
core/src/main/scala/cats/MonadError.scala 100% <100%> (ø) ⬆️
core/src/main/scala/cats/data/IorT.scala 97.39% <100%> (-0.03%) ⬇️
core/src/main/scala/cats/syntax/monadError.scala 100% <100%> (ø) ⬆️
...n/scala/cats/laws/discipline/MonadErrorTests.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c51fe61...19745e3. Read the comment docs.

@kailuowang
Copy link
Contributor

We already have 2 sign-offs, but since I made a couple lines of changes here. Maybe @LukaJCB can give it another look?

@mpilquist
Copy link
Member

Is it weird to call this rethrow when E could be any type (i.e. not a Throwable)?

@SystemFw
Copy link
Contributor Author

SystemFw commented Dec 5, 2017

It is a bit weird, and we had a brief discussion on gitter cause I was not sure about the original name.
I started with absolve, then materialize/unmaterialize were floating around, in the end I've settled with rethrow. reraise is more consistent I guess, but it's fairly ugly as well

@mpilquist
Copy link
Member

:) I have no objections

@kailuowang
Copy link
Contributor

Hmm I do like reraise better, not a strong preference though

@SystemFw
Copy link
Contributor Author

SystemFw commented Dec 5, 2017

I don't have a strong preference either tbh

@kailuowang
Copy link
Contributor

do you want to change to reraise? or I can make another PR against your branch?

@SystemFw
Copy link
Contributor Author

SystemFw commented Dec 6, 2017

It's past two so I won't be able to do anything until tomorrow
Go ahead if you have time though :)

@kailuowang
Copy link
Contributor

never mind about the rename, I noticed that the word "rethrow" is already used numerous time in MonadError's doc.

Copy link
Member

@LukaJCB LukaJCB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@kailuowang kailuowang merged commit f1de85a into typelevel:master Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants