Regarding:
let crunched = raw .> |m| m * alpha .> filter(|e| e > 0.01) .> ...;
Haskell has such an operator & (infixl 1, defined in Data.Function) such that you can write:
expr & \a -> a + 1 & \a -> a + 1
However, I don’t find that it is used often, partly because it is hard to tell from the operator alone where the lambda ends. I think .> in this example suffers the same problem.
My proposal can be decomposed into two independent parts:
- allow method syntax for free functions and associated functions.
- allow paths in method syntax, i.e
foo.Arc::clone() etc.
They interact well with each other, but they are orthogonal.
Correct me if I am wrong, but I think what is controversial is 1. but not 2.
As I elaborated in the post you linked to, UMCS can be made to work well in documentation by listing relevant free functions that take the type as its first argument (or a reference to it…) at the type. A more general solution is to list all functions that mention the type in some page easily reachable from the type’s documentation. This is sorely needed today anyways in my experience.
Associated functions of a trait with no type parameters can’t be called with method syntax, however, they do “belong” to the type. I think most existing free functions also naturally bias towards one type as a receiver, or can be made to do when encoding the function. “Belonging” is too fuzzy a notion to have such rigid rules as we have right now. I also don’t think the mental model of belonging goes away when letting free functions be called as methods. I know this, because when writing in Haskell, there are only free functions, but yet, I do think about which type to put first and what function belongs to what type all the time.