maxfischer2781 / chainlet

Python module for linking generators/iterators to processing chains
MIT License
1 stars 0 forks source link

Protocol for merging chainlets #9

Open maxfischer2781 opened 6 years ago

maxfischer2781 commented 6 years ago

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.