Title says it all. Seen lots of answers where folks have implemented f @ g, but this requires wrapping f, g in some infix decorator or class. Is it possible to get this to work? Maybe by patching some class that all functions are an instance of or something?
Basically I'd like to get this to work:
f = lambda x: x
g = lambda y: y
def h(a): return a
# <magic>
z = f @ g @ h
assert z(1) == 1
Key here is that the magic above cannot be specific to/reassign f, g, or h.
Edit: Hey whoever closed this and linked that other question, that isn't what I'm asking at all? I am asking about pointfree function composition. More broadly, the answer to their question is yes, and it appears the answer to my question is no. I don't know how on earth this could be a duplicate if that's the case.
I'm not sure If I get your question right but as you said in your question you can patch the class and add
__matmul__magic method. E.g.:Prints: