-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libexpr: experimental pipe operators
- Loading branch information
Showing
10 changed files
with
174 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
synopsis: "Add `pipe-operators` experimental feature" | ||
prs: | ||
- 11131 | ||
--- | ||
|
||
This is a draft implementation of [RFC 0148](https://github.com/NixOS/rfcs/pull/148). | ||
|
||
The `pipe-operators` experimental feature adds [`<|` and `|>` operators][pipe operators] to the Nix language. | ||
*a* `|>` *b* is equivalent to the function application *b* *a*, and | ||
*a* `<|` *b* is equivalent to the function application *a* *b*. | ||
|
||
For example: | ||
|
||
``` | ||
nix-repl> 1 |> builtins.add 2 |> builtins.mul 3 | ||
9 | ||
nix-repl> builtins.add 1 <| builtins.mul 2 <| 3 | ||
7 | ||
``` | ||
|
||
`<|` and `|>` are right and left associative, respectively, and have lower precedence than any other operator. | ||
These properties may change in future releases. | ||
|
||
See [the RFC](https://github.com/NixOS/rfcs/pull/148) for more examples and rationale. | ||
|
||
[pipe operators]: @docroot@/language/operators.md#pipe-operators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: experimental Nix feature 'pipe-operators' is disabled; add '--extra-experimental-features pipe-operators' to enable it | ||
at /pwd/lang/eval-fail-pipe-operators.nix:1:3: | ||
1| 1 |> 2 | ||
| ^ | ||
2| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |> 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters