【发布时间】:2012-04-04 13:26:10
【问题描述】:
我基本上是在问为什么以下代码行无法编译:
type IGenericType<'a> =
abstract member MyFunc : 'a -> 'a -> 'a
type Implementer() =
member x.Test () () = () // unit->unit->unit
interface IGenericType<unit> with
member x.MyFunc a b = b // FS0017
// member x.MyFunc () () = () // FS0017
只是好奇是否有一种方法可以使这项工作按预期进行。我认为这是一个限制,它与单元和泛型的实现有关。
我目前正在使用以下解决方法:
type Nothing =
| Nothing
type Implementer() =
interface IGenericType<Nothing> with
member x.MyFunc a b = b
希望有人能对这种行为有所启发。
【问题讨论】: