From 351645d29975716325e4aa590e9d542da6c8276f Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Thu, 14 Nov 2024 12:36:25 -1000 Subject: [PATCH] Implicitly use Show[Expectation] --- core/shared/src/main/scala/cats/parse/Parser.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/shared/src/main/scala/cats/parse/Parser.scala b/core/shared/src/main/scala/cats/parse/Parser.scala index 76584aff..66e803b1 100644 --- a/core/shared/src/main/scala/cats/parse/Parser.scala +++ b/core/shared/src/main/scala/cats/parse/Parser.scala @@ -974,13 +974,13 @@ object Parser { def unapply(error: Error): Option[(Int, NonEmptyList[Expectation])] = Some((error.failedAtOffset, error.expected)) - implicit val catsShowError: Show[Error] = + implicit def catsShowErrorGivenExpectation(implicit showExp: Show[Expectation]): Show[Error] = new Show[Error] { def show(error: Error): String = { val nl = "\n" def errorMsg = { - val expectations = error.expected.toList.iterator.map(e => s"* ${e.show}").mkString(nl) + val expectations = error.expected.toList.iterator.map(e => s"* ${showExp.show(e)}").mkString(nl) s"""|expectation${if (error.expected.tail.nonEmpty) "s" else ""}: |$expectations""".stripMargin @@ -1037,6 +1037,9 @@ object Parser { } } } + + // This is here for binary compatibility, but no longer implicit + val catsShowError: Show[Error] = catsShowErrorGivenExpectation(Expectation.catsShowExpectation) } /** Enables syntax to access product01, product and flatMap01 This helps us build Parser instances