This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-02
Channels
- # announcements (5)
- # beginners (35)
- # calva (15)
- # chlorine-clover (9)
- # clj-kondo (8)
- # clojure (34)
- # clojure-europe (6)
- # clojure-uk (1)
- # clojurescript (4)
- # conjure (23)
- # data-science (2)
- # datalog (6)
- # emacs (1)
- # events (8)
- # figwheel-main (3)
- # fulcro (10)
- # jackdaw (3)
- # joker (1)
- # kaocha (1)
- # malli (4)
- # nrepl (1)
- # off-topic (1)
- # pathom (1)
- # re-frame (4)
- # reagent (2)
- # reveal (11)
- # rewrite-clj (15)
- # rum (1)
- # sci (61)
- # shadow-cljs (1)
Oh my. Accumulating both :in
and :path
in explain errors seems redundant. If we know Schema and either of schema-path (`:path`) or a value-path (`:in`), we can calculate the other. Simplifies both -explain
and the malli utils. Sweet.
and the code is dead simple:
(defn in->path [schema in]
(loop [i 0, s schema, acc []]
(or (and (>= i (count in)) acc)
(recur (inc i) (get s (in i)) (if-not (m/-key s) (conj acc (in i)) acc)))))
(defn path->in [schema path]
(loop [i 0, s schema, acc []]
(or (and (>= i (count path)) acc)
(let [[i k] (if-let [k (m/-key s)] [i k] [(inc i) (path i)])]
(recur i (get s k) (conj acc k))))))
@ikitommi Published dynaload to Clojars: https://clojars.org/borkdude/dynaload