Contents

This checklist is a practical summary of the idiomatic chapters. It is not a scoring rubric. A "no" answer is a prompt to justify the choice, and a "yes" answer is only meaningful when the surrounding code supports it.

Contracts#

Question Why it matters
Does every public function state its domain? A precondition is the caller's side of the interface
Does every public function state a guarantee worth relying on? A postcondition is the callee's side
Is every non-obvious property in the narrowest type possible? A refinement or invariant removes repeated checks
Are contract predicates pure and named after domain rules? Pure predicates fold and read clearly
Are result names used only in postconditions? Result names are not body variables
Is the function free of parameter mutation? Haze has no old; postconditions see final values
Are loop invariants present where correctness is not obvious? The invariant is the loop's contract
Is -release treated as a performance switch, not a way to hide failures? Compile-time checks remain; runtime checks disappear

Types#

Question Why it matters
Are invalid states unrepresentable? A sum or invariant is stronger than a comment
Are identifiers and measures distinct types? Nominal refinements prevent accidental mixing
Are optional values Option rather than sentinels? Absence becomes explicit
Are fallible operations Result rather than sentinel codes? The caller handles the failure
Are records used for grouped data and sums for alternatives? The shape matches the domain
Is a string used only for genuinely textual data? Enums and sums replace stringly typed modes
Are generic types instantiated explicitly where required? Generic record literals need type arguments
Are refinements constructed with ? when the input is runtime data? Normal construction must be provable

Errors#

Question Why it matters
Is the failure expected by the caller? Expected failure belongs in Result
Is the failure a caller or implementation bug? A bug belongs in a contract, not Result
Does the error type carry enough context to recover? A bare string often loses structure
Is ? used only when the error type already matches? ? requires the exact error type
Is the error mapped explicitly at a boundary? Error domains should not leak silently
Is unwrap absent? There is no unwrap in Haze
Are error paths tested? Success-only tests leave half the API unverified

Mutation and Loops#

Question Why it matters
Is mutation confined to locals and deliberate APIs? Shared mutation complicates contracts
Does a function mutate a parameter? Postconditions see the mutated value
Is a pipeline used for a transformation? map, filter, and fold describe the shape
Is a loop used for a process with state or early exit? A loop is clearer than a contrived fold
Does a loop that accumulates carry an invariant? The invariant explains why the result is correct
Does a range invariant use the terminal boundary correctly? The header is checked at the terminal index
Is cleanup expressed with defer? Scope-based cleanup runs on every exit path
Are deferred calls free of ?, return, and escaping break? These are restricted inside a defer

Modules and Visibility#

Question Why it matters
Is the public surface the smallest that callers need? Every export is a promise
Are helpers private by default? Visibility should be deliberate
Does the module have one reason to change? Cohesion makes contracts easier to reason about
Are imports explicit where a wildcard is not clearly safe? Explicit names avoid collisions
Is the standard library used instead of duplicated code? The library follows the same idioms
Are tests in the module or in a dedicated test file? The runner treats each file as an entry
Are tests in imported modules run separately? Imported tests are not executed by the importer

FFI#

Question Why it matters
Is the capability genuinely unavailable in Haze? FFI gives up contracts, purity, and managed values
Is the extern declaration private? Callers should not depend on the C ABI
Does the public wrapper take and return Haze types? cstr and ptr should not leak into the domain
Are foreign errors translated to Result? Null pointers and error codes are expected failures
Are lengths, ranges, and null pointers checked before the call? The C function will not check Haze preconditions
Is pointer ownership documented and enforced? Haze does not track foreign memory
Is platform variation handled with @cfg? A single extern is rarely portable
Is the boundary module small and tested? The risk should be isolated

Tests#

Question Why it matters
Are boundary values tested? Contracts state laws; tests exercise edges
Are error variants tested? An untested error path is an unverified path
Are checked-construction failures tested through a helper? The test function returns void
Are loop boundaries tested? The terminal invariant check is easy to miss
Are defer ordering and early exits tested? Cleanup order is part of the behaviour
Are tests using assert only inside a test block? Assertions are test-only
Is the test runner invoked on the directory or file that contains the tests? Imported tests do not run implicitly

Readability#

Question Why it matters
Does every helper name a concept rather than restate its body? A name should add meaning
Is the smallest form used for the computation? Expression, pipeline, loop, or recursion should match intent
Are long functions split at domain boundaries? Small functions are easier to contract and test
Are comments reserved for context that is not checkable? A checkable claim belongs in a contract
Is the formatting produced by hz fmt? Consistency removes noise from review
Does the code avoid unnecessary abstraction? A generic helper used once is usually worse than the concrete operation

The Review Sequence#

A practical review reads the code in the order in which the guarantees are established. Start with the types and ask whether the domain is represented precisely. Then read the contracts and ask whether the caller and callee responsibilities are clear. Then read the bodies and ask whether the implementation makes the contracts obvious. Finally read the tests and ask whether the boundary cases are covered.

type Positive = i32 : invariant self > 0

contract Funded(account Account, amount i64) {
    pre amount > 0
    pre amount <= account.balance
}

fn withdraw(account Account, amount i64) Account
    : Funded(account, amount)
    : post r => r.id == account.id
    : post r => r.balance == account.balance - amount
=> Account { id = account.id, balance = account.balance - amount }

The type says what a positive value is. The contract says what a funded withdrawal requires. The postconditions say what the caller receives. The body is an expression because the design has already made the operation total. A reviewer can check each layer independently, and a change to one layer has a clear effect on the others.

The Final Standard#

Idiomatic Haze code makes its guarantees visible at the smallest scope that can carry them. A type carries what it can. A contract carries what the type cannot. A test carries a concrete example. A comment carries the reasoning that none of the others can express.

A function is ready when a caller can read its signature, know what is required, know what is guaranteed, and handle the expected failures without reading the body. That is the standard the rest of the language is designed to support.