Skip to content

Commit

Permalink
Merge pull request #3630 from bplommer/functionk-widen-narrow
Browse files Browse the repository at this point in the history
  • Loading branch information
larsrh authored Oct 10, 2020
2 parents c28b4de + 57c5571 commit fb0678d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/main/scala/cats/arrow/FunctionK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ trait FunctionK[F[_], G[_]] extends Serializable { self =>
*/
def and[H[_]](h: FunctionK[F, H]): FunctionK[F, Tuple2K[G, H, *]] =
new FunctionK[F, Tuple2K[G, H, *]] { def apply[A](fa: F[A]): Tuple2K[G, H, A] = Tuple2K(self(fa), h(fa)) }

/**
* Widens the output type of this `FunctionK` from `G` to `G0`
*/
def widen[G0[x] >: G[x]]: FunctionK[F, G0] = this.asInstanceOf[FunctionK[F, G0]]

/**
* Narrows the input type of this `FunctionK` from `F` to `F0`
*/
def narrow[F0[x] <: F[x]]: FunctionK[F0, G] = this.asInstanceOf[FunctionK[F0, G]]
}

object FunctionK extends FunctionKMacroMethods {
Expand Down

0 comments on commit fb0678d

Please sign in to comment.