我需要一個不同的行爲來做!然後讓!在我自定義的計算表達式中有沒有辦法做不同的實現!然後讓!在計算表達式中?
我嘗試通過以下方式來實現這一目標:
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