Release v0.4.0Edition 0.2
2.8 Recap and reference
Page 9 of 9
2.8.1 For agents
una --json check . prints each diagnostic with its code, message, primary span and repairs; una --json test . prints each example's outcome. U0007 carries an exact edit, the literal rewritten, which una fix . applies. U5001 gives a counterexample and repairs that are descriptions only (a guard, a wider type, a wrapping or saturating method). U0101, U1001, U1002, U2001 and U2022 depend on intent, so they carry no repair. The compact rule: Int is unbounded and exact, with Euclidean / and mod; money is Int cents; every division by a value that is not a nonzero literal, and every operation or narrowing on U8…U64, I8…I64, is a proof obligation; types never convert implicitly.
2.8.2 Recap
- Every value has a type.
printtakes aText; put a number into one with braces:"{units} units". let name = valuenames a value;let name: Type = valuealso states its type. A body makes each name once.Intis a whole number of any size, so a sum or a product is exact.- Keep money in
Intcents, and divide last:order * 15 / 100. *,/andmodcome before+and-, left to right; parentheses change the order./andmodare Euclidean. A divisor that may be zero is refuted with a counterexample.- A fixed-width type, such as
U8, is for a number of a set size. Every operation on it is proved to fit; wrapping and saturating are methods. - Integer types never mix: convert with
to_int(), or narrow withto_u8()and its proof.
2.8.3 Reference
- Construct pages: source files, comments and literals, functions,
example - Commands:
una check,una run,una test,una fix,una explain - Standard library: the prelude (
abs,min,max) - Diagnostics: U0007, U0101, U1001, U1002, U2001, U2022, U5001
- Specification: lexical structure, grammar, types, dynamic semantics, verification, the standard library, fixed-width integers