Skip to content

Commit

Permalink
make NonEmptyChainImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
satorg committed Jun 2, 2022
1 parent 99d36c0 commit bf2194c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 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,12 @@
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 {
private[data] object NonEmptyChainImpl extends NonEmptyChainImpl {
// 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 All @@ -44,6 +42,12 @@ private[data] object NonEmptyChainImpl extends NonEmptyChainInstances with Scala

private[data] def unwrap[A](s: Type[A]): Chain[A] =
s.asInstanceOf[Chain[A]]
}

// This class has to be public to expose public methods to Mima.
@deprecated("for internal purposes only - do not use", "2.8.0")
sealed abstract class NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
self: NonEmptyChainImpl.type =>

def fromChain[A](as: Chain[A]): Option[NonEmptyChain[A]] =
if (as.nonEmpty) Option(create(as)) else None
Expand Down Expand Up @@ -83,10 +87,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

0 comments on commit bf2194c

Please sign in to comment.