Skip to content

Commit

Permalink
Simplify FunctionK.or by using Coproduct.fold. (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterneyens authored and johnynek committed Oct 18, 2016
1 parent 3b0c07c commit 86491ba
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions core/src/main/scala/cats/arrow/FunctionK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ trait FunctionK[F[_], G[_]] extends Serializable { self =>
*/
def or[H[_]](h: FunctionK[H, G]): FunctionK[Coproduct[F, H, ?], G] =
new FunctionK[Coproduct[F, H, ?], G] {
def apply[A](fa: Coproduct[F, H, A]): G[A] = fa.run match {
case Left(ff) => self(ff)
case Right(gg) => h(gg)
}
def apply[A](fa: Coproduct[F, H, A]): G[A] = fa.fold(self, h)
}
}

Expand Down

0 comments on commit 86491ba

Please sign in to comment.