Nix <nix version>
Type :? for help.

nix-repl> :l doc-functor.nix
Added <number omitted> variables.

nix-repl> :doc multiplier
Function `__functor`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:12:23


Multiply the argument by the factor stored in the factor attribute.

nix-repl> :doc doubler
Function `multiply`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:5:17


Look, it's just like a function!

nix-repl> :doc recursive
Function `__functor`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:82:23


This looks bad, but the docs are ok because of the eta expansion.

nix-repl> :doc recursive2
error:
       … while partially calling '__functor' to retrieve documentation

       … while calling '__functor'
         at /path/to/tests/functional/repl/doc-functor.nix:90:17:
           89|     */
           90|     __functor = self: self.__functor self;
             |                 ^
           91|   };

       … from call site
         at /path/to/tests/functional/repl/doc-functor.nix:90:23:
           89|     */
           90|     __functor = self: self.__functor self;
             |                       ^
           91|   };

       (19999 duplicate frames omitted)

       error: stack overflow; max-call-depth exceeded
       at /path/to/tests/functional/repl/doc-functor.nix:90:23:
           89|     */
           90|     __functor = self: self.__functor self;
             |                       ^
           91|   };

nix-repl> :doc diverging
error:
       … while partially calling '__functor' to retrieve documentation

       (10000 duplicate frames omitted)

       … while calling '__functor'
         at /path/to/tests/functional/repl/doc-functor.nix:103:21:
          102|       f = x: {
          103|         __functor = self: (f (x + 1));
             |                     ^
          104|       };

       error: stack overflow; max-call-depth exceeded
       at /path/to/tests/functional/repl/doc-functor.nix:103:28:
          102|       f = x: {
          103|         __functor = self: (f (x + 1));
             |                            ^
          104|       };

nix-repl> :doc helper
Function `square`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:36:12


Compute x^2

nix-repl> :doc helper2
Function `__functor`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13


This is a function that can be overridden.

nix-repl> :doc lib.helper3
Function `__functor`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13


This is a function that can be overridden.

nix-repl> :doc helper3
Function `__functor`\
  … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13


This is a function that can be overridden.
