query
On this page

traceSeqN

lib.debug.traceSeqN

Docs pulled from | This Revision | 10 minutes ago


Like traceSeq, but only evaluate down to depth n. This is very useful because lots of traceSeq usages lead to an infinite recursion.

Inputs

depth

1. Function argument

x

2. Function argument

y

3. Function argument

Type

traceSeqN :: Int -> a -> b -> b

Examples

lib.debug.traceSeqN usage example

traceSeqN 2 { a.b.c = 3; } null
trace: { a = { b = {…}; }; }
=> null

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

traceSeqN =
    depth: x: y:
    let
      snip =
        v:
        if isList v then
          noQuotes "[…]" v
        else if isAttrs v then
          noQuotes "{…}" v
        else
          v;
      noQuotes = str: v: {
        __pretty = const str;
        val = v;
      };
      modify =
        n: fn: v:
        if (n == 0) then
          fn v
        else if isList v then
          map (modify (n - 1) fn) v
        else if isAttrs v then
          mapAttrs (const (modify (n - 1) fn)) v
        else
          v;
    in
    trace (generators.toPretty { allowPrettyValues = true; } (modify depth snip x)) y;