小编Ger*_*ard的帖子

F#:不一致的SRTP静态扩展方法类型匹配

我试图使用PrintfFormat类型解析器的强制解析,它最初似乎适用,int但随后的相同方法string却不起作用...虽然float起作用了,所以我认为是Value / Ref类型问题,但后来尝试了bool,但没有成功。像String一样工作。

int与float工作,string与bool不!?

(ParseApply方法目前是虚拟实现)

    type System.String  with static member inline ParseApply (path:string) (fn: string -> ^b) : ^b = fn ""
    type System.Int32   with static member inline ParseApply (path:string) (fn: int   -> ^b) : ^b = fn 0
    type System.Double  with static member inline ParseApply (path:string) (fn: float -> ^b) : ^b = fn 0.
    type System.Boolean with static member inline ParseApply (path:string) (fn: …
Run Code Online (Sandbox Code Playgroud)

extension-methods f# constraints

4
推荐指数
2
解决办法
192
查看次数

标签 统计

constraints ×1

extension-methods ×1

f# ×1