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

.raiseError syntax allows an error subtype #2511

Merged

Conversation

guersam
Copy link
Contributor

@guersam guersam commented Sep 18, 2018

Inspired by #2480, applying the same trick to .raiseError so that I can write MyException(...).raiseError[IO, Unit], instead of (MyException(...): Throwable).raiseError[IO, Unit].

}

test("raiseError syntax allows an error subtype") {
assert(Sub.raiseError[EitherWrapper, Unit].either.isLeft)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't keep should === convention here due to the lack of org.scalactic.CanEqual[Either[Super, Unit]]. Any advice?

Copy link
Contributor

@kailuowang kailuowang Sep 18, 2018

Choose a reason for hiding this comment

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

Not sure if you need a new instance to test. I assume that the test could be in a form of following code compiles

def a[F[_]](implicit F: ApplicativeError[F, CharSequence]): F[Int] = 
   "sdf".raiseError[F, Int]

This doesn't compile without your change, since "sdf".raiseError would requires a ApplicativeError[F, String])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's much better! I'll take it and move to SyntaxSuite.

@guersam guersam force-pushed the guersam/raiseerror-syntax-subtype branch from 9813b36 to bdf9f9e Compare September 18, 2018 05:29
@codecov-io
Copy link

Codecov Report

Merging #2511 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2511   +/-   ##
=======================================
  Coverage   95.38%   95.38%           
=======================================
  Files         357      357           
  Lines        6528     6528           
  Branches      281      281           
=======================================
  Hits         6227     6227           
  Misses        301      301
Impacted Files Coverage Δ
.../src/main/scala/cats/syntax/applicativeError.scala 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 1911e8b...053b5d3. Read the comment docs.

@guersam
Copy link
Contributor Author

guersam commented Sep 19, 2018

Applied @kailuowang's feedback and confirmed that new test doesn't compile with current master:

[error] /home/guersam/workspace/github/cats/tests/src/test/scala/cats/tests/SyntaxSuite.scala:353:32: could not find implicit value for parameter F: cats.ApplicativeError[F,String]
[error]     val fea = "meow".raiseError[F, A]
[error]                                ^
[error] one error found
[error] (testsJVM / Test / compileIncremental) Compilation failed
[error] Total time: 4 s, completed Sep 19, 2018 10:20:53 AM

@guersam guersam force-pushed the guersam/raiseerror-syntax-subtype branch from 053b5d3 to e2da593 Compare September 19, 2018 02:53
@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #2511 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2511   +/-   ##
=======================================
  Coverage   95.38%   95.38%           
=======================================
  Files         357      357           
  Lines        6528     6528           
  Branches      281      278    -3     
=======================================
  Hits         6227     6227           
  Misses        301      301
Impacted Files Coverage Δ
.../src/main/scala/cats/syntax/applicativeError.scala 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 8c39153...e2da593. Read the comment docs.

@guersam
Copy link
Contributor Author

guersam commented Sep 19, 2018

I don't see any reason of the CI failure in scala 2.13.0-M4 😢 TRAVIS_SCALA_VERSION=2.13.0-M4 scripts/travis-publish.sh runs fine on my machine.

Copy link
Contributor

@kailuowang kailuowang left a comment

Choose a reason for hiding this comment

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

Thanks!

@mberndt123
Copy link
Contributor

Heh, nice to see that my PR inspired somebody literally at the other end of the world!

@kailuowang kailuowang added this to the 1.5 milestone Oct 30, 2018
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.

5 participants