summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2018-10-12 14:51:46 -0400
committerGraham Christensen <graham@grahamc.com>2018-10-12 16:06:11 -0400
commite7549b96ad013da56e990440bb58986683d80d7c (patch)
tree0e1199d214fc5e2823266205f6e3aca4f53db5fa /doc
parent7a90980194c662e77aebf23955be2ad9d5c6ee27 (diff)
downloadnixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar.gz
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar.bz2
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar.lz
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar.xz
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.tar.zst
nixlib-e7549b96ad013da56e990440bb58986683d80d7c.zip
nixpkgs docs: finish up mapAttrsRecursive
Diffstat (limited to 'doc')
-rw-r--r--doc/functions/library/attrsets.xml82
1 files changed, 82 insertions, 0 deletions
diff --git a/doc/functions/library/attrsets.xml b/doc/functions/library/attrsets.xml
index 6f23e267bab2..5d8182cc6097 100644
--- a/doc/functions/library/attrsets.xml
+++ b/doc/functions/library/attrsets.xml
@@ -966,5 +966,87 @@ lib.attrsets.mapAttrsToList (name: value: "${name}=${value}")
    itself to attribute sets. Also, the first argument of the argument function
    is a <emphasis>list</emphasis> of the names of the containing attributes.
   </para>
+
+  <variablelist>
+   <varlistentry>
+    <term>
+     <varname>f</varname>
+    </term>
+    <listitem>
+     <para>
+      <literal>[ String ] -> Any -> Any</literal>
+     </para>
+     <para>
+      Given a list of attribute names and value, return a new value.
+     </para>
+     <variablelist>
+      <varlistentry>
+       <term>
+        <varname>name_path</varname>
+       </term>
+       <listitem>
+        <para>
+         The list of attribute names to this value.
+        </para>
+        <para>
+         For example, the <varname>name_path</varname> for the
+         <literal>example</literal> string in the attribute set <literal>{ foo
+         = { bar = "example"; }; }</literal> is <literal>[ "foo" "bar"
+         ]</literal>.
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term>
+        <varname>value</varname>
+       </term>
+       <listitem>
+        <para>
+         The attribute's value.
+        </para>
+       </listitem>
+      </varlistentry>
+     </variablelist>
+    </listitem>
+   </varlistentry>
+   <varlistentry>
+    <term>
+     <varname>set</varname>
+    </term>
+    <listitem>
+     <para>
+      The attribute set to recursively map over.
+     </para>
+    </listitem>
+   </varlistentry>
+  </variablelist>
+
+  <example xml:id="function-library-lib.attrsets.mapAttrsRecursive-example">
+   <title>A contrived example of using <function>lib.attrsets.mapAttrsRecursive</function></title>
+<programlisting><![CDATA[
+mapAttrsRecursive
+  (path: value: concatStringsSep "-" (path ++ [value]))
+  {
+    n = {
+      a = "A";
+      m = {
+        b = "B";
+        c = "C";
+      };
+    };
+    d = "D";
+  }
+=> {
+     n = {
+       a = "n-a-A";
+       m = {
+         b = "n-m-b-B";
+         c = "n-m-c-C";
+       };
+     };
+     d = "d-D";
+   }
+    ]]></programlisting>
+  </example>
  </section>
 </section>