Skip to content

Commit

Permalink
lib/trivial: Refactor pipe slightly
Browse files Browse the repository at this point in the history
Pushes the `let` outside too, which should make it a bit faster
  • Loading branch information
infinisil committed Jan 27, 2020
1 parent 5e46d5a commit 8022565
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/trivial.nix
Expand Up @@ -58,9 +58,8 @@ rec {
of the next function, and the last function returns the
final value.
*/
pipe = val: functions:
let reverseApply = x: f: f x;
in builtins.foldl' reverseApply val functions;
pipe = let reverseApply = x: f: f x; in
builtins.foldl' reverseApply;
/* note please don’t add a function like `compose = flip pipe`.
This would confuse users, because the order of the functions
in the list is not clear. With pipe, it’s obvious that it
Expand Down

0 comments on commit 8022565

Please sign in to comment.