Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/src/main/scala/cats/Show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.util.UUID
import scala.collection.immutable.{BitSet, Queue, Seq, SortedMap, SortedSet}
import scala.concurrent.duration.{Duration, FiniteDuration}
import scala.util.Try
import scala.{specialized => sp}

/**
* A type class to provide textual representation. It is meant to be a
Expand Down Expand Up @@ -65,6 +66,13 @@ object Show extends ScalaVersionSpecificShowInstances with ShowInstances {
*/
def show[A](f: A => String): Show[A] = f(_)

/**
* Convert an implicit `Show[B]` to a `Show[A]` using the given
* function `f`.
*/
def by[@sp A, @sp B](f: A => B)(implicit ev: Show[B]): Show[A] =
a => ev.show(f(a))

/**
* creates an instance of [[Show]] using object toString
*/
Expand Down