Affine

dev.constructive.eo.data.Affine
See theAffine companion object
sealed trait Affine[A, B]

Carrier for the Optional family — sealed hierarchy: Affine.Miss (no focus; carries Fst[A]) and Affine.Hit (focus present; carries Snd[A] + B). Miss / Hit store fields directly (no Either / Tuple2 wrapper); a .affine: Either[Fst[A], (Snd[A], B)] legacy accessor reconstructs the old view on demand. Prefer matching Miss(...) / Hit(...) for zero-alloc access.

At every constructor site A is a concrete Tuple2 (so Fst[A] / Snd[A] reduce); when carried through an Optic[…, Affine] existential, A is abstract and the match types stay inert.

Type parameters

A

existential leftover tuple

B

focus type

Attributes

Companion
object
Source
Affine.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Hit[A, B]
class Miss[A, B]

Members list

Value members

Concrete methods

def aFold[C](f: Fst[A] => Affine[A, C], g: ((Snd[A], B)) => Affine[A, C]): Affine[A, C]

Fold both branches into a new Affine[A, C]. Dispatches via direct pattern match (no intermediate Either).

Fold both branches into a new Affine[A, C]. Dispatches via direct pattern match (no intermediate Either).

Type parameters

C

focus type of the output

Attributes

Source
Affine.scala
def aTraverse[C, G[_] : Applicative](f: B => G[C]): G[Affine[A, C]]

Effectful traversal — runs f on the hit branch, passes the miss branch through via Applicative.pure.

Effectful traversal — runs f on the hit branch, passes the miss branch through via Applicative.pure.

Type parameters

C

focus produced by f

G

effect constructor

Attributes

Source
Affine.scala
def fold[C](onMiss: Fst[A] => C, onHit: (Snd[A], B) => C): C

Monomorphic fold — pattern-match on Miss/Hit and run the matching branch.

Monomorphic fold — pattern-match on Miss/Hit and run the matching branch.

Type parameters

C

output type

Attributes

Source
Affine.scala

Deprecated methods

def affine: Either[Fst[A], (Snd[A], B)]

Legacy Either-shaped accessor (reconstructs a fresh Either + Tuple2 on each call). New code should pattern-match Miss / Hit or use fold directly.

Legacy Either-shaped accessor (reconstructs a fresh Either + Tuple2 on each call). New code should pattern-match Miss / Hit or use fold directly.

Attributes

Deprecated
[Since version 0.6.3] pattern-match Miss / Hit or use fold instead
Source
Affine.scala