Design decisions

107. Collapse std.prefix to one prefix(a) / Prefix and one Diff family (2026-11-21)

  • Decision. Collapse prefix1/prefix2/prefix_n and Prefix1/Prefix2/PrefixN into one prefix(a) constructor and one user-visible Prefix type family dispatching by shape across [D]T (Prefix<D, T>), [R, C]T (Prefix<R, C, T>), and List<T>/[0..n]T (Prefix<T>). Every shape exposes O(1) .sum(range...) and O(1) .prefix(bound...) (adding .prefix(r, c) on 2-D grids) with build/query costs documented. Collapse Diff1<D, T> and Diff2<R, C, T> into one Diff family (Diff<D, T>() and Diff<R, C, T>()). Internal specializations (_Prefix2, _PrefixList, _Diff2) stay hidden from cpl-doc and display as Prefix/Diff. stdlib/prelude.cp exports use std.prefix.{Diff, Prefix} (net -2 prelude names). The removed arity-suffixed names (prefix1, prefix2, prefix_n, Prefix1, Prefix2, PrefixN, Diff1, Diff2) are compile errors with machine-applicable fixes in cpl-check and cpl fix (L0513), and all live ports, dreams, tests, editor data, and docs are migrated.
  • Reason. One spelling per idea: prefix sums and difference arrays are one concept parameterized by shape, not three or two separately named APIs by arity.
  • Reverse. Restore Prefix1/Prefix2/PrefixN/prefix1/prefix2/prefix_n/Diff1/Diff2 in stdlib/prefix.cp and stdlib/prelude.cp, remove prefix_shape_struct/INTERNAL_BUILT_ON dispatch in cpl-check/cpl-ir, and revert L0513 to warning-only call rewrites.