Packages

• package
Definition Classes
root
• package

The Scala API for Quantities, Units of Measure and Dimensional Analysis

Squants

The Scala API for Quantities, Units of Measure and Dimensional Analysis

Overview

Squants is a framework of data types and a domain specific language (DSL) for representing Quantities, their Units of Measure, and their Dimensional relationships. The API supports typesafe dimensional analysis, improved domain models and more. All types are immutable and thread-safe.

Typedefs and implicits for common usages

Definition Classes
root
Version

0.1

Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package
Definition Classes
squants
• package

Squants Market API

Squants Market API

Market Types are similar but not quite the same as other quantities in the library.

The primary type, squants.market.Money, is derived from Quantity, and its Units of Measure are Currencies. However, because the conversion multipliers between units can not be predefined, many of the behaviors have been overridden and augmented to realize correct behavior.

squants.market.Prices represent a Ratio between Money and some other Quantity. Prices can be created from ratios of Money and a Quantity

```val money: Money = USD(10)
val length: Length = Meters(1)
val price: Price[Length] = money / length```

Multiplying a Price * Quantity will yield Money amount that represents the cost of the quantity

`val cost: Money = price * Meters(3.8)`

and multiplying Price * Money will yield the corresponding Quantity amount

```val budget: Money = USD(250)
val quote: Length = price * budget```

squants.market.CurrencyExchangeRates represent conversion rates between currencies. Use them to explicitly convert Money values in one currency to values in another.

squants.market.MoneyContext provide the implicit context necessary to perform cross-currency operations on Money values with conversions automatically applied.

Some binary math operations will work on Moneys of like Currency with no MoneyContext in scope. Attempts to perform these operations on Moneys of dissimilar currencies will throw an exception at runtime.

Other operations, including direct conversions to other currencies, require a MoneyContext and will not compile without it. However, there is no compile time check to determine if the correct exchange rates will be available at runtime. Operation requiring conversion without the required rates available will throw a NoSuchExchangeRateException at runtime.

The defaultMoneyContext uses the USD as the default and provides a list of ~20 common currencies, and NO exchange rates. If your application requires something different you should initialize your own implicit MoneyContext

Definition Classes
squants
Since

0.1

• package mass

Definition Classes
squants
Since

0.1

• Carats
• ChemicalAmount
• ChemicalAmountConversions
• ChemicalAmountUnit
• Density
• DensityConversions
• DensityUnit
• Grams
• GramsPerSquareCentimeter
• Kilograms
• KilogramsPerCubicMeter
• KilogramsPerHectare
• KilogramsPerSquareMeter
• Kilopounds
• Mass
• MassConversions
• MassUnit
• Megapounds
• Micrograms
• Milligrams
• Moles
• Ounces
• Pennyweights
• PoundMoles
• Pounds
• Stone
• Tolas
• Tonnes
• TroyGrains
• TroyOunces
• TroyPounds
• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

p

squants

mass 

package mass

Source
package.scala
Since

0.1

Linear Supertypes
Ordering
1. Alphabetic
2. By Inheritance
Inherited
1. mass
2. AnyRef
3. Any
1. Hide All
2. Show All
Visibility
1. Public
2. All

Type Members

Since

0.2.3

3. final class ChemicalAmount extends Quantity[ChemicalAmount]

Since

0.1

4. trait ChemicalAmountUnit extends UnitOfMeasure[ChemicalAmount] with UnitConverter
5. final class Density extends Quantity[Density]

Since

0.1

6. trait DensityUnit extends UnitOfMeasure[Density] with UnitConverter with SiUnit
7. final class Mass extends Quantity[Mass] with TimeIntegral[motion.MassFlow]

Represents a quantity of Mass

Represents a quantity of Mass

Since

0.1

8. trait MassUnit extends UnitOfMeasure[Mass] with UnitConverter

Base trait for units of squants.mass.Mass

Value Members

2. object
3. object Carats extends MassUnit
4. object ChemicalAmount extends Dimension[ChemicalAmount] with BaseDimension with Serializable
5. object
6. object Density extends Dimension[Density] with Serializable
7. object
8. object Grams extends MassUnit with PrimaryUnit
9. object GramsPerSquareCentimeter extends AreaDensityUnit with UnitConverter
10. object Kilograms extends MassUnit with SiBaseUnit
11. object KilogramsPerCubicMeter extends DensityUnit with PrimaryUnit
12. object KilogramsPerHectare extends AreaDensityUnit with UnitConverter
13. object KilogramsPerSquareMeter extends AreaDensityUnit with PrimaryUnit with SiUnit
14. object Kilopounds extends MassUnit
15. object Mass extends Dimension[Mass] with BaseDimension with Serializable

Factory singleton for squants.mass.Mass values

16. object

Implicit conversions for squants.mass.Mass

Implicit conversions for squants.mass.Mass

Provides support fot the DSL

17. object Megapounds extends MassUnit
18. object Micrograms extends MassUnit
19. object Milligrams extends MassUnit
20. object Moles extends ChemicalAmountUnit with PrimaryUnit with SiBaseUnit
21. object Ounces extends MassUnit
22. object Pennyweights extends MassUnit
23. object PoundMoles extends ChemicalAmountUnit
24. object Pounds extends MassUnit
25. object Stone extends MassUnit
26. object Tolas extends MassUnit
27. object Tonnes extends MassUnit
28. object TroyGrains extends MassUnit
29. object TroyOunces extends MassUnit
30. object TroyPounds extends MassUnit