Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose newtype objects to Mima #4219

Merged
merged 3 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions core/src/main/scala/cats/data/NonEmptyChain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
package cats
package data

import NonEmptyChainImpl.create

import cats.instances.StaticMethods
import cats.kernel._

import scala.collection.immutable.SortedMap

private[data] object NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
/**
* Actual implementation for [[cats.data.NonEmptyChain]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptyChain]] instead.
*/
object NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
// The following 3 types are components of a technique to
// create a no-boxing newtype. It's copied from the
// newtypes lib by @alexknvl
Expand Down Expand Up @@ -83,10 +88,12 @@ class NonEmptyChainOps[A](private val value: NonEmptyChain[A])
extends AnyVal
with NonEmptyCollection[A, Chain, NonEmptyChain] {

import NonEmptyChainImpl.{create, unwrap}

/**
* Converts this chain to a `Chain`
*/
final def toChain: Chain[A] = NonEmptyChainImpl.unwrap(value)
final def toChain: Chain[A] = unwrap(value)

/**
* Returns a new NonEmptyChain consisting of `a` followed by this. O(1) runtime.
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/scala/cats/data/NonEmptyMapImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ import cats.kernel._

import scala.collection.immutable._

private[data] object NonEmptyMapImpl extends NonEmptyMapInstances with Newtype2 {
/**
* Actual implementation for [[cats.data.NonEmptyMap]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptyMap]] instead.
*/
object NonEmptyMapImpl extends NonEmptyMapInstances with Newtype2 {

private[data] def create[K, A](m: SortedMap[K, A]): Type[K, A] =
m.asInstanceOf[Type[K, A]]
Expand Down
13 changes: 11 additions & 2 deletions core/src/main/scala/cats/data/NonEmptySet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ package data
import cats.kernel._

import scala.collection.immutable._

import kernel.compat.scalaVersionSpecific._

private[data] object NonEmptySetImpl extends NonEmptySetInstances with Newtype {
/**
* Actual implementation for [[cats.data.NonEmptySet]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptySet]] instead.
*/
object NonEmptySetImpl extends NonEmptySetInstances with Newtype {

private[data] def create[A](s: SortedSet[A]): Type[A] =
s.asInstanceOf[Type[A]]
Expand Down Expand Up @@ -433,7 +441,8 @@ sealed abstract private[data] class NonEmptySetInstances0 extends NonEmptySetIns
}

sealed abstract private[data] class NonEmptySetInstances1 {
private[data] def catsDataEqForNonEmptySet[A](implicit A: Order[A]): Eq[NonEmptySet[A]] =
@deprecated("use catsDataEqForNonEmptySetFromEqA instead", "2.8.0")
def catsDataEqForNonEmptySet[A](implicit A: Order[A]): Eq[NonEmptySet[A]] =
catsDataEqForNonEmptySetFromEqA[A]

implicit def catsDataEqForNonEmptySetFromEqA[A](implicit A: Eq[A]): Eq[NonEmptySet[A]] =
Expand Down