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

Tomasz Czyż tomasz.czyz at gmail.com
Mon Jun 12 17:57:44 CEST 2017


nice, thank you

2017-06-12 16:33 GMT+01:00 Profpatsch <mail at profpatsch.de>:

> 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 <nixpkgs>)
> "<λ:{(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 at lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>



-- 
Tomasz Czyż
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170612/f219ceab/attachment.html>


More information about the nix-dev mailing list