(fa: F[A]).recoverSomeT[E2]( e: E => ???: E2 )
=> EitherT[F, E2, A]
blocking { ... }
.
lazy val
lazy val
intentionally these days are when constructing infinite recursive effects
def
instead but it cuts down on the allocations
Semaphore
I'm trying to make a very simple looping function with a delay using CATS effects (2.0.0-RC1 due to Scala 13).
import cats.effect._
import scala.concurrent.duration.FiniteDuration
object TaskScheduler {
def loop[F[_] : Sync](delay: FiniteDuration, fun: () => F[Unit])
(implicit timer: Timer[F]): F[Unit] =
for {
_ <- timer.sleep(delay)
_ <- fun()
_ <- loop(delay, fun)
} yield ()
}
however, when I try to compile this I get:
sbt:root> tickets/compile
[info] Compiling 15 Scala sources to /home/rohdef/git/smart-tickets/tickets/target/scala-2.13/classes ...
[error] /home/rohdef/git/smart-tickets/tickets/src/main/scala/dk/rohdef/scheduler/TaskScheduler.scala:11:23: value flatMap is not a member of type parameter F[Unit]
[error] _ <- timer.sleep(delay)
[error] ^
[error] /home/rohdef/git/smart-tickets/tickets/src/main/scala/dk/rohdef/scheduler/TaskScheduler.scala:12:15: value flatMap is not a member of type parameter F[Unit]
[error] _ <- fun()
[error] ^
[error] /home/rohdef/git/smart-tickets/tickets/src/main/scala/dk/rohdef/scheduler/TaskScheduler.scala:13:16: value map is not a member of type parameter F[Unit]
[error] _ <- loop(delay, fun)
[error] ^
[error] three errors found
[error] (tickets / Compile / compileIncremental) Compilation failed
[error] Total time: 2 s, completed Aug 10, 2019 1:23:20 PM
sbt:root>
which puzzles me thoroughly, since Sync is a Monad as far as I can see, so both map and flatMap should be present to my knowledge. So, what am I doing wrong?