Iso

dev.constructive.eo.optics.Iso$package.Iso
object Iso

Constructor for Iso — a bijective single-focus optic, backed by Direct. The Iso type alias above names the concrete BijectionIso for the monomorphic case, so ascribing it is safe; Iso.apply returns that class carrying the fused compose overloads and capability mixins. Consuming signatures should still demand a capability (CanGet[S, A], CanReverseGet[S, A], …) rather than name Iso. An iso encodes a data-shape bijection. Direct[X, A] = A carries no leftover, so every Iso operation reduces to plain function application.

Attributes

Source
Iso.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Iso.type

Members list

Grouped members

Constructors

def apply[S, T, A, B](f: S => A, g: B => T): BijectionIso[S, T, A, B]

Construct an Iso from forward get: S => A and reverse reverseGet: B => T. Polymorphic; use S = T = A = B for the monomorphic case.

Construct an Iso from forward get: S => A and reverse reverseGet: B => T. Polymorphic; use S = T = A = B for the monomorphic case.

Attributes

Example
case class Person(age: Int, name: String)
val pairIso = Iso[(Int, String), (Int, String), Person, Person](
 t => Person(t._1, t._2),
 p => (p.age, p.name),
)
Source
Iso.scala