Fork me on GitHub
#meander
<
2021-06-13
>
markaddleman00:06:54

One common use case I have is editing an element within a sequence. Is there a reason something like the following isn't included in the meander API?

(m/defsyntax within [label element-pattern]
  `(m/seqable ~(symbol (str "!" label "-before"))
              ...
              ~element-pattern
              & ~(symbol (str "?" label "-after"))))

markaddleman00:06:11

It allows me to write:

(m/rewrite [[1 2 3]]
  (within outer (within inner (m/and ?n 1)))
  (within outer (within inner (m/app inc ?n))))

markaddleman01:06:39

That may have come across snarkily - NOT how I meant it. My real question is, is there some reason this approach isn't going to work in general?