News for hackers. Stuff that matters.
Re:Can 1/3 and 1/3 = 2/6? It seemed so by scarmig on Tuesday May 26, 2020 @11:35AM (#23312439)
F# offers a nifty "unit of measure" language feature to help with that. You might have

  [<Measure>] type lbFeather 
  [<Measure>] type lbGold
  [<Measure>] type lbLead

  let convertGoldToLead ( weight : float<lbGold> ) = 1.0<lbLead> / 1.0<lbGold> * weight

  // works
  let barOfGold = 1.0<lbGold>
  let barOfLead = convertGoldToLead barOfGold
  // doesn't work
  let bagOfFeathers = 1.0<lbFeather>
  let leadDuck = convertGoldToLead bagOfFeathers
  // Error reported: mismatched units.

There are no comments on this comment yet.