Open 0rvar opened 1 month ago
I now recall why I didn't implement this: just
accepts sequences, not just individual characters.
I think this is potentially a good reason to re-deduplicate just
, splitting it into just
and seq
as before. That way, the behaviour of just(0..4)
would be to accept any number from 0 to 4 (exclusive) and seq(0..4)
would be to accept a sequence of numbers, 0-3 (inclusive).
Re-deduplicating would allow for the behaviour you're looking for!
I just made an initial attempt at this, but ran into problems: it led to a constraint such that just
required the input to implement ValueInput
, which isn't always practical, making just
difficult to use for token streams and the like. One could feasibly imagine a solution that involves splitting out just into 3 combinators, like so:
just(...)
: doesn't return the token (works with all inputs)filter(...)
returns the token by-value (requires I: ValueInput
)seq(...)
returns the matched tokens by-ref (requires I: SliceInput
)Thoughts welcome on this!
Repro:
This does not compile due to: