Unfold

dev.constructive.eo.optics.Unfold
See theUnfold companion class
object Unfold

Constructors for Unfold — build-only multi-focus optic, backed by Forget[F] (Forget[F][X, B] = F[B]) with S = A = Unit ruling out the read path; .embed is the consumption surface.

Attributes

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

Members list

Grouped members

Constructors

def algebra[T, B, F[_]](embed: F[B] => T): Unfold[T, B, F]

Construct from a recursion-scheme algebra over a pattern functor — F need not (and usually cannot) be Applicative, so the vestigial to has no canonical value and THROWS if a read-side operation forces it. The build-only surface (.embed, the fused andThens, the build side of composition) never does.

Construct from a recursion-scheme algebra over a pattern functor — F need not (and usually cannot) be Applicative, so the vestigial to has no canonical value and THROWS if a read-side operation forces it. The build-only surface (.embed, the fused andThens, the build side of composition) never does.

Attributes

Example
enum BinF[+A]:
 case LeafF(n: Int); case BranchF(l: A, r: A)
val eval = Unfold.algebra[Int, Int, BinF] {
 case BinF.LeafF(n)      => n
 case BinF.BranchF(l, r) => l + r
}
Source
Unfold.scala
def apply[T, B, F[_]](embed: F[B] => T)(using F: Applicative[F]): Unfold[T, B, F]

Construct from embed: F[B] => T for an Applicative[F] — the vestigial to is honestly pure(()).

Construct from embed: F[B] => T for an Applicative[F] — the vestigial to is honestly pure(()).

Attributes

Example
val sum = Unfold((xs: List[Int]) => xs.sum)
sum.embed(List(1, 2, 3))   // 6
Source
Unfold.scala