I have the next code written using Cats IO that executes multiple actions in parallel (simplified):
import cats.effect._
import cats.implicits._
import scala.concurrent.ExecutionContext.Implicits.global
class ParallelExecIO {
def exec: IO[List[String]] = {
val foo = IO.shift *> IO("foo")
val bar = IO.shift *> IO("bar")
List(foo, bar).parSequence
}
}
Is it possible to rewrite this code using effect abstraction? What type evidences should be provided?
Sample:
class ParallelExecIO[F[_]: ConcurrentEffect /* ??? */] {
def exec: F[List[String]] = {
val foo = Async.shift[F](implicitly) *> "foo".pure[F]
val bar = Async.shift[F](implicitly) *> "bar".pure[F]
List(foo, bar).parSequence
}
}
[error] value parSequence is not a member of List[F[String]]