Packages

Units as meaning for the Macaw family: UCUM codes read through ucum with macaw's rules, ISO 4217 currencies, and the fixed list of quantities with their facts.

Current section

Files

Jump to
macaw_units README.md
Raw

README.md

<img src="brand/logo/macaw_scarlet.svg" alt="The Macaw logo, a scarlet macaw in flight" width="128">

# macaw_units

> **This software is a very early release, and not ready for general use.**

Public home: [github.com/dcoai/macaw_units](https://github.com/dcoai/macaw_units) · Docs: [hexdocs.pm](https://hexdocs.pm/macaw_units)

Units as meaning for the Macaw family: macaw's layer over `ucum`, currencies, and the quantities' facts ([spec/00](https://github.com/dcoai/macaw_units/blob/main/spec/00-overview.md)). It depends on `ucum` and `macaw_base` only, so macaw_data and macaw_draw share one vocabulary of units without either depending on the other (dco-tek/macaw/macaw#478).

| Module | What it is |
|---|---|
| `Macaw.Units.Unit` | UCUM codes read through `ucum` with macaw's stricter rules: `parse/1`, `valid?/1`, `dimension/1`, `factor/1`, `kind/1`, `symbol/2`, `format_error/1` ([spec/01 §1](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#units-codes), [§2](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#units-dimension), [§4](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#units-symbol)); `currency/1` and `minor_units/1` over the ISO 4217 table ([§3](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#units-currency)); exact `conversion/2` and `convert/2,3` ([§5](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#units-conversion)) |
| `Macaw.Units.Quantity` | the fixed list of quantities: `all/0`, `of_unit/1`, `resolve/1`, `base_unit/1` ([spec/01 §6](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#quantities)); `kind/1`, `bounds/1,2` ([§7](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#quantities-kind)); `additivity/2` ([§8](https://github.com/dcoai/macaw_units/blob/main/spec/01-units.md#quantities-additivity)) |
| `Macaw.Units.Error` | what every `!` twin raises: its value twin's reason, worded by macaw_base's `Macaw.Base.Fault.sentence/2` with units' words ([spec/00 §3](https://github.com/dcoai/macaw_units/blob/main/spec/00-overview.md#units-errors)) |

Presentation is not here: a person's typed symbols, a quantity's display families, unit systems and label are macaw_format's.

## Installation

Two runtime dependencies, `ucum` and `macaw_base`. From Hex:

```elixir
{:macaw_units, "~> 0.1.0"}
```

Part of [Macaw](https://github.com/dcoai/macaw).

## License

MIT; see the LICENSE file.