Knows Not Much
Knows Not Much

Reputation: 31546

Convert List of Cats Effect IO to IO

With Futures, If I have a list of Futures. I can convert them into a single future by doing Future.sequence. but on the cats.effect.IO there is no IO.sequence method.

So if I have a List[IO[Long]] how do I convert it into IO[List[Long]]

Upvotes: 3

Views: 821

Answers (1)

Emiliano Martinez
Emiliano Martinez

Reputation: 4133

Something like that what are you looking for?:

import cats.instances.list._
import cats.syntax.parallel._

val listIo : List[IO[Long]] = ???

listIo.parSequence

Upvotes: 3

Related Questions