Equivalence

zio.prelude.Equivalence
See theEquivalence companion object
trait Equivalence[A, B] extends PartialEquivalence[A, B, Nothing, Nothing]

An Equivalence[A, B] defines an equivalence between two types A and B. These types represent different ways to store the same information.

For example, a List[Byte] is equivalent to a Vector[Byte]. Similarly, a List[Char] is equivalent to a String.

Equivalences are symmetrical. So if A is equivalent to B, then B is equivalent to A.

Value parameters

from

A function that converts a B into an A.

to

A function that converts an A into a B.

Attributes

Companion
object
Graph
Supertypes
trait PartialEquivalence[A, B, Nothing, Nothing]
class Object
trait Matchable
class Any
Self type
Equivalence[A, B]

Members list

Value members

Abstract methods

def from: B => A
def to: A => B

Concrete methods

def >>>[C](that: Equivalence[B, C]): Equivalence[A, C]

Composes this equivalence with the specified equivalence.

Composes this equivalence with the specified equivalence.

Attributes

def andThen[C](that: Equivalence[B, C]): Equivalence[A, C]

A named method for >>>.

A named method for >>>.

Attributes

def compose[C](that: Equivalence[C, A]): Equivalence[C, B]
override def flip: Equivalence[B, A]

Flips this equivalence around.

Flips this equivalence around.

Attributes

Definition Classes
final def fromPartial: B => Either[Nothing, A]
final def toPartial: A => Either[Nothing, B]

Inherited methods

def >>>[C, E3, E4](that: PartialEquivalence[B, C, E3, E4]): PartialEquivalence[A, C, E3, E4]

Attributes

Inherited from:
PartialEquivalence
def andThen[C, E3, E4](that: PartialEquivalence[B, C, E3, E4]): PartialEquivalence[A, C, E3, E4]

Attributes

Inherited from:
PartialEquivalence
def canonicalLeft(a: A): Option[A]

Attributes

Inherited from:
PartialEquivalence
def canonicalLeftOrError[E](a: A)(implicit ev1: Nothing <:< E, ev2: Nothing <:< E): Either[E, A]

Attributes

Inherited from:
PartialEquivalence
def canonicalRight(b: B): Option[B]

Attributes

Inherited from:
PartialEquivalence
def canonicalRightOrError[E](b: B)(implicit ev1: Nothing <:< E, ev2: Nothing <:< E): Either[E, B]

Attributes

Inherited from:
PartialEquivalence
def compose[C, E3, E4](that: PartialEquivalence[C, A, E3, E4]): PartialEquivalence[C, B, E3, E4]

Attributes

Inherited from:
PartialEquivalence