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

Adding an operator like Haskell's '$' #1845

Closed
Ekleog opened this issue Feb 6, 2018 · 15 comments
Closed

Adding an operator like Haskell's '$' #1845

Ekleog opened this issue Feb 6, 2018 · 15 comments
Assignees
Labels
feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@Ekleog
Copy link
Member

Ekleog commented Feb 6, 2018

The title says it all, I'm thinking it would be useful for eg.

builtins.trace "my debug stuff" $
# some multiline complex code that would require parenthesing otherwise

What do you think about it? I guess it's too late for the feature freeze, but $ being already reserved for ${} I guess it wouldn't be a breaking change anyway.

@dtzWill
Copy link
Member

dtzWill commented Feb 7, 2018

This would be crazy useful for exactly the use case described here, I run into this often! 😁

@lheckemann
Copy link
Member

Also for (import <nixpkgs> {}).callPackage $!

@Ekleog
Copy link
Member Author

Ekleog commented Oct 11, 2018

Also for builtins.seq.

@lilyball
Copy link
Member

lilyball commented Aug 5, 2020

I really want this operator. And in particular, the right-hand side should support functions, because that's really what I want this for. I want to be able to take an existing

{ foo, bar }:
…

and change it to

lib.makeOverridable $
{ foo, bar }:
…

@lilyball
Copy link
Member

lilyball commented Aug 5, 2020

Keywords to improve search discoverability of this issue: infix application operator

@lilyball
Copy link
Member

lilyball commented Aug 5, 2020

On a similar note I'd also like the composition operator (.), though I find its lack less annoying than the lack of the application operator.

@stale
Copy link

stale bot commented Feb 12, 2021

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

@stale stale bot added the stale label Feb 12, 2021
@lheckemann
Copy link
Member

We still want this!

@stale stale bot removed the stale label Feb 12, 2021
@stale
Copy link

stale bot commented Aug 13, 2021

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

@stale stale bot added the stale label Aug 13, 2021
@lilyball
Copy link
Member

I still want this very much!

@stale
Copy link

stale bot commented Apr 16, 2022

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

@stale stale bot added the stale label Apr 16, 2022
@fricklerhandwerk fricklerhandwerk added feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc labels Sep 13, 2022
@infinisil
Copy link
Member

I think $ is a hard sell, but here's an alternative that might get wider approval:

apply foo;
apply bar;
baz

# Equivalent to
foo (bar baz)

Advantages compared to $:

  • It fits better into the Nix syntax, which already supports with ...; and assert ...;
  • It mirrors both the syntax and semantics of the new experimental CLI's --apply option

Disadvantages:

@piegamesde
Copy link
Member

FYI there is now an RFC that proposes something similar, people in here might have opinions about |> vs <| that I'd be interested in hearing.

NixOS/rfcs#148

@roberth roberth added the RFC Related to an accepted RFC label Jun 2, 2023
@roberth roberth removed the RFC Related to an accepted RFC label Jun 2, 2023
@thufschmitt
Copy link
Member

This is a change with potential impact on the whole ecosystem (similar to NixOS/rfcs#110 or NixOS/rfcs#148), so it wouldn't be right for it to be decided here. Anyone willing for this to happen, please open an RFC about it to bring the discussion to a more visible place.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-06-22-nix-team-meeting-minutes-65/29643/1

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

Successfully merging a pull request may close this issue.