F# Units of Measure – A Worked Example
stevenpemberton.net
stevenpemberton.net
One key point to take heed of, is that units of measure do not exist at runtime. They are intended for static type checking only and therefore prevent us implementing functionality based on checking units.
They are also not part of the wider .NET type system and can therefore not be consumed, or used, by any non F# assembly. If exposing units of measure to consumers, the units are simply not visible and all values will be treated as there underlying, dimensionless type.
I did find an exploration of this topic at https://stackoverflow.com/questions/348853/units-of-measure-...
This way you would almost never have "raw" int or float types.
Hmm, maybe we'll just have to put it in a separate project even if it feels silly to just have a few classes there, which in turn are strongly related to others. It just feels so perfect for these particular classes.