Commit 548a28f2 authored by Profpatsch's avatar Profpatsch

lib/types: add nestedOf composed type

Makes it possible to have arbitrarily deeply nested structures. Requisite for
creating a `tests` option.
parent 6523df45
......@@ -437,6 +437,18 @@ rec {
functor = (defaultFunctor name) // { wrapped = finalType; };
};
# An arbitrarily deeply nested structure of `containerType`
# with `type` at the leaves.
# Examples for `nestedOf attrsOf int`:
# { }, { foo = 4; }, { foo = 4; bar.baz = 20 };
# Examples for `nestedOf listOf str`:
# [ ], [[[[ "hello" ]]]], [ "hello", [[[[] [[ "nyan" ]] ]]]]
nestedOf = containerType: type:
lib.fix (nestedType:
containerType (either type nestedType)
// { name = "nestedOf";
description = "nested ${(containerType type).description}"; });
# Obsolete alternative to configOf. It takes its option
# declarations from the ‘options’ attribute of containing option
# declaration.
......
......@@ -216,6 +216,19 @@
<replaceable>to</replaceable>. Can be used to preserve backwards
compatibility of an option if its type was changed.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<varname>types.nestedOf</varname>
<replaceable>containerType</replaceable>
<replaceable>type</replaceable>
</term>
<listitem>
<para>An arbitrarily nested structure of
<replaceable>containerType</replaceable> values with
<replaceable>type</replaceable> at the leaves.
See definition docstring for examples.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment