-
Notifications
You must be signed in to change notification settings - Fork 75
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
cats-effect module #155
cats-effect module #155
Conversation
BenFradet
commented
May 30, 2017
•
edited
Loading
edited
- js support
- remove hardcoded cats-effect version once sbt-org-policies is out
- doc
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.
Reviews/help welcome 👍
import github4s.free.interpreters.{Capture, Interpreters} | ||
import scalaj.http.HttpResponse | ||
|
||
object implicits extends HttpRequestBuilderExtensionJVM { |
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.
should I create one implicits for the jvm and one for js?
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.
By now, I think that you should. Nevertheless, I guess we want to get rid of this kind of implicit import.
One option would use a fully compatible http client for both jvm and js: https://github.com/pepegar/hammock .
What do you think?
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.
in the long run I think this would be great indeed.
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.
welp I think I see what you mean since roshttp is tied to Future we can't support IO in scala js
build.sbt
Outdated
lazy val catsEffect = (project in file("cats-effect")) | ||
.settings(moduleName := "github4s-cats-effect") | ||
.settings(catsEffectDependencies: _*) | ||
.dependsOn(github4sJVM) |
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.
is it ok to depend on both github4sJVM
and github4sJS
?
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.
I don't know if cat-effects
is already a crossed-project with Scalajs (but it will be likely). If that's already the case, we could make catsEffect
module as crossProject
too.
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.
yes it supports scala js, I'll try making it a cross project
project/ProjectPlugin.scala
Outdated
|
||
lazy val catsEffectDependencies: Def.Setting[Seq[ModuleID]] = | ||
libraryDependencies ++= Seq( | ||
"org.typelevel" %% "cats-effect" % "0.3", |
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.
to rm
Codecov Report
@@ Coverage Diff @@
## master #155 +/- ##
==========================================
+ Coverage 86.92% 86.95% +0.03%
==========================================
Files 36 40 +4
Lines 566 575 +9
Branches 2 1 -1
==========================================
+ Hits 492 500 +8
- Misses 74 75 +1
Continue to review full report at Codecov.
|
build.sbt
Outdated
lazy val catsEffect = (project in file("cats-effect")) | ||
.settings(moduleName := "github4s-cats-effect") | ||
.settings(catsEffectDependencies: _*) | ||
.dependsOn(github4sJVM) |
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.
I don't know if cat-effects
is already a crossed-project with Scalajs (but it will be likely). If that's already the case, we could make catsEffect
module as crossProject
too.
import github4s.free.interpreters.{Capture, Interpreters} | ||
import scalaj.http.HttpResponse | ||
|
||
object implicits extends HttpRequestBuilderExtensionJVM { |
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.
By now, I think that you should. Nevertheless, I guess we want to get rid of this kind of implicit import.
One option would use a fully compatible http client for both jvm and js: https://github.com/pepegar/hammock .
What do you think?
project/ProjectPlugin.scala
Outdated
|
||
lazy val catsEffectDependencies: Def.Setting[Seq[ModuleID]] = | ||
libraryDependencies ++= Seq( | ||
"org.typelevel" %% "cats-effect" % "0.3", |
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.
sbt-org-policies 0.5.2
has been already released: https://github.com/47deg/sbt-org-policies/releases/tag/v0.5.2
BTW I don't know why my review was sent twice XD |
Since it seems we can't use a
What do you think? |
Makes sense 👍 |
val res = response.unsafeRunSync | ||
res.isLeft shouldBe true | ||
} | ||
} |
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.
This spec is never run, I don't know why.
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.
See #156
} | ||
.getOrElse(fail("effect attempt failed")) | ||
} | ||
} |
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.
curious as to how you found all 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.
cats-effects
project, I only adapted it for our use case ;)
docs/src/main/tut/docs.md
Outdated
### Using `cats.effect.IO` | ||
|
||
On the JVM: | ||
```scala |
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.
I can't seem to get this example to compile with tut despite adding cats-effect to the doc deps, any ideas?
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.
See #158
} | ||
.getOrElse(fail("effect attempt failed")) | ||
} | ||
} |
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.
cats-effects
project, I only adapted it for our use case ;)
docs/src/main/tut/docs.md
Outdated
### Using `cats.effect.IO` | ||
|
||
On the JVM: | ||
```scala |
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.
See #158
project/ProjectPlugin.scala
Outdated
), | ||
coverageExcludedPackages := "<empty>;github4s\\.scalaz\\..*", | ||
coverageExcludedPackages := "<empty>;github4s\\.scalaz\\..*;github4s\\.cats\\.effect\\..*", |
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.
Why are we excluding these tests?
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.
Just thought I'd exclude them like what is being done for scalaz, happy to include them.
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.
👍
scalaz doesn't have tests, cats-effect has thanks to your work :)
mmh I get 100% coverage on cats-effect-jvm but 78.57% on js, because of the HttpRequestBuilder for IO, I'll try adding tests for that as well. |
Ohh, thanks. Let's try it, if not, we could remove the 80% restriction. |
Yup, I'll try tomorrow. Anyway the low coverage is only temporary since once we move to hammock there'll be no HttpRequestBuilder extension for IO and the capture instance will be used in JS so we'll be at 💯 for both JVM and JS. |
@juanpedromoreno I think it's ready for a review 👍 |
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.
Looks great to me, thanks! Outstanding job
Thanks a lot for your help, merging! |