Scala 3 库是否有一个与 derives 一起使用的 Show 类型类?

Does the Scala 3 library have a Show typeclass that works with `derives`?

在 Scala 3 中,可以让编译器使用 derives TC 语法派生某些类型类的实例。

这里的文档页面https://dotty.epfl.ch/docs/reference/contextual/derivation.html给出了一个从类型类Eq OrderingShow派生的例子,说这些类型类是“常见的例子”。

  1. Show在图书馆什么地方吗?
  2. 如果没有,标准库中是否有用于漂亮打印的类型类?
  3. 我被Haskell宠坏了吗?
  1. 我猜没有。至少到目前为止还没有。自己定义很容易。而且很容易定义它的许多自定义风格(对于任何必要的用例)。

  2. 我猜没有。

  3. 可能你是:)以及cats, scalaz

https://typelevel.org/cats/typeclasses/show.html

https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Show.scala