Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
object Ex11 extends IOApp {
def naiveParMapN[A, B] (io1: IO[A], io2: IO[B]): IO[(A, B)] = {
io1.start.bracket { f1 =>
io2.start.bracket { f2 =>
for {
a <- f1.join
b <- f2.join
} yield (a, b)
def run(args: List[String]): IO[ExitCode] = {
val a = IO(1).debug()
val b = IO(2).debug()
naiveParMapN(a, b).debug().flatMap(_ => IO.pure(ExitCode.Success))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment