3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/lib/trivial.nix
Shea Levy 932dd06f3f Revert "Add isPath to trivial.nix"
This breaks NixOS, and I don't actually need it, so someone who needs it
can bring this back without breaking NixOS :)

This reverts commit 2742087bdd.

Signed-off-by: Shea Levy <shea@shealevy.com>
2013-05-02 15:04:21 -04:00

39 lines
965 B
Nix

with {
inherit (import ./lists.nix) deepSeqList;
inherit (import ./attrsets.nix) deepSeqAttrs;
};
rec {
# Identity function.
id = x: x;
# Constant function.
const = x: y: x;
# Named versions corresponding to some builtin operators.
concat = x: y: x ++ y;
or = x: y: x || y;
and = x: y: x && y;
mergeAttrs = x: y: x // y;
# Take a function and evaluate it with its own returned value.
fix = f: let result = f result; in result;
# Flip the order of the arguments of a binary function.
flip = f: a: b: f b a;
# `seq x y' evaluates x, then returns y. That is, it forces strict
# evaluation of its first argument.
seq = x: y: if x == null then y else y;
# Like `seq', but recurses into lists and attribute sets to force evaluation
# of all list elements/attributes.
deepSeq = x: y:
if builtins.isList x
then deepSeqList x y
else if builtins.isAttrs x
then deepSeqAttrs x y
else seq x y;
}