You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
, but doesn't help much, as it's a CompoiteRegistry which has all the base schemas merged in it. I think we should:
clearly separate the base registry with local (accumulated) registries, e.g. we could have a new LocalRegistry type, which contains the accumulation of all the local things
helpers to get the accumulated local registry entries from a schema
have an option to m/form to use the accumulated registry.
figure out a default for 3: maybe the top-level m/form should always have the accumulated registry, child forms not: this way the m/form could always be compiled back into Schema, and the child forms would not contain duplicate/accumulated registry entries.
Thank you! This makes total sense to me and seems like what I've done.
I think on (4), the natural default is the one which round-trips with highest fidelity and can be slotted back into the parent. The behaviour you're suggesting seems to match that approach. Just to make sure I understand, it sounds like the default would be:
user>
(deftop
[:map {:registry {::x 'int?}}
::x
[:k
[:schema {:registry {::y 'string?}}
[:tuple::x::y]]]])
;; ...
user> (m/form top)
;; identical to `top`, so includes the top-level registry
user> (m/form (m/get top ::x))
::x
user> (m/form (m/get top :k))
[:schema {:registry {::y 'string?}}
[:tuple::x::y]]
;; ^ these are useless without first being handed a registry that provides the ::x;; that said, it doesn't create extra noise if it's now wrapped back in [:schema {:registry ...} <THIS>]
Perhaps there's a way to achieve this that I've simply been missing. :)
Projection in the context of registries is a place where cycling out and back in through
m/form
breaks down.When using utilities like
mu/get
and similar (which I use to project types), the parent's registry is seemingly preserved... until serialization.Whether part of
m/form
or a secondary utility, should it be possible to perform projections like these whilst preserving the registry?I need this functionality for my use so I've built a custom version of
mu/get
that:mu/get
and the composite registryupdate-properties assoc
to put the projected registry on the new root... but it seems like it should be possible to use the
(-> ... mu/get m/form)
example above without all of this messing around. :)The text was updated successfully, but these errors were encountered: