There should be an accessible way to define how chainlets of the same or different types can be merged.
Given a chainlet like
@funclet
def multiply(value, by=4):
return value * by
it is desirable to ensure
multiply(a) >> multiply(b) == multiply(a * b)
is automatically ensured. There is currently no simple way to do this.
It is currently possible to overwrite ChainLink._link, to act before the Linker is run. Obviously, this requires overwriting a hidden method.
A more plugable mechanism that also works cleanly for funclet and co would be preferable.
[ ] Use a special method, such as __compile__, __merge__ or __link__
[ ] Ensure it is run consistently with the linker
Should be skipped if __merge__ is None (same as for __hash__)
This could replace/supersede a linker run
[ ] Allow setting the method on funclet
Probably similar to property.set, e.g. multiply.merge
There should be an accessible way to define how chainlets of the same or different types can be merged. Given a chainlet like
it is desirable to ensure
is automatically ensured. There is currently no simple way to do this.
It is currently possible to overwrite
ChainLink._link
, to act before theLinker
is run. Obviously, this requires overwriting a hidden method. A more plugable mechanism that also works cleanly forfunclet
and co would be preferable.__compile__
,__merge__
or__link__
__merge__ is None
(same as for__hash__
)funclet
multiply.merge