This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-19
Channels
- # babashka (2)
- # babashka-sci-dev (15)
- # beginners (44)
- # clara (6)
- # clj-kondo (5)
- # clojure (39)
- # clojure-europe (5)
- # clojurescript (14)
- # data-science (5)
- # datahike (6)
- # datalevin (7)
- # graalvm (2)
- # helix (3)
- # humbleui (8)
- # minecraft (1)
- # missionary (10)
- # nbb (8)
- # nrepl (2)
- # portal (11)
- # shadow-cljs (3)
- # tools-deps (6)
- # xtdb (10)
Hi, I’m trying to get https://github.com/clojure/data.avl sorted-maps to print like clojure.core/sorted-map, but can’t find my way around it, anyone able to help? image displays how data.avl/sorted-map is displayed in comparison to core/sorted-map (data.avl above, core below)
If you implement https://clojuredocs.org/clojure.datafy/datafy for the custom map types provided by data.avl, you can then automatically datafy all values sent to tap with something like:
(require '[clojure.datafy :as d])
(require '[portal.api :as p])
(def submit (comp p/submit d/datafy))
(add-tap submit)
Thanks, that solved the trick for making AVLMaps to print like clojure core sorted-maps, but I am observing that clojure core sorted-maps are not printing in order when using java.time.Instant as keys, any idea why this might be? (When printing it in the repl, they are printed in order)
I think this might be because portal treats all maps as hash maps on the client :thinking_face: Might need to revisit serialization around sorted maps.
By default the UI will always try to render maps in sorted order, so another option is to get tagged objects sorting
> Might need to revisit serialization around sorted maps. I’d go for this instead of sorting the tagged literal, as it will allow sorted maps with custom comparator to also work properly and display the sorted-maps order. Where can I find the code for this? I can try and give it a go myself
nvm found it 🙂 trying to setup a local env to develop portal, maybe a quick solution (that doesn’t require a new type) would be to check if map is sorted? to not sort in here: https://github.com/djblue/portal/blob/master/src/portal/ui/inspector.cljs#L473 , something like (cond-> (not (sorted? values)) (try-sort-map))
Opened, https://github.com/djblue/portal/issues/128 thanks for the feedback here!