Manage physical units. Inspired by kotlin.time.Duration. Alchemist allow type safe arithmetic between different physical quantities defined in the International System of Units.
val time: Duration = 10.seconds
val length: Length = 10.kilometers
val velocity: Velocity = length / time
val acceleration: Acceleration = velocity / time
val mass: Mass = 10.kilograms
val force: Force = acceleration * mass
val energy: Energy = force * length
val power: Power = energy / time
val area: Area = length * length
val volume: Volume = length * length * length
[versions]
alchemist = "0.1.0"
[libraries]
alchemist = { module = "io.github.kevincianfarini.alchemist:alchemist", version.ref = "alchemist" }
- Model physical quantities as Kotlin value classes which wrap a single
Long
value. - Provide logical arithmetic between different physical quantities, like
power = energy / time
. - Allow for the implementation of custom units on physical quanities that Alchemist does not provide, such as horsepower as a unit of
Power
or Rankine degrees forTemperature
. - (In the future) Allow different order of magnitude precision and wider ranges of valid values.
- Easy extensibility for custom formulas, such as
energyₖ = ½ * mass * velocity²
.
- Using generic or floating point values as the underlying storage mechanism.
- Representing arbitrary formulaic expressions.
- Providing as many formulaic conversions as possible out of the box, such as
energyₖ = ½ * mass * velocity²
. - Infinitely precise values.
- Infinitely large ranges of valid values.
Platform | Compiled | Tested in CI |
---|---|---|
androidNativeArm32 | ✅ | ❌ |
androidNativeArm64 | ✅ | ❌ |
androidNativeX64 | ✅ | ❌ |
androidNativeX86 | ✅ | ❌ |
iosArm64 | ✅ | ❌ |
iosSimulatorArm64 | ✅ | ✅ |
iosX64 | ✅ | ✅ |
js | ✅ | ✅ |
jvm | ✅ | ✅ |
linuxArm64 | ✅ | ❌ (Prohibited by Tier 2 support.) |
linuxX64 | ✅ | ✅ |
macosArm64 | ✅ | ✅ |
macosX64 | ✅ | ✅ |
mingwX64 | ✅ | ✅ |
tvosArm64 | ✅ | ❌ |
tvosSimulatorArm64 | ✅ | ✅ |
tvosX64 | ✅ | ✅ |
wasmJs | ✅ | ✅ |
wasmWasi | ✅ | ❌ (Prohibited by KT-60964.) |
watchosArm32 | ✅ | ❌ |
watchosArm64 | ✅ | ❌ |
watchosDeviceArm64 | ✅ | ❌ |
watchosSimuatorArm64 | ✅ | ✅ |
watchosX64 | ✅ | ✅ |