Add haskell's $ operator to the nix language#5577
Conversation
|
I'm not really in favor of this. It's another syntax for Nix users to learn, while the benefit is saving a small amount of typing. Nix is not a general purpose language, so convenience features like this are probably less important than keeping the learning curve manageable. If we add something like this, I would be more in favor of a pipe syntax ( |
|
Changes like this should probably go through an RFC FYI. |
|
I don't think the learning curve will be impacted much by this. Using this operator is completely optional and when a user runs into a situation where it makes sense to use it, they are likely quite proficient in Nix already and working on moderately complex code. |
|
I marked this as stale due to inactivity. → More info |
|
To avoid duplication, I think this should be discussed in the issue here: #1845 |
|
Closing for the same reasons as #1845. Let's get some community consensus on this first |
Since I started using nix, one thing has been constantly bothering me: lack of the
$operator in the nix language.One doesn't need to look far to find function calls with nested parentheses that would be better off without them, and I couldn't find a reason for the absence of this operator. So I implemented it to see if this would work.
The patch is simple, all tests pass, including two simple test cases added to test this operator.
I have also manually tried parsing my own nix derivations with added usages of this new operator.
That being said, I do not claim to have thought of every possible edge case.
The operator itself is the same as function application, i.e.
foo a, except thatfoo bar bazis left associative, andfoo $ bar $ bazis right associative.Also, this PR fixes #1845 .