From 46dd6a6e4ebef853742c8ebc77b4ad078473bb36 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 24 Apr 2017 17:01:22 -0400 Subject: [PATCH] default value for dummy variable --- core/src/main/scala/cats/data/Const.scala | 4 +-- core/src/main/scala/cats/data/EitherT.scala | 28 +++++++++---------- core/src/main/scala/cats/data/OptionT.scala | 4 +-- core/src/main/scala/cats/data/Validated.scala | 2 +- core/src/main/scala/cats/syntax/either.scala | 2 +- free/src/main/scala/cats/free/Free.scala | 4 +-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/src/main/scala/cats/data/Const.scala b/core/src/main/scala/cats/data/Const.scala index ac7b3d1864f..599b9546800 100644 --- a/core/src/main/scala/cats/data/Const.scala +++ b/core/src/main/scala/cats/data/Const.scala @@ -40,7 +40,7 @@ object Const extends ConstInstances { def empty[A, B](implicit A: Monoid[A]): Const[A, B] = Const(A.empty) - private[data] final class OfPartiallyApplied[B](val dummy: Boolean) extends AnyVal { + private[data] final class OfPartiallyApplied[B](val dummy: Boolean = true ) extends AnyVal { def apply[A](a: A): Const[A, B] = Const(a) } @@ -52,7 +52,7 @@ object Const extends ConstInstances { * res0: Const[String, Int] = Const(a) * }}} */ - def of[B]: OfPartiallyApplied[B] = new OfPartiallyApplied(true) + def of[B]: OfPartiallyApplied[B] = new OfPartiallyApplied } private[data] sealed abstract class ConstInstances extends ConstInstances0 { diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index 31efe10f101..910af3719c3 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -231,7 +231,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) { object EitherT extends EitherTInstances { - private[data] final class LeftPartiallyApplied[B](val dummy: Boolean) extends AnyVal { + private[data] final class LeftPartiallyApplied[B](val dummy: Boolean = true ) extends AnyVal { def apply[F[_], A](fa: F[A])(implicit F: Functor[F]): EitherT[F, A, B] = EitherT(F.map(fa)(Either.left)) } @@ -244,9 +244,9 @@ object EitherT extends EitherTInstances { * res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Left(err))) * }}} */ - final def left[B]: LeftPartiallyApplied[B] = new LeftPartiallyApplied[B](true) + final def left[B]: LeftPartiallyApplied[B] = new LeftPartiallyApplied[B] - private[data] final class LeftTPartiallyApplied[F[_], B](val dummy: Boolean) extends AnyVal { + private[data] final class LeftTPartiallyApplied[F[_], B](val dummy: Boolean = true ) extends AnyVal { def apply[A](a: A)(implicit F: Applicative[F]): EitherT[F, A, B] = EitherT(F.pure(Either.left(a))) } @@ -259,9 +259,9 @@ object EitherT extends EitherTInstances { * res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Left(err))) * }}} */ - final def leftT[F[_], B]: LeftTPartiallyApplied[F, B] = new LeftTPartiallyApplied[F, B](true) + final def leftT[F[_], B]: LeftTPartiallyApplied[F, B] = new LeftTPartiallyApplied[F, B] - private[data] final class RightPartiallyApplied[A](val dummy: Boolean) extends AnyVal { + private[data] final class RightPartiallyApplied[A](val dummy: Boolean = true ) extends AnyVal { def apply[F[_], B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = EitherT(F.map(fb)(Either.right)) } @@ -274,9 +274,9 @@ object EitherT extends EitherTInstances { * res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(3))) * }}} */ - final def right[A]: RightPartiallyApplied[A] = new RightPartiallyApplied[A](true) + final def right[A]: RightPartiallyApplied[A] = new RightPartiallyApplied[A] - private[data] final class PurePartiallyApplied[F[_], A](val dummy: Boolean) extends AnyVal { + private[data] final class PurePartiallyApplied[F[_], A](val dummy: Boolean = true ) extends AnyVal { def apply[B](b: B)(implicit F: Applicative[F]): EitherT[F, A, B] = right(F.pure(b)) } @@ -289,7 +289,7 @@ object EitherT extends EitherTInstances { * res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(3))) * }}} */ - final def pure[F[_], A]: PurePartiallyApplied[F, A] = new PurePartiallyApplied[F, A](true) + final def pure[F[_], A]: PurePartiallyApplied[F, A] = new PurePartiallyApplied[F, A] /** * Alias for [[pure]] @@ -331,9 +331,9 @@ object EitherT extends EitherTInstances { * * The reason for the indirection is to emulate currying type parameters. */ - final def fromEither[F[_]]: FromEitherPartiallyApplied[F] = new FromEitherPartiallyApplied(true) + final def fromEither[F[_]]: FromEitherPartiallyApplied[F] = new FromEitherPartiallyApplied - private[data] final class FromEitherPartiallyApplied[F[_]](val dummy: Boolean) extends AnyVal { + private[data] final class FromEitherPartiallyApplied[F[_]](val dummy: Boolean = true ) extends AnyVal { def apply[E, A](either: Either[E, A])(implicit F: Applicative[F]): EitherT[F, E, A] = EitherT(F.pure(either)) } @@ -349,9 +349,9 @@ object EitherT extends EitherTInstances { * res1: EitherT[List, String, Int] = EitherT(List(Right(42))) * }}} */ - final def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied(true) + final def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied - private[data] final class FromOptionPartiallyApplied[F[_]](val dummy: Boolean) extends AnyVal { + private[data] final class FromOptionPartiallyApplied[F[_]](val dummy: Boolean = true ) extends AnyVal { def apply[E, A](opt: Option[A], ifNone: => E)(implicit F: Applicative[F]): EitherT[F, E, A] = EitherT(F.pure(Either.fromOption(opt, ifNone))) } @@ -384,9 +384,9 @@ object EitherT extends EitherTInstances { * res0: EitherT[Id, String, String] = EitherT(Left(The input does not look like a phone number)) * }}} */ - final def cond[F[_]]: CondPartiallyApplied[F] = new CondPartiallyApplied(true) + final def cond[F[_]]: CondPartiallyApplied[F] = new CondPartiallyApplied - private[data] final class CondPartiallyApplied[F[_]](val dummy: Boolean) extends AnyVal { + private[data] final class CondPartiallyApplied[F[_]](val dummy: Boolean = true ) extends AnyVal { def apply[E, A](test: Boolean, right: => A, left: => E)(implicit F: Applicative[F]): EitherT[F, E, A] = EitherT(F.pure(Either.cond(test, right, left))) } diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index aff74291bf5..2ee5531c985 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -162,9 +162,9 @@ object OptionT extends OptionTInstances { * * The reason for the indirection is to emulate currying type parameters. */ - def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied(true) + def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied - private[data] final class FromOptionPartiallyApplied[F[_]](val dummy: Boolean) extends AnyVal { + private[data] final class FromOptionPartiallyApplied[F[_]](val dummy: Boolean = true ) extends AnyVal { def apply[A](value: Option[A])(implicit F: Applicative[F]): OptionT[F, A] = OptionT(F.pure(value)) } diff --git a/core/src/main/scala/cats/data/Validated.scala b/core/src/main/scala/cats/data/Validated.scala index ba66dd13490..8a3e06c6382 100644 --- a/core/src/main/scala/cats/data/Validated.scala +++ b/core/src/main/scala/cats/data/Validated.scala @@ -260,7 +260,7 @@ object Validated extends ValidatedInstances with ValidatedFunctions{ */ def catchOnly[T >: Null <: Throwable]: CatchOnlyPartiallyApplied[T] = new CatchOnlyPartiallyApplied[T](true) - private[data] final class CatchOnlyPartiallyApplied[T](val dummy: Boolean) extends AnyVal{ + private[data] final class CatchOnlyPartiallyApplied[T](val dummy: Boolean = true ) extends AnyVal{ def apply[A](f: => A)(implicit T: ClassTag[T], NT: NotNull[T]): Validated[T, A] = try { valid(f) diff --git a/core/src/main/scala/cats/syntax/either.scala b/core/src/main/scala/cats/syntax/either.scala index 723317655d5..400be22d886 100644 --- a/core/src/main/scala/cats/syntax/either.scala +++ b/core/src/main/scala/cats/syntax/either.scala @@ -288,7 +288,7 @@ final class EitherObjectOps(val either: Either.type) extends AnyVal { // scalast } } -private[syntax] final class CatchOnlyPartiallyApplied[T](val dummy: Boolean) extends AnyVal { +private[syntax] final class CatchOnlyPartiallyApplied[T](val dummy: Boolean = true ) extends AnyVal { def apply[A](f: => A)(implicit CT: ClassTag[T], NT: NotNull[T]): Either[T, A] = try { Right(f) diff --git a/free/src/main/scala/cats/free/Free.scala b/free/src/main/scala/cats/free/Free.scala index 3956f629fd5..5e8cb214a8c 100644 --- a/free/src/main/scala/cats/free/Free.scala +++ b/free/src/main/scala/cats/free/Free.scala @@ -217,12 +217,12 @@ object Free { * bound independently of the `A` parameter below. */ def inject[F[_], G[_]]: FreeInjectKPartiallyApplied[F, G] = - new FreeInjectKPartiallyApplied(true) + new FreeInjectKPartiallyApplied /** * Pre-application of an injection to a `F[A]` value. */ - private[free] final class FreeInjectKPartiallyApplied[F[_], G[_]](val dummy: Boolean) extends AnyVal { + private[free] final class FreeInjectKPartiallyApplied[F[_], G[_]](val dummy: Boolean = true ) extends AnyVal { def apply[A](fa: F[A])(implicit I: InjectK[F, G]): Free[G, A] = Free.liftF(I.inj(fa)) }