Fork me on GitHub
#meander
<
2021-02-06
>
ribelo23:02:55

I don't know if this is a bug, but gather does not work in conjunction with map-of

ribelo23:02:51

(m/rewrite {:a 1 :b 2}
  (m/map-of (m/pred keyword? !ks) _) [!ks ...])
;; => [:a :b]
(m/rewrite {:a 1 :b 2}
  (m/map-of (m/gather (m/pred keyword? !ks)) _) [!ks ...])
;; => nil
(m/rewrite [:a :b :c 1]
  (m/gather (m/pred keyword? !ks) _) [!ks ...])
;; => [:a :b :c]

jimmy01:02:38

I think there is a misunderstanding of what gather is for. Gather matches seqables. So you could combine gather with map-of like this.

(m/rewrite {[:a :b 2 :c] 1 [:b :c :d 4 :e] 2}
  (m/map-of (m/gather (m/pred keyword? !ks)) _) [!ks ...])
Seems like a rather unlikely thing to be doing. Maybe you were trying to gather up things on a map? Something like this?
(m/rewrite {:a 1 :b 3 "stuff" 5}
  {& (m/gather [(m/pred keyword? !k) !v])}
  (m/map-of !k !v))
;; => {:a 1 :b 3}