简体   繁体   English

更好的 monadic 无法去除元组的糖分

[英]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.我正在尝试将更好的 monadic for合并到一个项目中,因为它是可爱的元组脱糖,目前似乎没有用。 I have:我有:

  • added the plugin in my plugins.sbt : addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1") .在我的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我已经将我的 scala 版本从2.13.2降级到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)它被调用如下: (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.我正在使用 sbt 版本1.5.8 ,并且我已经重新编译并重新加载了 metals 中的项目以确保包含编译器插件。 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.在这一点上我唯一能想到的是,插件可能没有在我的 build.sbt 中自动获取,因为我没有更新它以使用插件plugins.sbt因为我假设 sbt 会为你做这件事。

It turns out I wasn't importing the plugin into my project via plugins.sbt .原来我没有通过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 .正如luis (即 GOAT)在评论中指出的那样, better-monadic-for是一个编译器插件,而不是 sbt 插件,必须添加到您的build.sbt中。

I adding the plugin to my library dependencies in my build.sbt instead worked:我将插件添加到我的build.sbt中的库依赖项而不是工作:

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"),
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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