Re: [Nix-dev] A nix pretty-printer and a trace function you can tell how deep it should go

2017-06-12 Thread Tomasz Czyż
nice, thank you

2017-06-12 16:33 GMT+01:00 Profpatsch :

> https://github.com/NixOS/nixpkgs/pull/26433
>
> Pretty Printing:
>
> nix-repl> lib.generators.toPretty {} { foo = [ 2 3 netcat-openbsd ]; bar =
> lib.id; x = {args, def ? 42}: args; }
> "{ \"bar\" = <λ>; \"foo\" = [ 2 3 <δ> ]; \"x\" = <λ:{args,(def)}>; }"
>
> nix-repl> lib.generators.toPretty {} (import )
> "<λ:{(config),(crossSystem),(localSystem),(overlays),(
> platform),(system)}>"
>
>
> Trace Folding:
>
> nix-repl> foo = { a = [ 1 [ 2 3 ] ]; b = { c.d.e = "yip yip"; }; }
>
> nix-repl> lib.traceValSeqN 10 foo
> trace: { "a" = [ 1 [ 2 3 ] ]; "b" = { "c" = { "d" = { "e" = "yip yip"; };
> }; }; }
> { a = [ ... ]; b = { ... }; }
>
> nix-repl> lib.traceValSeqN 3 foo
> trace: { "a" = [ 1 [ 2 3 ] ]; "b" = { "c" = { "d" = {…}; }; }; }
> { a = [ ... ]; b = { ... }; }
>
> nix-repl> lib.traceValSeqN 1 foo
> trace: { "a" = […]; "b" = {…}; }
> { a = [ ... ]; b = { ... }; }
>
> nix-repl> lib.traceValSeqN 0 foo
> trace: {…}
> { a = [ ... ]; b = { ... }; }
>
>
> https://twitter.com/Profpatsch/status/874127956884566016
>
> I hope this helps some people.
> Please review the code.
>
>
> --
> Proudly written in Mutt with Vim on NixOS.
> Q: Why is this email five sentences or less?
> A: http://five.sentenc.es
> May take up to five days to read your message. If it’s urgent, call me.
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>



-- 
Tomasz Czyż
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] A nix pretty-printer and a trace function you can tell how deep it should go

2017-06-12 Thread Profpatsch
https://github.com/NixOS/nixpkgs/pull/26433

Pretty Printing:

nix-repl> lib.generators.toPretty {} { foo = [ 2 3 netcat-openbsd ]; bar = 
lib.id; x = {args, def ? 42}: args; }
"{ \"bar\" = <λ>; \"foo\" = [ 2 3 <δ> ]; \"x\" = <λ:{args,(def)}>; }"

nix-repl> lib.generators.toPretty {} (import )
"<λ:{(config),(crossSystem),(localSystem),(overlays),(platform),(system)}>"


Trace Folding:

nix-repl> foo = { a = [ 1 [ 2 3 ] ]; b = { c.d.e = "yip yip"; }; }

nix-repl> lib.traceValSeqN 10 foo
trace: { "a" = [ 1 [ 2 3 ] ]; "b" = { "c" = { "d" = { "e" = "yip yip"; }; }; }; 
}
{ a = [ ... ]; b = { ... }; }

nix-repl> lib.traceValSeqN 3 foo
trace: { "a" = [ 1 [ 2 3 ] ]; "b" = { "c" = { "d" = {…}; }; }; }
{ a = [ ... ]; b = { ... }; }

nix-repl> lib.traceValSeqN 1 foo
trace: { "a" = […]; "b" = {…}; }
{ a = [ ... ]; b = { ... }; }

nix-repl> lib.traceValSeqN 0 foo
trace: {…}
{ a = [ ... ]; b = { ... }; }


https://twitter.com/Profpatsch/status/874127956884566016

I hope this helps some people.
Please review the code.


-- 
Proudly written in Mutt with Vim on NixOS.
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
May take up to five days to read your message. If it’s urgent, call me.
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev