これがなぜコンパイルに失敗するのか誰に知っていますか?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
ありがとう。 –
@Stefan: 'unit'型を(関数または型に対して)引数として使用すると、一般的に問題ありません。このバグ/制限は抽象メンバを実装するときにのみ現れるでしょう(これは、F#コンパイラにとって少し面倒な領域です)。 –
興味深いことに、C#で動作し、F#で関数を使用できます。おそらくバグとして報告されるべきです。 –