Fork me on GitHub

hello, how can I make a pattern that says a key must not be in the map?

Ben Sless14:06:18

Maybe by writing a pattern that fails (bottom) if it succeed in matching a key in a map? (and {k (some v)} fail)


I found that just using {:key nil} seems to work fine

Ben Sless14:06:27

What if the key exists with a nil value? Is it possible?


I think in this case will match the same, which is fine for my use case but I can see some other case might wanna know the difference


There is currently not a (clean) way to distinguish between a missing key and a key with a nil value. 😐


I think something in the direction of what match combinators do would be interesting to have in meander, for the case we are discussing they have the absent matcher (


it is possible to make a custom syntax on meander for that?


For interpreted Meander, sure, but for compiled, it’s possible but too much work for the time I am currently making for the project (which has only been on the zeta branch). The issue boils down to compiled meander resolving key values with get. We could switch to find for specific keys but, again, it’s a lot of work. A workaround be papered over with defsyntax

{& (m/scan [:foo ?x])}


Use {} to ensure you get a map, then m/scan the keys. But that is really kinda ugly.


{:foo ?foo & (not ?x) :as ?x}
Might work too.


Right because if ?x is {} and & ?x succeeds then you know :foo isn’t a key.