Closed mwchase closed 5 years ago
Piggyback off the existing implementation by actually constructing the namedtuple, but with an empty ns, then subtype it with the actual bases, substituting the namedtuple (require NamedTuple to be at the end of the bases), but forward the
I suddenly remember why I don't usually do this exact kind of thing.
From inspecting Dennis's use of the data
keyword, this is top priority.
Current idea is to investigate making a class decorator that generates a new class. Basically, aim to re-implement namedtuples, but using ADT design principles. May end up renaming the adt
function to some derivative of "sum", and this can be "product".
Wait, this is just frozen dataclasses, isn't it.
... But, I can hook into the existing destructurers instead of trying to teach it dataclasses.
Current plan is to try making a base class that pulls in the necessary dependencies and does stuff in a __init_subclass__
function. There should be no final-type trickery.
Possibly, sum types should be made to work by the same mechanism.
Untested, but this stuff is in the current master.
Or maybe, some kind of helper metaclass that could be applied to mixins intended to go ahead of NamedTuples/namedtuples.
Motivation: