Iso

dev.constructive.eo.optics.Iso
object Iso

Constructor for Iso — a bijective single-focus optic, backed by Direct. An Iso[S, A] (short for Optic[S, S, A, A, Direct]) 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