Skip to content

Commit

Permalink
Move Compose instance for Map to separate trait
Browse files Browse the repository at this point in the history
Fix binary compatibility issues by moving the new Compose instance for Map
to a separate trait.
  • Loading branch information
denisrosca committed Aug 14, 2018
1 parent 284b183 commit c6abd50
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/main/scala/cats/implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ object implicits
with syntax.AllSyntaxBinCompat2
with instances.AllInstances
with instances.AllInstancesBinCompat0
with instances.AllInstancesBinCompat1
3 changes: 3 additions & 0 deletions core/src/main/scala/cats/instances/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ trait AllInstances
trait AllInstancesBinCompat0
extends FunctionInstancesBinCompat0
with Tuple2InstancesBinCompat0

trait AllInstancesBinCompat1
extends MapInstancesBinCompat0
5 changes: 5 additions & 0 deletions core/src/main/scala/cats/instances/map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ trait MapInstances extends cats.kernel.instances.MapInstances {
}
// scalastyle:on method.length

}

trait MapInstancesBinCompat0 {

implicit def catsStdComposeForMap: Compose[Map] = new Compose[Map] {

def compose[A, B, C](f: Map[B, C], g: Map[A, B]): Map[A, C] = {
Expand All @@ -94,4 +98,5 @@ trait MapInstances extends cats.kernel.instances.MapInstances {
}

}

}
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/package.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats

package object instances {
object all extends AllInstances with AllInstancesBinCompat0
object all extends AllInstances with AllInstancesBinCompat0 with AllInstancesBinCompat1
object bigInt extends BigIntInstances
object bigDecimal extends BigDecimalInstances
object bitSet extends BitSetInstances
Expand All @@ -21,7 +21,7 @@ package object instances {
object invariant extends InvariantMonoidalInstances
object list extends ListInstances
object long extends LongInstances
object map extends MapInstances
object map extends MapInstances with MapInstancesBinCompat0
object option extends OptionInstances
object order extends OrderInstances
object ordering extends OrderingInstances
Expand Down
4 changes: 2 additions & 2 deletions testkit/src/main/scala/cats/tests/CatsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cats
package tests

import catalysts.Platform
import cats.instances.{AllInstances, AllInstancesBinCompat0}
import cats.instances.{AllInstances, AllInstancesBinCompat0, AllInstancesBinCompat1}
import cats.syntax.{AllSyntax, AllSyntaxBinCompat0, AllSyntaxBinCompat1, AllSyntaxBinCompat2, EqOps}
import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.{FunSuite, FunSuiteLike, Matchers}
Expand Down Expand Up @@ -33,7 +33,7 @@ trait CatsSuite extends FunSuite
with GeneratorDrivenPropertyChecks
with Discipline
with TestSettings
with AllInstances with AllInstancesBinCompat0
with AllInstances with AllInstancesBinCompat0 with AllInstancesBinCompat1
with AllSyntax with AllSyntaxBinCompat0 with AllSyntaxBinCompat1
with AllSyntaxBinCompat2
with StrictCatsEquality { self: FunSuiteLike =>
Expand Down

0 comments on commit c6abd50

Please sign in to comment.