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

How to import identity operations in scalaz?

syntax.IdOps 似乎没有 "companion" 对象来导入它的隐含函数(参见 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@1adfe356

scala> import selfish._
import selfish._

有导入的方法吗?

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._