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

cats-effect module #155

Merged
merged 9 commits into from
Jun 10, 2017
Merged

cats-effect module #155

merged 9 commits into from
Jun 10, 2017

Conversation

BenFradet
Copy link
Contributor

@BenFradet BenFradet commented May 30, 2017

  • js support
  • remove hardcoded cats-effect version once sbt-org-policies is out
  • doc

Copy link
Contributor Author

@BenFradet BenFradet left a 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 {
Copy link
Contributor Author

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?

Copy link
Member

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.

#45

One option would use a fully compatible http client for both jvm and js: https://github.com/pepegar/hammock .

What do you think?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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


lazy val catsEffectDependencies: Def.Setting[Seq[ModuleID]] =
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "0.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to rm

@codecov-io
Copy link

codecov-io commented May 31, 2017

Codecov Report

Merging #155 into master will increase coverage by 0.03%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...cala/github4s/HttpRequestBuilderExtensionJVM.scala 100% <ø> (ø) ⬆️
.../scala/github4s/cats/effect/jvm/ImplicitsJVM.scala 100% <100%> (ø)
...in/scala/github4s/cats/effect/js/ImplicitsJS.scala 100% <100%> (ø)
...scala/github4s/cats/effect/IOCaptureInstance.scala 100% <100%> (ø)
.../cats/effect/IOHttpRequestBuilderExtensionJS.scala 75% <75%> (ø)
...scala/github4s/HttpRequestBuilderExtensionJS.scala 81.48% <92.85%> (+0.71%) ⬆️

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 583aa1a...c3690d2. Read the comment docs.

build.sbt Outdated
lazy val catsEffect = (project in file("cats-effect"))
.settings(moduleName := "github4s-cats-effect")
.settings(catsEffectDependencies: _*)
.dependsOn(github4sJVM)
Copy link
Member

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 {
Copy link
Member

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.

#45

One option would use a fully compatible http client for both jvm and js: https://github.com/pepegar/hammock .

What do you think?


lazy val catsEffectDependencies: Def.Setting[Seq[ModuleID]] =
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "0.3",
Copy link
Member

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

@juanpedromoreno
Copy link
Member

BTW I don't know why my review was sent twice XD

@BenFradet
Copy link
Contributor Author

Since it seems we can't use a Capture with HttpRequestBuilderExtensionJS, we can either:

  • build a HttpRequestBuilderExtensionJS specifically for IO in cats-effect js
  • not support cats-effect in js for the moment (until we port everything to hammock)

What do you think?

@juanpedromoreno
Copy link
Member

Makes sense 👍

val res = response.unsafeRunSync
res.isLeft shouldBe true
}
}
Copy link
Contributor Author

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.

Copy link
Member

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"))
}
}
Copy link
Contributor Author

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?

Copy link
Member

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 ;)

### Using `cats.effect.IO`

On the JVM:
```scala
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 can't seem to get this example to compile with tut despite adding cats-effect to the doc deps, any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

See #158

@BenFradet BenFradet changed the title [wip] cats-effect module cats-effect module Jun 7, 2017
}
.getOrElse(fail("effect attempt failed"))
}
}
Copy link
Member

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 ;)

### Using `cats.effect.IO`

On the JVM:
```scala
Copy link
Member

Choose a reason for hiding this comment

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

See #158

),
coverageExcludedPackages := "<empty>;github4s\\.scalaz\\..*",
coverageExcludedPackages := "<empty>;github4s\\.scalaz\\..*;github4s\\.cats\\.effect\\..*",
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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 :)

@BenFradet
Copy link
Contributor Author

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.

@juanpedromoreno
Copy link
Member

Ohh, thanks. Let's try it, if not, we could remove the 80% restriction.

@BenFradet
Copy link
Contributor Author

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.

@BenFradet
Copy link
Contributor Author

@juanpedromoreno I think it's ready for a review 👍

Copy link
Member

@juanpedromoreno juanpedromoreno left a 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 :shipit:

@BenFradet
Copy link
Contributor Author

Thanks a lot for your help, merging!

@BenFradet BenFradet merged commit f59e2de into master Jun 10, 2017
@BenFradet BenFradet deleted the bf-cats-effect branch June 10, 2017 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants