Grapheme

Grapheme :: # (opaque)

Extended grapheme cluster boundaries and materializers.

The public contract is range-first and implements the default, un-tailored Unicode 17 extended grapheme cluster algorithm.

iter_ranges : Str -> Iter(ByteRange)

Visit half-open byte ranges in source order through Iter.

ranges : Str -> List(ByteRange)

Collect half-open byte ranges in source order.

slices : Str -> List(Str)

Return seamless slices of the source, retaining its backing storage.

owned : Str -> List(Str)

Return independently materialized cluster strings.

Cursor

Grapheme.Cursor :: # (opaque)

Incremental segmentation over scalar-aligned Str chunks.

init : {  } -> Cursor
push : Cursor, Str, state, (state, ByteRange -> state) -> Try({ cursor : Cursor, state : state }, Error)

Consume a chunk and fold each irrevocable cluster range into caller state. A chunk boundary is not treated as end of text.

finish : Cursor, state, (state, ByteRange -> state) -> Try({ cursor : Cursor, state : state }, Error)

Mark end of text and emit the final nonempty cluster exactly once.