Reputation: 11649
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
Upvotes: 2
Views: 6015
Reputation: 2395
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
Upvotes: 10