trait Representable[F[_]] extends Serializable
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
- Alphabetic
- By Inheritance
- Representable
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- abstract type Representation
Abstract Value Members
- abstract def F: Functor[F]
-
abstract
def
index[A](f: F[A]): (Representation) ⇒ A
Create a function that "indexes" into the
F
structure usingRepresentation
Create a function that "indexes" into the
F
structure usingRepresentation
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
-
abstract
def
tabulate[A](f: (Representation) ⇒ A): F[A]
Reconstructs the
F
structure using the index functionReconstructs the
F
structure using the index functionExample:
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 Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()