lib/generators.toPretty: functors should print as functions
Not attribute sets. So move the function case forward
This commit is contained in:
parent
05e4d371ef
commit
15c5ba9d28
|
@ -235,6 +235,13 @@ rec {
|
||||||
else "[" + introSpace
|
else "[" + introSpace
|
||||||
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
|
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
|
||||||
+ outroSpace + "]"
|
+ 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
|
else if isAttrs v then
|
||||||
# apply pretty values if allowed
|
# apply pretty values if allowed
|
||||||
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
||||||
|
@ -247,13 +254,6 @@ rec {
|
||||||
(name: value:
|
(name: value:
|
||||||
"${libStr.escapeNixIdentifier name} = ${go (indent + " ") value};") v)
|
"${libStr.escapeNixIdentifier name} = ${go (indent + " ") value};") v)
|
||||||
+ outroSpace + "}"
|
+ 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})";
|
else abort "generators.toPretty: should never happen (v = ${v})";
|
||||||
in go "";
|
in go "";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue