如何在scalaz中导入身份操作?

时间:2015-01-28 11:31:46

标签: scala scalaz traits

syntax.IdOps似乎没有“伴侣”对象来导入其含义(请参阅selfless pattern),因此很难在REPL中使用它,例如:

scala> val selfish = new scalaz.syntax.ToIdOps{} //I don't want to do this, it feels wrong
selfish: scalaz.syntax.ToIdOps = $anon$1@1adfe356

scala> import selfish._
import selfish._

有没有办法导入它?

1 个答案:

答案 0 :(得分:7)

https://github.com/scalaz/scalaz/blob/v7.1.2/core/src/main/scala/scalaz/syntax/Syntax.scala#L117

您可以使用scalaz.syntax.id代替new scalaz.syntax.ToIdOps{}

import scalaz.syntax.id._