Skip to content
No description, website, or topics provided.
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
compile-bench
core/src/main/scala
project
test/src
.gitignore
README.md

README.md

scunits

(or Yet Another Scala Units Library)

scunits is an experimental, extensible library for type-checking dimensional quantities and handling units of measure in scala. Exponents of base quantities (mass, time, etc.) are stored at the type-level in recursive list structures similar to shapeless's hlists, but without any run-time instances. All measurements are stored as Doubles of their appropriate SI unit and only converted to a specific unit when needed.

Features

  • Type safe comparisons, arithmetic and more.
  • All measurements (Scalar) are Value Classes wrapping Doubles. Performance is identical to Doubles once the JIT is warm.
  • New base quantities may be added.
  • Dimensions (Dims), units (UnitM) and measurements (Scalar) may be composed by multiplication and division
  • All SI prefixes (kilo, centi, etc.)
  • Array wrappers (ArrayM) for unboxed arrays
  • < 200k jar file size (for now...)
  • No dependencies
  • Reasonable compilation times: https://github.com/gbeaty/scunits/blob/master/compile-bench/Bench.scala

Using scunits

See: https://github.com/gbeaty/scunits/blob/type-logic/test/src/test/scala/Examples.scala

Getting scunits

scunits is not curretly in a maven repository. You'll have to git clone https://github.com/gbeaty/scunits.git, run sbt publish-local, then add "org.scunits" %% "core" % "0.0.2-SNAPSHOT" to your project dependencies.

You can’t perform that action at this time.