Skip to content

Commit

Permalink
* make traits private and sealed to be consistent with typelevel#612
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Sanchez committed Nov 22, 2015
1 parent 0a1f1f7 commit 4a922ab
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/scala/cats/std/function.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.arrow.{Arrow, Choice}
import cats.data.Xor
import cats.functor.Contravariant

trait Function0Instances {
private[std] sealed trait Function0Instances {
implicit val function0Instance: Bimonad[Function0] =
new Bimonad[Function0] {
def extract[A](x: () => A): A = x()
Expand All @@ -26,7 +26,7 @@ trait Function0Instances {
}
}

trait Function1Instances extends Function1Instances0 {
private[std] sealed trait Function1Instances extends Function1Instances0 {
implicit def function1Contravariant[R]: Contravariant[? => R] =
new Contravariant[? => R] {
def contramap[T1, T0](fa: T1 => R)(f: T0 => T1): T0 => R =
Expand Down Expand Up @@ -78,33 +78,33 @@ trait Function1Instances extends Function1Instances0 {
new Function1MonoidK {}
}

trait Function1Instances0 {
private[std] sealed trait Function1Instances0 {
implicit def function1Semigroup[A,B](implicit S: Semigroup[B]): Semigroup[A => B] =
new Function1Semigroup[A, B] { def B: Semigroup[B] = S }

implicit val function1SemigroupK: SemigroupK[Lambda[A => A => A]] =
new Function1SemigroupK {}
}

private[std] trait Function1Semigroup[A, B] extends Semigroup[A => B] {
private[std] sealed trait Function1Semigroup[A, B] extends Semigroup[A => B] {
implicit def B: Semigroup[B]

override def combine(x: A => B, y: A => B): A => B = { a =>
B.combine(x(a), y(a))
}
}

private[std] trait Function1Monoid[A, B] extends Monoid[A => B] with Function1Semigroup[A, B] {
private[std] sealed trait Function1Monoid[A, B] extends Monoid[A => B] with Function1Semigroup[A, B] {
implicit def B: Monoid[B]

override def empty: A => B = _ => B.empty
}

private[std] trait Function1SemigroupK extends SemigroupK[Lambda[A => A => A]] {
private[std] sealed trait Function1SemigroupK extends SemigroupK[Lambda[A => A => A]] {
override def combine[A](x: A => A, y: A => A): A => A = x compose y
}

private[std] trait Function1MonoidK extends MonoidK[Lambda[A => A => A]] with Function1SemigroupK {
private[std] sealed trait Function1MonoidK extends MonoidK[Lambda[A => A => A]] with Function1SemigroupK {
override def empty[A]: A => A = identity[A]
}

Expand Down

0 comments on commit 4a922ab

Please sign in to comment.