until package:smith

Variant of foldUntil that collects elements into an array.
Repeatedly run the parser, folding over the results, until a token that satisfies the predicate is encountered. This is strict in the accumulator. Tokens the do not match predicate are not consumed. For example, consider the input sequence:
Var "a", Var "x1", Var "x2", CloseParen
This could be matched by:
P.foldUntil
(== CloseParen)
(\xs -> P.any ErrMsg >>= \case {Var x -> pure (x : xs); _ -> P.fail ErrMsg})
[]
The accumulated list would be backwards in this example, and the cursor would be positioned before, not after, CloseParen.