dev.constructive.eo.schemes.zoo

Members list

Type members

Classlikes

final class Ana[F[_], Seed, S](val coalg: Seed => F[Seed])(using F: Traverse[F], E: Embed[F, S]) extends BuildScheme[S, Seed]

Anamorphism citizen — an unfold (BuildScheme) with X = S (the structure it threads). Carries coalg so cross can fuse with a node-blind Cata (→ Hylo) or a course-of-value Histo (→ Dyna). Refining X upward to Coattr = μX. Seed + F[X] (the free monad) gives the multi-layer unfold (futumorphism — Futu).

Anamorphism citizen — an unfold (BuildScheme) with X = S (the structure it threads). Carries coalg so cross can fuse with a node-blind Cata (→ Hylo) or a course-of-value Histo (→ Dyna). Refining X upward to Coattr = μX. Seed + F[X] (the free monad) gives the multi-layer unfold (futumorphism — Futu).

Attributes

Source
Ana.scala
Supertypes
class BuildScheme[S, Seed]
trait Optic[Unit, S, Unit, Seed, Direct]
class Object
trait Matchable
class Any
object Apo

Attributes

Companion
class
Source
Apo.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Apo.type
final class Apo[F[_], A, S](val coalg: A => F[Either[S, A]])(using F: Traverse[F], E: Embed[F, S]) extends BuildScheme[S, A]

Apomorphism citizen — an unfold that may short-circuit with a finished subtree (BuildScheme) with X = Either[S, A] (the residual): each child slot is either Left(s) — an already-built S, grafted in directly — or Right(a) — a seed to keep unfolding.

Apomorphism citizen — an unfold that may short-circuit with a finished subtree (BuildScheme) with X = Either[S, A] (the residual): each child slot is either Left(s) — an already-built S, grafted in directly — or Right(a) — a seed to keep unfolding.

coalg: A => F[Either[S, A]] is the build-side dual of Para's read-side subterm retention: where para reads original subterms, apo writes finished ones. The Either residual is the Prism's match worn build-side. An all-Right coalgebra degenerates to Ana.

'''The residual is a data.Affine optic.''' apo's per-slot decision is exactly Affine's build seam — Left(s) is Miss(s) (a finished slot, the O(1) graft), Right(a) is Hit((), a) (keep unfolding). Apo.scatter exposes that decision as a composable Affine-carried optic (a scatter), and this engine constructs and consumes it through that optic: every slot goes residual → scatter.to → Miss/Hit → engine, so apo genuinely speaks the carrier the carrier was written for. The pure Machines.foldLayeredOr engine still recurses over an Either at its boundary (it is shared with elgot/cozygo); the Miss/Hit decision is collapsed onto that boundary at the last step.

'''O(1) graft.''' A Miss(s) subtree is placed into its result slot by reference — the engine's Left arm returns it without recursing or re-projecting. Stack-safe.

Attributes

Companion
object
Source
Apo.scala
Supertypes
class BuildScheme[S, A]
trait Optic[Unit, S, Unit, A, Direct]
class Object
trait Matchable
class Any
final case class Attr[F[_], A](head: A, tail: F[Attr[F, A]])

Cofree-without-laziness: a fold result (head) decorating one layer of already-decorated children (tail). The histomorphism's algebra sees F[Attr[F, A]] — each child's result plus that child's entire decorated history.

Cofree-without-laziness: a fold result (head) decorating one layer of already-decorated children (tail). The histomorphism's algebra sees F[Attr[F, A]] — each child's result plus that child's entire decorated history.

Type parameters

A

the fold result decorating each node

F

the pattern functor

Attributes

Companion
object
Source
Attr.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Attr

Attributes

Companion
class
Source
Attr.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Attr.type
final class BuildM[S, B, M[_], XI] extends BuildScheme[M[S], B]

Monadic-build citizen — the effectful unfold schemes (BuildScheme at carrier M[S]): an unfold whose coalgebra returns its layer in M and whose effects are sequenced through the construction. Builds B => M[S] (.reverseGet yields M[S]).

Monadic-build citizen — the effectful unfold schemes (BuildScheme at carrier M[S]): an unfold whose coalgebra returns its layer in M and whose effects are sequenced through the construction. Builds B => M[S] (.reverseGet yields M[S]).

The build-side mirror of FoldM: one class carries the whole M-unfold zoo — Schemes.anaM / Schemes.apoM / Schemes.futuM — differing only by the expand handed to the shared engine. The residual index rides the phantom XI (anaM is BuildM[…, S], apoM is BuildM[…, Either[S, A]], futuM is BuildM[…, Coattr[F, A]]), preserving the monad-tower index the same way FoldM preserves the comonad-tower one.

Runs on Machines.foldLayeredM under the same single-pass / linear / sequential M contract as FoldM.

Type parameters

XI

the residual index this unfold threads — the optic existential X, carried as a type parameter so one class spans the whole build-side M-zoo.

Attributes

Companion
object
Source
BuildM.scala
Supertypes
class BuildScheme[M[S], B]
trait Optic[Unit, M[S], Unit, B, Direct]
class Object
trait Matchable
class Any
object BuildM

Attributes

Companion
class
Source
BuildM.scala
Supertypes
class Object
trait Matchable
class Any
Self type
BuildM.type
abstract class BuildScheme[T, B] extends Optic[Unit, T, Unit, B, Direct]

Build-direction scheme — a Review-shaped optic over Direct building B => T (.reverseGet).

Build-direction scheme — a Review-shaped optic over Direct building B => T (.reverseGet).

Attributes

Source
SchemeShapes.scala
Supertypes
trait Optic[Unit, T, Unit, B, Direct]
class Object
trait Matchable
class Any
Known subtypes
class Ana[F, Seed, S]
class Apo[F, A, S]
class BuildM[S, B, M, XI]
class Comutu[F, A, B, S]
class Cozygo[F, A, B, S]
class Futu[F, A, S]
class Postpro[F, A, S]
Show all
final class Cata[F[_], S, A](val alg: F[A] => A)(using F: Traverse[F], P: Project[F, S]) extends ReadScheme[S, A]

Catamorphism citizen — a node-blind fold (ReadScheme) with X = Nothing, the forgetful (trivial) resolution of the recursion index. Carries alg so Ana.cross can rebuild the fused Hylo machine.

Catamorphism citizen — a node-blind fold (ReadScheme) with X = Nothing, the forgetful (trivial) resolution of the recursion index. Carries alg so Ana.cross can rebuild the fused Hylo machine.

alg: F[A] => A sees only the already-folded children (named constructors), never the source node — that blindness (X = Nothing) is the soundness condition that licenses fusion. Refining X upward gives the richer folds: F[(S, A)] (paramorphism, Para) and Attr = νX. A × F[X] (histomorphism, the cofree comonad — Histo).

Attributes

Source
Cata.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
object Chrono

Attributes

Companion
class
Source
Chrono.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Chrono.type
final class Chrono[A, B] extends ReadScheme[A, B]

Chronomorphism citizen — the fused futu-then-histo refold (ReadScheme), Hylo lifted to the universal indices: unfold through the free monad (Coattr), fold through the cofree comonad (Attr), no intermediate S. Built by Futu.cross or Chrono.apply. A nominally-distinct member of the fused-refold family (see Hylo): honest X = Nothing.

Chronomorphism citizen — the fused futu-then-histo refold (ReadScheme), Hylo lifted to the universal indices: unfold through the free monad (Coattr), fold through the cofree comonad (Attr), no intermediate S. Built by Futu.cross or Chrono.apply. A nominally-distinct member of the fused-refold family (see Hylo): honest X = Nothing.

Attributes

Companion
object
Source
Chrono.scala
Supertypes
class ReadScheme[A, B]
trait Optic[A, Unit, B, Unit, Direct]
class Object
trait Matchable
class Any
enum Coattr[F[_], A]

Free-without-suspension: a futumorphism's coalgebra answers each slot with either a seed still to expand (Coattr.Pure) or an already-known layer to unroll without consulting the coalgebra again (Coattr.Roll) — the multi-layer-per-step channel.

Free-without-suspension: a futumorphism's coalgebra answers each slot with either a seed still to expand (Coattr.Pure) or an already-known layer to unroll without consulting the coalgebra again (Coattr.Roll) — the multi-layer-per-step channel.

Type parameters

A

the seed type

F

the pattern functor

Attributes

Companion
object
Source
Coattr.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Coattr

Attributes

Companion
enum
Source
Coattr.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Coattr.type
final class Codyna[A, B] extends ReadScheme[A, B]

The fused multi-layer-unfold → node-blind-fold refold (ReadScheme) — the mirror of Dyna, opposite diagonal of the refold quadrant: a free-monad futu unfold (Coattr) whose fold is a plain cata, no intermediate S. Built by Futu.cross or Codyna.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing. (Codyna is a descriptive name — the free-unfold/plain-fold refold has no standard one in the literature.)

The fused multi-layer-unfold → node-blind-fold refold (ReadScheme) — the mirror of Dyna, opposite diagonal of the refold quadrant: a free-monad futu unfold (Coattr) whose fold is a plain cata, no intermediate S. Built by Futu.cross or Codyna.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing. (Codyna is a descriptive name — the free-unfold/plain-fold refold has no standard one in the literature.)

Attributes

Companion
object
Source
Codyna.scala
Supertypes
class ReadScheme[A, B]
trait Optic[A, Unit, B, Unit, Direct]
class Object
trait Matchable
class Any
object Codyna

Attributes

Companion
class
Source
Codyna.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Codyna.type
object Coelgot

Attributes

Companion
class
Source
Coelgot.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Coelgot.type
final class Coelgot[A, B] extends ReadScheme[A, B]

Co-Elgot citizen — a Hylo whose fold may read the seed (ReadScheme): coalg: A => F[A] unfolds, alg: (A, F[B]) => B folds with the originating seed in hand (the build-side analogue of Para's subterm retention, on the fused refold). Built by Coelgot.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Co-Elgot citizen — a Hylo whose fold may read the seed (ReadScheme): coalg: A => F[A] unfolds, alg: (A, F[B]) => B folds with the originating seed in hand (the build-side analogue of Para's subterm retention, on the fused refold). Built by Coelgot.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Attributes

Companion
object
Source
Coelgot.scala
Supertypes
class ReadScheme[A, B]
trait Optic[A, Unit, B, Unit, Direct]
class Object
trait Matchable
class Any
final class Comutu[F[_], A, B, S](val coalgA: A => F[Either[A, B]], val coalgB: B => F[Either[A, B]])(using F: Traverse[F], E: Embed[F, S]) extends BuildScheme[S, A]

Comutumorphism citizen — the build-side dual of Mutu (BuildScheme) with X = Either[A, B]: two coalgebras unfold by mutual co-recursion, each slot tagged with the coalgebra that produced it.

Comutumorphism citizen — the build-side dual of Mutu (BuildScheme) with X = Either[A, B]: two coalgebras unfold by mutual co-recursion, each slot tagged with the coalgebra that produced it.

coalgA: A => F[Either[A, B]] and coalgB: B => F[Either[A, B]] are the two mutually co-recursive unfolds; the entry seed is an A (Left). It generalises Cozygo — that scheme is comutu where the secondary coalgebra never re-enters the primary type — and so, like its fold-side mirror, degenerates to Ana when only one coalgebra is ever reached. Stack-safe (the Machines.foldLayered machine).

Attributes

Source
Comutu.scala
Supertypes
class BuildScheme[S, A]
trait Optic[Unit, S, Unit, A, Direct]
class Object
trait Matchable
class Any
final class Cozygo[F[_], A, B, S](val aux: B => F[B], val coalg: A => F[Either[B, A]])(using F: Traverse[F], E: Embed[F, S]) extends BuildScheme[S, A]

Cozygomorphism citizen (the generalised apomorphism, g-apo) — the build-side dual of Zygo (BuildScheme) with X = Either[B, A]: each child slot is either Left(b) — a seed handed to the auxiliary coalgebra — or Right(a) — a seed for the main one.

Cozygomorphism citizen (the generalised apomorphism, g-apo) — the build-side dual of Zygo (BuildScheme) with X = Either[B, A]: each child slot is either Left(b) — a seed handed to the auxiliary coalgebra — or Right(a) — a seed for the main one.

aux: B => F[B] is a self-contained unfold (a plain Ana over B); once a slot goes Left(b) it stays in B-land. coalg: A => F[Either[B, A]] is the main unfold, choosing per slot which coalgebra continues. It mirrors how Apo (X = Either[S, A]) sits above Ana: cozygo's residual is Either[B, A] for an arbitrary auxiliary carrier B rather than the finished structure S. An all-Right coalg never consults aux and degenerates to Ana.

'''Versus Apo.''' Apo's Left(s) grafts an already-built S by reference (O(1), no recursion); cozygo's Left(b) keeps unfolding through aux, so it builds rather than grafts — the honest dual of zygo's auxiliary fold. Stack-safe (the Machines.foldLayered machine).

Attributes

Source
Cozygo.scala
Supertypes
class BuildScheme[S, A]
trait Optic[Unit, S, Unit, A, Direct]
class Object
trait Matchable
class Any
final class Dyna[A, B] extends ReadScheme[A, B]

Dynamorphism citizen — the fused plain-unfold → course-of-value-fold refold (ReadScheme), the refold-quadrant diagonal between Hylo (plain→plain) and Chrono (free→cofree): a plain ana unfold whose fold sees each node's decorated history (Attr), no intermediate S. Built by Ana.cross or Dyna.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Dynamorphism citizen — the fused plain-unfold → course-of-value-fold refold (ReadScheme), the refold-quadrant diagonal between Hylo (plain→plain) and Chrono (free→cofree): a plain ana unfold whose fold sees each node's decorated history (Attr), no intermediate S. Built by Ana.cross or Dyna.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Attributes

Companion
object
Source
Dyna.scala
Supertypes
class ReadScheme[A, B]
trait Optic[A, Unit, B, Unit, Direct]
class Object
trait Matchable
class Any
object Dyna

Attributes

Companion
class
Source
Dyna.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Dyna.type
object Elgot

Attributes

Companion
class
Source
Elgot.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Elgot.type
final class Elgot[A, B] extends ReadScheme[A, B]

Elgot citizen — a Hylo whose unfold may short-circuit (ReadScheme): coalg: A => Either[B, F[A]] answers Left(b) (the seed resolves directly, stop) or Right(layer) (keep unfolding); alg: F[B] => B folds the rest. Driven by the short-circuit-aware Machines.foldLayeredOr. Built by Elgot.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Elgot citizen — a Hylo whose unfold may short-circuit (ReadScheme): coalg: A => Either[B, F[A]] answers Left(b) (the seed resolves directly, stop) or Right(layer) (keep unfolding); alg: F[B] => B folds the rest. Driven by the short-circuit-aware Machines.foldLayeredOr. Built by Elgot.apply. Nominally distinct in the fused-refold family (see Hylo): honest X = Nothing.

Attributes

Companion
object
Source
Elgot.scala
Supertypes
class ReadScheme[A, B]
trait Optic[A, Unit, B, Unit, Direct]
class Object
trait Matchable
class Any
final class FoldM[S, A, M[_], XI] extends ReadScheme[S, M[A]]

Monadic-fold citizen — the effectful read schemes (ReadScheme at focus M[A]): a fold whose algebra returns M[A] and whose effects are sequenced through the structure in Foldable order. Reads S => M[A] (.get yields M[A]).

Monadic-fold citizen — the effectful read schemes (ReadScheme at focus M[A]): a fold whose algebra returns M[A] and whose effects are sequenced through the structure in Foldable order. Reads S => M[A] (.get yields M[A]).

One class carries the whole read-side M-zoo — Schemes.cataM / Schemes.paraM / Schemes.histoM and the fused Schemes.hyloM / Schemes.chronoM — exactly as the pure Cata / Para / … differ only by the combine they hand the shared engine. The recursion index is not erased by the consolidation: it rides the phantom type parameter XI, so cataM is FoldM[…, Nothing], paraM is FoldM[…, F[(S, A)]], etc. — the same X-as-index thesis the pure zoo pins per class, here pinned per factory.

All variants run on the single Machines.foldLayeredM engine (the Monad[M]-lifted walk, tailRecM-driven and stack-safe). '''Contract:''' M must be a single-pass, linear, sequentially-evaluated monad (Id, Eval, State, IO, …). A branching / replaying M (List, retrying effects) shares the engine's mutable walk state across branches and corrupts the fold — see Machines.foldLayeredM's contract.

Type parameters

XI

the recursion index this fold retains — the optic existential X, carried as a type parameter so one class spans the whole read-side M-zoo without losing the index.

Attributes

Companion
object
Source
FoldM.scala
Supertypes
class ReadScheme[S, M[A]]
trait Optic[S, Unit, M[A], Unit, Direct]
class Object
trait Matchable
class Any
object FoldM

Attributes

Companion
class
Source
FoldM.scala
Supertypes
class Object
trait Matchable
class Any
Self type
FoldM.type
final class Futu[F[_], A, S](val coalg: A => F[Coattr[F, A]])(using F: Traverse[F], E: Embed[F, S]) extends BuildScheme[S, A]

Futumorphism citizen — a multi-layer unfold (BuildScheme) with X = Coattr[F, A], the free monad μX. A + F[X]. The build-side mirror of Histo. coalg: A => F[Coattr[F, A]] answers each slot with Coattr.Pure (keep unfolding) or Coattr.Roll (a prebuilt layer, no coalgebra call), so one step may emit several layers; the root seed enters as Coattr.Pure. An all-Pure coalgebra degenerates to Ana. Carries coalg so cross can fuse with Histo (→ Chrono) or Cata (→ Codyna). Stack-safe.

Futumorphism citizen — a multi-layer unfold (BuildScheme) with X = Coattr[F, A], the free monad μX. A + F[X]. The build-side mirror of Histo. coalg: A => F[Coattr[F, A]] answers each slot with Coattr.Pure (keep unfolding) or Coattr.Roll (a prebuilt layer, no coalgebra call), so one step may emit several layers; the root seed enters as Coattr.Pure. An all-Pure coalgebra degenerates to Ana. Carries coalg so cross can fuse with Histo (→ Chrono) or Cata (→ Codyna). Stack-safe.

Attributes

Source
Futu.scala
Supertypes
class BuildScheme[S, A]
trait Optic[Unit, S, Unit, A, Direct]
class Object
trait Matchable
class Any
final class Histo[F[_], S, A](val alg: F[Attr[F, A]] => A)(using F: Traverse[F], P: Project[F, S]) extends ReadScheme[S, A]

Histomorphism citizen — a course-of-value fold (ReadScheme) with X = Attr[F, A], the cofree comonad νX. A × F[X]. The thesis at its sharpest: the histomorphism's existential is literally the universal index for folds. Cata is the same shape at X = Nothing; Histo keeps the whole decorated history, so Histo : Cata :: Lens : Getter.

Histomorphism citizen — a course-of-value fold (ReadScheme) with X = Attr[F, A], the cofree comonad νX. A × F[X]. The thesis at its sharpest: the histomorphism's existential is literally the universal index for folds. Cata is the same shape at X = Nothing; Histo keeps the whole decorated history, so Histo : Cata :: Lens : Getter.

alg: F[Attr[F, A]] => A sees, per child, not just its folded result but its entire decorated subtree (Attr.head = result, Attr.tail = the child's own decorated layer) — folds unreachable by a single-pass Cata. Heads-only (alg ∘ map(_.head)) degenerates to Cata. Space honesty: course-of-value recursion retains O(n) Attr cells by nature. Stack-safe.

Attributes

Source
Histo.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
object Hylo

Attributes

Companion
class
Source
Hylo.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Hylo.type
final class Hylo[Seed, A] extends ReadScheme[Seed, A]

Hylomorphism citizen — the fused refold (ReadScheme) with X = Nothing. Built by Ana.cross or Hylo.apply; carries only the fused refold, no tree. Not a primitive — it is ana.cross(cata).

Hylomorphism citizen — the fused refold (ReadScheme) with X = Nothing. Built by Ana.cross or Hylo.apply; carries only the fused refold, no tree. Not a primitive — it is ana.cross(cata).

The fused-refold family (Hylo / Chrono / Dyna / Codyna / Elgot / Coelgot) share this shape — a refold: Seed => A with a vestigial build side, so X = Nothing for all of them honestly. They are nominally distinct named types (one per construction), not different existential indices: fusion is exactly the act of discarding the intermediate index.

Attributes

Companion
object
Source
Hylo.scala
Supertypes
class ReadScheme[Seed, A]
trait Optic[Seed, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
final class Meta[S, A, T] extends ReadScheme[S, T]

Metamorphism citizen — a fold-then-unfold read S => T (ReadScheme). The fold-direction dual of Hylo: where hylo is the fused unfold-then-fold (X = Nothing, deforests), meta is the fold-then-unfold whose existential X = A is the neck — the intermediate value the fold produces and the unfold consumes.

Metamorphism citizen — a fold-then-unfold read S => T (ReadScheme). The fold-direction dual of Hylo: where hylo is the fused unfold-then-fold (X = Nothing, deforests), meta is the fold-then-unfold whose existential X = A is the neck — the intermediate value the fold produces and the unfold consumes.

That non-trivial X is the honest statement that meta cannot fuse: it folds a functor F down to A, then unfolds a different G back up; with F ≠ G there is no project ∘ embed cancellation, so A is genuinely materialised. (Even F = G does not fuse it — the barrier is the scalar neck, not the functor mismatch.) Built by Cata.meta or Meta.apply.

Type parameters

A

the neck — the retained intermediate value type (the optic's existential X)

Attributes

Companion
object
Source
Meta.scala
Supertypes
class ReadScheme[S, T]
trait Optic[S, Unit, T, Unit, Direct]
class Object
trait Matchable
class Any
object Meta

Attributes

Companion
class
Source
Meta.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Meta.type
final class MetaChrono[S, A, T] extends ReadScheme[S, T]

Metamorphism at the universal indices (ReadScheme) — the fold→unfold dual of Chrono, reading S => T. Fold the F-recursive S course-of-value to a neck A (the cofree history, Attr), then multi-layer-unfold A into a G-recursive T (the free coalgebra, Coattr). Built by Histo.meta or MetaChrono.apply.

Metamorphism at the universal indices (ReadScheme) — the fold→unfold dual of Chrono, reading S => T. Fold the F-recursive S course-of-value to a neck A (the cofree history, Attr), then multi-layer-unfold A into a G-recursive T (the free coalgebra, Coattr). Built by Histo.meta or MetaChrono.apply.

The universal-index twin of Meta: same X = A neck, same no-fusion (F ≠ G). The cofree comonad on the fold side and the free monad on the unfold side never cancel across the neck — chrono is exactly this combination with F = G, where they do.

Type parameters

A

the neck — the retained intermediate value type (the optic's existential X)

Attributes

Companion
object
Source
MetaChrono.scala
Supertypes
class ReadScheme[S, T]
trait Optic[S, Unit, T, Unit, Direct]
class Object
trait Matchable
class Any
object MetaChrono

Attributes

Companion
class
Source
MetaChrono.scala
Supertypes
class Object
trait Matchable
class Any
Self type
MetaChrono.type
final class Mutu[F[_], S, A, B](val algA: F[(A, B)] => A, val algB: F[(A, B)] => B)(using F: Traverse[F], P: Project[F, S]) extends ReadScheme[S, A]

Mutumorphism citizen — a fold by mutual recursion (ReadScheme) with X = F[(A, B)]: two algebras compute a pair (A, B) per node, each free to read both halves of its children.

Mutumorphism citizen — a fold by mutual recursion (ReadScheme) with X = F[(A, B)]: two algebras compute a pair (A, B) per node, each free to read both halves of its children.

algA: F[(A, B)] => A and algB: F[(A, B)] => B are the two mutually-recursive functions; the citizen returns the A half. It generalises Zygo — zygo(aux)(alg) is mutu where the second algebra ignores the A half (algB = aux ∘ map(_._2)) — and so, transitively, Para and Cata. The two results are computed in one pass over the structure. Stack-safe (the Machines.foldLayered machine).

Attributes

Source
Mutu.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
final class Para[F[_], S, A](val alg: F[(S, A)] => A)(using F: Traverse[F], P: Project[F, S]) extends ReadScheme[S, A]

Paramorphism citizen — a fold that retains the original subterms (ReadScheme) with X = F[(S, A)]: each child slot pairs the original subterm S with its folded result A.

Paramorphism citizen — a fold that retains the original subterms (ReadScheme) with X = F[(S, A)]: each child slot pairs the original subterm S with its folded result A.

alg: F[(S, A)] => A is strictly more informed than Cata's F[A] => A — it can read the subterm itself, not just its summary. Ignoring the S half degenerates to Cata.

'''On the existential, honestly.''' X = F[(S, A)] is the store-comonad complement, which is why the brainstorm flags para as the candidate writable scheme (para : Cata :: Lens : Getter). get-put holds definitionally (re-embedding the retained subterms rebuilds the node), but put-get holds only under an algebra-coherence condition — so the lawful writable Lens is conditional, not free. This citizen ships the unconditionally-sound read; the writable put is a scoped follow-up rather than an asserted capability.

Subterms come from the layer the machine already expanded — each child is paired with its folded result positionally, in Foldable order (sound for any lawful Traverse), so there is no per-node re-project and no per-node List. Stack-safe (the Machines.foldLayeredPaired machine).

Attributes

Source
Para.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
final class Postpro[F[_], A, S](val eta: FunctionK[F, F], val coalg: A => F[A])(using F: Traverse[F], P: Project[F, S], E: Embed[F, S]) extends BuildScheme[S, A]

Postpromorphism citizen — an unfold that applies a natural transformation η : F ~> F after each step (BuildScheme). The build-side mirror of Prepro: the coalgebra coalg: A => F[A] is exactly Ana's (so X = S, the structure it threads), but each emitted subtree is hoisted through η once per level it sits below the root.

Postpromorphism citizen — an unfold that applies a natural transformation η : F ~> F after each step (BuildScheme). The build-side mirror of Prepro: the coalgebra coalg: A => F[A] is exactly Ana's (so X = S, the structure it threads), but each emitted subtree is hoisted through η once per level it sits below the root.

Like Prepro, this is the layer-transforming axis, not an index refinement: apo/futu refine the residual X; postpro keeps ana's index and decorates the layer optic on the embed glue side. With η = id it is exactly Ana.

'''Cost, honestly.''' Each built child subtree is hoisted (embed ∘ η at every layer) before its parent embeds it, so a node at depth k is re-transformed k times: O(n · depth), the inherent cost of the postpromorphism. Both the outer build and each hoist run on the stack-safe Machines.foldLayered machine.

Attributes

Source
Postpro.scala
Supertypes
class BuildScheme[S, A]
trait Optic[Unit, S, Unit, A, Direct]
class Object
trait Matchable
class Any
final class Prepro[F[_], S, A](val eta: FunctionK[F, F], val alg: F[A] => A)(using F: Traverse[F], P: Project[F, S], E: Embed[F, S]) extends ReadScheme[S, A]

Prepromorphism citizen — a fold that applies a natural transformation η : F ~> F before recursing (ReadScheme). The algebra alg: F[A] => A is exactly Cata's — node-blind, so X = Nothing — but the recursion is reshaped: the layer reaching a node at depth k has had η applied k times.

Prepromorphism citizen — a fold that applies a natural transformation η : F ~> F before recursing (ReadScheme). The algebra alg: F[A] => A is exactly Cata's — node-blind, so X = Nothing — but the recursion is reshaped: the layer reaching a node at depth k has had η applied k times.

This is the orthogonal axis to the comonad/monad index towers. para/histo refine what the algebra sees (the existential X); prepro keeps the trivial index and instead decorates the layer optic — the project peel is pre-composed with the accumulating η. With η = id it is exactly Cata.

'''Cost, honestly.''' Each descent applies η to a whole subtree before folding it (the one-shot hoist embed ∘ η at every layer), so a node at depth k is re-transformed k times: O(n · depth) total, the inherent cost of the prepromorphism (Uustalu & Vene). Both the outer fold and each hoist run on the stack-safe Machines.foldLayered machine.

Attributes

Source
Prepro.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
abstract class ReadScheme[S, A] extends Optic[S, Unit, A, Unit, Direct]

Read-direction scheme — a Getter-shaped optic over Direct reading S => A (.get).

Read-direction scheme — a Getter-shaped optic over Direct reading S => A (.get).

Attributes

Source
SchemeShapes.scala
Supertypes
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any
Known subtypes
class Cata[F, S, A]
class Chrono[A, B]
class Codyna[A, B]
class Coelgot[A, B]
class Dyna[A, B]
class Elgot[A, B]
class FoldM[S, A, M, XI]
class Histo[F, S, A]
class Hylo[Seed, A]
class Meta[S, A, T]
class MetaChrono[S, A, T]
class Mutu[F, S, A, B]
class Para[F, S, A]
class Prepro[F, S, A]
class Zygo[F, S, A, B]
Show all
final class Zygo[F[_], S, A, B](val aux: F[B] => B, val alg: F[(B, A)] => A)(using F: Traverse[F], P: Project[F, S]) extends ReadScheme[S, A]

Zygomorphism citizen — a fold carrying an auxiliary algebra alongside the main one (ReadScheme) with X = F[(B, A)]: each child slot pairs the auxiliary result B with the main result A.

Zygomorphism citizen — a fold carrying an auxiliary algebra alongside the main one (ReadScheme) with X = F[(B, A)]: each child slot pairs the auxiliary result B with the main result A.

aux: F[B] => B runs a second, self-contained fold whose results the main alg: F[(B, A)] => A may read per child. It is the rung the comonad tower skips between Cata (X = Nothing) and Para (X = F[(S, A)]): para is exactly zygo at B = S with aux = embed (the auxiliary fold rebuilds the original subterm), and ignoring the B half (alg ∘ map(_._2)) degenerates to Cata. The further generalisation — letting aux also see the A half — is the mutumorphism (Mutu).

'''On the existential.''' X = F[(B, A)] is the store comonad over the auxiliary carrier B, the same store-comonad complement Para flags as its writable candidate, but over an arbitrary B rather than the structure S. The two results are computed in one pass (the fold yields (B, A) pairs; the final projection keeps the A). Stack-safe (the Machines.foldLayered machine).

Attributes

Source
Zygo.scala
Supertypes
class ReadScheme[S, A]
trait Optic[S, Unit, A, Unit, Direct]
class Object
trait Matchable
class Any