Design decisions

51. Seq and Indexed trait unification (2026-11-21)

  1. Built-in Seq and Indexed traits are backed by one central Ty::seq_elem() / is_seq() / is_indexed() predicate in cpl-check and cpl-ir. Str, List<T>, 1D [D]T, Range<I>, and O(1) slice/reverse views all satisfy Seq and Indexed without conversion, and generic functions written <S: Seq, T> or <S: Indexed> check bounds at instantiation and deduce element type T from S. Reason: eliminates per-container overloads (runs, prefix_function, z_function, is_palindrome, is_sorted, prod, pairs, excl_fold, sum/min/max) and gives O(1) views a single plug-in point (Ty::StrView, Ty::ListView). Reverse: revert seq_elem/is_seq/is_indexed and restore concrete parameter types in stdlib/seq.cp and stdlib/strings.cp.
  2. Zero-based s.at(i) and s.get(i) are the uniform Indexed accessors, while a[i] preserves domain safety on [D]T. Str gains .first, .last, .last(k), .get(i), .at(i); Range<I> gains r[i], .get(i), .at(i), .last(k) and sum/min/max/runs; 1D [D]T gains .get(i) and .at(i). Generic <S: Indexed> algorithms (such as prefix_function and z_function) index via s.at(i) so nominal-domain arrays [V]T work without weakening WRONG_DOMAIN checks on a[i]. Reverse: remove at/get arms in cpl-ir/src/lower/call.rs.