我有以下代码如何变换OO调用到一些通用的函数调用
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}
它完美地工作,如果我把它用正常OO符号。
printfn "100 %s" (Shows().GetShow("some").Show("some"))
不过,我想换行成一个功能,以便
let inline show x = (Shows().GetShow(x).Show(x))
但是这给了我下面的错误
[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>
任何想法如何克服呢?