You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current mechanisms for customizing value printing does not fully support generic classes, as can be seen in the example from the documentation, which does not compile without warnings:
sbt:root> Test/compile
[info] compiling 1 Scala source to /Users/morgen/scratch/target/scala-2.13/test-classes ...
[error] /Users/morgen/scratch/src/test/scala/com/morgen/CustomListOfCharPrinterTest.scala:7:13: non-variable type argument Char in type pattern List[Char] (the underlying of List[Char]) is unchecked since it is eliminated by erasure
[error] case l: List[Char] => l.mkString
[error] ^
[error] No warnings can be incurred under -Werror.
[error] two errors found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Feb 7, 2024, 6:59:49 PM
sbt:root>
This is likely because the current way the pretty printer works is via reflection. AFAIK the only way around this would be to switch to an implementation based on implicits.
Pros:
Could compile without warnings
Easy to hook into existing mechanisms like cats.Show
Can fall back to calling printer/munitPrint for compatibility with existing customization mechanisms.
Cons:
Requires significant changes to the API surface
Harder to debug if it's not printing the way that's expected
The text was updated successfully, but these errors were encountered:
The current mechanisms for customizing value printing does not fully support generic classes, as can be seen in the example from the documentation, which does not compile without warnings:
Output:
This is likely because the current way the pretty printer works is via reflection. AFAIK the only way around this would be to switch to an implementation based on implicits.
Pros:
cats.Show
printer
/munitPrint
for compatibility with existing customization mechanisms.Cons:
The text was updated successfully, but these errors were encountered: