Created
June 24, 2025 22:43
-
-
Save benhutchison/ec9ee2633af32b9938be5577799f8ef0 to your computer and use it in GitHub Desktop.
Direct syntax doesn't work with Cats mapN operator but does work with equivalent pattern match
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala 3.7.0 | |
//> using dep org.typelevel::cats-effect:3.6.1 | |
//> using dep io.github.dotty-cps-async::dotty-cps-async:1.1.2 | |
//> using dep io.github.dotty-cps-async::cps-async-connect-cats-effect:1.1.0 | |
import cats.* | |
import cats.implicits.* | |
import cats.effect.* | |
import cats.effect.implicits.* | |
import cps.* | |
import cps.monads.catsEffect.given | |
object MapNProblemExample: | |
//Error.. "Required:cps.AsyncShift[cats.syntax.Tuple2SemigroupalOps[Option, Int, Int]]) .." | |
// def notWork = async[IO]: | |
// (Option(1), Option(1)).mapN((a, b) => IO(a + b).await).getOrElse(42) | |
def work = async[IO]: | |
(Option(1), Option(1)).match | |
case (Some(a), Some(b)) => IO(a + b).await | |
case _ => 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
full error: