Skip to content

Commit

Permalink
remove unused variable
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 13, 2023
1 parent c241438 commit 5f56c2f
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ class IOEffectSpec(implicit ee: ExecutionEnv) extends Specification with ScalaCh

def sleepFor(duration: FiniteDuration) =
try Thread.sleep(duration.toMillis)
catch { case t: Throwable => () }
catch { case _: Throwable => () }

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait EffImplicits {

def tailRecM[A, B](a: A)(f: A => Eff[AnyRef, Either[A, B]]): Eff[AnyRef, B] =
f(a) match {
case Pure(v, l) =>
case Pure(v, _) =>
v match {
case Left(a1) => tailRecM(a1)(f)
case Right(b) => Pure(b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ trait EffInterpretation {
result
}

case ap @ ImpureAp(unions, continuation, last) =>
case ImpureAp(unions, continuation, last) =>
val effects = unions.unions.map(_.tagged.valueUnsafe.asInstanceOf[M[Any]])
val sequenced = Traverse[Vector].sequence(effects)(applicative)

Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/org/atnos/eff/Interpret.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait Interpret {

def interpretLastEff(last: Eff[R, Unit]): Eff[U, Unit] =
last match {
case Pure(a, last1) =>
case Pure(_, last1) =>
interpretLast(last1).value.map(_.value).getOrElse(Eff.pure(()))

case Impure(NoEffect(a), c, last1) =>
Expand Down Expand Up @@ -82,7 +82,7 @@ trait Interpret {
case Left(other) => Impure(other, interpretContinuation(c), interpretLast(last))
}

case ap @ ImpureAp(unions, continuation, last) =>
case ImpureAp(unions, continuation, last) =>
val collected = unions.project

if (collected.effects.isEmpty)
Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/org/atnos/eff/IntoPoly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trait IntoPolyLower1 extends IntoPolyLower2 {
def apply[A](union: Union[FxAppend[NoFx, R], A]): Union[R, A] =
union match {
case UnionAppendR(r) => r
case UnionAppendL(l) => throw new EffImpossibleException("impossible - intoNoFxAppendL for UnionAppendL")
case UnionAppendL(_) => throw new EffImpossibleException("impossible - intoNoFxAppendL for UnionAppendL")
case UnionTagged(_, _) => throw new EffImpossibleException("impossible - intoNoFxAppendL for UnionTagged")
}
}
Expand All @@ -51,7 +51,7 @@ trait IntoPolyLower1 extends IntoPolyLower2 {
def apply[A](union: Union[FxAppend[R, NoFx], A]): Union[R, A] =
union match {
case UnionAppendL(l) => l
case UnionAppendR(r) => throw new EffImpossibleException("impossible - intoNoFxAppendR for UnionAppendR")
case UnionAppendR(_) => throw new EffImpossibleException("impossible - intoNoFxAppendR for UnionAppendR")
case UnionTagged(_, _) => throw new EffImpossibleException("impossible - intoNoFxAppendR for UnionTagged")
}
}
Expand Down
8 changes: 4 additions & 4 deletions core/shared/src/main/scala/org/atnos/eff/Last.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ case class Last[R](value: Option[Eval[Eff[R, Unit]]]) {
def <*(last: Last[R]): Last[R] =
(value, last.value) match {
case (None, None) => this
case (Some(r), None) => this
case (None, Some(l)) => last
case (Some(_), None) => this
case (None, Some(_)) => last
case (Some(r), Some(l)) => Last(Option(r.map2(l)((a, b) => b <* a)))
}

def *>(last: Last[R]): Last[R] =
(value, last.value) match {
case (None, None) => this
case (Some(r), None) => this
case (None, Some(l)) => last
case (Some(_), None) => this
case (None, Some(_)) => last
case (Some(r), Some(l)) => Last(Option(r.map2(l)(_ *> _)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ trait ErrorInterpretation[F] extends ErrorCreation[F] { outer =>
def ignoreException[R, E <: Throwable: ClassTag, A](action: Eff[R, A])(implicit m: ErrorOrOk /= R): Eff[R, Unit] =
catchError[R, A, Unit](
action,
(a: A) => (),
(_: A) => (),
{
case Left(t) if implicitly[ClassTag[E]].runtimeClass.isInstance(t) =>
EffMonad[R].pure(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object TimedFuture {
}

def raiseError[A](e: Throwable): TimedFuture[A] =
TimedFuture((s, ec) => Future.failed(e))
TimedFuture((_, _) => Future.failed(e))

def handleErrorWith[A](fa: TimedFuture[A])(f: Throwable => TimedFuture[A]): TimedFuture[A] =
TimedFuture((s, ec) => fa.runNow(s, ec).recoverWith[A] { case t => f(t).runNow(s, ec) }(ec))
Expand Down
2 changes: 1 addition & 1 deletion jvm/src/test/scala/org/atnos/eff/EffApplicativeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class EffApplicativeSpec(implicit ee: ExecutionEnv) extends Specification with S
runDsl(c.cast[Continuation[Fx1[UserDsl], User, A]].apply(getWebUser(i)))
case Impure(UnionTagged(GetUsers(is), _), c, _) =>
runDsl(c.cast[Continuation[Fx1[UserDsl], List[User], A]].apply(getWebUsers(is)))
case ap @ ImpureAp(u, m, _) =>
case ap @ ImpureAp(_, _, _) =>
runDsl(ap.toMonadic)
case Impure(_, _, _) =>
sys.error("this should not happen with just one effect. Got " + eff)
Expand Down
2 changes: 1 addition & 1 deletion jvm/src/test/scala/org/atnos/eff/FutureEffectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,5 @@ class FutureEffectSpec(implicit ee: ExecutionEnv) extends Specification with Sca

def sleepFor(duration: FiniteDuration) =
try Thread.sleep(duration.toMillis)
catch { case t: Throwable => () }
catch { case _: Throwable => () }
}
18 changes: 9 additions & 9 deletions macros/src/main/scala/org/atnos/eff/macros/EffMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EffMacros(val c: blackbox.Context) {

type Paramss = List[List[ValDef]]
def paramssToArgs(paramss: Paramss): List[List[TermName]] =
paramss.filter(_.nonEmpty).map(_.collect { case t @ ValDef(mods, name, _, _) => name })
paramss.filter(_.nonEmpty).map(_.collect { case ValDef(_, name, _, _) => name })

// remove () if no args
def methodCallFmt(method: c.universe.Tree, args: Seq[Seq[TermName]]) = if (args.flatten.isEmpty) method else q"$method(...$args)"
Expand Down Expand Up @@ -65,7 +65,7 @@ class EffMacros(val c: blackbox.Context) {
}

def findImplicitBracket(paramss: List[List[ValDef]]): Option[Int] = {
paramss.zipWithIndex.find { case (params, idx) => params.exists(_.mods.hasFlag(Flag.IMPLICIT)) }.map(_._2)
paramss.zipWithIndex.find { case (params, _) => params.exists(_.mods.hasFlag(Flag.IMPLICIT)) }.map(_._2)
}
def addImplicits(newImplicits: List[ValDef], paramss: List[List[ValDef]]) = {
findImplicitBracket(paramss).map { idx =>
Expand All @@ -87,9 +87,9 @@ class EffMacros(val c: blackbox.Context) {
// check some constraints that will result in a compiler error
stats.foreach {
case x: ValOrDefDef if x.mods.hasFlag(Flag.PRIVATE | Flag.PROTECTED) => c.abort(x.pos, "try using access modifier: package-private")
case v @ ValDef(_, _, rt: TypeTree, _) => c.abort(v.pos, s"Define the return type for:") // requires explicit return type
case d @ DefDef(_, _, _, _, rt: TypeTree, _) => c.abort(d.pos, s"Define the return type for:") // requires explicit return type
case v @ ValDef(mods, _, rt, _) if mods.hasFlag(Flag.MUTABLE) => c.abort(v.pos, s"var is not allow in @eff trait $tpname")
case v @ ValDef(_, _, _: TypeTree, _) => c.abort(v.pos, s"Define the return type for:") // requires explicit return type
case d @ DefDef(_, _, _, _, _: TypeTree, _) => c.abort(d.pos, s"Define the return type for:") // requires explicit return type
case v @ ValDef(mods, _, _, _) if mods.hasFlag(Flag.MUTABLE) => c.abort(v.pos, s"var is not allow in @eff trait $tpname")
case v @ ValDef(_, _, rt, EmptyTree) =>
if (!isReturnTypeOfTypeAlias(rt))
c.abort(v.pos, s"Abstract val needs to have return type ${typeAlias.name}[...], otherwise, make it non-abstract.")
Expand Down Expand Up @@ -124,7 +124,7 @@ class EffMacros(val c: blackbox.Context) {
val implicits = fixedParams match {
// this should not happen, there should be implicit parameters
case Nil => Nil
case ps :: is :: _ => is
case _ :: is :: _ => is
case is :: _ => is
}

Expand All @@ -151,7 +151,7 @@ class EffMacros(val c: blackbox.Context) {
trait SideEffect extends org.atnos.eff.SideEffect[${sealedTrait.name}] {
def apply[A](fa: ${sealedTrait.name}[A]): A = fa match {
case ..${absValsDefsOps.map {
case DefDef(_, name, _, paramss, rt, _) =>
case DefDef(_, name, _, paramss, _, _) =>
val binds = nonStackParams(paramss).flatMap(_.collect { case t: ValDef => Bind(t.name, Ident(termNames.WILDCARD)) })
val args = nonStackParams(paramss).map(_.collect { case t: ValDef => Ident(t.name.toTermName) })
val rhs = if (args.isEmpty) q"$name" else q"$name(...${args})"
Expand All @@ -178,7 +178,7 @@ class EffMacros(val c: blackbox.Context) {
trait Translate[R, U] extends org.atnos.eff.Translate[${sealedTrait.name}, U] {
def apply[X](fa: ${sealedTrait.name}[X]): Eff[U, X] = fa match {
case ..${absValsDefsOps.map {
case DefDef(_, name, _, paramss, rt, _) =>
case DefDef(_, name, _, paramss, _, _) =>
val binds = nonStackParams(paramss).flatMap(_.collect { case t: ValDef => Bind(t.name, Ident(termNames.WILDCARD)) })
val args = nonStackParams(paramss).map(_.collect { case t: ValDef => Ident(t.name.toTermName) })
val rhs = if (args.isEmpty) q"$name" else q"$name(...${args})"
Expand Down Expand Up @@ -273,7 +273,7 @@ class EffMacros(val c: blackbox.Context) {
trait FunctionK[M[_]] extends cats.~>[${sealedTrait.name}, M] {
def apply[X](fa: ${sealedTrait.name}[X]): M[X] = fa match {
case ..${absValsDefsOps.map {
case DefDef(_, name, _, paramss, rt, _) =>
case DefDef(_, name, _, paramss, _, _) =>
val binds = nonStackParams(paramss).flatMap(_.collect { case t: ValDef => Bind(t.name, Ident(termNames.WILDCARD)) })
val args = nonStackParams(paramss).map(_.collect { case t: ValDef => Ident(t.name.toTermName) })
val rhs = if (args.isEmpty) q"$name" else q"$name(...${args})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ trait SafeInterpretation extends SafeCreation { outer =>
}
}

case FailedValue(t) =>
case FailedValue(_) =>
Eff.pure(())

case FailedFinalizer(t) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object EffScalaz {
case NoEffect(a) => Monad[M].point(-\/(continuation(a).addLast(last)))
case UnionTagged(ta: M[Nothing] @unchecked, _) =>
last match {
case Last(Some(l)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last)))
case Last(Some(_)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last)))
case Last(None) => Monad[M].map(ta)(x => -\/(continuation(x)))
}
}
Expand All @@ -60,17 +60,17 @@ object EffScalaz {
case NoEffect(a) => Monad[M].point(-\/(continuation(a).addLast(last)))
case UnionTagged(ta: M[Nothing] @unchecked, _) =>
last match {
case Last(Some(l)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last)))
case Last(Some(_)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last)))
case Last(None) => Monad[M].map(ta)(x => -\/(continuation(x)))
}
}

case ap @ ImpureAp(unions, continuation, last) =>
case ImpureAp(unions, continuation, last) =>
val effects = unions.unions.collect { case UnionTagged(mx: M[Nothing] @unchecked, _) => mx }
val sequenced = applicative.sequence[Nothing, Vector](effects)

last match {
case Last(Some(l)) => Monad[M].map(sequenced)(x => -\/(continuation(x).addLast(last)))
case Last(Some(_)) => Monad[M].map(sequenced)(x => -\/(continuation(x).addLast(last)))
case Last(None) => Monad[M].map(sequenced)(x => -\/(continuation(x)))
}
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/test/scala/org/atnos/eff/EffSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class EffSpec extends Specification with ScalaCheck with ThrownExpectations with

def stacksafeReader = {
val list = (1 to 5000).toList
val action = list.traverse(i => ReaderEffect.ask[ReaderStringFx, String])
val action = list.traverse(_ => ReaderEffect.ask[ReaderStringFx, String])

action.runReader("h").run ==== list.map(_ => "h")
}
Expand All @@ -123,7 +123,7 @@ class EffSpec extends Specification with ScalaCheck with ThrownExpectations with
type S = Fx.fx2[ReaderString, WriterString]

val list = (1 to 5000).toList
val action = list.traverse(i => ReaderEffect.ask[S, String] >>= WriterEffect.tell[S, String])
val action = list.traverse(_ => ReaderEffect.ask[S, String] >>= WriterEffect.tell[S, String])

action.runReader("h").runWriter.run ==== ((list.map(_ => ()), list.map(_ => "h")))
}
Expand Down
2 changes: 1 addition & 1 deletion shared/src/test/scala/org/atnos/eff/EitherEffectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class EitherEffectSpec extends Specification with ScalaCheck with EitherMatchers

def handleFromCatchNonFatal = {
val newException = new Exception("bam")
val caught = EitherEffect.fromCatchNonFatal { throw new Exception("boom"); 1 }((t: Throwable) => newException)
val caught = EitherEffect.fromCatchNonFatal { throw new Exception("boom"); 1 }((_: Throwable) => newException)

caught.runEither.run must beLeft(newException)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,5 @@ class TwitterFutureEffectSpec(implicit ee: ExecutionEnv) extends Specification w

def sleepFor(duration: FiniteDuration) =
try Thread.sleep(duration.toMillis)
catch { case t: Throwable => () }
catch { case _: Throwable => () }
}

0 comments on commit 5f56c2f

Please sign in to comment.