简体   繁体   中英

better monadic for fails to desugar tuples

I am trying to incorporate better monadic for into a project for it's lovely tuple desugaring which doesn't appear to be working currently. I have:

  • added the plugin in my plugins.sbt : addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1") .
  • I have downgraded my scala version from 2.13.2 to 2.13.1
  • and I've updated my code as follows to take advantage of the desugaring as follows

I have a helper method with the following signature:

def helper(shifts: List[Shift], taskMap: Map[String, Double]): F[(Int, Int)]

It is being called as follows: (offProd, prod) <- helper(shifts, taskMap)

without the desugaring it compiles fine.

I'm using sbt version 1.5.8 and I have recompiled and reloaded the project in metals to ensure the compiler plugin is included. The only thing I can think of at this point is maybe the plugin is not being picked up automatically in my build.sbt, as I haven't updated it to use the plugins.sbt as I'm assuming sbt does that for you.

It turns out I wasn't importing the plugin into my project via plugins.sbt . As luis (ie the GOAT) pointed out in the comments, better-monadic-for is a compiler plugin not an sbt plugin and must be added to your build.sbt .

I adding the plugin to my library dependencies in my build.sbt instead worked:

compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")

(eg)

libraryDependencies ++= Seq(
  "io.circe" %% "circe-core" % "0.14.1",
  //... more typelevel libraries here
  compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM