gpt4 book ai didi

scala - 在 Scala REPL 中查找使用的隐式

转载 作者:行者123 更新时间:2023-12-04 23:26:12 25 4
gpt4 key购买 nike

我经常通过使用 Scalaz 皮条客找到解决问题的巧妙方法。通常解决方案的工作原理是

import scalaz._
import Scalaz._
foobar frobnicate quux
// magic

现在,我希望能够看到我实际使用了什么隐式添加到我的 Foobar 中。一种粗鲁的方法。通过这种方式,我可以进行更精细的导入,并了解我隐式使用的工具的新知识。

Is there some way to find out what implicit conversions the compiler actually used to compile some expression?

最佳答案

您还可以使用 -Xprint:typer 查看代码的完全扩展版本。 scalac 的选项。在 sbt 项目中,可以添加一行

scalacOptions += "-Xprint:typer"

build.sbt并使用 compile 查看结果命令。

(取自retronym链接的答案)

关于scala - 在 Scala REPL 中查找使用的隐式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12498750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com