を階層C#クラス対組合を区別: public abstract class A ...
public class B : A ...
public class C : A ...
void my_fct(A x) {
if (x is B) { block_1 }
else if (x is C) { block_2 }
else { block_3 }
}
I持っている2つのネストされた差別組合: type ServiceTypes =
| Contexts
| Context of int
| Producers
type ServiceActions =
| Get of ServiceTypes
| Update of ServiceTypes
とネスト一致ステートメント: let s_
差別化されたユニオンにメソッドとプロパティを追加することは可能ですが、レコードのフィールドと同様に、インスタンスがユニオンが作成されたときに設定する必要がある不変フィールドを追加できますか? type union =
| OptionOne of int
| OptionTwo of string
{
AFieldUsedForBothCases : st
私は、識別されたユニオンであるASTタイプに文字列をパーズするF#プログラムを作成しています。 fsi(Mono + Mac OS X上)を使用してコードを実行すると、ASTが素敵な形式で印刷されます。しかし、printfn "%s" <| ast.ToString()を使うと、FSI_0002.Absyn+clazzのようなものが得られます。すべての識別された共用体型のためにToStringメソ