Type-safe units of measure in Roc.
Feet, inches and centimeters are all Length
s, so they can all be added to and converted to each other.
height = Quantity.feet 5 |> Quantity.add (Quantity.inches 11)
Stdout.line! "Taylor Swift is $(height |> Quantity.toCentimeters |> Num.toStr) centimeters tall."
Taylor Swift is 180.34 centimeters tall.
But incompatible units cannot be used together.
isThisAKilometer = Quantity.kilograms 1 |> Quantity.add (Quantity.meters 1)
This 2nd argument to add has an unexpected type: ...
For a list of all the supported units, see the documentation.
This project is released under the UPL licence and is partly based on the elm-units library, which is licenced under the BSD 3-Clause License.