listOf
lib.types.listOf
Docs pulled from | This Revision | 18 days ago
Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.
Noogle detected
Implementation
The following is the current implementation of this function.
elemType:
mkOptionType rec {
name = "listOf";
description = "list of ${
optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
}";
descriptionClass = "composite";
check = {
__functor = _self: isList;
isV2MergeCoherent = true;
};
merge = {
__functor =
self: loc: defs:
(self.v2 { inherit loc defs; }).value;
v2 =
{ loc, defs }:
let
evals = filter (x: x.optionalValue ? value) (
concatLists (
imap1 (
n: def:
imap1 (
m: def':
(mergeDefinitions (loc ++ [ "[definition ${toString n}-entry ${toString m}]" ]) elemType [
{
inherit (def) file;
value = def';
}
])
) def.value
) defs
)
);
in
{
headError = checkDefsForError check loc defs;
value = map (x: x.optionalValue.value or x.mergedValue) evals;
valueMeta.list = map (v: v.checkedAndMerged.valueMeta) evals;
};
};
emptyValue = {
value = [ ];
};
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "*" ]);
getSubModules = elemType.getSubModules;
substSubModules = m: listOf (elemType.substSubModules m);
functor = (elemTypeFunctor name { inherit elemType; }) // {
type = payload: lib.types.listOf payload.elemType;
};
nestedTypes.elemType = elemType;
}