This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-08
Channels
- # announcements (13)
- # asami (9)
- # aws (1)
- # aws-lambda (1)
- # babashka (37)
- # beginners (70)
- # calva (19)
- # cider (23)
- # clara (10)
- # clj-kondo (15)
- # cljdoc (14)
- # clojure (3)
- # clojure-bay-area (1)
- # clojure-europe (40)
- # clojure-nl (3)
- # clojure-serbia (1)
- # clojure-uk (31)
- # clojuredesign-podcast (1)
- # clojurescript (9)
- # community-development (7)
- # data-oriented-programming (1)
- # datomic (44)
- # emacs (13)
- # figwheel-main (14)
- # fulcro (6)
- # jobs (6)
- # malli (15)
- # meander (7)
- # off-topic (74)
- # other-languages (1)
- # pathom (3)
- # portal (3)
- # re-frame (25)
- # reagent (6)
- # reitit (2)
- # reveal (1)
- # rewrite-clj (6)
- # ring (5)
- # shadow-cljs (11)
- # specter (7)
- # xtdb (7)
@nathanmarz: thanks for the tip, changing to vtransformed
brings it down to 163.9 µs. The implementation code is beyond me at the moment, so I simply created the following in my namespace:
(s/defdynamicnav vtransformed
"Navigates to a view of the current value by transforming it with the
specified path and update-fn."
[path update-fn]
(s/late-bound-nav [late (s/late-path path)
late-fn update-fn]
(select* [this structure next-fn]
(next-fn (s/compiled-vtransform late late-fn structure)))
(transform* [this structure next-fn]
(next-fn (s/compiled-vtransform late late-fn structure)))))
Results are correct across all versions of the parser. Latest parser looks like this:
(s/select [s/ALL :systems s/ALL :containers s/ALL
(vtransformed [(s/collect-one :name) :dependencies s/ALL]
(fn [[c] d]
{:container c
:dependency (:name d)
:transports (:transport d)
:entities (:data_entity d '())}))
:dependencies s/ALL]
yaml-data)
@h0bbit looking at it again it looks like you actually want a version of view
that lets you look at collected values at the same time
then you could write:
(s/select [s/ALL :systems s/ALL :containers s/ALL
(s/collect-one :name) :dependencies s/ALL
(my-view
(fn [[c] d]
{:container c
:dependency (:name d)
:transports (:transport d)
:entities (:data_entity d '())}
))]
yaml-data)
my-view
would be:
(defrichnav my-view
[afn]
(select* [this vals structure next-fn]
(next-fn [] (afn vals structure)))
(transform* [this vals structure next-fn]
(next-fn [] (afn vals structure))))
seems like that should be much faster
@nathanmarz: wow, that brought it down to 87.3 µs. Thanks. I have loads to learn and think about with this library!