Alchemist
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
Download
[versions]
alchemist = "0.2.0"
[libraries]
alchemist = { module = "io.github.kevincianfarini.alchemist:alchemist", version.ref = "alchemist" }
Alchemist's Goals
- 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 or Rankine degrees for .
Alchemist's Non-Goals
- 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 Support