Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This value is not a function and cannot be applied

Tags:

f#

Pretty simple function for operation of negation.

let negation (value:option<bool>) =
   match value with
   |Some true -> Some false
   |Some false -> Some true
   |None -> failwith "OOPS"

but when i call it:

negation Some true 

it complains that

This value is not a function and cannot be applied
like image 495
Sal-laS Avatar asked Jul 19 '26 10:07

Sal-laS


1 Answers

You need some parens there:

negation (Some true)

Or:

negation <| Some true

Without the parens like that F# compiler would understand that line as

(negation Some) true

because function application is left-binding and then types are not match: negation would need to be of type: ('a -> option 'a) -> bool -> bool which clearly isn't (is of type bool option -> bool option)

In addition: (opinion included)

Negation function is called not : bool -> bool. You are trying to use that on the bool wrapped by option, so maybe that should be sufficient:

let negation : bool option -> bool option = Option.map not
like image 78
Bartek Kobyłecki Avatar answered Jul 21 '26 09:07

Bartek Kobyłecki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!