summary refs log tree commit diff
path: root/pkgs/lib/trivial.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-02-09 16:51:03 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-02-09 16:51:03 +0000
commit599015e8b071bc8d38779fbfc37961db1ac0f464 (patch)
tree12cfb8ef316f4021ef81d135a5c331804a817809 /pkgs/lib/trivial.nix
parenteebb6f106c445c5661975a60a55b07ad91c6fa47 (diff)
downloadnixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar.gz
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar.bz2
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar.lz
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar.xz
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.tar.zst
nixpkgs-599015e8b071bc8d38779fbfc37961db1ac0f464.zip
* Split lib/default.nix into several files, as it had become a big
  mess.  Also cleaned up some functions:

  - foldl appeared broken (it recursively called fold).
  - Renamed logicalAND/logicalOR to and/or.
  - Removed listOfListsToAttrs, eqStrings: obsolete.
  - Removed isInList, which does the same thing as elem.
  - stringToCharacters: don't return a "" at the end of the list.
  - Renamed concatList to concat, as concatList (singular) is a
    misnomer: it takes two lists.  Likewise, renamed mergeAttr to
    mergeAttrs.

  misc.nix still contains a lot of stuff that should be refactored and
  moved to other files.

svn path=/nixpkgs/trunk/; revision=14013
Diffstat (limited to 'pkgs/lib/trivial.nix')
-rw-r--r--pkgs/lib/trivial.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkgs/lib/trivial.nix b/pkgs/lib/trivial.nix
new file mode 100644
index 00000000000..a4fbd164fe5
--- /dev/null
+++ b/pkgs/lib/trivial.nix
@@ -0,0 +1,18 @@
+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;
+
+}