Skip to content

📏 Type-safe units of measure in Roc

License

UPL-1.0, BSD-3-Clause licenses found

Licenses found

UPL-1.0
LICENCE
BSD-3-Clause
LICENCE-elm-units
Notifications You must be signed in to change notification settings

Hasnep/roc-units

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

Topics

Resources

License

UPL-1.0, BSD-3-Clause licenses found

Licenses found

UPL-1.0
LICENCE
BSD-3-Clause
LICENCE-elm-units

Stars

Watchers

Forks

Packages

No packages published