This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-23
Channels
- # admin-announcements (1)
- # alda (1)
- # bangalore-clj (5)
- # beginners (17)
- # boot (392)
- # capetown (4)
- # cider (16)
- # cljs-dev (24)
- # cljsrn (33)
- # clojure (106)
- # clojure-berlin (1)
- # clojure-nl (1)
- # clojure-russia (168)
- # clojure-spec (85)
- # clojure-uk (137)
- # clojurescript (83)
- # clojutre (4)
- # component (10)
- # cursive (6)
- # datavis (9)
- # datomic (11)
- # defnpodcast (15)
- # dirac (4)
- # docker (1)
- # ethereum (1)
- # hoplon (27)
- # jobs (5)
- # jobs-rus (1)
- # lein-figwheel (2)
- # luminus (5)
- # off-topic (5)
- # om (13)
- # onyx (60)
- # parinfer (2)
- # planck (12)
- # proton (2)
- # re-frame (45)
- # rethinkdb (5)
- # ring-swagger (9)
- # spacemacs (9)
- # specter (49)
- # test-check (1)
- # untangled (104)
- # yada (10)
Is there a more comprehensive guide to writing navigators? I feel like I'm not getting the full picture from the API documentation.
Also, it feels like there's significant overlap between declarepath
/ providepath
recursive paths and navigators?
not sure what you mean by overlap, declarepath
/ providepath
is the main way to make a recursive navigator
I do agree the docs need work
Ah, there's probably a hole in my understanding around the intended uses of navigators and paths.
studying the implementations of the core navigators will probably help
Specter is awesome, by the way! Even with my flawed understanding of it it's already paying dividends.
thanks
though I will say the real power is unlocked when you understand how to write your own navigators
> though I will say the real power is unlocked when you understand how to write your own navigators I'd love to hear more about this: What kind of custom navigators do you feel deliver the most value?
@zane I have a whole suite of navigators for DAGs that I use privately
as an example
I can do very sophisticated recursive DAG transformations with almost no effort at all, and it runs with near optimal performance
the key is since that everything composes, you have a combinatoric explosion of ways in which you can apply Specter
For simple recursive descent through EDN I shouldn't have to reach for custom navigators though, right?
most likely
you'll start off using Specter for getting in and out of nested data structures, and later you'll see how much more the concept of navigation generalizes
a big moment for me was realizing that adding to a set could be expressed as a navigator
(setval [:a (subset #{})] #{:new-elem} data)
This was making me think about navigators that descended into connections somehow, but that might be 🍌s.
select is semantically identical to the list monad, though specter's implementation is far more efficient
I looked at how transform might be done as a monad some time ago but it wasn't obvious, and it wasn't really important to figure out
Hmm. So view
is a bit weird in that it doesn't allow for transformations inside the view. (Which I guess makes sense.)
view
works just fine in transform
transformed
is similar to view
except done with a path and transform function
@zane no, those navigators are not publicly available
I guess what I mean is, this is not what I was expecting:
(setval [(view namespace)]
"woo"
:hey/there)
So now I'm trying to write NAMESPACE
:
(defnav NAMESPACE
[]
(select* [this structure next-fn]
(next-fn (namespace structure)))
(transform* [this structure next-fn]
(keyword (next-fn (namespace structure))
(name structure))))
nice one, I have a similar navigator
you want to handle the no-namespace case as well (when (next-fn (namespace structure))
returns nil)