Live data from Hacker News

Specter – Clojure API for immutable programming (2017)

nathanmarz.com

1–10 of 44 posts

Re: Specter – Clojure API for immutable programming (2017)

#3
Specter is fantastic. It makes transformations on deeply nested data structures easy. Want to transform all the "datetimes" from JSON data into actual datetimes (or vice versa)? It takes about five minutes if you have to look everything up. Works with ClojureScript too.

Some production code:

    (defn transform-tagged-values [x]
      (sp/transform (sp/walker tr/tagged-value?) tagged-value->cljs x))
Give it a predicate for which values to transform, and a function to do the transformation. Couldn't be easier.

Re: Specter – Clojure API for immutable programming (2017)

#6
Specter is tremendously useful and rarely lets on a case where it can’t perform a transformation. For ensuring that you’re getting the most efficient form of a transformation [0] it’s incredible —- and it is somewhat data-oriented, allowing easy saving and reuse of navigators.

Meander [1] is also wonderful. Its unification-based approach makes for nice expressions of intent. Its strategy-based approach to rewriting [2] is more flexible than most common walker libraries, too.

[0]: https://github.com/redplanetlabs/specter/wiki/Specter's-inli...

[1]: https://github.com/noprompt/meander

[2]: https://github.com/noprompt/meander/blob/epsilon/doc/strateg...

Re: Specter – Clojure API for immutable programming (2017)

#9
post #8

Like SQL for nested maps in Clojureland. Neat. The DSL [ALL :a even?] does feel a tiny bit un-clojurey to me as well, maybe making it look like [:all :a even?] would make it clearer.

Well, not sure about that exactly. Consider a map like:

    {:all {:a 2} :foo {:a 4}}
Maybe namespaced keys would fit that usecase
Post reply on HN