Traversal
Constructors for Traversal. Every constructor here — each / pEach / selfChildren and the two / three / four fixed-arity variants — rides the MultiFocus[PSVec] carrier, so they all compose through the standard .andThen in both directions (past a Lens, a Prism, another traversal, …).
Attributes
- Source
- Traversal.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Traversal.type
Members list
Grouped members
Constructors
Monomorphic Traversal over Traverse[T] — S = T = T[A], focus preserved.
Monomorphic Traversal over Traverse[T] — S = T = T[A], focus preserved.
Attributes
- Source
- Traversal.scala
Polymorphic counterpart to each — allows focus type change.
Polymorphic counterpart to each — allows focus type change.
Reassembly walks the original container with Functor.map plus a captured positional var — equivalent to Traverse.mapAccumulate but without the State thunk chain (the dominant CPU cost on profiled nested traversals). For ArraySeq the .from body bypasses Traverse[ArraySeq].map entirely (which threads through StrictOptimizedSeqOps → non-devirtualised SeqOps.size$, observed as 18% CPU), instead wrapping the focus vector directly via ArraySeq.unsafeWrapArray.
Attributes
- Source
- Traversal.scala
Monomorphic self-traversal from an explicit immediate-children view — focuses the values of S that are themselves S (the immediate sub-terms), with S itself as the leftover skeleton. children(s) is the immediate children as a focus vector; rebuild(s, vec) reassembles s with that same number of children swapped in (same order). The two must agree on arity and order: rebuild(s, children(s)) == s.
Monomorphic self-traversal from an explicit immediate-children view — focuses the values of S that are themselves S (the immediate sub-terms), with S itself as the leftover skeleton. children(s) is the immediate children as a focus vector; rebuild(s, vec) reassembles s with that same number of children swapped in (same order). The two must agree on arity and order: rebuild(s, children(s)) == s.
PSVec-native: to / from pass the PSVec straight through, so both the read path (Plated.children / universe, which read to(s)._2) and the write path (Plated.transform / rewrite, which traverse and rebuild through the carrier) avoid any List ↔ PSVec conversion. This is the carrier behind Plated — a recursive ADT's plate. Unlike each / pEach there is no container T[_]; the children of a node are gathered case-by-case, and the variable arity across cases (a binary node has two children, a leaf none) is exactly the PSVec shape.
Attributes
- Source
- Traversal.scala
Traversal over two per-element getters with a reverse reassembly. The arity is known at construction time, so the foci tabulate straight into the MultiFocus[PSVec] carrier and the result composes like any other traversal — past each, a Lens, a Prism, or another fixed-arity hop. reverse sees only the (modified) foci: the constructor is full-cover, so any leftover context of S must be rebuilt by reverse itself (drill with a Lens first when there are sibling fields). For the Grate-shaped Int => A encoding, see MultiFocus.tuple.
Traversal over two per-element getters with a reverse reassembly. The arity is known at construction time, so the foci tabulate straight into the MultiFocus[PSVec] carrier and the result composes like any other traversal — past each, a Lens, a Prism, or another fixed-arity hop. reverse sees only the (modified) foci: the constructor is full-cover, so any leftover context of S must be rebuilt by reverse itself (drill with a Lens first when there are sibling fields). For the Grate-shaped Int => A encoding, see MultiFocus.tuple.
Attributes
- Source
- Traversal.scala
Value members
Concrete methods
Fixed-arity-4 — see two. @group Constructors