haskell-unittyped / README.md

UnitTyped is a Haskell library for type-safe calculations on numbers with units.

It comes with all SI units and a large number of units derived from them, but it also makes it very easy to add new dimensions and units. It can give new definitions of *, /, +, -, ==, <, <=, > and >= to make notation as natural as possible. To define a new unit, only the multiplication factor and a string to display it is required. From just that, all other conversions can be inferred.

While it uses a large number of Haskell extensions, all units and dimensions are empty datatypes, so should not be a burden at runtime.

Examples:

    *Main> 1 *| meter |+| 35 *| centi meter
    1.35 m

coerce can be used to change from one unit to a different unit in the same dimension:

    *Main> 120 *| kilo meter |/| hour |*| 20 *| minute `as` mile
    24.854847689493358 mile

See the wiki for more complicated examples.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.