Search code examples
scalaintellij-ideafs2cats-effect

Intellij: Expression of type IO[Long] doesn't conform to expected type FS2_[O2_]


I tried the code of this Blog: a-streaming-library-with-a-superpower-fs2-and-functional-programming

In Intellij this code:

Stream("bob", "alice", "joe")
      .evalMap(name => IO.fromFuture(IO(loadUserIdByName(name)))) // <- here is the exception
      .compile
      .toList

Gives me this exception:

Expression of type IO[Long] doesn't conform to expected type FS2_[O2_]

Running the code with sbt works without a problem.

Is there a way to get rid of this exception in Intellij?


Solution

  • I noticed myself the typechecker always needs some help here, so explicitly set the effect and return type: in your case evalMap[IO, Long]