let noneIfEmptyString = (value: string, cvt: string => 'a):option<'a> => {
if value == "" {
None
} else {
value->cvt->Some
}
}
let intValue = noneIfEmptyString("0",int_of_string)
let floatValue = noneIfEmptyString("0",float_of_string)
I try this code , but got error:
This has type: string => float
Somewhere wanted: string => int
The incompatible parts:
float vs int