Skip to content

Commit

Permalink
Merge pull request #3187 from travisbrown/topic/dotty-type-inference-…
Browse files Browse the repository at this point in the history
…help

Helping out Dotty's type inference
  • Loading branch information
travisbrown authored Dec 9, 2019
2 parents f81ac6f + a0ea859 commit 023ec75
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/ApplicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ trait ApplicativeError[F[_], E] extends Applicative[F] {
* `F[A]` values.
*/
def recover[A](fa: F[A])(pf: PartialFunction[E, A]): F[A] =
handleErrorWith(fa)(e => (pf.andThen(pure _)).applyOrElse(e, raiseError _))
handleErrorWith(fa)(e => (pf.andThen(pure(_))).applyOrElse(e, raiseError[A](_)))

/**
* Recover from certain errors by mapping them to an `F[A]` value.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Composed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private[cats] trait ComposedApply[F[_], G[_]] extends Apply[λ[α => F[G[α]]]]
def G: Apply[G]

override def ap[A, B](fgf: F[G[A => B]])(fga: F[G[A]]): F[G[B]] =
F.ap(F.map(fgf)(gf => G.ap(gf)(_)))(fga)
F.ap(F.map(fgf)(gf => (ga: G[A]) => G.ap(gf)(ga)))(fga)

override def product[A, B](fga: F[G[A]], fgb: F[G[B]]): F[G[(A, B)]] =
F.map2(fga, fgb)(G.product)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/IorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ abstract private[data] class IorTInstances1 extends IorTInstances2 {
type F[x] = IorT[F0, E, x]
private[this] val identityK: IorT[F0, E, *] ~> IorT[F0, E, *] = FunctionK.id
private[this] val underlyingParallel: Parallel.Aux[Ior[E, *], Ior[E, *]] =
Parallel[Ior[E, *], Ior[E, *]]
Ior.catsDataParallelForIor[E]

def parallel: IorT[F0, E, *] ~> IorT[F0, E, *] = identityK
def sequential: IorT[F0, E, *] ~> IorT[F0, E, *] = identityK
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Nested.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ abstract private[data] class NestedApplicativeError[F[_], G[_], E]

def FG: Applicative[λ[α => F[G[α]]]] = AEF.compose[G](G)

def raiseError[A](e: E): Nested[F, G, A] = Nested(AEF.map(AEF.raiseError(e))(G.pure))
def raiseError[A](e: E): Nested[F, G, A] = Nested(AEF.map(AEF.raiseError[A](e))(G.pure))

def handleErrorWith[A](fa: Nested[F, G, A])(f: E => Nested[F, G, A]): Nested[F, G, A] =
Nested(AEF.handleErrorWith(fa.value)(e => f(e).value))
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/instances/map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ private[instances] trait MapInstancesBinCompat0 {
val functor: Functor[Map[K, *]] = cats.instances.map.catsStdInstancesForMap[K]

def mapFilter[A, B](fa: Map[K, A])(f: A => Option[B]) =
fa.collect(scala.Function.unlift(t => f(t._2).map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, A)) => f(t._2).map(t._1 -> _)))

override def collect[A, B](fa: Map[K, A])(f: PartialFunction[A, B]) =
fa.collect(scala.Function.unlift(t => f.lift(t._2).map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, A)) => f.lift(t._2).map(t._1 -> _)))

override def flattenOption[A](fa: Map[K, Option[A]]) =
fa.collect(scala.Function.unlift(t => t._2.map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, Option[A])) => t._2.map(t._1 -> _)))

override def filter[A](fa: Map[K, A])(f: A => Boolean) =
fa.filter { case (_, v) => f(v) }
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/instances/sortedMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ private[instances] trait SortedMapInstancesBinCompat0 {
}

override def mapFilter[A, B](fa: SortedMap[K, A])(f: (A) => Option[B]): SortedMap[K, B] =
fa.collect(scala.Function.unlift(t => f(t._2).map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, A)) => f(t._2).map(t._1 -> _)))

override def collect[A, B](fa: SortedMap[K, A])(f: PartialFunction[A, B]): SortedMap[K, B] =
fa.collect(scala.Function.unlift(t => f.lift(t._2).map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, A)) => f.lift(t._2).map(t._1 -> _)))

override def flattenOption[A](fa: SortedMap[K, Option[A]]): SortedMap[K, A] =
fa.collect(scala.Function.unlift(t => t._2.map(t._1 -> _)))
fa.collect(scala.Function.unlift((t: (K, Option[A])) => t._2.map(t._1 -> _)))

override def filter[A](fa: SortedMap[K, A])(f: (A) => Boolean): SortedMap[K, A] =
fa.filter { case (_, v) => f(v) }
Expand Down

0 comments on commit 023ec75

Please sign in to comment.