Search code examples
scalafunctional-programmingscala-catsfs2

Changing effect type of fs2.Stream


I'm using doobie which can produce an fs2.Stream[ConnectionIO, Int] of database rows (Int in my case). The ConnectionIO[A] is doobie's internal type.

Given a HKT F[_] and val nt: ConnectionIO ~> F is there a way to get fs2.Stream[F, Int] from fs2.Stream[ConnectionIO, Int]?

I didn't find some sort of mapK defined for fs2.Stream.


Solution

  • The method you're looking for is called translate, or translateInterruptible in some cases.