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

Updates to cats 1.0-RC1 and cats-effect 0.5 #458

Merged
merged 17 commits into from Nov 7, 2017

Conversation

Projects
None yet
3 participants
@alexandru
Member

alexandru commented Nov 7, 2017

Fixes #456.

This is a fork of PR #457 — which isn't sufficient because:

  1. cats.Parallel is now in Cats
  2. cats-effect/#82ap has to be consistent with flatMap and thus preserve ordering for all Monad implementations

This means that what we did with the extra import Task.nondeterminism no longer works, however we can now defer all our parallelism needs to the new cats.Parallel, which is simpler and easier, simplifying our implicits a lot.

And now that we can use cats.Parallel, introducing:

  1. Iterant.parZip
  2. Iterant.parZipMap

/cc @alonsodomin

@codecov

This comment has been minimized.

codecov bot commented Nov 7, 2017

Codecov Report

Merging #458 into master will increase coverage by 0.02%.
The diff coverage is 90.82%.

@@            Coverage Diff            @@
##           master    #458      +/-   ##
=========================================
+ Coverage   89.18%   89.2%   +0.02%     
=========================================
  Files         347     351       +4     
  Lines        9505    9524      +19     
  Branches     1255    1252       -3     
=========================================
+ Hits         8477    8496      +19     
  Misses       1028    1028

alexandru added some commits Nov 7, 2017

@alexandru alexandru merged commit 622b1a9 into monix:master Nov 7, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
}))
}
/** We need to mixin [[CatsAsyncForTask]], because if we

This comment has been minimized.

@wogan

wogan Nov 7, 2017

Contributor

Is this true even with the priority of the traits mixed into Task? Does this also mean you could have conflicts for Monad (etc) which both CatsEffectForTask and CatsAsyncForTask implement?

This comment has been minimized.

@alexandru

alexandru Nov 7, 2017

Member

Yes, because unfortunately Scala's implicit resolution is a complex thing that nobody really knows how it works.

But the gist is this — the compiler basically calculates a score. And so this works:

class Foo
class Bar extends Foo

trait Level1 extends Level0 {
  implicit bar: Bar = new Bar
}

trait Level0 {
  implicit foo: Foo = new Foo
}

But this does not:

trait Level1 extends Level0 {
  implicit foo: Foo = new Foo
}

trait Level0 {
  implicit bar: Bar = new Bar
}

This is because Bar <: Foo and somehow the compiler when calculating the score of those 2 implicits will end up with the same number, the different cake levels being balanced against the subtyping relationship we have here.

Fortunately what I did works, even for Monad:

scala> import monix.execution.Scheduler.Implicits.global
import monix.execution.Scheduler.Implicits.global

scala> import monix.eval._
import monix.eval._

scala> implicitly[cats.Monad[Task]]
res0: cats.Monad[monix.eval.Task] = monix.eval.instances.CatsAsyncForTask$@2f600d06

This is because the compiler does not see CatsEffectForTask as being a subtype of CatsAsyncForTask. A weird rule, but there you have it.

@@ -118,4 +118,9 @@ trait ArbitraryInstancesBase extends monix.execution.ArbitraryInstances {
Cogen[Unit].contramap(_ => ())
implicit def cogenForCoeval[A](implicit A: Numeric[A]): Cogen[Coeval[A]] =
Cogen((x: Coeval[A]) => A.toLong(x.value))
// implicit val isoTask: Isomorphisms[Task] =

This comment has been minimized.

@wogan

wogan Nov 7, 2017

Contributor

remove?

This comment has been minimized.

@alexandru

alexandru Nov 7, 2017

Member

👍 forgot that junk

import cats.laws.IsEq
import cats.kernel.laws._
import cats.laws._
//import cats.kernel.laws._

This comment has been minimized.

@wogan

wogan Nov 7, 2017

Contributor

also here

@alexandru alexandru added this to the 3.0.0 milestone Jan 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment