Skip to content

Commit

Permalink
add explicit type
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Sep 10, 2023
1 parent fdb2a3e commit 1a07945
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 47 deletions.
3 changes: 2 additions & 1 deletion core/shared/src/main/scala/cats/effect/IOFiber.scala
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ private final class IOFiber[A](
masks += 1
val id = masks
val poll = new Poll[IO] {
def apply[B](ioa: IO[B]) = IO.Uncancelable.UnmaskRunLoop(ioa, id, IOFiber.this)
def apply[B](ioa: IO[B]): IO[B] =
IO.Uncancelable.UnmaskRunLoop(ioa, id, IOFiber.this)
}

val next =
Expand Down
10 changes: 5 additions & 5 deletions kernel/shared/src/main/scala/cats/effect/kernel/Async.scala
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ object Async {
implicit protected def F: Async[F]

override protected final def delegate = super.delegate
override protected final def C = F
override protected final def C: Clock[F] = F

override def unique: OptionT[F, Unique.Token] =
delay(new Unique.Token())
Expand Down Expand Up @@ -477,7 +477,7 @@ object Async {
implicit protected def F: Async[F]

override protected final def delegate = super.delegate
override protected final def C = F
override protected final def C: Clock[F] = F

override def unique: EitherT[F, E, Unique.Token] =
delay(new Unique.Token())
Expand Down Expand Up @@ -549,7 +549,7 @@ object Async {
implicit protected def F: Async[F]

override protected final def delegate = super.delegate
override protected final def C = F
override protected final def C: Clock[F] = F

override def unique: IorT[F, L, Unique.Token] =
delay(new Unique.Token())
Expand Down Expand Up @@ -620,7 +620,7 @@ object Async {
implicit protected def F: Async[F]

override protected final def delegate = super.delegate
override protected final def C = F
override protected final def C: Clock[F] = F

override def unique: WriterT[F, L, Unique.Token] =
delay(new Unique.Token())
Expand Down Expand Up @@ -688,7 +688,7 @@ object Async {
implicit protected def F: Async[F]

override protected final def delegate = super.delegate
override protected final def C = F
override protected final def C: Clock[F] = F

override def unique: Kleisli[F, R, Unique.Token] =
delay(new Unique.Token())
Expand Down
18 changes: 10 additions & 8 deletions kernel/shared/src/main/scala/cats/effect/kernel/Clock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object Clock {
implicit F0: Monad[F],
C0: Clock[F]): Clock[OptionT[F, *]] =
new OptionTClock[F] {
def applicative = OptionT.catsDataMonadForOptionT(F)
def applicative: Applicative[OptionT[F, *]] = OptionT.catsDataMonadForOptionT(F)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0
}
Expand All @@ -73,7 +73,7 @@ object Clock {
implicit F0: Monad[F],
C0: Clock[F]): Clock[EitherT[F, E, *]] =
new EitherTClock[F, E] {
def applicative = EitherT.catsDataMonadErrorForEitherT(F)
def applicative: Applicative[EitherT[F, E, *]] = EitherT.catsDataMonadErrorForEitherT(F)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0
}
Expand All @@ -82,7 +82,8 @@ object Clock {
implicit F0: Monad[F],
C0: Clock[F]): Clock[StateT[F, S, *]] =
new StateTClock[F, S] {
def applicative = IndexedStateT.catsDataMonadForIndexedStateT(F)
def applicative: Applicative[IndexedStateT[F, S, S, *]] =
IndexedStateT.catsDataMonadForIndexedStateT(F)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0
}
Expand All @@ -92,7 +93,7 @@ object Clock {
C0: Clock[F],
L0: Monoid[L]): Clock[WriterT[F, L, *]] =
new WriterTClock[F, L] {
def applicative = WriterT.catsDataMonadForWriterT(F, L)
def applicative: Applicative[WriterT[F, L, *]] = WriterT.catsDataMonadForWriterT(F, L)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0

Expand All @@ -105,7 +106,7 @@ object Clock {
C0: Clock[F],
L0: Semigroup[L]): Clock[IorT[F, L, *]] =
new IorTClock[F, L] {
def applicative = IorT.catsDataMonadErrorForIorT(F, L)
def applicative: Applicative[IorT[F, L, *]] = IorT.catsDataMonadErrorForIorT(F, L)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0

Expand All @@ -116,7 +117,7 @@ object Clock {
implicit F0: Monad[F],
C0: Clock[F]): Clock[Kleisli[F, R, *]] =
new KleisliClock[F, R] {
def applicative = Kleisli.catsDataMonadForKleisli(F)
def applicative: Applicative[Kleisli[F, R, *]] = Kleisli.catsDataMonadForKleisli(F)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0
}
Expand All @@ -126,7 +127,7 @@ object Clock {
C0: Clock[F],
D0: Defer[F]): Clock[ContT[F, R, *]] =
new ContTClock[F, R] {
def applicative = ContT.catsDataContTMonad(D)
def applicative: Applicative[ContT[F, R, *]] = ContT.catsDataContTMonad(D)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0
implicit override def D: Defer[F] = D0
Expand All @@ -137,7 +138,8 @@ object Clock {
C0: Clock[F],
L0: Monoid[L]): Clock[ReaderWriterStateT[F, R, L, S, *]] =
new ReaderWriterStateTClock[F, R, L, S] {
def applicative = IndexedReaderWriterStateT.catsDataMonadForRWST(F, L)
def applicative: Applicative[ReaderWriterStateT[F, R, L, S, *]] =
IndexedReaderWriterStateT.catsDataMonadForRWST(F, L)
implicit override def F: Monad[F] = F0
implicit override def C: Clock[F] = C0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ object GenTemporal {
with Clock.OptionTClock[F] {

implicit protected def F: GenTemporal[F, E]
protected def C = F
protected def C: Clock[F] = F

override protected def delegate: MonadError[OptionT[F, *], E] =
OptionT.catsDataMonadErrorForOptionT[F, E]
Expand All @@ -325,7 +325,7 @@ object GenTemporal {
with Clock.EitherTClock[F, E0] {

implicit protected def F: GenTemporal[F, E]
protected def C = F
protected def C: Clock[F] = F

override protected def delegate: MonadError[EitherT[F, E0, *], E] =
EitherT.catsDataMonadErrorFForEitherT[F, E, E0]
Expand All @@ -339,7 +339,7 @@ object GenTemporal {
with Clock.IorTClock[F, L] {

implicit protected def F: GenTemporal[F, E]
protected def C = F
protected def C: Clock[F] = F

override protected def delegate: MonadError[IorT[F, L, *], E] =
IorT.catsDataMonadErrorFForIorT[F, L, E]
Expand All @@ -353,7 +353,7 @@ object GenTemporal {
with Clock.WriterTClock[F, L] {

implicit protected def F: GenTemporal[F, E]
protected def C = F
protected def C: Clock[F] = F

implicit protected def L: Monoid[L]

Expand All @@ -369,7 +369,7 @@ object GenTemporal {
with Clock.KleisliClock[F, R] {

implicit protected def F: GenTemporal[F, E]
protected def C = F
protected def C: Clock[F] = F

override protected def delegate: MonadError[Kleisli[F, R, *], E] =
Kleisli.catsDataMonadErrorForKleisli[F, R, E]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ private[effect] trait ResourceHOInstances0 extends ResourceHOInstances1 {
implicit def catsEffectAsyncForResource[F[_]](implicit F0: Async[F]): Async[Resource[F, *]] =
new ResourceAsync[F] {
def F = F0
override def applicative = this
override def applicative: ResourceAsync[F] = this
}

implicit def catsEffectSemigroupKForResource[F[_], A](
Expand All @@ -1242,7 +1242,7 @@ private[effect] trait ResourceHOInstances1 extends ResourceHOInstances2 {
implicit F0: Temporal[F]): Temporal[Resource[F, *]] =
new ResourceTemporal[F] {
def F = F0
override def applicative = this
override def applicative: Applicative[Resource[F, *]] = this
}

implicit def catsEffectSyncForResource[F[_]](implicit F0: Sync[F]): Sync[Resource[F, *]] =
Expand All @@ -1257,7 +1257,7 @@ private[effect] trait ResourceHOInstances2 extends ResourceHOInstances3 {
implicit F0: Concurrent[F]): Concurrent[Resource[F, *]] =
new ResourceConcurrent[F] {
def F = F0
override def applicative = this
override def applicative: ResourceConcurrent[F] = this
}

implicit def catsEffectClockForResource[F[_]](
Expand Down Expand Up @@ -1430,7 +1430,7 @@ abstract private[effect] class ResourceAsync[F[_]]
with Async[Resource[F, *]] { self =>
implicit protected def F: Async[F]

override def applicative = this
override def applicative: ResourceAsync[F] = this

override def unique: Resource[F, Unique.Token] =
Resource.unique
Expand Down
14 changes: 7 additions & 7 deletions kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ object Sync {
with Clock.OptionTClock[F] {

implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): OptionT[F, A] =
OptionT.liftF(F.suspend(hint)(thunk))
Expand All @@ -225,7 +225,7 @@ object Sync {
with MonadCancel.EitherTMonadCancel[F, E, Throwable]
with Clock.EitherTClock[F, E] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): EitherT[F, E, A] =
EitherT.liftF(F.suspend(hint)(thunk))
Expand All @@ -236,7 +236,7 @@ object Sync {
with MonadCancel.StateTMonadCancel[F, S, Throwable]
with Clock.StateTClock[F, S] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): StateT[F, S, A] =
StateT.liftF(F.suspend(hint)(thunk))
Expand All @@ -247,7 +247,7 @@ object Sync {
with MonadCancel.WriterTMonadCancel[F, S, Throwable]
with Clock.WriterTClock[F, S] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): WriterT[F, S, A] =
WriterT.liftF(F.suspend(hint)(thunk))
Expand All @@ -258,7 +258,7 @@ object Sync {
with MonadCancel.IorTMonadCancel[F, L, Throwable]
with Clock.IorTClock[F, L] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): IorT[F, L, A] =
IorT.liftF(F.suspend(hint)(thunk))
Expand All @@ -269,7 +269,7 @@ object Sync {
with MonadCancel.KleisliMonadCancel[F, R, Throwable]
with Clock.KleisliClock[F, R] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): Kleisli[F, R, A] =
Kleisli.liftF(F.suspend(hint)(thunk))
Expand All @@ -280,7 +280,7 @@ object Sync {
with MonadCancel.ReaderWriterStateTMonadCancel[F, R, L, S, Throwable]
with Clock.ReaderWriterStateTClock[F, R, L, S] {
implicit protected def F: Sync[F]
protected def C = F
protected def C: Clock[F] = F

def suspend[A](hint: Type)(thunk: => A): ReaderWriterStateT[F, R, L, S, A] =
ReaderWriterStateT.liftF(F.suspend(hint)(thunk))
Expand Down
5 changes: 3 additions & 2 deletions laws/shared/src/main/scala/cats/effect/laws/AsyncTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import org.scalacheck._
import org.scalacheck.Prop.forAll
import org.scalacheck.util.Pretty
import org.typelevel.discipline.Laws

import scala.concurrent.ExecutionContext
import scala.concurrent.duration.FiniteDuration
Expand Down Expand Up @@ -84,7 +85,7 @@ trait AsyncTests[F[_]] extends GenTemporalTests[F, Throwable] with SyncTests[F]

new RuleSet {
val name = "async"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
temporal[A, B, C](
tolerance,
Expand Down Expand Up @@ -194,7 +195,7 @@ trait AsyncTests[F[_]] extends GenTemporalTests[F, Throwable] with SyncTests[F]

new RuleSet {
val name = "async"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
temporal[A, B, C](tolerance)(
implicitly[Arbitrary[A]],
Expand Down
4 changes: 2 additions & 2 deletions laws/shared/src/main/scala/cats/effect/laws/ClockTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ trait ClockTests[F[_]] extends Laws {
def clock(implicit exec: F[Boolean] => Prop): RuleSet = {
new RuleSet {
val name = "clock"
val bases = Nil
val parents = Seq()
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents: Seq[RuleSet] = Seq()

val props = Seq("monotonicity" -> exec(laws.monotonicity))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import org.scalacheck._
import org.scalacheck.Prop.forAll
import org.scalacheck.util.Pretty
import org.typelevel.discipline.Laws

trait GenSpawnTests[F[_], E] extends MonadCancelTests[F, E] with UniqueTests[F] {

Expand Down Expand Up @@ -68,7 +69,7 @@ trait GenSpawnTests[F[_], E] extends MonadCancelTests[F, E] with UniqueTests[F]
// these are the OLD LAWS retained only for bincompat
new RuleSet {
val name = "concurrent"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
monadCancel[A, B, C](
implicitly[Arbitrary[A]],
Expand Down Expand Up @@ -159,7 +160,7 @@ trait GenSpawnTests[F[_], E] extends MonadCancelTests[F, E] with UniqueTests[F]

new RuleSet {
val name = "concurrent"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
monadCancel[A, B, C](
implicitly[Arbitrary[A]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import org.scalacheck._
import org.scalacheck.Prop.forAll
import org.scalacheck.util.Pretty
import org.typelevel.discipline.Laws

import scala.concurrent.duration.FiniteDuration

Expand Down Expand Up @@ -84,7 +85,7 @@ trait GenTemporalTests[F[_], E] extends GenSpawnTests[F, E] with ClockTests[F] {

new RuleSet {
val name = "temporal"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
spawn[A, B, C](
implicitly[Arbitrary[A]],
Expand Down Expand Up @@ -177,7 +178,7 @@ trait GenTemporalTests[F[_], E] extends GenSpawnTests[F, E] with ClockTests[F] {

new RuleSet {
val name = "temporal"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
spawn[A, B, C](
implicitly[Arbitrary[A]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import org.scalacheck._
import org.scalacheck.Prop.forAll
import org.scalacheck.util.Pretty
import org.typelevel.discipline.Laws

trait MonadCancelTests[F[_], E] extends MonadErrorTests[F, E] {

Expand Down Expand Up @@ -111,7 +112,7 @@ trait MonadCancelTests[F[_], E] extends MonadErrorTests[F, E] {

new RuleSet {
val name = "monadCancel"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(monadError[A, B, C])

val props = {
Expand Down
3 changes: 2 additions & 1 deletion laws/shared/src/main/scala/cats/effect/laws/SyncTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms

import org.scalacheck._
import org.scalacheck.Prop.forAll
import org.typelevel.discipline.Laws

trait SyncTests[F[_]]
extends MonadCancelTests[F, Throwable]
Expand Down Expand Up @@ -58,7 +59,7 @@ trait SyncTests[F[_]]

new RuleSet {
val name = "sync"
val bases = Nil
val bases: Seq[(String, Laws#RuleSet)] = Nil
val parents = Seq(
monadCancel[A, B, C](
implicitly[Arbitrary[A]],
Expand Down
Loading

0 comments on commit 1a07945

Please sign in to comment.