Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharkdp/purescript-quantities
Physical quantities and units
https://github.com/sharkdp/purescript-quantities
math physics purescript unit-conversion units
Last synced: 19 days ago
JSON representation
Physical quantities and units
- Host: GitHub
- URL: https://github.com/sharkdp/purescript-quantities
- Owner: sharkdp
- License: mit
- Created: 2016-07-18T13:50:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-22T15:48:35.000Z (over 1 year ago)
- Last Synced: 2024-12-14T08:54:11.791Z (about 2 months ago)
- Topics: math, physics, purescript, unit-conversion, units
- Language: PureScript
- Homepage: https://pursuit.purescript.org/packages/purescript-quantities/
- Size: 177 KB
- Stars: 54
- Watchers: 4
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# purescript-quantities
A PureScript library to represent and work with physical quantities and units. Note that this library
focuses on a representation at *run time* as opposed to other projects which use the type system to
encode physical units at *compile time*.## Examples
``` purs
> showResult $ 2.0 .* minute ⊕ 30.0 .* second
"2.5 min"> showResult $ (85.0 .* mile ./ hour) `convertTo` (meter ./ second)
"37.9984 m/s"> showResult $ (10.0 .* meter ./ second) `convertTo` (kilo meter ./ hour)
"36 km/h"> log $ showResult $ (10.0 .* joule) `convertTo` watt
Cannot convert unit 'J' (SI: 'm²·g/s²')
to unit 'W' (SI: 'm²·g/s³')> showResult $ sin (90.0 .* degree)
"1"
```Calculate the time it takes to download a *2.7GB* file on a *6Mbit/s* connection:
``` purs
> let filesize = 2.7 .* giga byte
> let speed = 6.0 .* mega bit ./ second
> showResult $ (filesize ⊘ speed) `convertTo` minute
"60 min"
```Calculate the oscillation period *T = 2π sqrt(L/g)* of a pendulum with length *L = 20cm*:
``` purs
> let g = 9.81 .* meter ./ second .^ 2.0
> let length = 20.0 .* centi meter
> let period = scalar 2.0 ⊗ pi ⊗ sqrt (length ⊘ g)> prettyPrint (fullSimplify period)
"0.89714 s"
```## Development
```
npm install
spago -x test.dhall test
```## Documentation
- [Module documentation](https://pursuit.purescript.org/packages/purescript-quantities)