summary refs log blame commit diff
path: root/pkgs/lib/trivial.nix
blob: af47a8c88415e8d93fbf4fccc4381882cb175464 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                           
                            



                                                                


                                                         



                                                                     
 
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;
  
}