Does malli.util respect registries? I've setup mine according to the doc on github but stuff like malli.util/get-in don't work unless I deref the atom. malli.core does respect the registry
I'm not quite following you, could you give some code examples? Which atom are you talking about?
Sure thing. I used the code in https://github.com/metosin/malli/blob/master/docs/reusable-schemas.md#schemas-via-global-registry
(require '[malli.registry :as mr])
(defonce *registry (atom {}))
(defn register! [type ?schema]
(swap! *registry assoc type ?schema))
(mr/set-default-registry!
(mr/composite-registry
(m/default-schemas)
(mr/mutable-registry *registry)))
In my REPL:
repl> (require '[malli.core :as m])
nil
repl> (require '[malli.registry :as mr])
(defonce *registry (atom {}))
(defn register! [type ?schema]
(swap! *registry assoc type ?schema))
(mr/set-default-registry!
(mr/composite-registry
(m/default-schemas)
(mr/mutable-registry *registry)))
nilnil#'repl/register!#object[malli.registry$composite_registry$reify__15462 0x33b05f17 "malli.registry$composite_registry$reify__15462@33b05f17"]
repl> (register! ::foo [:map [:a :int]])
#:repl{:foo [:map [:a :int]]}
repl> (require '[malli.util :as mu])
nil
repl> (mu/get ::foo :a)
nil
repl> (mu/get [:map [:a :int]] :a)
:int
repl> (m/deref ::foo)
[:map [:a :int]]
repl> Am I suppose to pass in the registry in the options? The atom I mentioned was the registry itself
It's probably a good idea to deref before using mu/get. there are lots of wrappers of :map like :merge and :union , I'm guessing ::foo is another similar example.
Perhaps ::foo implements LensSchema, worth trying (mu/get-in ::foo [0 :a])
(mu/get-in ::foo [0 :a]) works! Although in this case it does seem better to just deref/deref-recursively