I'm either not seeing something obvious or just generally confused The code I have looks like:
let inline createContext source destination =
let src = (fun amount (s:^T) -> (^T : (member DecreaseBalance : decimal -> ^a) (s, amount)))
let dst = (fun amount (d:^T) -> (^T : (member IncreaseBalance : decimal -> ^a) (d, amount)))
let log = (fun msg a -> (^T : (member LogMessage : string -> ^a) (a, msg)))
let f = fun amount -> src amount source |> ignore
log "" source |> ignore
let f = fun amount -> dst amount destination |> ignore
log "" destination |> ignore
new Context (source, destination, src, dst, log)
let src = new Account(0m)
let dst = new Account(0m)
let ctxt = createContext src dst
The type Account fullfils the member constraints of createContext. Intellisense claims the signartur of createContext to be Account -> Account -> Context but the compiler complains at src in the last line with "This expression was expected to have type unit but here has type Account" Any idea of what I'm missing?
If I rename a member function of Account so it no longer meets the constraints I get "The type 'Account' does not support any operators named 'LogMessage'" which is what I would expect in that scenario. I get the same error message if I pass () as the first argument. That unit doesn't support LogMessage (not that it would bring me any good if that actually compiled)