F # discriminatory unions correspond to OO class hierarchies pretty closely, so this is probably the best option. The most noticeable difference is that you cannot add new cases to a discriminatory union without changing the type declaration. On the other hand, you can easily add new functions that work with the type (which roughly corresponds to adding new virtual methods in C #).
So, if you do not expect to add new inherited classes (cases), then this is the best option. Otherwise, you can use F # object types (or other parameters, depending on the scenario).
Another point related to your code is that since you cannot add new cases, the F # compiler knows that the only cases you need are B and C As a result, block_3 never be executed, which means you can simply write:
let my_fct x = match x with | B -> ( block_1 ) | C -> ( block_2 )
source share