Skip to content

v3.0.0

Choose a tag to compare

@github-actions github-actions released this 13 May 21:23
3c50650

Replace STREAM[T] with state-explicit generator(initial, advance) #major (#84)

Bugs fixed:

  • The STREAM[T] union and || infix shipped in 2.1.0 turned out
    near-useless in practice. Every non-trivial generator ended up as
    a wrapper function returning STREAM[T] (so the "value form" pitch
    collapses to "factory function returns sequence"); every step
    allocated a closure-per-yield; and the recursive-lambda pattern
    required threading state through call args with no compiler-side
    state-machine rewrite. For the common case of "produce a sequence
    in a functional way" it was strictly worse than an Iterator-style
    helper with an explicit state type parameter.

Technical:

  • Adds generator[T, S](initial: S, advance: S -> MAYBE[(T, S)]) -> Pipe[T] and a backing GENERATOR_PIPE[T, S]: Pipe[T] class.
    State type S is a first-class type parameter, distinct from
    element type T. The advance function is pure
    (S -> MAYBE[(T, S)]) — returns an empty MAYBE to terminate, or
    MAYBE((value, next_state)) to yield. No closure allocation per
    step — the mutable state cursor lives in GENERATOR_PIPE.
  • Removes STREAM[T], STREAM_PIPE[T], the
    pipe(() -> STREAM[T]) / pipe(STREAM[T]) overloads, and the
    unused ITERATOR_PIPE[T] (was only reached via the
    pipe(Iterator[T]) overload already dropped in 2.1.1).

Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com