seqexp
seqexp copied to clipboard
Regex protocol implementations for Symbols and Vectors`
I suggest that both symbols and vectors should by default use equality tests in patterns, rather than be treated as predicate functions (both symbols and vectors implement AFn).
For example, I think it's natural if I want to match an empty vector to do something like this:
user=> (se/exec (se/cat []) (list []))
Execution error (IllegalArgumentException) at net.cgrand.seqexp/boot-grouping-vm$step$fn (seqexp.clj:352).
Key must be integer
On the other hand, I can't imagine ever wanting something like this:
user=> (se/exec (se/cat [1 2 3]) [0])
{:rest (), :match (0)}
Similarly, I think it's natural to expect symbols to act like keywords. Contrast:
user=> (se/exec (se/cat :foo) (list :foo))
{:rest (), :match (:foo)}
with:
user=> (se/exec (se/cat 'foo) (list 'foo))
nil