simple-units: Simple arithmetic with SI units using type-checked dimensional analysis.

[ library, mit, numeric, numerical ] [ Propose Tags ] [ Report a vulnerability ]

Please see the README on GitHub at https://github.com/groscoe/simple-units#readme


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0.0, 1.0.1.0, 1.0.1.1, 1.0.2
Dependencies base (>=4.9 && <5), first-class-families (>=0.5 && <0.6) [details]
License MIT
Copyright 2019 Gustavo Roscoe
Author Gustavo Roscoe
Maintainer gustavo@gustavoroscoe.com
Category Numeric, Numerical
Home page https://github.com/groscoe/simple-units#readme
Bug tracker https://github.com/groscoe/simple-units/issues
Source repo head: git clone https://github.com/groscoe/simple-units
Uploaded by groscoe at 2019-04-17T14:59:12Z
Distributions
Downloads 1471 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-04-17 [all 1 reports]

Readme for simple-units-1.0.1.1

[back to package description]

simple-units

A Haskell library for simple arithmetic with SI units using type-checked dimensional analysis.

>>> let newton = kilogram .* meter ./ (second .* second)
>>> 23*newton
23.0 kg*m/s^2
>>> let g = 6.67408e-11 * newton .* (meter .* meter) ./ (kilogram .* kilogram)
>>> g -- gravitational constant
6.67408e-11 m^3/kg*s^2
>>> let gravity m1 m2 r = g .* (m1 * kilogram) .* (m2 * kilogram) ./ (r*meter .* r*meter)
>>> let earth_mass = 5.972e24 * kilogram
>>> let mars_mass = 6.417e23 * kilogram
>>> let earth_radius = 6371 * kilo meter
>>> let mars_radius = 3389.5 * kio meter
>>> let weight_on_earth mass = gravity mass earth_mass earth_radius
>>> let weight_on_mars mass = gravity mass mars_mass mars_radius
>>> weight_on_earth (80 * kilogram)
785.5719790179963 kg*m/s^2
>>> weight_on_mars (80 * kilogram)
298.22370259533704 kg*m/s^2
>>> weight_on_mars 1 ./ weight_on_earth 1
0.3796261966575378 <adimensional>