相关疑难解决方法(0)

由于单位F#接口继承失败

有谁知道为什么这不能编译?

type MyInterface<'input, 'output> = 
    abstract member MyFun: 'input -> 'output

type MyClass() = 
    interface MyInterface<string, unit> with
        member this.MyFun(input: string) = ()
    //fails with error FS0017: The member 'MyFun : string -> unit' does not have the correct type to override the corresponding abstract method.
type MyUnit = MyUnit
type MyClass2() = 
    //success
    interface MyInterface<string, MyUnit> with
        member this.MyFun(input: string) = MyUnit
Run Code Online (Sandbox Code Playgroud)

f# unit-type

17
推荐指数
1
解决办法
529
查看次数

标签 统计

f# ×1

unit-type ×1