This works:
type MyType () =
static member MyFn (fn : Func<bool>) = fn.Invoke ()
MyType.MyFn (fun _ -> false)
This does not (error FS0002):
let myFn (fn : Func<bool>) = fn.Invoke ()
myFn (fun _ -> false)
Neither does this (error FS0002):
type MyDU = Fn of Func<bool>
Fn (fun _ -> false)
What is the reason for this rather annoying inconsistency?
F. no. failure (pass/fail option)
Author has 267 answers and 164.6K answer views 5y. Depends. My school's handbook says “A-Exceptional, B-Above Average, C-Average, D-Below Average, F-Unsatisfactory”
This behavior is covered by section 8.13.7 (Type-directed Conversions at Member Invocations) of the F# spec, where it states:
Note: These type-directed conversions are primarily for interoperability with existing member-based .NET libraries and do not apply at invocations of functions defined in modules or bound locally in expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With