malli

https://github.com/metosin/malli :malli:
juhoteperi 2021-04-02T08:09:24.308400Z

: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

juhoteperi 2021-04-02T08:09:54.308600Z

Or hmph, I might be confusing it with malli.util/merge... not sure if this works similarly

juhoteperi 2021-04-02T08:12:53.308800Z

:merge should same as malli.util/merge

Helins 2021-04-02T08:13:02.309300Z

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 :multischema 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.

Helins 2021-04-02T08:35:00.309700Z

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.

1👌