FS0003: This value is not a function and cannot be applied
This message is given when a parameter is given to a value that cannot accept parameters. This is often the case when attempting to use an indexer into a collection like a list, array, or IEnumerable.
The following code demonstrates one way the error can be seen:
let v = 10 v "a parameter"
In the previous snippet, the FS0003 error is shown because the value
v is not a function that accepts parameters.
error FS0003: This value is not a function and cannot be applied.
Another way the error can be seen is when incorrectly using the indexer available on a type:
let listOfInts = [1; 2; 3] printfn "%d" (listOfInts)
In the previous snippet, the FS0003 error is shown because in F# indexers are accessed via
.[index] syntax instead of
error FS0003: This value is not a function and cannot be applied. Did you intend to access the indexer via listOfInts.[index] instead?
To solve this message, you must determine which of these two scenarios is the root cause.
If an indexer was intended to be used, make sure the syntax is correct as suggested by the error message. In this case, the correct usage would be
If a function was intended to be called, make sure the value you're calling is in fact a function. Is there a typo in the name? Try adding type annotations to let-bindings to ensure the code is in line with the intended types.