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:77: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:85:17:
           84|      */
           85|     __functor = self: self.__functor self;
             |                 ^
           86|   };

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

       (19999 duplicate frames omitted)

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

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:97:19:
           96|     f = x: {
           97|       __functor = self: (f (x + 1));
             |                   ^
           98|     };

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

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:45:23


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:45:23


This is a function that can be overridden.

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


This is a function that can be overridden.