typelevel/squants
58.2
Adequate · 28 September 2026
9.2k
lines of production code
Scala
primary language
2
measurements over time
What this system is
Squants is a Scala library that provides a domain-specific language for type-safe dimensional analysis, representing physical quantities such as length, mass, energy, and time with their respective units. It enables precise unit conversions, arithmetic operations, and cross-platform compatibility across JVM, JavaScript, and Scala Native. The system also includes support for data storage metrics and cross-currency financial calculations, allowing developers to model complex physical and economic domains with compile-time safety.
How it got here
2014 — Core architecture rewrite
24 changes.
The project underwent a comprehensive architectural overhaul, removing all legacy quantity implementations across domains such as motion, space, thermal, and energy. This cleanup was accompanied by the deletion of corresponding test suites and a build system migration to sbt-typelevel with Scala Native support.
2015–2017 — Library expansion and platform support
13 changes.
This period focused on significantly expanding the Squants library by adding comprehensive quantity types across diverse domains such as physics, thermodynamics, and finance. The work also included enhancing core functionality with cross-currency support and extending platform compatibility to include Scala Native.
Features
Add DataRate and Information quantity types with binary and metric unit support
The library now includes new \DataRate\ and \Information\ types in the \squants.information\ package, enabling users to model data transfer speeds and storage sizes. \DataRate\ supports conversion to various units including bytes-per-second (B/s, KB/s, MB/s, etc.) and bits-per-second (bps, Kbps, Mbps, etc.), covering both metric prefixes (Kilo, Mega, Giga) and binary prefixes (Kibi, Mebi, Gibi). \Information\ represents data volume with support for bytes (B, KB, MB, GiB, etc.) and bits (bit, Kbit, Mbit, Gibit, etc.), allowing precise handling of both decimal and binary storage measurements.
shared/src/main/scala/squants/information · high confidence
Add thermal quantity support with Rankine scale and improved parsing
This change introduces the thermal package, adding support for Temperature and ThermalCapacity quantities. Temperature now includes the Rankine scale alongside Kelvin, Celsius, and Fahrenheit, with Kelvin using the standard 'K' symbol (no degree sign). The temperature string parser has been updated to be more flexible with whitespace, handle scientific notation, and correctly parse units using case-insensitive symbols (f, c, k, r) with optional degree symbols. ThermalCapacity is also added with JoulesPerKelvin as its primary unit.
shared/src/main/scala/squants/thermal · high confidence
Added Scala Native platform support with platform-specific formatting
The library now supports Scala Native as a target platform. To ensure consistent behavior across JVM, JS, and Native, a new \Platform\ object was added to each target directory containing a \crossFormat\ helper for uniform Double formatting. On JVM and JS, this helper formats whole numbers with one decimal place (e.g., "1.0") to match JVM's default behavior, while on Scala Native, it falls back to standard string representation because Scala Native does not yet support the same string formatting capabilities.
js, jvm, native · high confidence
Expanded electrostatic and electromagnetic quantity types
The \squants.electro\ package now includes a comprehensive set of new types for electric charge densities (area, linear, volume), charge-to-mass ratio, electric current density, electric field strength, magnetic field strength, conductivity, permittivity, and permeability. Existing core types such as Capacitance, ElectricCharge, ElectricCurrent, ElectricPotential, ElectricalResistance, Inductance, and MagneticFlux have been implemented or expanded with additional unit conversions (e.g., picofarads, nanohenries, microvolts) and cross-dimensional operations (e.g., converting resistance to conductance, charge to capacitance via potential). The package also exposes the Elementary Constant for fundamental physics calculations.
shared/src/main/scala/squants/electro · high confidence
Initial release of the Squants quantity and units of measure library
This change introduces the core Squants library for Scala, providing a domain-specific language for representing quantities, units of measure, and dimensional analysis. It adds foundational types such as \Quantity\, \Dimension\, and \UnitOfMeasure\, along with specific implementations for physical quantities including length, mass, time, and energy. The release also includes support for dimensionless quantities (e.g., percent, dozen), metric and binary system multipliers, vector operations via \SVector\, and quantity ranges. Additionally, it defines photometric quantities like illuminance, luminance, and luminous flux, enabling type-safe dimensional analysis and conversions across these domains.
shared/src/main/scala/squants · high confidence
Introduce space quantity types and units
Adds the core space dimension types—Angle, Area, Length, SolidAngle, and Volume—along with their respective unit definitions and conversion helpers. This enables users to model and convert spatial measurements, including support for SI units, US customary units, astronomical units (parsecs, light-years), and specialized units like barns and electron-volt lengths.
shared/src/main/scala/squants/space · high confidence
Introduction of cross-currency money operations and exchange rate support
This change introduces a new market module that enables working with multiple currencies. It adds \CurrencyExchangeRate\ for defining rates between currency pairs and \MoneyContext\ to manage a set of currencies and exchange rates, allowing implicit cross-currency conversions, additions, subtractions, and comparisons. The \Money\ class is updated to support these operations via the context, and a \Price\ type is added to represent ratios between money and other quantities. The default context is initialized with a broad set of fiat and cryptocurrency currencies (including BTC, ETH, LTC, and various national currencies) but with no exchange rates by default.
shared/src/main/scala/squants/market · high confidence
New energy, power, and derived quantity types
The library introduces a comprehensive set of new quantity types in the energy package: Energy (with units like Wh, J, eV, Btu, and Ergs), Power (W, kW, MW, GW, Btu/hr, Ergs/s, and Solar Luminosity), PowerRamp (W/h, W/m, etc.), SpecificEnergy (Grays, rads, erg/g), EnergyDensity (J/m³), MolarEnergy (J/mol), and PowerDensity (W/m³). It also adds a KineticEnergy helper and operator overloads for Energy \* ParticleFlux = Irradiance, enabling users to model radiological and thermodynamic quantities alongside standard energy and power metrics.
shared/src/main/scala/squants/energy · high confidence
New mass-related quantity types and units
The mass package now includes new quantity types for AreaDensity (with units like kg/m² and lbs/acre), ChemicalAmount (moles and pound-moles), Density (supporting prefixes from nano to kilo for both mass and volume units), and MomentOfInertia (kg·m² and lb·ft²). The existing Mass dimension has been expanded with new units including Stone, Troy weight units (grains, pennyweights, ounces, pounds), Tolas, Carats, Solar Masses, Daltons, and electron-volt mass equivalents (eV to EeV).
shared/src/main/scala/squants/mass · high confidence
New motion and rotational dynamics quantities added
The \squants.motion\ package now includes new quantity types for linear motion derivatives (Jerk, Yank), rotational dynamics (AngularAcceleration, Torque, MomentOfInertia), and additional units for MassFlow, VolumeFlow, Pressure, and Momentum. Users can now perform calculations involving these physical quantities, such as converting between angular and linear acceleration via radius, or computing torque from moment of inertia and angular acceleration.
shared/src/main/scala/squants/motion · high confidence
New radiological and radiometric quantity types in the radio package
The \squants.radio\ package now includes a comprehensive set of new quantity types for radiological and radiometric measurements. Users can now work with Activity (Becquerels, Curies, Rutherfords), Dose (Sieverts, Rems), Irradiance (Watts per square meter, ergs per second per square centimeter), SpectralIrradiance (Watts per cubic meter, per nanometer, per micron, and per angstrom), ParticleFlux, AreaTime, Radiance, RadiantIntensity, SpectralIntensity, and SpectralPower. These additions enable precise unit conversions and arithmetic operations specific to radiation and light intensity domains, such as calculating energy from irradiance and area, or converting between different spectral density units.
shared/src/main/scala/squants/radio · high confidence
New time-related quantity types and conversions
This change introduces new quantity types for frequency (Hertz, Kilohertz, etc.) and refined time handling, including a new Time class with explicit conversions to and from Scala Duration, and support for second-order time derivatives via TimeSquared. Users can now work with frequency units like MHz and GHz, convert time values to Scala's Duration type while preserving unit semantics, and perform calculations involving squared time intervals.
shared/src/main/scala/squants/time · high confidence
Removals
Removal of Market module components
The \squants.market\ package has been removed, deleting the \CurrencyExchangeRate\, \MoneyContext\, \Price\, and \package.scala\ files. This eliminates the library's built-in support for currency definitions, exchange rate management, cross-currency money conversions, and price ratios.
src/main/scala/squants/market · high confidence
Removal of energy and radio quantity definitions
The \squants.energy\ and \squants.radio\ packages have been removed from the library. This deletion eliminates the definitions and unit conversions for energy-related quantities (such as \Energy\, \Power\, \PowerRamp\, and \SpecificEnergy\) and radio-related quantities (including \Irradiance\, \Radiance\, \RadiantIntensity\, \SpectralIntensity\, and \SpectralPower\). Users relying on these specific physical quantity types and their associated string parsing or conversion helpers will no longer have access to them in this version.
src/main/scala/squants/energy · high confidence
Removal of legacy core quantity types and conversion traits
The \BinarySystem\, \Dimensionless\, \MetricSystem\, \Quantity\, \QuantityRange\, \Ratio\, and \UnitOfMeasure\ files have been deleted from the \squants\ package. This removes the original implementations of the quantity hierarchy, unit conversion logic (including \UnitConverter\ and \UnitMultiplier\), and dimensionless units (such as \Each\, \Dozen\, \Score\, and \Gross\), indicating a significant architectural shift or replacement of the core quantity model.
src/main/scala/squants · high confidence
Removal of legacy electro package files
The legacy implementation files in the \squants.electro\ package (including \Capacitance.scala\, \Conductivity.scala\, \ElectricCharge.scala\, \ElectricCurrent.scala\, \ElectricPotential.scala\, \ElectricalConductance.scala\, \ElectricalResistance.scala\, \Inductance.scala\, \MagneticFlux.scala\, \MagneticFluxDensity.scala\, \Resistivity.scala\, and \package.scala\) have been deleted. This change removes the previous definitions of electrical units and quantities, indicating a migration to a new underlying model or structure for the electro domain.
src/main/scala/squants/electro · high confidence
Removal of legacy space quantity definitions
The \Angle\, \Area\, \Length\, \SolidAngle\, and \Volume\ classes, along with their associated unit objects and conversion helpers in the \squants.space\ package, have been removed from the codebase. This change eliminates the previous implementations of these spatial quantities, indicating they are no longer part of the library's public API or are being replaced by a different implementation strategy.
src/main/scala/squants/space · high confidence
Removal of legacy time, frequency, and derivative models
The legacy \Time\, \Frequency\, \TimeDerivative\, and \TimeIntegral\ classes and their associated unit objects (such as \Hertz\, \Seconds\, \Milliseconds\) have been removed from the \squants.time\ package. This change eliminates the previous model where frequency was treated as a derivative of dimensionless counts over time and where time quantities relied on specific implicit conversions to Scala \Duration\. Users will no longer have access to these specific types or their factory methods (e.g., \Hertz\, \Seconds\, \Time.apply(String)\), requiring migration to the updated quantity model.
src/main/scala/squants/time · high confidence
Removal of mass-related quantity classes and units
The \ChemicalAmount\, \Density\, \Mass\, and \mass\ package object files have been deleted from the source tree. This removes the library's support for mass-based quantities (such as grams, kilograms, pounds), chemical amounts (moles), and derived units like density, effectively stripping these types from the \squants.mass\ package.
src/main/scala/squants/mass · high confidence
Removal of motion package quantities and types
The entire \squants.motion\ package has been removed from the library. This change deletes all source files defining motion-related quantities and their units, including \Acceleration\, \AngularVelocity\, \Force\, \Jerk\, \MassFlowRate\, \Momentum\, \Pressure\, \Velocity\, \VolumeFlowRate\, and \Yank\, along with the \Direction\ and \Vector\ types previously defined in the package object. Users relying on these specific motion quantities will no longer have access to them in this version.
src/main/scala/squants/motion · high confidence
Removal of photo package luminous quantity definitions
The \squants.photo\ package has been removed, deleting all definitions for luminous quantities including \Illuminance\, \Luminance\, \LuminousEnergy\, \LuminousExposure\, \LuminousFlux\, and \LuminousIntensity\, along with their associated unit objects (e.g., \Lux\, \Lumens\, \Candelas\) and conversion helpers. Users relying on these specific photometric types will no longer have access to them in this library version.
src/main/scala/squants/photo · high confidence
Removal of thermal quantity definitions
The Temperature, ThermalCapacity, and related unit definitions in the squants.thermal package have been removed from the library. This deletion eliminates the ability to represent and convert temperature values (Celsius, Fahrenheit, Kelvin) and thermal capacity (Joules per Kelvin) quantities, as well as the associated conversion logic and string parsing for these types.
src/main/scala/squants/thermal · high confidence
Test coverage
Added comprehensive test suite for Squants library; Removed legacy ScalaTest and ScalaCheck tests for space quantities; Removed legacy ScalaTest specs and Scalacheck properties for the electro package; Removed legacy energy package test suites; Removed legacy market test suite; Removed legacy motion package tests; Removed legacy test suite for core quantity types; Removed legacy test suite for mass quantities; Removed legacy test suite for time-related quantities; Removed obsolete thermal test suite; Removed radio package test suite.
Dependencies
Migrate to sbt-typelevel and add Scala Native support
The build system has been refactored to use the sbt-typelevel plugin, updating the organization to org.typelevel and setting the base version to 2.0. This change introduces cross-compilation support for Scala Native alongside existing JVM and JS platforms, while also consolidating build settings and enabling a separate documentation module using Mdoc.
(dependencies) · high confidence
Housekeeping
Cleaned up stale sbt build cache files; Initial repository setup and documentation; Removal of local Maven repository cache and build artifacts.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 60 → 58 (-1.5)
- Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.
Lenses
- Code Health 95 → 95 (+0.0)
- Architecture 100 → 81 (-19.0)
- Maturity 47 → 46 (-0.5)
- Readiness 63 → 63 (+0.0)
- Security 65 → 65 (+0.0)
Resolved (2)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
New (1)
- Projects may be oversized for their cohesion
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
typelevel/squants was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 28 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 29aa57f4a1958daf9a5a397cca8982b1654e164c — the exact code this score is about.
- Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.