Je le code suivantComment transformer OO appels en une certaine fonction générique appelle
type Show<'a> =
abstract member Show: 'a -> string
type Shows() =
member inline this.GetShow(x:string) =
{new Show<string> with member this.Show(x:string) = x}
member inline this.GetShow(x:int) =
{new Show<int> with member this.Show(x:int) = sprintf "%A" x}
qui fonctionne parfaitement si je l'appelle en utilisant la notation normale OO.
printfn "100 %s" (Shows().GetShow("some").Show("some"))
Cependant, j'aimerais conclure que dans une fonction afin que
let inline show x = (Shows().GetShow(x).Show(x))
Mais cela me donne l'erreur suivante
[FS0041] A unique overload for method 'GetShow' could not be determined based
on type information prior to this program point. A type annotation may be
needed. Candidates:
member Shows.GetShow : x:int -> Show<int>,
member Shows.GetShow : x:string -> Show<string>
Toute idée comment surmonter cela?