:merge
with two map schemas creates a new map schema with keys from both schemas, so Cat and Dog don't refer to AnimalBase but are instead just map schemas with properties from the inputs
Or hmph, I might be confusing it with malli.util/merge
... not sure if this works similarly
:merge
should same as malli.util/merge
https://github.com/metosin/malli/blob/master/src/malli/util.cljc#L401
I believe malli.util/merge
is indeed eager in that sense (creating a new map schema and forgetting about AnimalBase
). But theoretically, since this example relies on data and :merge
, that :multi
schema could deduce that all dispatched schemas are maps that could have a common set of keys.
But it is just the most straightforward way of representing single inheritance IMO, maybe there is something better.
Sorry I realized my example was a bit misleading so I deleted it so it doesn't spam the channel. I'll work more on this and try to come back with a real-world one.