Hacker News new | ask | show | jobs
by rtpg 1016 days ago
Function-ified visitor pattern I guess? Python's NodeTransformer[0] is a good example of a thing like this though only across AST nodes.

Going along some previous discussions about jq, and stuff like specter (for Clojure), I do think it would be cool if there were more syntactic niceties for path expressions, extracting data from nested data structures/lists/etc, and applying transformations on them.

Specter can have a "nice DSL" (for certain definitions of nice!) thanks to Clojure's macro functionality. Haskell lenses get somewhere thanks to custom infix operator syntax being a thing. I have yet to see a library that tackles this nicely without those two tools though.

[0]: https://docs.python.org/3/library/ast.html#ast.NodeTransform...