Skip to content

Units

Culsma uses quantity literals for physical values.

Examples:

text
100uL
37C
10min

Quantity Literals

A quantity is a number with an optional unit suffix.

text
10
12.5
5mL
95C

When an operation expects a physical dimension, the unit must be present and compatible with that dimension.

Common Supported Families

DimensionExamples
TemperatureC, K
VolumeuL, ul, mL, ml, L
Timems, s, sec, min, hr, h, day
Massug, mg, g, kg

Type and unit checks are handled before runtime execution.

The lexer also recognizes additional unit suffixes used by language contracts, including concentration, agitation, field, percent, power, voltage, and dimensionless-style suffixes:

text
ng_per_uL
ug_per_mL
rpm
rcf
xg
Hz
mM
uM
nM
nm
um
pct
%
mW
W
V
X

Not every recognized suffix is valid in every argument position. For example, duration expects a time unit, and capacity expects a volume unit.

Canonical spellings are preferred for new source: s, h, uL, mL, and %. Legacy aliases such as sec, hr, ul, ml, and pct remain accepted for compatibility but produce typecheck warnings where the contract has a canonical unit.

Negative Values

A leading - is expression syntax, not part of the quantity token.

text
-20C

This still behaves as a quantity-like temperature expression for type and unit checking.

Identifier Deferral

When a quantity is stored in a binding, type checking may defer the final value until the identifier is resolved.

text
let t = 37C;
with env(thermal = t, duration = 10min) {
    hold(reactor);
}

This keeps let-bound quantity patterns usable without requiring every value to be retyped at the use site.

Where Unit Errors Appear

Unit problems are typecheck diagnostics, not runtime material errors.

Examples:

  • unknown unit
  • missing unit where a dimension is required
  • volume supplied where time is expected

Runtime remains responsible for state-dependent feasibility, such as insufficient material or capacity overflow.

Released under the Apache-2.0 license.