Skip to content

Commit

Permalink
updated to have PartialFunctionInstances mixed in with AllInstances; …
Browse files Browse the repository at this point in the history
…improved doctests with less imports now needed
  • Loading branch information
gagandeepkalra committed Jun 12, 2020
1 parent e815d83 commit 4fd8927
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 1 addition & 3 deletions core/src/main/scala-2.12/cats/instances/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ abstract class AllInstancesBinCompat
with AllInstancesBinCompat4
with AllInstancesBinCompat5
with AllInstancesBinCompat6
with AllInstancesBinCompat7

trait AllInstances
extends AnyValInstances
Expand Down Expand Up @@ -44,6 +43,7 @@ trait AllInstances
with TupleInstances
with UUIDInstances
with VectorInstances
with PartialFunctionInstances

trait AllInstancesBinCompat0 extends FunctionInstancesBinCompat0 with Tuple2InstancesBinCompat0

Expand All @@ -64,5 +64,3 @@ trait AllInstancesBinCompat4 extends SortedMapInstancesBinCompat1 with MapInstan
trait AllInstancesBinCompat5 extends SortedSetInstancesBinCompat0

trait AllInstancesBinCompat6 extends SortedSetInstancesBinCompat1 with SortedMapInstancesBinCompat2

trait AllInstancesBinCompat7 extends PartialFunctionInstances
4 changes: 1 addition & 3 deletions core/src/main/scala-2.13+/cats/instances/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ abstract class AllInstancesBinCompat
with AllInstancesBinCompat4
with AllInstancesBinCompat5
with AllInstancesBinCompat6
with AllInstancesBinCompat7

trait AllInstances
extends AnyValInstances
Expand Down Expand Up @@ -46,6 +45,7 @@ trait AllInstances
with TupleInstances
with UUIDInstances
with VectorInstances
with PartialFunctionInstances

trait AllInstancesBinCompat0 extends FunctionInstancesBinCompat0 with Tuple2InstancesBinCompat0

Expand All @@ -66,5 +66,3 @@ trait AllInstancesBinCompat4 extends SortedMapInstancesBinCompat1 with MapInstan
trait AllInstancesBinCompat5 extends SortedSetInstancesBinCompat0

trait AllInstancesBinCompat6 extends SortedSetInstancesBinCompat1 with SortedMapInstancesBinCompat2

trait AllInstancesBinCompat7 extends PartialFunctionInstances
1 change: 0 additions & 1 deletion core/src/main/scala/cats/implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ object implicits
with instances.AllInstancesBinCompat4
with instances.AllInstancesBinCompat5
with instances.AllInstancesBinCompat6
with instances.AllInstancesBinCompat7
12 changes: 8 additions & 4 deletions core/src/main/scala/cats/instances/partialFunction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import cats.arrow.{ArrowChoice, CommutativeArrow}

trait PartialFunctionInstances {

implicit val catsStdInstancesForPartialFunction: ArrowChoice[PartialFunction] with CommutativeArrow[PartialFunction] =
implicit def catsStdInstancesForPartialFunction: ArrowChoice[PartialFunction] with CommutativeArrow[PartialFunction] =
PartialFunctionInstances.instance
}

private object PartialFunctionInstances {

private val instance: ArrowChoice[PartialFunction] with CommutativeArrow[PartialFunction] =
new ArrowChoice[PartialFunction] with CommutativeArrow[PartialFunction] {

/**
Expand Down Expand Up @@ -34,10 +40,8 @@ trait PartialFunctionInstances {
* Example:
* {{{
* scala> import cats.arrow.Arrow
* scala> import cats.arrow.Strong
* scala> import cats.implicits._
* scala> val f: PartialFunction[Int, Int] = Arrow[PartialFunction].lift(_ * 2)
* scala> val fab = Strong[PartialFunction].first[Int,Int,Int](f)
* scala> val fab = Arrow[PartialFunction].first[Int,Int,Int](f)
* scala> fab((2,3))
* res0: (Int, Int) = (4,3)
* }}}
Expand Down

0 comments on commit 4fd8927

Please sign in to comment.