summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2017-03-15 18:29:33 +0100
committerProfpatsch <mail@profpatsch.de>2017-03-15 18:29:33 +0100
commitb052a3629463f2f064a0a3da50dbebd73b587651 (patch)
tree04921287d9f144d87970bd2226439c9fc6e2f36b /lib/trivial.nix
parent763e21e982370f67c126f92a1113ea949db3b6e0 (diff)
downloadnixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar.gz
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar.bz2
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar.lz
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar.xz
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.tar.zst
nixlib-b052a3629463f2f064a0a3da50dbebd73b587651.zip
lib/trivial: expand function docs
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index abe5a16c67d6..40499b2b5092 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -1,17 +1,44 @@
 rec {
 
-  # Identity function.
+  /* The identity function
+     For when you need a function that does “nothing”.
+
+     Type: id :: a -> a
+  */
   id = x: x;
 
-  # Constant function.
+  /* The constant function
+     Ignores the second argument.
+     Or: Construct a function that always returns a static value.
+
+     Type: const :: a -> b -> a
+     Example:
+       let f = const 5; in f 10
+       => 5
+  */
   const = x: y: x;
 
-  # Named versions corresponding to some builtin operators.
+
+  ## Named versions corresponding to some builtin operators.
+
+  /* Concat two strings */
   concat = x: y: x ++ y;
+
+  /* boolean “or” */
   or = x: y: x || y;
+
+  /* boolean “and” */
   and = x: y: x && y;
+
+  /* Merge two attribute sets shallowly, right side trumps left
+
+     Example:
+       mergeAttrs { a = 1; b = 2; } // { b = 3; c = 4; }
+       => { a = 1; b = 3; c = 4; }
+  */
   mergeAttrs = x: y: x // y;
 
+
   # Compute the fixed point of the given function `f`, which is usually an
   # attribute set that expects its final, non-recursive representation as an
   # argument: