Alright, so I gather then that:
- `v` is what we are navigating into.
- That `coll` is supposed to be result of a call to `datafy`
- That `v` is supposed to be contained inside `coll`, retrievable by `k`
Thus a usage scenario would be:
(let [coll (datafy some-obj)
k :next-thing
v (get coll k)]
(nav coll k v))
This would return another thing (aka, arbitrary datafiable Object), which is obtained from navigating into `v`.
In that sense, `v` is supposed to be a hyperlink, and it is not really a collection, which is why we navigate to what the hyperlink points too, and that returns another thing which we can later datafy as well if we want too, and possibly navigate further into.
So a full example could be:
(let [url (as-url "
http://clojure.org")
clojure-page-as-coll (datafy url) ...
At this point, depending on the datafy implementation for URL, we could assume we got back the following:
{:content
:links {:get-started (as-url "
https://clojure.org/guides/getting_started")
:overview (as-url "
https://clojure.org/about/rationale")
...}
...}
And so say we wanted to navigate into [:links :overview] we would do:
(let [url (as-url "
http://clojure.org")
clojure-page-as-coll (datafy url)
overview-url (get-in coll [:links :overview])
overview-page (nav clojure-page-as-coll [:links :overview] overview-url) ...
So at this point, we have datafied a URL as a Clojure coll. And we've drilled-down into it using normal Clojure collection functions. And when we reached another Navigable value, we called nav on it to fetch the next page.
The only thing I'm a bit confused still. Is if you look at my example, I assume `nav` returns a datafied result. But Sean mentioned it shouldn't. But that doesn't even make sense in my example. I start with a URL. I can nav into that URL to get the page back, but there are no `coll` context yet. And I could have nav return something that is not already data, but I don't have such a thing, and making one up just cause seems weird.
So I'm assuming here that `nav` can return data or datafiable things, it doesn't really matter. And it is assumed datafy will be called on it no matter what, but if it is already data, datafy will just return the data, since that's the default impl for Map.
So you'd continue as such:
(let [url (as-url "
http://clojure.org")
clojure-page-as-coll (datafy url)
overview-url (get-in coll [:links :overview])
overview-page (nav clojure-page-as-coll [:links :overview] overview-url)
overview-page-as-coll (datafy overview-page)]
overview-page)
Is this correct? Or should you actually start with `nav` ? Or maybe my example is a bad one, since it seems `datafy` is redundant in my case, as someone could have just done:
(let [clojure-page (nav nil nil (as-url "
http://clojure.org"))
overview-url (get-in clojure-page [:links :overview])
overview-page (nav clojure-page [:links :overview] overview-url)]
overview-page)
Thanks!