FS0002: Function Unexpected

This message is given when a lambda is passed as a parameter where a value is expected.

The following code demonstrates the error:

let ignoreInt (f: int) = ()

do ignoreInt (fun x -> x + 1)

This code results in the following output:

error FS0002: This function takes too many arguments, or is used in a context where a function is not expected

Here, the type of ignoreInt is defined to be a function of int -> unit, but a lambda of type int -> int is passed instead. Because int -> int is not the same type as int this message is reported.

To fix this message, the code should be changed so that a non-lambda argument is passed to the function, as in this example:

let ignoreInt (i: int) = ()

do ignoreInt 1