42. Range structures stdlib (spec/lib/rationale/ranges.md, §4.10, 2026-11-21)
- 42.1
DualSegTree<D, T, F>is its own type, not a mode onLazySegTree. Range-apply + point-get needs no fold monoid, nopull, and nospanarray (cf2255e2friction). Putting it onLazySegTreeforces a fake monoid and wastes half the work. It pushes top-down by default so non-commutative tags are always sound. Reverse: fold intoLazySegTree.
- 42.2
DualFenwick<D, T>andRangeFenwick<D>are separate types fromFenwick<D, T>. Addingrange_addontoFenwickwould let a user callsum(r)on a difference-array Fenwick and get nonsense. Separate types make the invariant unbreakable. Reverse: drop the types and add a helper method.
- 42.3
fill: ?T = noneis a named constructor argument onSegTree.new,LazySegTree.new, andDualSegTree.new. Follows the named-option rule instead of adding.filled(...)variants, and avoids allocating a throwaway[D]Tarray for constant-initialized DP trees (cf2207ffriction). Reverse: remove the parameter.
- 42.4
prefix_foldandsuffix_foldreturn[D.bounds]T, notList<T>. Querying everything outsider: Range<D>ism.op(pref[r.lo], suff[r.hi])with zero.ord/.ord + 1arithmetic (cf2062e2friction). Coordinates with 41.3 so the pair lives in one module (std.prefixorstd.seq, not duplicated). Reverse: return a wrapper struct.
- 42.5
MaxSublives instd.algebraand implementsReversible. Kadane's 4-field summary is the most repeated custom monoid in the corpus (cf2255e2), andReversiblemakes tree-path max-subarray queries work withRooted.fold_path. Reverse: move to a separate module or local-lib.
- 42.6 Algebra stays value-based (
Monoid,Action); static dispatch is left to the core lane. MovingMonoid/Actionto traits waits on associated constants (decision 26.4), and removingstd::functionoverhead is a general closure-monomorphization pass incpl-codegen, not a stdlib-specific hack. Reverse: switch to traits once associated constants land.