Jadpo is experimental and not ready for production. These docs follow the compiler's main branch as of 1 Nov 2026. What's built · Install 0.2.0
jadpo
Reference: Standard library

Standard types

Length

On this page

A length or distance, held in metres to 6 places, written 5km, 45cm, 3inch or 2metre; m is minutes.

Physical quantities; ordered; since Jadpo 0.1.0.

Make one

text.parse(raw, as: Length) reads one from its text; text that isn't one at all fails malformed, such as 5, "" or 1.2.3.

These operations give one: geo.distance, geo.length, units.of and units.sum.

Text, JSON and storage

text.from writes its canonical text, the one form text.parse reads back. JSON sends an object of its parts.

Text JSON
-1.5 metre {"value":"-1.5","unit":"metre"}
0.0254 metre {"value":"0.0254","unit":"metre"}
1000 metre {"value":"1000","unit":"metre"}

It is stored in one column named for the field, of type numeric(38, 6), holding the length in metres (m). 0.0254 metre is stored as 0.0254.

Shown to people

text.format(value, locale:) shows it to people in their locale. A call may also give unit:.

With locale: Locale.en_gb:

Value Shown
-1.5 metre -1.5 m
0.0254 metre 0.0254 m
1000 metre 1,000 m

Operations

  • geo.distance(from: Point, to: Point) -> Length: The geodesic distance between two points on the ellipsoid, rounded half to even to the micrometre.
  • geo.length(line: T) -> Length: A LineString's or MultiLineString's length: each edge measured as distance measures it, and summed.
  • geo.within(a: T, b: U, distance: Length?) -> Bool: geo.contains(b, a); or, with distance:, whether two points are at most that far apart, as geo.distance measures them.
  • units.in(value: Quantity, unit: QuantityUnit, scale: Int, rounding: Rounding) -> Decimal: value in unit, a unit of its kind, as a Decimal of scale places rounded by rounding: units.in(5km, LengthUnit.mile, scale: 2, rounding: Rounding.half_even) is 3.11.
  • units.of(value: Number, unit: QuantityUnit) -> Quantity: value of unit, an Int or a Decimal, as the quantity of unit's kind, converted exactly to the base unit and rounded half to even to the kind's scale: units.of(5, LengthUnit.mile).
  • units.sum(items: List<Quantity>) -> Quantity: The items added up, all of one kind; nothing for no items. A Temperature or a SoundLevel doesn't add to itself, so neither is summed.

Like every standard type, it also has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It is ordered, so < and sorting take it. Every standard type meets one contract says how they work.

Markdown for agents: /docs/types/type-length.md.Built from Jadpo main at e00e61f.