非静的なパブリック メンバーのアクティブ パターンが許可されているかどうかはわかりませんが、コンパイラが文句を言うことなくそれらを定義できます。それらが許可されている場合、1 つに一致するための構文は何ですか? コンパイラは、FooBar2.doSomething の Foo の型の不一致を示しています。'a -> Choice<'b,'c>
与えられた期待'a -> 'd -> Choice<unit,unit>
// No error in this class, static works great
type FooBar() =
static member (|Foo|Bar|) (x, y) =
match x = y with
| true -> Foo
| false -> Bar
member x.doSomething y =
match x, y with
| Foo -> ()
| Bar -> ()
type FooBar2() =
member x.(|Foo|Bar|) y =
match x = y with
| true -> Foo
| false -> Bar
// compiler error on "Foo"
member x.doSomething y =
match y with
| Foo -> ()
| Bar -> ()