redplanetlabs / specter

Clojure(Script)'s missing piece
Apache License 2.0
2.52k stars 105 forks source link

Implicit navigator for maps #244

Closed nathanmarz closed 4 years ago

nathanmarz commented 6 years ago

Maps could implicitly act as a filter function checking the structure of the value in question, e.g.: {:type "a"} could stay navigated only if the value for the :type key is "a". Likewise, {:k1 {:k2 "b"} :k3 "c"} would check two values, one of them being nested in another map. This is a common use case for which selected? is more verbose than an anonymous function.

This navigator should also work properly with locals in the closure, such as {:type some-local}.

barrtrek commented 5 years ago

I could use this yesterday :)

nathanmarz commented 4 years ago

Closing this because not sure this is a good idea. May reopen in the future if there's a more compelling idea for maps as implicit navs.