Skip to content

Commit

Permalink
Merge pull request #1096 from edmundnoble/inject-null
Browse files Browse the repository at this point in the history
Fix Inject instance and reduceRightToOption null behavior
  • Loading branch information
non committed Jun 8, 2016
2 parents 8f6d2d6 + 86fa9b2 commit 948e85c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Reducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import simulacrum.typeclass
* Overriden from `Foldable[_]` for efficiency.
*/
override def reduceRightToOption[A, B](fa: F[A])(f: A => B)(g: (A, Eval[B]) => Eval[B]): Eval[Option[B]] =
reduceRightTo(fa)(f)(g).map(Option(_))
reduceRightTo(fa)(f)(g).map(Some(_))

/**
* Traverse `F[A]` using `Apply[G]`.
Expand Down
4 changes: 2 additions & 2 deletions free/src/main/scala/cats/free/Inject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ private[free] sealed abstract class InjectInstances {
new Inject[F, F] {
def inj[A](fa: F[A]): F[A] = fa

def prj[A](ga: F[A]): Option[F[A]] = Option(ga)
def prj[A](ga: F[A]): Option[F[A]] = Some(ga)
}

implicit def leftInjectInstance[F[_], G[_]]: Inject[F, Coproduct[F, G, ?]] =
new Inject[F, Coproduct[F, G, ?]] {
def inj[A](fa: F[A]): Coproduct[F, G, A] = Coproduct.leftc(fa)

def prj[A](ga: Coproduct[F, G, A]): Option[F[A]] = ga.run.fold(Option(_), _ => None)
def prj[A](ga: Coproduct[F, G, A]): Option[F[A]] = ga.run.fold(Some(_), _ => None)
}

implicit def rightInjectInstance[F[_], G[_], H[_]](implicit I: Inject[F, G]): Inject[F, Coproduct[H, G, ?]] =
Expand Down

0 comments on commit 948e85c

Please sign in to comment.