Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 564 Bytes

CUSTOM.md

File metadata and controls

16 lines (11 loc) · 564 Bytes

Custom types with units

Warning: this is an experimental feature and may be subject to removal or severe redesign.

Since 0.0.8, you can create add units to any type N you want. It will support arithmetic operations if there is an implementation of Numeric[N] and comparisons if there's Ordering[N].

import io.github.karols.units._
import io.github.karols.units.SI._

val x: WithU[BigInt, metre] = BigInt(100).of[metre]
val y: WithU[BigInt, metre] = BigInt(50).of[metre]

x * y // == BigInt(5000).of[square[metre]]