Hasnep / roc-units

πŸ“ Type-safe units of measure in Roc

Home Page:https://hasnep.github.io/roc-units

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Roc Units

Type-safe units of measure in Roc.

Example

Feet, inches and centimeters are all Lengths, 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.

Licence

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.

About

πŸ“ Type-safe units of measure in Roc

https://hasnep.github.io/roc-units

License:Universal Permissive License v1.0


Languages

Language:Roc 96.3%Language:Nix 2.8%Language:Just 0.8%