Module Stream.Replace

replace_all, streamed: each Leftmost_longest match m is replaced by f m, everything else passes through unchanged.

feed returns the next piece of the output; input is held back only while it could still belong to a match (at most one longest-pattern length), so pieces flow promptly. Replace.flush returns the final piece: the concatenation of all pieces equals replace_all ~f of the concatenated input.

type state
val start : t -> f:(match_ -> string) -> state
val feed : t -> state -> string -> state * string
val flush : state -> string

The stream is finished: do not feed the state again.

val pos : state -> int

Total bytes fed so far.