Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haskell's $ operator to the nix language #5577

Closed
wants to merge 1 commit into from
Closed

Conversation

Mewp
Copy link

@Mewp Mewp commented Nov 16, 2021

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 that foo bar baz is left associative, and foo $ bar $ baz is right associative.

Also, this PR fixes #1845 .

@edolstra
Copy link
Member

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 (f | g | h instead of h $ g $ f).

@L-as
Copy link
Member

L-as commented Nov 21, 2021

Changes like this should probably go through an RFC FYI.

@max-privatevoid
Copy link
Contributor

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.

@stale
Copy link

stale bot commented Jun 12, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jun 12, 2022
@fricklerhandwerk fricklerhandwerk added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Sep 9, 2022
@infinisil
Copy link
Member

To avoid duplication, I think this should be discussed in the issue here: #1845

@stale stale bot removed the stale label Apr 24, 2023
@thufschmitt
Copy link
Member

Closing for the same reasons as #1845. Let's get some community consensus on this first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding an operator like Haskell's '$'
7 participants