Skip to content

Commit

Permalink
Updates for Dotty
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Feb 25, 2020
1 parent ed66ab2 commit c698196
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jdk:

scala_version_212: &scala_version_212 2.12.10
scala_version_213: &scala_version_213 2.13.1
scala_version_dotty: &scala_version_dotty 0.22.0-bin-20200201-c4c847f-NIGHTLY
scala_version_dotty: &scala_version_dotty 0.22.0-RC1

before_install:
- export PATH=${PATH}:./vendor/bundle
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ lazy val testingDependencies = Seq(
libraryDependencies ++= (
if (isDotty.value)
Seq(
"dev.travisbrown" %% "discipline-scalatest" % (disciplineScalatestVersion + "-20200201-c4c847f-NIGHTLY") % Test
"dev.travisbrown" %% "discipline-scalatest" % disciplineScalatestVersion % Test
)
else
Seq(
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2.13+/cats/instances/arraySeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ private[cats] object ArraySeqInstances {
}

override def map2[A, B, Z](fa: ArraySeq[A], fb: ArraySeq[B])(f: (A, B) => Z): ArraySeq[Z] =
if (fb.isEmpty) ArraySeq.empty // do O(1) work if fb is empty
if (fb.isEmpty) ArraySeq.untagged.empty // do O(1) work if fb is empty
else fa.flatMap(a => fb.map(b => f(a, b))) // already O(1) if fa is empty

override def map2Eval[A, B, Z](fa: ArraySeq[A], fb: Eval[ArraySeq[B]])(f: (A, B) => Z): Eval[ArraySeq[Z]] =
if (fa.isEmpty) Eval.now(ArraySeq.empty) // no need to evaluate fb
if (fa.isEmpty) Eval.now(ArraySeq.untagged.empty) // no need to evaluate fb
else fb.map(fb => map2(fa, fb)(f))

def foldLeft[A, B](fa: ArraySeq[A], b: B)(f: (B, A) => B): B =
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/scala/cats/data/ContT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ object ContT {
* }}}
*/
def liftK[M[_], B](implicit M: FlatMap[M]): M ~> ContT[M, B, *] =
λ[M ~> ContT[M, B, *]](ContT.liftF(_))
new (M ~> ContT[M, B, *]) {
def apply[A](ma: M[A]): ContT[M, B, A] = ContT.liftF(ma)
}

/**
* Similar to [[pure]] but evaluation of the argument is deferred.
Expand Down Expand Up @@ -148,11 +150,11 @@ object ContT {
* }}}
*/
def apply[M[_], A, B](fn: (B => M[A]) => M[A]): ContT[M, A, B] =
FromFn(AndThen(fn))
new FromFn(AndThen(fn))

/** Similar to [[apply]] but evaluation of the argument is deferred. */
def later[M[_], A, B](fn: => (B => M[A]) => M[A]): ContT[M, A, B] =
DeferCont(() => FromFn(AndThen(fn)))
DeferCont(() => new FromFn(AndThen(fn)))

def tailRecM[M[_], A, B, C](a: A)(fn: A => ContT[M, C, Either[A, B]])(implicit M: Defer[M]): ContT[M, C, B] =
ContT[M, C, B] { (cb: (B => M[C])) =>
Expand Down
2 changes: 1 addition & 1 deletion laws/src/main/scala/cats/laws/TraverseFilterLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait TraverseFilterLaws[F[_]] extends FunctorFilterLaws[F] {
def traverseEitherConsistentWithTraverseFilter[G[_], E, A, B](fa: F[A], f: A => G[Option[B]], e: E)(
implicit G: Monad[G]
): IsEq[G[F[B]]] =
fa.traverseEither(a => f(a).map(_.toRight(e)))((_, _) => Applicative[G].unit) <-> fa.traverseFilter(f)
F.traverseEither(fa)(a => f(a).map(_.toRight(e)))((_, _) => Applicative[G].unit) <-> fa.traverseFilter(f)
}

object TraverseFilterLaws {
Expand Down

0 comments on commit c698196

Please sign in to comment.