"private[syntax]" 在 Scala 中

"private[syntax]" in Scala

"private[syntax]" 语言功能是什么?

/** Wraps a value `self` and provides methods related to `Show` */
final class ShowOps[F] private[syntax](val self: F)(implicit val F: Show[F]) extends Ops[F] {
  ////
  final def show: Cord = F.show(self)
  final def shows: String = F.shows(self)
  final def print: Unit = Console.print(shows)
  final def println: Unit = Console.println(shows)
  ////
}

^ 位置:scalaz-series-7.3.x/core/src/main/scala/scalaz/syntax/ShowSyntax.scala

private[packageX] 表示以下 method/class/object/constructor 只能从该包内访问 - 在这种情况下 syntax 是包名称,并且此构造函数只能从 syntax包。