Skip to content

No Money/Currency types: add Semantics.Money (ISO 4217 Currency, Money that refuses cross-currency arithmetic, allocation without lost pennies) #367

Description

@matt-edmondson

What's missing

Phase 3 of the semantic-domains roadmap proposes a Semantics.Money package. None of it exists: there is no project, no Currency or Money type, and no ISO 4217 table.

Plan: docs/roadmap-semantic-domains.md L132-L148

  • Currency (ISO 4217), Money (decimal amount + currency), arithmetic that refuses cross-currency add/subtract at compile or runtime, rounding policies, allocation/splitting without losing pennies, formatting per culture.
  • Explicitly not part of the quantity generator — currency isn't convertible by a fixed constant. Document why (mirrors the log-scale "doesn't obey linear arithmetic" carve-out).
  • FX/exchange-rate handling ... Recommend a minimal ExchangeRate type, no rate sourcing.

The roadmap describes itself as a proposal rather than a commitment, so whether this is still wanted is your call. Phase 0 identifiers, Phase 1 music analysis and Phase 2 Color have all shipped. The roadmap marks Phase 3 as depending on nothing.

Why it matters

The roadmap calls money "the canonical 'primitive obsession' target and the clearest showcase of the semantic-type thesis after strings". Today a consumer who adds a decimal USD amount to a decimal EUR amount gets a number back with no error. A consumer who splits 100.00 three ways with plain division gets 33.33 × 3 = 99.99 and loses a cent.

Decision to confirm first

Open question 3 (L230) asks whether money stays outside the quantity model. The roadmap recommends keeping it out.

Acceptance criteria

  • A new Semantics.Money project that follows the repo's one-package-per-domain layout, with the same target matrix as Strings/Music unless generic math is needed.
  • Currency: ISO 4217 code plus minor-unit digits, with Parse/TryParse/ToString.
  • Money: immutable, a decimal amount plus a currency.
  • Adding or subtracting two different currencies throws, or does not compile.
  • Allocation and splitting keep the total exact; for example, 100.00 split three ways gives 33.34 / 33.33 / 33.33.
  • An explicit rounding policy and culture-aware formatting.
  • Optionally, a minimal ExchangeRate conversion type with no rate sourcing.
  • Documentation of why Money is not a generated quantity.
  • Tests in Semantics.Test.

Dependencies

None.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions