Because IntelliJ does not play all that nicely with Cats, I am sometimes explicit about type parameters in my code to avoid ugly red lines. For example, if we assume this gives a red line under IO.pure(x.toString)
,
List(1, 2, 3).traverse(x => IO.pure(x.toString))
then I can easily add the types and IntelliJ is happy:
List(1, 2, 3).traverse[IO, String](x => IO.pure(x.toString))
Now, with parTraverse
it seems a bit more difficult because of the functor parameter:
List(1, 2, 3).parTraverse[IO, ???, String](x => IO.pure(x.toString)) //what is ???
Is there any way to figure out the type of the F[_]
parameter here so I can please IntelliJ or is this some partial unification thing and so I'm doomed to ugliness? Thanks
If you go to the scaladoc api of cats-effects, and search for Parallel
instances, it lists you just a single implicit method that produces Parallel[IO, ???]
, namely Parallel[IO, Par]
provided by cats.effect.IO.ioParallel
. So, it seems that cats.effect.IO.Par
should do the trick:
List(1, 2, 3).parTraverse[IO, Par, String](x => IO.pure(x.toString))