Add haskell's $ operator to the nix language #5577
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 baz
is left associative, andfoo $ bar $ baz
is right associative.Also, this PR fixes #1845 .