Skip to content

Commit

Permalink
Fix some migration syntax issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grryum committed Apr 2, 2024
1 parent ff99411 commit 52bb4e0
Show file tree
Hide file tree
Showing 29 changed files with 111 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ trait BindInstanceChain[TC[f[_, _]] >: Bind[f]] {

override def handle[E, X, A](fa: Either[E, A], h: E => A): Either[X, A] = Right(fa.fold(h, identity))

override def monad[E]: Monad[Either[E, *]] = implicitly
override def monad[E]: Monad[Either[E, _]] = implicitly

override def bifunctor: Bifunctor[Either] = implicitly
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import tofu.internal.EffectCompHK
trait MonoidalK[U[_[_]]] extends PureK[U] with ApplyK[U] {
def zipWith2K[F[_], G[_], H[_]](af: U[F], ag: U[G])(f2: Function2K[F, G, H]): U[H]

override def map2K[F[_], G[_], H[_]](af: U[F], ag: U[G])(f: Tuple2K[F, G, *] ~> H): U[H] =
override def map2K[F[_], G[_], H[_]](af: U[F], ag: U[G])(f: Tuple2K[F, G, _] ~> H): U[H] =
zipWith2K(af, ag)(Function2K.untupled(f))

override def mapK[F[_], G[_]](af: U[F])(fk: F ~> G): U[G] =
zipWith2K[F, UnitK, G](af, unitK)(Function2K[F, UnitK]((f, _) => fk(f)))

override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[Tuple2K[F, G, *]] =
override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[Tuple2K[F, G, _]] =
zipWith2K(af, ag)(Function2K[F, G]((f, g) => Tuple2K(f, g)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.{Applicative, Apply, FlatMap, Monoid, MonoidK, Semigroup, SemigroupK
import tofu.syntax.funk.funK
import tofu.syntax.monadic.*

/** A function `[F[_], A] =>> A => F[Unit]` An algebra `U[Post[F, *]]` is an algebra which translates all actions to `A
/** A function `[F[_], A] =>> A => F[Unit]` An algebra `U[Post[F, _]]` is an algebra which translates all actions to `A
* \=> F[Unit]`. This is useful to represent actions succeeding main logic.
*/
trait Post[F[_], A] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.{Applicative, Apply, Monoid, MonoidK, Semigroup, SemigroupK, ~>}
import tofu.syntax.funk.funK
import tofu.syntax.monadic.*

/** Newtype for `[F[_], A] =>> F[Unit]`. An algebra `U[Pre[F, *]]` is an algebra which translates all actions to
/** Newtype for `[F[_], A] =>> F[Unit]`. An algebra `U[Pre[F, _]]` is an algebra which translates all actions to
* `F[Unit]`. This is useful to represent actions preceding main logic.
*/
object Pre extends PreInstances {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tofu.control.Bind
import tofu.higherKind.bi.RepresentableB.Tab

trait RepresentableB[U[f[_, _]]] extends MonoidalBK[U] with EmbedBK[U] {
def bitabulate[F[_, _]](repr: RepBK[U, *, *] FunBK F): U[F]
def bitabulate[F[_, _]](repr: RepBK[U, _, _] FunBK F): U[F]

final def tab[F[_, _]]: Tab[U, F] = new Tab(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import tofu.instances.bind._

class CatsInstancesFromBindSuite {
def summonBindInstances[F[+_, +_]](implicit bind: Bind[F]): Unit = {
requireApplicative[F[Throwable, *]]
requireFlatMap[F[Nothing, *]]
requireApplicative[F[Throwable, _]]
requireFlatMap[F[Nothing, _]]
}

def requireApplicative[F[_]](implicit applicative: Applicative[F]): Unit = ()
Expand Down
12 changes: 6 additions & 6 deletions modules/kernel/src/main/scala/tofu/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ object Local {
* that can use `F[Ctx]` inside.
*
* @tparam F
* context-aware effect e.g.`ReaderT[Lower, Ctx, *]`
* context-aware effect e.g.`ReaderT[Lower, Ctx, _]`
*/
@deprecated("Migrate to With* typeclasses", "0.10.3")
trait Provide[F[_]] extends ContextBase {
Expand Down Expand Up @@ -205,10 +205,10 @@ trait Provide[F[_]] extends ContextBase {
*
* @example
* {{{ trait ProcessHandler[G[_]] { def mapK[M[_]](fk: G ~> M): ProcessHandler[M] = ??? //...other methods } type
* WithMyContext[F[_], A] = ReaderT[F, MyCtx, A] val contextualProcessHandler: ProcessHandler[IO WithMyContext *] =
* WithMyContext[F[_], A] = ReaderT[F, MyCtx, A] val contextualProcessHandler: ProcessHandler[IO WithMyContext _] =
* ???
*
* val processHandler: ProcessHandler[IO] = processHandler.mapK( WithProvide[IO WithMyContext *, IO,
* val processHandler: ProcessHandler[IO] = processHandler.mapK( WithProvide[IO WithMyContext _, IO,
* MyCtx].runContextK ) }}}
*/
def runContextK(ctx: Ctx): F ~> Lower = funK[F, Lower](a => runContext(a)(ctx))
Expand Down Expand Up @@ -244,7 +244,7 @@ object Provide {
/** Combination of [[Local]] and [[Provide]]
*
* @tparam F
* context-aware effect e.g.`ReaderT[Lower, Ctx, *]`
* context-aware effect e.g.`ReaderT[Lower, Ctx, _]`
*/
@deprecated("Migrate to With* typeclasses", "0.10.3")
trait RunContext[F[_]] extends Local[F] with Provide[F] {
Expand All @@ -256,9 +256,9 @@ trait RunContext[F[_]] extends Local[F] with Provide[F] {
*
* type WithMyContext[F[_], A] = ReaderT[F, MyCtx, A]
*
* val processHandler: ProcessHandler[IO WithMyContext *] = ???
* val processHandler: ProcessHandler[IO WithMyContext _] = ???
*
* val contextualHandler: IO WithMyContext ProcessHandler[IO] = processHandler.mapK( WithRun[WithMyContext[IO, *],
* val contextualHandler: IO WithMyContext ProcessHandler[IO] = processHandler.mapK( WithRun[WithMyContext[IO, _],
* IO, MyCtx].unlift.map(fk => processHandler.mapK(fk)) ) //now it is able to process MyCtx but is wrapped in IO
* WithMyContext * }}}
* @return
Expand Down
10 changes: 5 additions & 5 deletions modules/kernel/src/main/scala/tofu/Errors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ object Errors extends DataEffectComp[Errors] {
trait ErrorBase
object ErrorBase extends ErrorsBaseInstances {

final implicit def readerTErrors[F[_], R, E](implicit F: Errors[F, E]): Errors[ReaderT[F, R, *], E] =
new Errors[ReaderT[F, R, *], E] {
final implicit def readerTErrors[F[_], R, E](implicit F: Errors[F, E]): Errors[ReaderT[F, R, _], E] =
new Errors[ReaderT[F, R, _], E] {
def raise[A](err: E): ReaderT[F, R, A] =
ReaderT.liftF(F.raise(err))

Expand Down Expand Up @@ -177,12 +177,12 @@ class ErrorsBaseInstances2 extends ErrorsBaseInstances3 {

class ErrorsBaseInstances3 {

final implicit def eitherTIntance[F[_], E](implicit F: Monad[F]): ErrorsTo[EitherT[F, E, *], F, E] =
final implicit def eitherTIntance[F[_], E](implicit F: Monad[F]): ErrorsTo[EitherT[F, E, _], F, E] =
new EitherTErrorsTo[F, E]

final implicit def optionTIntance[F[_]](implicit F: Monad[F]): ErrorsTo[OptionT[F, *], F, Unit] =
final implicit def optionTIntance[F[_]](implicit F: Monad[F]): ErrorsTo[OptionT[F, _], F, Unit] =
new OptionTErrorsTo[F]

final implicit def eitherIntance[E]: ErrorsTo[Either[E, *], Id, E] = new EitherErrorsTo[E]
final implicit def eitherIntance[E]: ErrorsTo[Either[E, _], Id, E] = new EitherErrorsTo[E]
final implicit val optionTIntance: ErrorsTo[Option, Id, Unit] = OptionErrorsTo
}
4 changes: 2 additions & 2 deletions modules/kernel/src/main/scala/tofu/Perform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait Performer[F[_], -Cont[_], Cancel] {
}

object Performer {
type OfExit[F[_], E] = Performer[F, PerformOf.ExitCont[E, *], Unit]
type OfExit[F[_], E] = Performer[F, PerformOf.ExitCont[E, _], Unit]

implicit def contravariantK[F[_], Cancel]: ContravariantK[({ type L[x[_]] = Performer[F, x, Cancel] })#L] =
new PerformerContravariantK[F, Cancel]
Expand All @@ -49,7 +49,7 @@ object PerformVia extends PerformInstance with PerformInstance1 {
trait PerformInstance1 {
implicit def performReader[F[_]: Functor, Cont[_], R, Cancel](implicit
RP: PerformVia[F, Cont, Cancel]
): PerformVia[ReaderT[F, R, *], Cont, Cancel] = new PerformViaReader(RP)
): PerformVia[ReaderT[F, R, _], Cont, Cancel] = new PerformViaReader(RP)
}

object PerformOf extends Effect2Comp[PerformOf] {
Expand Down
4 changes: 2 additions & 2 deletions modules/kernel/src/main/scala/tofu/Scoped.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait Scoped[Tag, F[_]] {

final def tagged[NewTag]: Scoped[NewTag, F] = this.asInstanceOf[Scoped[NewTag, F]]

final def midPoint: Point[Mid[F, *]] = new Point[Mid[F, *]] {
final def midPoint: Point[Mid[F, _]] = new Point[Mid[F, _]] {
def point[A]: Mid[F, A] = runScoped(_)
}
}
Expand Down Expand Up @@ -78,7 +78,7 @@ object Scoped extends ScopedInstance with ScopedInstancesMacro {
}

/** helpful method to create middleware that executes all proceses in the given scope */
def mid[Tag, U[_[_]], F[_]](implicit U: PureK[U], F: Scoped[Tag, F]): U[Mid[F, *]] = U.pureK(F.midPoint)
def mid[Tag, U[_[_]], F[_]](implicit U: PureK[U], F: Scoped[Tag, F]): U[Mid[F, _]] = U.pureK(F.midPoint)
}

trait ScopedExecute[Tag, F[_]] extends Scoped[Tag, F] {
Expand Down
6 changes: 3 additions & 3 deletions modules/kernel/src/main/scala/tofu/WithProvide.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import tofu.syntax.funk.funK

/** Synonym for [[Provide]] with explicit `C` as `Ctx` and `G` as `Lower` for better type inference
*
* Can be seen as transformation `F[*] = C => G[*]`
* Can be seen as transformation `F[_] = C => G[_]`
*/
trait WithProvide[F[_], G[_], C] extends Provide[F] with Lift[G, F] {
override type Lower[A] = G[A]
Expand Down Expand Up @@ -40,10 +40,10 @@ trait WithProvide[F[_], G[_], C] extends Provide[F] with Lift[G, F] {
*
* @example
* {{{ trait ProcessHandler[G[_]] { def mapK[M[_]](fk: G ~> M): ProcessHandler[M] = ??? //...other methods } type
* WithMyContext[F[_], A] = ReaderT[F, MyCtx, A] val contextualProcessHandler: ProcessHandler[IO WithMyContext *] =
* WithMyContext[F[_], A] = ReaderT[F, MyCtx, A] val contextualProcessHandler: ProcessHandler[IO WithMyContext _] =
* ???
*
* val processHandler: ProcessHandler[IO] = processHandler.mapK( WithProvide[IO WithMyContext *, IO,
* val processHandler: ProcessHandler[IO] = processHandler.mapK( WithProvide[IO WithMyContext _, IO,
* MyCtx].runContextK ) }}}
*/
override def runContextK(ctx: Ctx): F ~> Lower = funK[F, Lower](runContext(_)(ctx))
Expand Down
6 changes: 3 additions & 3 deletions modules/kernel/src/main/scala/tofu/WithRun.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tofu.syntax.funk.funK
/** Synonym for both [[RunContext]] and [[Unlift]] with explicit `C` as `Ctx` and `G` as `Lower` for better type
* inference
*
* Can be seen as transformation `F[*] = C => G[*]`
* Can be seen as transformation `F[_] = C => G[_]`
*/
trait WithRun[F[_], G[_], C] extends WithProvide[F, G, C] with WithLocal[F, C] with RunContext[F] with Unlift[G, F] {
override type Ctx = C
Expand All @@ -20,9 +20,9 @@ trait WithRun[F[_], G[_], C] extends WithProvide[F, G, C] with WithLocal[F, C] w
*
* type WithMyContext[F[_], A] = ReaderT[F, MyCtx, A]
*
* val processHandler: ProcessHandler[IO WithMyContext *] = ???
* val processHandler: ProcessHandler[IO WithMyContext _] = ???
*
* val contextualHandler: IO WithMyContext ProcessHandler[IO] = processHandler.mapK( WithRun[WithMyContext[IO, *],
* val contextualHandler: IO WithMyContext ProcessHandler[IO] = processHandler.mapK( WithRun[WithMyContext[IO, _],
* IO, MyCtx].unlift.map(fk => processHandler.mapK(fk)) ) //now it is able to process MyCtx but is wrapped in IO
* WithMyContext * }}}
* @return
Expand Down
10 changes: 5 additions & 5 deletions modules/kernel/src/main/scala/tofu/concurrent/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ object Atom extends AtomInstances {
}
}

def stateTAtom[F[_]: Applicative, A]: Atom[StateT[F, A, *], A] = StateTAtom()
def stateTAtom[F[_]: Applicative, A]: Atom[StateT[F, A, _], A] = StateTAtom()

private case class StateTAtom[F[_]: Applicative, A]() extends Atom[StateT[F, A, *], A] {
private case class StateTAtom[F[_]: Applicative, A]() extends Atom[StateT[F, A, _], A] {
override def get: StateT[F, A, A] = StateT.get
override def set(a: A): StateT[F, A, Unit] = StateT.set(a)
override def getAndSet(a: A): StateT[F, A, A] = StateT(a1 => (a, a1).pure[F])
override def update(f: A => A): StateT[F, A, Unit] = StateT.modify(f)
override def modify[B](f: A => (A, B)): StateT[F, A, B] = StateT(a => f(a).pure[F])
}

def calcMAtom[F[+_, +_], R, S, E]: Atom[CalcM[F, R, S, S, E, *], S] =
calcMAtomAny.asInstanceOf[Atom[CalcM[F, R, S, S, E, *], S]]
def calcMAtom[F[+_, +_], R, S, E]: Atom[CalcM[F, R, S, S, E, _], S] =
calcMAtomAny.asInstanceOf[Atom[CalcM[F, R, S, S, E, _], S]]

private class CalcMAtom[F[+_, +_], R, S, E]() extends Atom[CalcM[F, R, S, S, E, *], S] {
private class CalcMAtom[F[+_, +_], R, S, E]() extends Atom[CalcM[F, R, S, S, E, _], S] {
def get: CalcM[F, R, S, S, E, S] = CalcM.get
def set(a: S): CalcM[F, R, S, S, E, Unit] = CalcM.set(a).void
def getAndSet(a: S): CalcM[F, R, S, S, E, S] = CalcM.get[S] << CalcM.set(a)
Expand Down
6 changes: 3 additions & 3 deletions modules/kernel/src/main/scala/tofu/concurrent/Exit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Exit {
case util.Success(res) => Completed(res)
}

private[this] object exitInstanceAny extends Traverse[Exit[Any, *]] with ApplicativeZip[Exit[Any, *]] {
private[this] object exitInstanceAny extends Traverse[Exit[Any, _]] with ApplicativeZip[Exit[Any, _]] {
def traverse[G[_], A, B](fa: Exit[Any, A])(f: A => G[B])(implicit G: Applicative[G]): G[Exit[Any, B]] =
fa match {
case Canceled => G.pure(Canceled)
Expand Down Expand Up @@ -78,8 +78,8 @@ object Exit {
def pure[A](x: A): Exit[Any, A] = Completed(x)
}

implicit def exitInstance[E]: Traverse[Exit[E, *]] with Applicative[Exit[E, *]] =
exitInstanceAny.asInstanceOf[Traverse[Exit[E, *]] with Applicative[Exit[E, *]]]
implicit def exitInstance[E]: Traverse[Exit[E, _]] with Applicative[Exit[E, _]] =
exitInstanceAny.asInstanceOf[Traverse[Exit[E, _]] with Applicative[Exit[E, _]]]

object CanceledException extends InterruptedException
}
8 changes: 4 additions & 4 deletions modules/kernel/src/main/scala/tofu/control/Selective.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ trait SelectiveInstances extends SelectiveInstances2 {
final implicit def selectiveOverMonad[F[_]: Monad]: SelectiveOverMonad[F] = new SelectiveOverMonad[F]
}
trait SelectiveInstances2 {
final implicit def selectiveOptionT[F[_]: Selective]: Selective[OptionT[F, *]] = new SelectiveOptionT[F]
final implicit def selectiveEitherT[F[_]: Selective, E]: Selective[EitherT[F, E, *]] = new SelectiveEitherT[F, E]
final implicit def selectiveReaderT[F[_]: Selective, R]: Selective[ReaderT[F, R, *]] = new SelectiveReaderT[F, R]
final implicit def selectiveWriterT[F[_]: Selective, W: Monoid]: Selective[WriterT[F, W, *]] =
final implicit def selectiveOptionT[F[_]: Selective]: Selective[OptionT[F, _]] = new SelectiveOptionT[F]
final implicit def selectiveEitherT[F[_]: Selective, E]: Selective[EitherT[F, E, _]] = new SelectiveEitherT[F, E]
final implicit def selectiveReaderT[F[_]: Selective, R]: Selective[ReaderT[F, R, _]] = new SelectiveReaderT[F, R]
final implicit def selectiveWriterT[F[_]: Selective, W: Monoid]: Selective[WriterT[F, W, _]] =
new SelectiveWriterT[F, W]
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait SelectiveWithMap[F[_]] extends Selective[F] {
override def map[A, B](fa: F[A])(f: A => B): F[B] = smap(fa)(f)
}

class SelectiveOptionT[F[_]](implicit F: Selective[F]) extends Selective[OptionT[F, *]] {
class SelectiveOptionT[F[_]](implicit F: Selective[F]) extends Selective[OptionT[F, _]] {
def selectAp[A, B](fe: OptionT[F, Either[A, B]])(ff: => OptionT[F, A => B]): OptionT[F, B] =
OptionT(F.selectAp(fe.value.map {
case Some(Left(a)) => Left(a)
Expand All @@ -59,7 +59,7 @@ class SelectiveOptionT[F[_]](implicit F: Selective[F]) extends Selective[OptionT
def pure[A](x: A): OptionT[F, A] = OptionT.pure(x)
}

class SelectiveEitherT[F[_], L](implicit F: Selective[F]) extends Selective[EitherT[F, L, *]] {
class SelectiveEitherT[F[_], L](implicit F: Selective[F]) extends Selective[EitherT[F, L, _]] {
def selectAp[A, B](fe: EitherT[F, L, Either[A, B]])(ff: => EitherT[F, L, A => B]): EitherT[F, L, B] =
EitherT(F.selectAp[A, Either[L, B]](fe.value.map {
case Right(Left(a)) => Left(a)
Expand All @@ -77,16 +77,16 @@ class SelectiveEitherT[F[_], L](implicit F: Selective[F]) extends Selective[Eith
}

class SelectiveReaderT[F[_], R](implicit FS: Selective[F])
extends Selective[ReaderT[F, R, *]] with ApplicativeDelegate[ReaderT[F, R, *]] {
val F: Applicative[ReaderT[F, R, *]] = implicitly
extends Selective[ReaderT[F, R, _]] with ApplicativeDelegate[ReaderT[F, R, _]] {
val F: Applicative[ReaderT[F, R, _]] = implicitly

def selectAp[A, B](fe: ReaderT[F, R, Either[A, B]])(ff: => ReaderT[F, R, A => B]): ReaderT[F, R, B] =
ReaderT(r => FS.selectAp(fe.run(r))(ff.run(r)))
}

class SelectiveWriterT[F[_], W: Monoid](implicit FS: Selective[F])
extends Selective[WriterT[F, W, *]] with ApplicativeDelegate[WriterT[F, W, *]] {
val F: Applicative[WriterT[F, W, *]] = implicitly
extends Selective[WriterT[F, W, _]] with ApplicativeDelegate[WriterT[F, W, _]] {
val F: Applicative[WriterT[F, W, _]] = implicitly

def selectAp[A, B](fe: WriterT[F, W, Either[A, B]])(ff: => WriterT[F, W, A => B]): WriterT[F, W, B] =
WriterT(FS.selectAp[(W, A), (W, B)](FS.map(fe.run) {
Expand Down
4 changes: 2 additions & 2 deletions modules/kernel/src/main/scala/tofu/data/Calc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ object Calc {
implicit def calcInstance[R, S, E]: CalcFunctorInstance[R, S, E] = new CalcFunctorInstance[R, S, E]

class CalcFunctorInstance[R, S, E]
extends MonadError[Calc[R, S, S, E, *], E] with cats.Defer[Calc[R, S, S, E, *]]
with StackSafeMonad[Calc[R, S, S, E, *]] with Guarantee[Calc[R, S, S, E, *]] {
extends MonadError[Calc[R, S, S, E, _], E] with cats.Defer[Calc[R, S, S, E, _]]
with StackSafeMonad[Calc[R, S, S, E, _]] with Guarantee[Calc[R, S, S, E, _]] {
def defer[A](fa: => Calc[R, S, S, E, A]): Calc[R, S, S, E, A] = Calc.defer(fa)
def raiseError[A](e: E): Calc[R, S, S, E, A] = Calc.raise(e)
def handleErrorWith[A](fa: Calc[R, S, S, E, A])(f: E => Calc[R, S, S, E, A]): Calc[R, S, S, E, A] = fa.handleWith(f)
Expand Down
Loading

0 comments on commit 52bb4e0

Please sign in to comment.