query
On this page

toFunction

lib.toFunction

Docs pulled from | This Revision | 13 minutes ago


Turns any non-callable values into constant functions. Returns callable values as is.

Inputs

v

Any value

Examples

lib.trivial.toFunction usage example

nix-repl> lib.toFunction 1 2
1

nix-repl> lib.toFunction (x: x + 1) 2
3
(lib.trivial.toFunction)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

toFunction =
    v:
    if isFunction v
    then v
    else k: v;