Representable

trait Representable[F[_]] extends Serializable

Representable.

Representable.

Is a witness to the isomorphism forall A. F[A] <-> Representation => A

Must obey the laws defined in cats.laws.RepresentableLaws i.e. tabulate andThen index = identity index andThen tabulate = identity

Inspired by the Haskell representable package http://hackage.haskell.org/package/representable-functors-3.2.0.2/docs/Data-Functor-Representable.html

Companion
object
trait Serializable
class Object
trait Matchable
class Any

Type members

Types

Value members

Abstract methods

def F: Functor[F]
def index[A](f: F[A]): Representation => A

Create a function that "indexes" into the F structure using Representation

Create a function that "indexes" into the F structure using Representation

Example:

scala> import cats.implicits._

scala> type Pair[A] = (A, A)

scala> val indexed: Boolean => String = Representable[Pair].index(("foo", "bar"))

scala> indexed(true)
res0: String = foo

scala> indexed(false)
res1: String = bar
def tabulate[A](f: Representation => A): F[A]

Reconstructs the F structure using the index function

Reconstructs the F structure using the index function

Example:

scala> import cats.implicits._

scala> type Pair[A] = (A, A)

scala> val f: Boolean => String = {
    | case true => "foo"
    | case false => "bar"
    | }

scala> f.tabulate[Pair]
res0: Pair[String] = (foo,bar)

Concrete methods

def compose[G[_]](G: Representable[G]): Aux[[α] =>> F[G[α]], (Representation, Representation)]