Fold

dev.constructive.eo.optics.Fold
object Fold

Constructors for Fold — read-only multi-focus optic, backed by Forget[F] (Forget[F][X, A] = F[A]). T = Unit rules out the write path; .foldMap is the consumption surface. Fold.select(p) narrows to a one-element Option stream. The build-only dual on the same carrier — assemble a T from an F-layer — is Unfold.

Both constructors return the concrete ForgetFold subclass so a hand-written Fold picks up its eager, carrier-free foldMap member (see ForgetFold.foldMap).

Attributes

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

Members list

Grouped members

Constructors

def apply[F[_], A](using Foldable[F]): ForgetFold[F[A], F, A]

Fold over any Foldable[F].

Fold over any Foldable[F].

Attributes

Example
import cats.instances.list.given
val listFold = Fold[List, Int]
listFold.foldMap(identity[Int])(List(1, 2, 3))   // 6
Source
Fold.scala

Value members

Concrete methods

def select[A](p: A => Boolean): ForgetFold[A, Option, A]

Filtering Fold — backed by Forget[Option]. @group Constructors

Filtering Fold — backed by Forget[Option]. @group Constructors

Attributes

Source
Fold.scala