Matcher implementation for headM \ tailM
Matcher implementation for the map
, flatMap
, and filter
operations.
Matcher implementation for left | right
.
A matcher that uses a custom function f
to consume the first N
elements
from the input before passing the remainder to the next matcher in the chain.
A matcher that uses a custom function f
to consume the first N
elements
from the input before passing the remainder to the next matcher in the chain.
For example:
Matcher.greedy { (stack, offset, avail) => if(avail >= 2 && stack(offset) == "foo" && stack(offset + 1) == "bar"){ Some("yes!" -> 2) } else { None } }
The matcher function's result type
The matching function. Given a reference to the stack elements, an offset position, and
the number of elements available starting from the offset, f
should return
an option containing a pair of the matched value and the unconsumed portion of the stack.
A new matcher which uses f
to determine how (and how much of) the stack is matched
A matcher that quickly rejects any input
A matcher that quickly matches any input as ()
without consuming any stack.
A matcher that matches any input as long as the next matcher in the chain will match some segment of that input.