Search code examples
functionf#option-type

'option<unit->unit> type and the equality' using F#


Consider the following code:

let fnOption = Some (fun () -> ())
fnOption = None

It gives the following error:

init.fsx(2,1): error FS0001: The type '(unit -> unit)' does not support the 'equality' constraint because it is a function type

Why is that? Did I overlook something?


Solution

  • If you really wanted to check for equality (and not to assign the value), then you can use Option.isNone fnOption. If you really do want to assign, look as kvb's answer.