A compact set of questions for reviewing Haze code against the idiomatic standard.
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.
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.
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.