1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 07:00:43 +00:00
nixpkgs/lib/tests
Profpatsch 8252861507 lib/trivial: add pipe function
`pipe` is a useful operator for creating pipelines of functions.

It works around the usual problem of e.g. string operations becoming
deeply nested functions.

In principle, there are four different ways this function could be
written:

pipe val [ f1 .. fn ]
pipe val [ fn .. f1 ]
compose [ f1 .. fn ] val
compose [ fn .. f1 ] val

The third and fourth form mirror composition of functions, they would
be the same as e.g. `(f1 << f2 << f3 .. << fn) val`.
However, it is not clear which direction the list should have (as one
can see in the second form, which is the most absurd.

In order not to confuse users, we decide for the most “intuitive”
form, which mirrors the way unix pipes work (thus the name `pipe`).
The flow of data goes from left to right.

Co-Authored-By: Silvan Mosberger <infinisil@icloud.com>
2019-10-21 13:19:16 +02:00
..
modules lib/types: Add oneOf, extension of either to a list of types 2019-08-06 14:08:42 +02:00
check-eval.nix lib/tests: Add check-eval.nix to run simple tests. 2018-03-04 06:28:49 -05:00
misc.nix lib/trivial: add pipe function 2019-10-21 13:19:16 +02:00
modules.sh lib/types: Add oneOf, extension of either to a list of types 2019-08-06 14:08:42 +02:00
release.nix make-tarball / lib-tests: reduce duplication 2019-07-11 18:02:05 +02:00
systems.nix lib: Add armv7a-linux to doubles.nix 2019-10-01 12:51:57 -04:00