Re:Please put units in names
by pharmakom on Monday March 21, 2022 @02:25AM
(#30750882)
F# has unit support in the type system :)
[ Parent
| on HN ]
Re:Please put units in names
by S04dKHzrKT on Monday March 21, 2022 @02:43AM
(#30750982)
An example for unfamiliar folks.
Many Languages
var lengthInFeet = 2;
var weightInKg = 2;
var sum = lengthInFeet + weightInKg; // Runs without issue but is an error
F# [<Measure>] type ft
[<Measure>] type kg
let lengthInFeet = 2<ft>
let weightInKg = 2<kg>
let sum = lengthInFeet + weightInKg // Compile time error
More info at https://fsharpforfunandprofit.com/posts/units-of-measure/