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

Make a bunch of classes final and a few private #622

Merged
merged 2 commits into from
Nov 15, 2015
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
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object OptionT extends OptionTInstances {
*/
def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied

class FromOptionPartiallyApplied[F[_]] private[OptionT] {
final class FromOptionPartiallyApplied[F[_]] private[OptionT] {
def apply[A](value: Option[A])(implicit F: Applicative[F]): OptionT[F, A] =
OptionT(F.pure(value))
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/cats/data/Prod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ private[data] sealed abstract class ProdInstances extends ProdInstances0 {
}
}

sealed abstract class ProdInstances0 extends ProdInstances1 {
private[data] sealed abstract class ProdInstances0 extends ProdInstances1 {
implicit def prodMonoidK[F[_], G[_]](implicit FF: MonoidK[F], GG: MonoidK[G]): MonoidK[Lambda[X => Prod[F, G, X]]] = new ProdMonoidK[F, G] {
def F: MonoidK[F] = FF
def G: MonoidK[G] = GG
}
}

sealed abstract class ProdInstances1 extends ProdInstances2 {
private[data] sealed abstract class ProdInstances1 extends ProdInstances2 {
implicit def prodSemigroupK[F[_], G[_]](implicit FF: SemigroupK[F], GG: SemigroupK[G]): SemigroupK[Lambda[X => Prod[F, G, X]]] = new ProdSemigroupK[F, G] {
def F: SemigroupK[F] = FF
def G: SemigroupK[G] = GG
}
}

sealed abstract class ProdInstances2 extends ProdInstances3 {
private[data] sealed abstract class ProdInstances2 extends ProdInstances3 {
implicit def prodApplicative[F[_], G[_]](implicit FF: Applicative[F], GG: Applicative[G]): Applicative[Lambda[X => Prod[F, G, X]]] = new ProdApplicative[F, G] {
def F: Applicative[F] = FF
def G: Applicative[G] = GG
}
}

sealed abstract class ProdInstances3 extends ProdInstances4 {
private[data] sealed abstract class ProdInstances3 extends ProdInstances4 {
implicit def prodApply[F[_], G[_]](implicit FF: Apply[F], GG: Apply[G]): Apply[Lambda[X => Prod[F, G, X]]] = new ProdApply[F, G] {
def F: Apply[F] = FF
def G: Apply[G] = GG
}
}

sealed abstract class ProdInstances4 {
private[data] sealed abstract class ProdInstances4 {
implicit def prodFunctor[F[_], G[_]](implicit FF: Functor[F], GG: Functor[G]): Functor[Lambda[X => Prod[F, G, X]]] = new ProdFunctor[F, G] {
def F: Functor[F] = FF
def G: Functor[G] = GG
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/cats/data/StreamingT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ object StreamingT extends StreamingTInstances {
* and Always). The head of `Cons` is eager -- a lazy head can be
* represented using `Wait(Always(...))` or `Wait(Later(...))`.
*/
private[cats] case class Empty[F[_], A]() extends StreamingT[F, A]
private[cats] case class Wait[F[_], A](next: F[StreamingT[F, A]]) extends StreamingT[F, A]
private[cats] case class Cons[F[_], A](a: A, tail: F[StreamingT[F, A]]) extends StreamingT[F, A]
private[cats] final case class Empty[F[_], A]() extends StreamingT[F, A]
private[cats] final case class Wait[F[_], A](next: F[StreamingT[F, A]]) extends StreamingT[F, A]
private[cats] final case class Cons[F[_], A](a: A, tail: F[StreamingT[F, A]]) extends StreamingT[F, A]

/**
* Create an empty stream of type A.
Expand Down Expand Up @@ -399,7 +399,7 @@ object StreamingT extends StreamingTInstances {
* evaluated.
*/
object syntax {
implicit class StreamingTOps[F[_], A](rhs: => StreamingT[F, A]) {
implicit final class StreamingTOps[F[_], A](rhs: => StreamingT[F, A]) {
def %::(a: A)(implicit ev: Applicative[F]): StreamingT[F, A] =
Cons(a, ev.pureEval(Always(rhs)))
def %:::(s: StreamingT[F, A])(implicit ev: Monad[F]): StreamingT[F, A] =
Expand All @@ -410,7 +410,7 @@ object StreamingT extends StreamingTInstances {
Wait(fs.map(_ concat ev.pureEval(Always(rhs))))
}

implicit class FStreamingTOps[F[_], A](rhs: F[StreamingT[F, A]]) {
implicit final class FStreamingTOps[F[_], A](rhs: F[StreamingT[F, A]]) {
def %::(a: A): StreamingT[F, A] =
Cons(a, rhs)
def %:::(s: StreamingT[F, A])(implicit ev: Monad[F]): StreamingT[F, A] =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cats.functor.Bifunctor
* `XorT[F, A, B]` wraps a value of type `F[A Xor B]`. An `F[C]` can be lifted in to `XorT[F, A, C]` via `XorT.right`,
* and lifted in to a `XorT[F, C, B]` via `XorT.left`.
*/
case class XorT[F[_], A, B](value: F[A Xor B]) {
final case class XorT[F[_], A, B](value: F[A Xor B]) {

def fold[C](fa: A => C, fb: B => C)(implicit F: Functor[F]): F[C] = F.map(value)(_.fold(fa, fb))

Expand Down
3 changes: 1 addition & 2 deletions core/src/main/scala/cats/syntax/bifunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ trait BifunctorSyntax {
new BifunctorOps[F, A, B](fab)
}

class BifunctorOps[F[_, _], A, B](fab: F[A, B])(implicit F: Bifunctor[F]) {

final class BifunctorOps[F[_, _], A, B](fab: F[A, B])(implicit F: Bifunctor[F]) {
def bimap[C, D](f: A => C, g: B => D): F[C,D] = F.bimap(fab)(f,g)

def leftMap[C](f: A => C): F[C, B] = F.leftMap(fab)(f)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/compose.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait ComposeSyntax {
new ComposeOps[F, A, B](fab)
}

class ComposeOps[F[_, _], A, B](fab: F[A, B])(implicit F: Compose[F]) {
final class ComposeOps[F[_, _], A, B](fab: F[A, B])(implicit F: Compose[F]) {
def compose[Z](fza: F[Z, A]): F[Z, B] = F.compose(fab, fza)
def andThen[C](fbc: F[B, C]): F[A, C] = F.andThen(fab, fbc)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ trait EitherSyntax {
implicit def eitherSyntax[A, B](eab: Either[A, B]): EitherOps[A, B] = new EitherOps(eab)
}

class EitherOps[A, B](val eab: Either[A, B]) extends AnyVal {
final class EitherOps[A, B](val eab: Either[A, B]) extends AnyVal {
def toXor: A Xor B = Xor.fromEither(eab)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/eq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait EqSyntax {
new EqOps[A](a)
}

class EqOps[A: Eq](lhs: A) {
final class EqOps[A: Eq](lhs: A) {
def ===(rhs: A): Boolean = macro Ops.binop[A, Boolean]
def =!=(rhs: A): Boolean = macro Ops.binop[A, Boolean]
}
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/syntax/flatMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait FlatMapSyntax extends FlatMapSyntax1 {
new IfMOps[F](fa)
}

class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {
final class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {
def flatMap[B](f: A => F[B]): F[B] = F.flatMap(fa)(f)
def mproduct[B](f: A => F[B]): F[(A, B)] = F.mproduct(fa)(f)
def >>=[B](f: A => F[B]): F[B] = F.flatMap(fa)(f)
Expand All @@ -41,10 +41,10 @@ class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {

}

class FlattenOps[F[_], A](ffa: F[F[A]])(implicit F: FlatMap[F]) {
final class FlattenOps[F[_], A](ffa: F[F[A]])(implicit F: FlatMap[F]) {
def flatten: F[A] = F.flatten(ffa)
}

class IfMOps[F[_]](fa: F[Boolean])(implicit F: FlatMap[F]) {
final class IfMOps[F[_]](fa: F[Boolean])(implicit F: FlatMap[F]) {
def ifM[B](ifTrue: => F[B], ifFalse: => F[B]): F[B] = F.ifM(fa)(ifTrue, ifFalse)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait FoldableSyntax extends Foldable.ToFoldableOps with FoldableSyntax1 {
new NestedFoldableOps[F, G, A](fga)
}

class NestedFoldableOps[F[_], G[_], A](fga: F[G[A]])(implicit F: Foldable[F]) {
final class NestedFoldableOps[F[_], G[_], A](fga: F[G[A]])(implicit F: Foldable[F]) {
def sequence_[B](implicit G: Applicative[G]): G[Unit] = F.sequence_(fga)
def foldK(implicit G: MonoidK[G]): G[A] = F.foldK(fga)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait GroupSyntax extends SemigroupSyntax {
new GroupOps[A](a)
}

class GroupOps[A: Group](lhs: A) {
final class GroupOps[A: Group](lhs: A) {
def |-|(rhs: A): A = macro Ops.binop[A, A]
def remove(rhs: A): A = macro Ops.binop[A, A]
def inverse(): A = macro Ops.unop[A]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/monadCombine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ trait MonadCombineSyntax {
new NestedMonadCombineOps[F, G, A](fga)
}

class NestedMonadCombineOps[F[_], G[_], A](fga: F[G[A]])(implicit F: MonadCombine[F]) {
final class NestedMonadCombineOps[F[_], G[_], A](fga: F[G[A]])(implicit F: MonadCombine[F]) {
def unite(implicit G: Foldable[G]): F[A] = F.unite(fga)
}
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ trait OptionSyntax {
implicit def optionSyntax[A](oa: Option[A]): OptionOps[A] = new OptionOps(oa)
}

class OptionIdOps[A](val a: A) extends AnyVal {
final class OptionIdOps[A](val a: A) extends AnyVal {
def some: Option[A] = Option(a)
}

class OptionOps[A](val oa: Option[A]) extends AnyVal {
final class OptionOps[A](val oa: Option[A]) extends AnyVal {
def toLeftXor[B](b: => B): A Xor B = oa.fold[A Xor B](Xor.Right(b))(Xor.Left(_))
def toRightXor[B](b: => B): B Xor A = oa.fold[B Xor A](Xor.Left(b))(Xor.Right(_))
def toInvalid[B](b: => B): Validated[A, B] = oa.fold[Validated[A, B]](Validated.Valid(b))(Validated.Invalid(_))
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/order.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait OrderSyntax extends PartialOrderSyntax {
new OrderOps[A](a)
}

class OrderOps[A: Order](lhs: A) {
final class OrderOps[A: Order](lhs: A) {
def compare(rhs: A): Int = macro Ops.binop[A, Int]
def min(rhs: A): A = macro Ops.binop[A, A]
def max(rhs: A): A = macro Ops.binop[A, A]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/partialOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait PartialOrderSyntax extends EqSyntax {
new PartialOrderOps[A](a)
}

class PartialOrderOps[A](lhs: A)(implicit A: PartialOrder[A]) {
final class PartialOrderOps[A](lhs: A)(implicit A: PartialOrder[A]) {
def >(rhs: A): Boolean = macro Ops.binop[A, Boolean]
def >=(rhs: A): Boolean = macro Ops.binop[A, Boolean]
def <(rhs: A): Boolean = macro Ops.binop[A, Boolean]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/profunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait ProfunctorSyntax {
new ProfunctorOps[F, A, B](fab)
}

class ProfunctorOps[F[_, _], A, B](fab: F[A, B])(implicit F: Profunctor[F]) {
final class ProfunctorOps[F[_, _], A, B](fab: F[A, B])(implicit F: Profunctor[F]) {
def lmap[C](f: C => A): F[C, B] = F.lmap(fab)(f)
def rmap[C](f: B => C): F[A, C] = F.rmap(fab)(f)
def dimap[C, D](f: C => A)(g: B => D): F[C, D] = F.dimap(fab)(f)(g)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/semigroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait SemigroupSyntax {
new SemigroupOps[A](a)
}

class SemigroupOps[A: Semigroup](lhs: A) {
final class SemigroupOps[A: Semigroup](lhs: A) {
def |+|(rhs: A): A = macro Ops.binop[A, A]
def combine(rhs: A): A = macro Ops.binop[A, A]
def combineN(rhs: Int): A = macro Ops.binop[A, A]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/split.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ trait SplitSyntax {
new SplitOps[F, A, B](fab)
}

class SplitOps[F[_, _], A, B](fab: F[A, B])(implicit F: Split[F]) {
final class SplitOps[F[_, _], A, B](fab: F[A, B])(implicit F: Split[F]) {
def split[C, D](fcd: F[C, D]): F[(A, C), (B, D)] = F.split(fab, fcd)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/streaming.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait StreamingSyntax {
implicit def streamingOps[A](as: => Streaming[A]): StreamingOps[A] =
new StreamingOps(Always(as))

class StreamingOps[A](rhs: Eval[Streaming[A]]) {
final class StreamingOps[A](rhs: Eval[Streaming[A]]) {
def %::(lhs: A): Streaming[A] = Cons(lhs, rhs)
def %:::(lhs: Streaming[A]): Streaming[A] = lhs ++ rhs
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/strong.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait StrongSyntax {
new StrongOps[F, A, B](fab)
}

class StrongOps[F[_, _], A, B](fab: F[A, B])(implicit F: Strong[F]) {
final class StrongOps[F[_, _], A, B](fab: F[A, B])(implicit F: Strong[F]) {
def first[C]: F[(A, C), (B, C)] = F.first(fab)
def second[C]: F[(C, A), (C, B)] = F.second(fab)
}
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/traverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait TraverseSyntax extends TraverseSyntax1 {
new NestedTraverseOps[F, G, A](fga)
}

class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
def traverse[G[_]: Applicative, B](f: A => G[B]): G[F[B]] = F.traverse(fa)(f)

def traverseU[GB](f: A => GB)(implicit U: Unapply[Applicative, GB]): U.M[F[U.A]] =
Expand All @@ -29,6 +29,6 @@ class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {

}

class NestedTraverseOps[F[_], G[_], A](fga: F[G[A]])(implicit F: Traverse[F]) {
final class NestedTraverseOps[F[_], G[_], A](fga: F[G[A]])(implicit F: Traverse[F]) {
def sequence(implicit G: Applicative[G]): G[F[A]] = F.sequence(fga)
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait ValidatedSyntax {
implicit def validatedIdSyntax[A](a: A): ValidatedIdSyntax[A] = new ValidatedIdSyntax(a)
}

class ValidatedIdSyntax[A](val a: A) extends AnyVal {
final class ValidatedIdSyntax[A](val a: A) extends AnyVal {
def valid[B]: Validated[B, A] = Validated.Valid(a)
def validNel[B]: ValidatedNel[B, A] = Validated.Valid(a)
def invalid[B]: Validated[A, B] = Validated.Invalid(a)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/xor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait XorSyntax {
implicit def xorIdSyntax[A](a: A): XorIdOps[A] = new XorIdOps(a)
}

class XorIdOps[A](val a: A) extends AnyVal {
final class XorIdOps[A](val a: A) extends AnyVal {
def left[B]: A Xor B = Xor.Left(a)
def right[B]: B Xor A = Xor.Right(a)
}
8 changes: 4 additions & 4 deletions project/Boilerplate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import sbt._
object Boilerplate {
import scala.StringContext._

implicit class BlockHelper(val sc: StringContext) extends AnyVal {
implicit final class BlockHelper(val sc: StringContext) extends AnyVal {
def block(args: Any*): String = {
val interpolated = sc.standardInterpolator(treatEscapes, args)
val rawLines = interpolated split '\n'
Expand All @@ -41,7 +41,7 @@ object Boilerplate {

val maxArity = 22

class TemplateVals(val arity: Int) {
final class TemplateVals(val arity: Int) {
val synTypes = (0 until arity) map (n => s"A$n")
val synVals = (0 until arity) map (n => s"a$n")
val synTypedVals = (synVals zip synTypes) map { case (v,t) => v + ":" + t}
Expand Down Expand Up @@ -111,10 +111,10 @@ object Boilerplate {
|package cats
|package syntax
|
|private[syntax] class ApplyBuilder[F[_]] {
|private[syntax] final class ApplyBuilder[F[_]] {
| def |@|[A](a: F[A]) = new ApplyBuilder1(a)
|
- private[syntax] class ApplyBuilder$arity[${`A..N`}](${params}) {
- private[syntax] final class ApplyBuilder$arity[${`A..N`}](${params}) {
- $next
- def ap[Z](f: F[(${`A..N`}) => Z])(implicit F: Apply[F]): F[Z] = F.ap$n(${`a..n`})(f)
- def map[Z](f: (${`A..N`}) => Z)(implicit F: Apply[F]): F[Z] = F.map$n(${`a..n`})(f)
Expand Down
2 changes: 1 addition & 1 deletion state/src/main/scala/cats/state/StateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private[state] sealed abstract class StateTInstances0 {

// To workaround SI-7139 `object State` needs to be defined inside the package object
// together with the type alias.
abstract class StateFunctions {
private[state] abstract class StateFunctions {

def apply[S, A](f: S => (S, A)): State[S, A] =
StateT.applyF(Trampoline.done((s: S) => Trampoline.done(f(s))))
Expand Down