Write a representation of a
into an existing mutable
StringBuilder.
Write a representation of a
into an existing mutable
StringBuilder.
This method is used to power render
, as well as used
recursively when building up larger representations.
Generate a String representation of a
.
Render is a typeclass to provide human-readable representations of values.
This typeclass provides two major concrete benefits over the built-in toString method:
2. Authors can override representations locally to improve error reporting in their own tests.
Claimant attempts to provide instances for most built-in Scala types, as well as a handy macro for generating instances for Scala case classes. For example, the following code produces a Render[Rectangle] value, which will use Render[Double] instances recursively:
case class Rectangle(height: Double, width: Double)
object Rectangle { implicit renderForRectangle: Render[Rectangle] = Render.caseClass[Rectangle] }
This typeclass is very similar to cats.Show (and probably others). One major design difference is that for a given type T, if a specific Render[T] is not available, this typeclass will generate an instance that just uses .toString. This behavior is intended to balance the benefits of custom representations with not requiring authors to write a bunch of new code in order ot use Claimant.