Permalink
Browse files

make private value class underlying "self" (#1378)

This feature is available since Scala 2.11.

scala/scala@4595ac6

(We dropped Scala 2.10 support in 7.3.x 48a9b51 )
  • Loading branch information...
xuwei-k committed May 5, 2017
1 parent 45b229e commit c0e4b531847348e1fd533c7d3605fe69320dde91
Showing with 35 additions and 35 deletions.
  1. +2 −2 core/src/main/scala/scalaz/EitherT.scala
  2. +1 −1 core/src/main/scala/scalaz/StrictTree.scala
  3. +1 −1 core/src/main/scala/scalaz/Validation.scala
  4. +1 −1 core/src/main/scala/scalaz/syntax/ContTOps.scala
  5. +1 −1 core/src/main/scala/scalaz/syntax/EitherOps.scala
  6. +1 −1 core/src/main/scala/scalaz/syntax/IdOps.scala
  7. +2 −2 core/src/main/scala/scalaz/syntax/KleisliOps.scala
  8. +1 −1 core/src/main/scala/scalaz/syntax/MaybeOps.scala
  9. +1 −1 core/src/main/scala/scalaz/syntax/MonadErrorIdOps.scala
  10. +1 −1 core/src/main/scala/scalaz/syntax/MonadTransSyntax.scala
  11. +1 −1 core/src/main/scala/scalaz/syntax/NonEmptyListOps.scala
  12. +1 −1 core/src/main/scala/scalaz/syntax/ReducerOps.scala
  13. +1 −1 core/src/main/scala/scalaz/syntax/StateOps.scala
  14. +1 −1 core/src/main/scala/scalaz/syntax/StrictTreeOps.scala
  15. +1 −1 core/src/main/scala/scalaz/syntax/TagOps.scala
  16. +2 −2 core/src/main/scala/scalaz/syntax/TheseOps.scala
  17. +1 −1 core/src/main/scala/scalaz/syntax/TreeOps.scala
  18. +1 −1 core/src/main/scala/scalaz/syntax/ValidationOps.scala
  19. +1 −1 core/src/main/scala/scalaz/syntax/WriterOps.scala
  20. +1 −1 core/src/main/scala/scalaz/syntax/std/BooleanOps.scala
  21. +1 −1 core/src/main/scala/scalaz/syntax/std/EitherOps.scala
  22. +1 −1 core/src/main/scala/scalaz/syntax/std/Function1Ops.scala
  23. +1 −1 core/src/main/scala/scalaz/syntax/std/Function2Ops.scala
  24. +1 −1 core/src/main/scala/scalaz/syntax/std/ListOps.scala
  25. +1 −1 core/src/main/scala/scalaz/syntax/std/OptionIdOps.scala
  26. +1 −1 core/src/main/scala/scalaz/syntax/std/OptionOps.scala
  27. +1 −1 core/src/main/scala/scalaz/syntax/std/StreamOps.scala
  28. +1 −1 core/src/main/scala/scalaz/syntax/std/StringOps.scala
  29. +1 −1 core/src/main/scala/scalaz/syntax/std/TryOps.scala
  30. +1 −1 core/src/main/scala/scalaz/syntax/std/VectorOps.scala
  31. +1 −1 effect/src/main/scala/scalaz/syntax/effect/IdOps.scala
  32. +1 −1 project/GenerateTupleW.scala
@@ -259,12 +259,12 @@ object EitherT extends EitherTInstances {
def rightU[A]: EitherTRight[A] =
new EitherTRight[A](true)
private[scalaz] final class EitherTLeft[B](val dummy: Boolean) extends AnyVal {
private[scalaz] final class EitherTLeft[B](private val dummy: Boolean) extends AnyVal {
def apply[FA](fa: FA)(implicit F: Unapply[Functor, FA]): EitherT[F.M, F.A, B] =
left[F.M, F.A, B](F(fa))(F.TC)
}
private[scalaz] final class EitherTRight[A](val dummy: Boolean) extends AnyVal {
private[scalaz] final class EitherTRight[A](private val dummy: Boolean) extends AnyVal {
def apply[FB](fb: FB)(implicit F: Unapply[Functor, FB]): EitherT[F.M, A, F.A] =
right[F.M, A, F.A](F(fb))(F.TC)
}
@@ -451,7 +451,7 @@ private trait StrictTreeEqual[A] extends Equal[StrictTree[A]] {
}
}
final class StrictTreeUnzip[A1, A2](val root: StrictTree[(A1, A2)]) extends AnyVal {
final class StrictTreeUnzip[A1, A2](private val root: StrictTree[(A1, A2)]) extends AnyVal {
private def unzipCombiner(rootLabel: (A1, A2))(accumulator: Seq[(StrictTree[A1], StrictTree[A2])]): (StrictTree[A1], StrictTree[A2]) = {
(StrictTree(rootLabel._1, accumulator.map(_._1).toVector), StrictTree(rootLabel._2, accumulator.map(_._2).toVector))
}
@@ -465,7 +465,7 @@ sealed abstract class ValidationInstances0 extends ValidationInstances1 {
}
}
final class ValidationFlatMap[E, A] private[scalaz](val self: Validation[E, A]) extends AnyVal {
final class ValidationFlatMap[E, A] private[scalaz](private val self: Validation[E, A]) extends AnyVal {
/** Bind through the success of this validation. */
def flatMap[EE >: E, B](f: A => Validation[EE, B]): Validation[EE, B] =
self match {
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class ContTOps[M[_], A](val self: M[A]) extends AnyVal {
final class ContTOps[M[_], A](private val self: M[A]) extends AnyVal {
final def cps[R](implicit M: Bind[M]): ContT[M, R, A] =
ContT((f: A => M[R]) => M.bind(self)(f))
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class EitherOps[A](val self: A) extends AnyVal {
final class EitherOps[A](private val self: A) extends AnyVal {
final def left[B]: (A \/ B) =
-\/(self)
@@ -3,7 +3,7 @@ package syntax
import annotation.tailrec
final class IdOps[A](val self: A) extends AnyVal {
final class IdOps[A](private val self: A) extends AnyVal {
/**Returns `self` if it is non-null, otherwise returns `d`. */
final def ??(d: => A)(implicit ev: Null <:< A): A =
if (self == null) d else self
@@ -3,15 +3,15 @@ package syntax
import Id._
final class KleisliIdOps[A](val self: A) extends AnyVal {
final class KleisliIdOps[A](private val self: A) extends AnyVal {
/** Lift the value into a Kleisli */
def liftKleisliId[R]: Kleisli[Id, R, A] = Kleisli[Id, R, A](_ => self)
/** Lift the value into a Reader. Alias for liftKleisliId */
def liftReader[R]: Reader[R, A] = liftKleisliId
}
final class KleisliFAOps[F[_], A](val self: F[A]) extends AnyVal {
final class KleisliFAOps[F[_], A](private val self: F[A]) extends AnyVal {
/** Lift the computation into a Kleisli */
def liftKleisli[R]: Kleisli[F, R, A] = Kleisli[F, R, A](_ => self)
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class MaybeOps[A](val self: A) extends AnyVal {
final class MaybeOps[A](private val self: A) extends AnyVal {
final def just: Maybe[A] = Maybe.just(self)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class MonadErrorIdOps[S](val self: S) extends AnyVal {
final class MonadErrorIdOps[S](private val self: S) extends AnyVal {
def raiseError[F[_], A](implicit F: MonadError[F, S]): F[A] =
F.raiseError[A](self)
}
@@ -5,6 +5,6 @@ trait ToMonadTransOps {
implicit def MonadTransGFGA[F[_[_], _], G[_], A](gfga: G[F[G, A]]): MonadTransGFGA[F, G, A] = new MonadTransGFGA[F, G, A](gfga)
}
final class MonadTransGFGA[F[_[_], _], G[_], A](val self: G[F[G, A]]) extends AnyVal {
final class MonadTransGFGA[F[_[_], _], G[_], A](private val self: G[F[G, A]]) extends AnyVal {
def wrapEffect(implicit F: MonadTrans[F], G: Monad[G]): F[G, A] = F.wrapEffect(self)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class NelOps[A](val self: A) extends AnyVal {
final class NelOps[A](private val self: A) extends AnyVal {
final def wrapNel: NonEmptyList[A] =
NonEmptyList(self)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class ReducerOps[A](val self: A) extends AnyVal {
final class ReducerOps[A](private val self: A) extends AnyVal {
/** Convert the value into a monoid */
def unit[M](implicit r: Reducer[A,M]): M = r.unit(self)
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class StateOps[A](val self: A) extends AnyVal {
final class StateOps[A](private val self: A) extends AnyVal {
def state[S]: State[S, A] = State.state[S, A](self)
def stateT[F[_]:Monad, S]: StateT[F, S, A] = StateT.stateT[F, S, A](self)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class StrictTreeOps[A](val self: A) extends AnyVal {
final class StrictTreeOps[A](private val self: A) extends AnyVal {
def strictNode(subForest: StrictTree[A]*): StrictTree[A] = StrictTree(self, subForest.toVector)
def strictLeaf: StrictTree[A] = StrictTree.Leaf(self)
@@ -3,7 +3,7 @@ package scalaz.syntax
import scalaz._
final class TagOps[A, T] private[syntax](val self: A @@ T) extends AnyVal {
final class TagOps[A, T] private[syntax](private val self: A @@ T) extends AnyVal {
def unwrap: A = Tag.unwrap(self)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class TheseOps[A](val self: A) extends AnyVal {
final class TheseOps[A](private val self: A) extends AnyVal {
final def wrapThis[B]: A \&/ B =
\&/.This(self)
@@ -15,7 +15,7 @@ final class TheseOps[A](val self: A) extends AnyVal {
\&/.That(self)
}
final class ThesePairOps[A, B](val self: (A, B)) extends AnyVal {
final class ThesePairOps[A, B](private val self: (A, B)) extends AnyVal {
final def both: A \&/ B =
\&/.Both(self._1, self._2)
}
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class TreeOps[A](val self: A) extends AnyVal {
final class TreeOps[A](private val self: A) extends AnyVal {
def node(subForest: Tree[A]*): Tree[A] = Tree.Node(self, subForest.toStream)
def leaf: Tree[A] = Tree.Leaf(self)
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class ValidationOps[A](val self: A) extends AnyVal {
final class ValidationOps[A](private val self: A) extends AnyVal {
def success[X]: Validation[X, A] = Validation.success[X, A](self)
def successNel[X]: ValidationNel[X, A] = success
@@ -1,7 +1,7 @@
package scalaz
package syntax
final class WriterOps[A](val self: A) extends AnyVal {
final class WriterOps[A](private val self: A) extends AnyVal {
def set[W](w: W): Writer[W, A] = WriterT.writer(w -> self)
def tell: Writer[A, Unit] = WriterT.tell(self)
@@ -6,7 +6,7 @@ import scalaz.std.{boolean => b}
import scalaz.Tags.{ Conjunction, Disjunction }
final class BooleanOps(val self: Boolean) extends AnyVal {
final class BooleanOps(private val self: Boolean) extends AnyVal {
final def conjunction: Boolean @@ Conjunction = Conjunction(self)
@@ -2,7 +2,7 @@ package scalaz
package syntax
package std
final class EitherOps[A, B](val self: Either[A, B]) extends AnyVal {
final class EitherOps[A, B](private val self: Either[A, B]) extends AnyVal {
final def disjunction: A \/ B = \/ fromEither self
@@ -4,7 +4,7 @@ package std
import Leibniz.===
final class Function1Ops[T, R](val self: T => R) extends AnyVal {
final class Function1Ops[T, R](private val self: T => R) extends AnyVal {
def on[X](f: (R, R) => X, t1: T, t2: T): X = f(self(t1), self(t2))
@@ -2,7 +2,7 @@ package scalaz
package syntax
package std
final class Function2Ops[T1, T2, R](val self: (T1, T2) => R) extends AnyVal {
final class Function2Ops[T1, T2, R](private val self: (T1, T2) => R) extends AnyVal {
def flip: (T2, T1) => R = (v2: T2, v1: T1) => self(v1, v2)
def on[X](f: (R, R) => X, t1: (T1, T1), t2: (T2, T2)): X = f(self(t1._1, t2._1), self(t1._2, t2._2))
@@ -5,7 +5,7 @@ package std
import scalaz.std.{list => l}
final class ListOps[A](val self: List[A]) extends AnyVal {
final class ListOps[A](private val self: List[A]) extends AnyVal {
final def intersperse(a: A): List[A] = l.intersperse(self, a)
final def tailOption: Option[List[A]] = l.tailOption(self)
@@ -1,7 +1,7 @@
package scalaz.syntax
package std
final class OptionIdOps[A](val self: A) extends AnyVal {
final class OptionIdOps[A](private val self: A) extends AnyVal {
def some: Option[A] = Some(self)
}
@@ -5,7 +5,7 @@ package std
import scalaz.std.{option => o}
import scalaz.Tags.{Last, First}
final class OptionOps[A](val self: Option[A]) extends AnyVal {
final class OptionOps[A](private val self: Option[A]) extends AnyVal {
final def cata[X](some: A => X, none: => X): X = o.cata(self)(some, none)
/**
@@ -5,7 +5,7 @@ package std
import scalaz.std.{stream => s}
final class StreamOps[A](val self: Stream[A]) extends AnyVal {
final class StreamOps[A](private val self: Stream[A]) extends AnyVal {
final def interleave(other: Stream[A]): Stream[A] = s.interleave(self, other)
final def toZipper: Option[Zipper[A]] = s.toZipper(self)
final def zipperEnd: Option[Zipper[A]] = s.zipperEnd(self)
@@ -4,7 +4,7 @@ package std
import scalaz.std.{string => s}
final class StringOps(val self: String) extends AnyVal {
final class StringOps(private val self: String) extends AnyVal {
/**
* Returns the same String value if the given value is 1 otherwise pluralises this String by appending an "s" unless
* this String ends with "y" and not one of ["ay", "ey", "iy", "oy", "uy"] in which case the 'y' character is chopped and "ies"
@@ -6,7 +6,7 @@ import scala.util.Try
import scalaz.std.{`try` => t}
final class TryOps[A](val self: Try[A]) extends AnyVal {
final class TryOps[A](private val self: Try[A]) extends AnyVal {
final def cata[B](success: A => B, failure: Throwable => B): B =
t.cata(self)(success, failure)
@@ -5,7 +5,7 @@ package std
import scalaz.std.{vector => v}
final class VectorOps[A](val self: Vector[A]) extends AnyVal {
final class VectorOps[A](private val self: Vector[A]) extends AnyVal {
final def intersperse(a: A): Vector[A] = v.intersperse(self, a)
final def toNel: Option[NonEmptyList[A]] = v.toNel(self)
@@ -4,7 +4,7 @@ package effect
import scalaz.effect.IO
final class IdOps[A](val self: A) extends AnyVal {
final class IdOps[A](private val self: A) extends AnyVal {
final def put(implicit S: Show[A]): IO[Unit] =
IO.put(self)
@@ -44,7 +44,7 @@ object GenerateTupleW {
}
val pimp = s"""|
|final class Tuple${arity}Ops[${tparams}](val value: (${tparams})) extends AnyVal {
|final class Tuple${arity}Ops[${tparams}](private val value: (${tparams})) extends AnyVal {
| def fold[Z](f: => (${tparams}) => Z): Z = {import value._; f(${params})}
| def toIndexedSeq[Z](implicit ev: value.type <:< Tuple${arity}[${ztparams}]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(${params})}
| def mapElements[${mapallTParams}](${mapallParams}): (${mapallTParams}) = (${mapallApply})

0 comments on commit c0e4b53

Please sign in to comment.