---
title: "10.10 Recap and reference"
url: https://una-lang.org/en/learn/collections/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 10.10 Recap and reference

## 10.10.1 For agents

:::agents
Every diagnostic of [Common mistakes](https://una-lang.org/en/learn/collections/common-mistakes/#s10-8) is available as JSON with `una --json check .`. For [a `when` that forgets `None`](https://una-lang.org/en/learn/collections/common-mistakes/#a-when-that-forgets-none-u2007):

```json include="mistakes/3/expected/commands/json.txt#L2"
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U2007","severity":"error","domain":"types","message":"`when` does not match variant `None` of `Option`","primary":{"file":"src/report.una","start":{"line":97,"col":3},"end":{"line":97,"col":7}},"related":[],"repairs":[{"rank":1,"escape_cost":0,"description":"add an arm for each missing variant, such as `is None`, or an `else` arm","edit":null}],"explain":"una explain U2007"}],"fixable":0}
```

The repair of U2007 has a description and no `edit`, because the right arm depends on what the absence means. The U0007 of [a brace in JSON text](https://una-lang.org/en/learn/collections/common-mistakes/#a-brace-in-json-text-u0007) carries exact edits, which `una fix .` applies. The compact rule: *a value from `first`, `at`, `get` or `first_where` is an `Option`, used through `when` or `or_else`; a call that changes a list or a map in place is written `edit xs.set(...)` on a `let edit` name; a lambda takes its types from the parameter it is passed to; `map`, `filter`, `fold` and `first_where` declare `fails of` their function.*
:::

## 10.10.2 Recap

:::recap
- A list holds values of one type, from position 0. `append` and `sort` give back new lists; `at` and `first` read one element, as an `Option`.
- `for x in xs` runs its body once per element, in order, and zero times for an empty list.
- A function type, `fn(Int) -> Int`, lets you pass a function by its name or as a lambda, `fn(x) -> …`, whose types come from where it is passed.
- A function type without `uses` or `fails` is pure; a lambda may fail only for a parameter whose function declares `fails of` it.
- Use `map`, `filter`, `fold` and `first_where` for one-expression steps, and `for` for longer ones.
- Group with a map: `get` and `or_else`, then `edit m.set(...)`. A map lists its keys in order, and its keys need an order.
- Parse JSON with a clause or `attempt`, read it with `when` and `get`, and write it with `to_json`.
:::

## 10.10.3 Reference

:::reference
- Construct pages: [functions and lambdas](https://una-lang.org/en/docs/language/functions/), [`for`](https://una-lang.org/en/docs/language/control-flow/for/), [`let edit` and `edit` parameters](https://una-lang.org/en/docs/language/control-flow/let-edit/), [`when`](https://una-lang.org/en/docs/language/control-flow/when/), [`if error` and `if none`](https://una-lang.org/en/docs/language/errors/if-error/), [`example`](https://una-lang.org/en/docs/language/examples/example/)
- Standard library: [the prelude](https://una-lang.org/en/docs/std/) (`List`, `Option`, `append`, `set`, `at`, `first`, `is_empty`, `first_where`, `contains`, `sum`, `sort`, `map`, `filter`, `fold`, `or_else`, `min`, `max`), [maps](https://una-lang.org/en/docs/std/maps/) (`Map`, `Entry`, `empty_map`), [text](https://una-lang.org/en/docs/std/text/) (`join`), [JSON](https://una-lang.org/en/docs/std/json/) (`Json`, `JsonError`, `parse_json`, `to_json`, `quote_json`)
- Diagnostics: [U0007](https://una-lang.org/en/docs/errors/U0007/), [U0101](https://una-lang.org/en/docs/errors/U0101/), [U2001](https://una-lang.org/en/docs/errors/U2001/), [U2007](https://una-lang.org/en/docs/errors/U2007/), [U2010](https://una-lang.org/en/docs/errors/U2010/), [U2020](https://una-lang.org/en/docs/errors/U2020/), [U2025](https://una-lang.org/en/docs/errors/U2025/), [U3001](https://una-lang.org/en/docs/errors/U3001/), [U3003](https://una-lang.org/en/docs/errors/U3003/), [U3007](https://una-lang.org/en/docs/errors/U3007/), [U3009](https://una-lang.org/en/docs/errors/U3009/)
- Specification: [functions and contracts](https://una-lang.org/en/docs/spec/04-functions-and-contracts/) (lambdas), [the standard library](https://una-lang.org/en/docs/spec/14-standard-library/), [the memory model](https://una-lang.org/en/docs/spec/17-memory-model/) (`for`, `let edit`, `set`), [constraints on generics](https://una-lang.org/en/docs/spec/20-constraints-on-generics/), [maps](https://una-lang.org/en/docs/spec/21-maps/), [JSON](https://una-lang.org/en/docs/spec/23-json/)
:::
