Using F # for the first time for a production thing and need a little help. See this code in which I added warnings that I receive as comments on each line:
type AssetClass =
| Corp
| Corp_SME
| Res_Mort
| Qual_Ret
| Ret_Oth
let Correlation assetClass pd sales =
match assetClass with
| Corp -> 0.12
| CORP_SME -> 0.24 // warning FS0049: Uppercase variable identifiers
| Res_Mort -> 0.15 // warning FS0026: This rule will never be matched
| Qual_Ret -> 0.04 // warning FS0026: This rule will never be matched
| Ret_Oth -> 0.03 // warning FS0026: This rule will never be matched
I checked and does not bluff, the third and other cases are really ignored. What I wonβt get here? (Pd and the sales data that I use in the actual implementation, I just left the formulas here.)
What I want to do is use a discriminatory union, as I would use an enumeration in C # and then include it. So in C #, I would type this:
enum AssetClass {
Corp,
Corp_SME,
Ret_Oth
}
float Correlation(AssetClass assetClass){
switch(assetClass){
case Corp: return 0.12;
case Corp_SME: return 0.12;
case Ret_Oth: return 0.12;
}
}
Can anyone help me out?
Thanks in advance,
Geert Yang
source
share