lib/generators.toPretty: functors should print as functions

Not attribute sets. So move the function case forward
This commit is contained in:
Silvan Mosberger 2020-09-17 18:18:50 +02:00
parent 05e4d371ef
commit 15c5ba9d28
No known key found for this signature in database
GPG Key ID: E8F1E9EAD284E17D

View File

@ -235,6 +235,13 @@ rec {
else "[" + introSpace
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
+ outroSpace + "]"
else if isFunction v then
let fna = lib.functionArgs v;
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList
(name: hasDefVal: if hasDefVal then name + "?" else name)
fna);
in if fna == {} then "<function>"
else "<function, args: {${showFnas}}>"
else if isAttrs v then
# apply pretty values if allowed
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
@ -247,13 +254,6 @@ rec {
(name: value:
"${libStr.escapeNixIdentifier name} = ${go (indent + " ") value};") v)
+ outroSpace + "}"
else if isFunction v then
let fna = lib.functionArgs v;
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList
(name: hasDefVal: if hasDefVal then name + "?" else name)
fna);
in if fna == {} then "<function>"
else "<function, args: {${showFnas}}>"
else abort "generators.toPretty: should never happen (v = ${v})";
in go "";