given
open System
open System.Windows
open System.Windows.Input
open System.ComponentModel
type RelayCommand (canExecute:(obj -> bool), action:(obj -> unit)) =
let event = new DelegateEvent<EventHandler>()
interface ICommand with
[<CLIEvent>]
member x.CanExecuteChanged = event.Publish
member x.CanExecute arg = canExecute(arg)
member x.Execute arg = action(arg)
member x.CheckCanExecute (sender:obj) (eventArgs:EventArgs) = event.Trigger([| sender;eventArgs |])
how do I write a statically resolved type parameterized function that can satisfy a call to CheckCanExecute ?
while this function works it doesn't help me learn statically resolved type parameter syntax
let checkCanExecute (c:RelayCommand) = c.CheckCanExecute (box this) (EventArgs())
I expected this to work
let checkCanExecute (e:^a) = (^a: (member CheckCanExecute: sender:obj -> EventArgs -> unit ) (e, (box me),(EventArgs())))
but at the callsite
checkCanExecute addCommand
I get method or object constructor 'CheckCanExecute' not found (when using the 2nd definition, the 1st compiles just fine)
how do I define a class let binding (or member binding if that is a better way to get the job done) that uses Statically Resolved Type Parameters to be able to call the method on anything that has the matching method signature?