Skip to content

Commit

Permalink
prepare latest Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 21, 2024
1 parent c085af4 commit b1e966f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ trait choose {
final class ChooseEffectOps[R, A](private val e: Eff[R, A]) extends AnyVal {

def runChoose[F[_]: Alternative](implicit member: Member[Choose, R]): Eff[member.Out, F[A]] =
ChooseInterpretation.runChoose(e)(Alternative[F], member.aux)
ChooseInterpretation.runChoose(e)(using Alternative[F], member.aux)

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait SafeInterpretation extends SafeCreation { outer =>
case None => Eff.pure((Right(a), errors.toList))
case Some((l, m)) =>
attempt(l)(m) flatMap {
case Left(t) => outer.finalizerException[R](t)(m) >> pure((Right(a), errors.toList))
case Left(t) => outer.finalizerException[R](t)(using m) >> pure((Right(a), errors.toList))
case Right(_) => pure((Right(a), errors.toList))
}
}
Expand All @@ -58,8 +58,8 @@ trait SafeInterpretation extends SafeCreation { outer =>

case Some((l, m)) =>
attempt(l)(m) flatMap {
case Left(t) => outer.finalizerException[R](t)(m) >> outer.exception[R, Out[A]](e)(m)
case Right(_) => outer.exception[R, Out[A]](e)(m)
case Left(t) => outer.finalizerException[R](t)(using m) >> outer.exception[R, Out[A]](e)(using m)
case Right(_) => outer.exception[R, Out[A]](e)(using m)
}
}
}
Expand All @@ -85,8 +85,8 @@ trait SafeInterpretation extends SafeCreation { outer =>
case None => Eff.pure(())
case Some((l, m)) =>
attempt(l)(m) flatMap {
case Left(t) => outer.finalizerException[R](t)(m) >> outer.exception[R, Unit](e)(m)
case Right(_) => outer.exception[R, Unit](e)(m)
case Left(t) => outer.finalizerException[R](t)(using m) >> outer.exception[R, Unit](e)(using m)
case Right(_) => outer.exception[R, Unit](e)(using m)
}
}

Expand All @@ -95,7 +95,7 @@ trait SafeInterpretation extends SafeCreation { outer =>
case None => Eff.impure(x, continuation)
case Some((l, m)) =>
attempt(l)(m) flatMap {
case Left(t) => outer.finalizerException[R](t)(m) >> Eff.impure(x, continuation)
case Left(t) => outer.finalizerException[R](t)(using m) >> Eff.impure(x, continuation)
case Right(_) => Eff.impure(x, continuation)
}
}
Expand Down Expand Up @@ -139,8 +139,8 @@ trait SafeInterpretation extends SafeCreation { outer =>

case Some((l, m)) =>
attempt(l)(m) flatMap {
case Left(t1) => outer.finalizerException[R](t1)(m) >> outer.exception[R, Out[A]](t)(m)
case Right(_) => exception[R, Out[A]](t)(m)
case Left(t1) => outer.finalizerException[R](t1)(using m) >> outer.exception[R, Out[A]](t)(using m)
case Right(_) => exception[R, Out[A]](t)(using m)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import _root_.scalaz.std.vector._
object EffScalaz {

def traverseA[R, F[_]: Traverse, A, B](fs: F[A])(f: A => Eff[R, B]): Eff[R, F[B]] =
Traverse[F].traverse(fs)(f)(EffScalazApplicative[R])
Traverse[F].traverse(fs)(f)(using EffScalazApplicative[R])

def sequenceA[R, F[_]: Traverse, A](fs: F[Eff[R, A]]): Eff[R, F[A]] =
Traverse[F].sequence(fs)(EffScalazApplicative[R])
Traverse[F].sequence(fs)(using EffScalazApplicative[R])

def flatTraverseA[R, F[_], A, B](fs: F[A])(
f: A => Eff[R, F[B]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ trait validate {
org.atnos.eff.ValidateEffect.runNel(r).map(_.fold(ls => \/.left(NonEmptyList.fromSeq(ls.head, ls.tail)), \/.right))

def runMapDisjunction[R, U, E, L: Semigroup, A](r: Eff[R, A])(map: E => L)(implicit m: Member.Aux[Validate[E, *], R, U]): Eff[U, L \/ A] =
org.atnos.eff.ValidateEffect.runMap(r)(map)(catsSemigroup(Semigroup[L]), m).map(_.fold(\/.left, \/.right))
org.atnos.eff.ValidateEffect.runMap(r)(map)(using catsSemigroup(Semigroup[L]), m).map(_.fold(\/.left, \/.right))

}
4 changes: 2 additions & 2 deletions shared/src/test/scala/org/atnos/eff/MemberSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ for 4-element stacks:
} yield s.size

def stateIn[E](implicit state: State[String, *] |= E, option: Option |= E): Eff[E, Int] =
readIn[E](state.transform[Reader[String, *]], option)
readIn[E](using state.transform[Reader[String, *]], option)

def readInOut[E: ReadStr: _option]: Eff[E, Int] =
for {
Expand All @@ -169,5 +169,5 @@ for 4-element stacks:
} yield s.size

def stateInOut[E](implicit state: State[String, *] /= E, option: Option |= E): Eff[E, Int] =
readInOut[E](state.transform[Reader[String, *]], option)
readInOut[E](using state.transform[Reader[String, *]], option)
}
10 changes: 5 additions & 5 deletions state/shared/src/main/scala/org/atnos/eff/syntax/state.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait state {
StateInterpretation.runState(s)(e)(member)

def runStateZero[S: Monoid](implicit member: Member[State[S, *], R]): Eff[member.Out, (A, S)] =
StateInterpretation.runStateZero(e)(Monoid[S], member.aux)
StateInterpretation.runStateZero(e)(using Monoid[S], member.aux)

def evalState[S](s: S)(implicit member: Member[State[S, *], R]): Eff[member.Out, A] =
StateInterpretation.evalState(s)(e)(member.aux)
Expand All @@ -26,10 +26,10 @@ trait state {
StateInterpretation.evalState(s)(e)(member.aux)

def evalStateZero[S: Monoid](implicit member: Member[State[S, *], R]): Eff[member.Out, A] =
StateInterpretation.evalStateZero(e)(Monoid[S], member.aux)
StateInterpretation.evalStateZero(e)(using Monoid[S], member.aux)

def evalStateZeroU[S: Monoid, U](implicit member: Member.Aux[State[S, *], R, U]): Eff[U, A] =
StateInterpretation.evalStateZero(e)(Monoid[S], member.aux)
StateInterpretation.evalStateZero(e)(using Monoid[S], member.aux)

def execState[S](s: S)(implicit member: Member[State[S, *], R]): Eff[member.Out, S] =
StateInterpretation.execState(s)(e)(member.aux)
Expand All @@ -38,10 +38,10 @@ trait state {
StateInterpretation.execState(s)(e)(member.aux)

def execStateZero[S: Monoid](implicit member: Member[State[S, *], R]): Eff[member.Out, S] =
StateInterpretation.execStateZero(e)(Monoid[S], member.aux)
StateInterpretation.execStateZero(e)(using Monoid[S], member.aux)

def execStateZeroU[S: Monoid, U](implicit member: Member.Aux[State[S, *], R, U]): Eff[U, S] =
StateInterpretation.execStateZero(e)(Monoid[S], member.aux)
StateInterpretation.execStateZero(e)(using Monoid[S], member.aux)

def lensState[BR, U, T, S](getter: S => T, setter: (S, T) => S)(implicit
m1: Member.Aux[State[T, *], R, U],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ trait validate {
ValidateInterpretation.runNel(e)(m.aux)

def runMap[E, L: Semigroup](map: E => L)(implicit m: Member[Validate[E, *], R]): Eff[m.Out, L Either A] =
ValidateInterpretation.runMap(e)(map)(Semigroup[L], m.aux)
ValidateInterpretation.runMap(e)(map)(using Semigroup[L], m.aux)

def runValidatedNel[E](implicit m: Member[Validate[E, *], R]): Eff[m.Out, ValidatedNel[E, A]] =
ValidateInterpretation.runValidatedNel(e)(m.aux)

def runIorMap[E, L: Semigroup](map: E => L)(implicit m: Member[Validate[E, *], R]): Eff[m.Out, L Ior A] =
ValidateInterpretation.runIorMap(e)(map)(Semigroup[L], m.aux)
ValidateInterpretation.runIorMap(e)(map)(using Semigroup[L], m.aux)

def runIorNel[E](implicit m: Member[Validate[E, *], R]): Eff[m.Out, E IorNel A] =
ValidateInterpretation.runIorNel(e)(m.aux)
Expand Down

0 comments on commit b1e966f

Please sign in to comment.