我需要一个不同的行为来做!然后让!在我自定义的计算表达式中有没有办法做不同的实现!然后让!在计算表达式中?
我尝试通过以下方式来实现这一目标:
type FooBuilder() = class
member b.Bind<'T, 'U>(x:'T, f:unit->'U):'U = failwith "not implemented" //do! implementation
member b.Bind<'T, 'U>(x:'T, f:'T->'U):'U = failwith "not implemented" //let! implementation
member b.Return<'T>(x:'T):'T = failwith "not implemented" //return implementation
end
let foo = FooBuilder()
let x = foo {
do!()
return 2
}
但是编译器给我一个错误:
A unique overload for method 'Bind' could not be determined based on type information prior to this program point. The available overloads are shown below (or in the Error List window). A type annotation may be needed.
有没有办法有不同的实现做的!然后让!?
非常感谢你对此详细解释 – 2011-04-06 14:54:00