F# operator overloading for conversion of multiple different units of measure
问题 I want to be able to do this: let duration = 1<hours> + 2<minutes> + 3<seconds> with the following types and functions (and possibly more units of measure): type [<Measure>] seconds type [<Measure>] minutes type [<Measure>] hours let seconds_per_minute = 60<seconds> / 1<minutes> let minutes_per_hour = 60<minutes> / 1<hours> let minutes_to_seconds minutes seconds = minutes * seconds_per_minute + seconds let hours_to_minutes hours minutes = hours * minutes_per_hour + minutes So basically "hours