lib/generators.toPretty: Switch away from δ and λ
- These symbols can be confusing for those not familiar with them - There's no harm in making these more obvious - Terminals may not print them correctly either Also changes the function argument printing slightly to be more obvious
This commit is contained in:
parent
073e9b2aed
commit
d0be9e9810
@ -237,10 +237,8 @@ rec {
|
|||||||
# apply pretty values if allowed
|
# apply pretty values if allowed
|
||||||
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
||||||
then v.__pretty v.val
|
then v.__pretty v.val
|
||||||
# TODO: there is probably a better representation?
|
|
||||||
else if v ? type && v.type == "derivation" then
|
else if v ? type && v.type == "derivation" then
|
||||||
"<δ:${v.name}>"
|
"<derivation ${v.drvPath}>"
|
||||||
# "<δ:${concatStringsSep "," (builtins.attrNames v)}>"
|
|
||||||
else "{" + introSpace
|
else "{" + introSpace
|
||||||
+ libStr.concatStringsSep introSpace (libAttr.mapAttrsToList
|
+ libStr.concatStringsSep introSpace (libAttr.mapAttrsToList
|
||||||
(name: value:
|
(name: value:
|
||||||
@ -248,11 +246,11 @@ rec {
|
|||||||
+ outroSpace + "}"
|
+ outroSpace + "}"
|
||||||
else if isFunction v then
|
else if isFunction v then
|
||||||
let fna = lib.functionArgs v;
|
let fna = lib.functionArgs v;
|
||||||
showFnas = concatStringsSep "," (libAttr.mapAttrsToList
|
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList
|
||||||
(name: hasDefVal: if hasDefVal then "(${name})" else name)
|
(name: hasDefVal: if hasDefVal then name + "?" else name)
|
||||||
fna);
|
fna);
|
||||||
in if fna == {} then "<λ>"
|
in if fna == {} then "<function>"
|
||||||
else "<λ:{${showFnas}}>"
|
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 "";
|
||||||
|
|
||||||
|
@ -445,7 +445,10 @@ runTests {
|
|||||||
expected = builtins.toJSON val;
|
expected = builtins.toJSON val;
|
||||||
};
|
};
|
||||||
|
|
||||||
testToPretty = {
|
testToPretty =
|
||||||
|
let
|
||||||
|
deriv = derivation { name = "test"; builder = "/bin/sh"; system = builtins.currentSystem; };
|
||||||
|
in {
|
||||||
expr = mapAttrs (const (generators.toPretty { multiline = false; })) rec {
|
expr = mapAttrs (const (generators.toPretty { multiline = false; })) rec {
|
||||||
int = 42;
|
int = 42;
|
||||||
float = 0.1337;
|
float = 0.1337;
|
||||||
@ -459,7 +462,7 @@ runTests {
|
|||||||
functionArgs = { arg ? 4, foo }: arg;
|
functionArgs = { arg ? 4, foo }: arg;
|
||||||
list = [ 3 4 function [ false ] ];
|
list = [ 3 4 function [ false ] ];
|
||||||
attrs = { foo = null; "foo bar" = "baz"; };
|
attrs = { foo = null; "foo bar" = "baz"; };
|
||||||
drv = derivation { name = "test"; system = builtins.currentSystem; };
|
drv = deriv;
|
||||||
};
|
};
|
||||||
expected = rec {
|
expected = rec {
|
||||||
int = "42";
|
int = "42";
|
||||||
@ -470,11 +473,11 @@ runTests {
|
|||||||
newlinestring = "\"\\n\"";
|
newlinestring = "\"\\n\"";
|
||||||
path = "/foo";
|
path = "/foo";
|
||||||
null_ = "null";
|
null_ = "null";
|
||||||
function = "<λ>";
|
function = "<function>";
|
||||||
functionArgs = "<λ:{(arg),foo}>";
|
functionArgs = "<function, args: {arg?, foo}>";
|
||||||
list = "[ 3 4 ${function} [ false ] ]";
|
list = "[ 3 4 ${function} [ false ] ]";
|
||||||
attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
|
attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
|
||||||
drv = "<δ:test>";
|
drv = "<derivation ${deriv.drvPath}>";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user