Skip to content

Commit

Permalink
renamed to cshow
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed Aug 9, 2017
1 parent fdcd48f commit f417043
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions core/src/main/scala/cats/Show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import cats.functor.Contravariant
@typeclass trait Show[T] extends Show.ContravariantShow[T] {
// duplicated so simulacrum knows it requires an instance of this trait
def show(t: T): String
def _show(t: T): String = show(t)
def cshow(t: T): String = show(t)
}

object Show {
trait ContravariantShow[-T] {
def _show(t: T): String
/**
* using a different name than `show` as a work around of scala bug https://github.com/scala/bug/issues/10458
*/
def cshow(t: T): String
}

/** creates an instance of [[Show]] using the provided function */
Expand All @@ -33,7 +36,7 @@ object Show {

final case class Shown(override val toString: String) extends AnyVal
object Shown {
implicit def mat[A](x: A)(implicit z: ContravariantShow[A]): Shown = Shown(z _show x)
implicit def mat[A](x: A)(implicit z: ContravariantShow[A]): Shown = Shown(z cshow x)
}

final case class ShowInterpolator(_sc: StringContext) extends AnyVal {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/RegressionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ object RegressionTests {
final case class First[A](getFirst: A) extends AnyVal
object First {
implicit def showInstance[A](implicit ev: Show[A]): Show[First[A]] = new Show[First[A]] {
override def show(f: First[A]): String = s"First(${ev.show(f.getFirst)})"
def show(f: First[A]): String = s"First(${ev.show(f.getFirst)})"
}
}

Expand Down

0 comments on commit f417043

Please sign in to comment.