Release v0.4.0Edition 0.2
4.9 Recap and reference
Page 10 of 10
4.9.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. U2004 and U2026 carry exact edits, which una fix . applies: the field's label, and the constraint [T: Eq]. U2007's repair names the missing variant, but the arm's value depends on intent, so add it by hand. U1001, U2001, U2009 and U2025 depend on intent. The compact rule: a record builds with every field labeled; a sum lists its variants with |, and one of a single variant starts with |; a when over a sum matches every variant or ends with else; a public generic function writes the constraint its body needs.
4.9.2 Recap
kind Parcelwith indented fields is a record: build it with every field labeled, and read a field with a dot.- A record never changes: to change a field, build a new record from the old one.
- Records are nominal: two kinds with the same fields are two types. An alias,
kind Sku = Text, is the type it names. kind Zone = Local | National | Abroadis a sum; a variant may carry fields, and a sum of one variant starts with|.value is AtLockertests the variant and gives aBool.whentakes a sum apart: one arm per variant, each binding the fields it uses, orelsefor the rest.- Leave out
elsewhere each variant needs its own answer: a new variant is then reported. - Generic kinds and functions take type parameters,
[T], with the weakest constraint the body needs.
4.9.3 Reference
- Construct pages:
kind,when, constraints on generics,example - Prelude:
Option - Commands:
una check,una test,una fix,una contract - Diagnostics: U0101, U1001, U1002, U2001, U2004, U2007, U2008, U2009, U2025, U2026, U2027, U7001
- Specification: types, grammar, functions and contracts, static semantics, constraints on generics