Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> What are your thoughts on implementing reversible patterns?

I'm thinking something like this

    (defprotocol Pattern
      (extract [this input] "=> bindings")
      (replace [this input bindings] "=> new-input"))
This should obey some rule like:

    (submap? (extract p (replace p input bindings)) bindings)
That would make the data-grammar/generic-traversal experiments much nicer and also cleanly delineates patterns from views. It may also help when I try to do things like generative testing.

Not quite sure how that would work for (or ...) and (not ...) patterns, so it still needs more hammock time.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: