---
title: "19.2 What edition 0.2 adds"
url: https://una-lang.org/en/learn/editions/what-edition-0-2-adds/
release: v0.4.0
edition: "0.1, 0.2, 0.3, 0.4"
---

# 19.2 What edition 0.2 adds

## 19.2.1 What changes from `0.1` to `0.2`

Edition `0.2` changes four things, each of which this section shows. Every rule this section states for `0.2` holds in `0.3` too, since editions are cumulative:

- **Constructs.** New ways to write code, such as `for` loops and `let edit`.
- **Keywords.** Words that become part of the language, `edit`, `take`, `old` and `together`, and one word reserved for a later edition, `weak`.
- **Rules.** A few rules that are stricter or different, such as the names a kind may take.
- **The prelude.** The functions every module has without an import, some of which become generic.

## 19.2.2 Moving the stock list to `0.2`

Move the stock list of [section 19.1](https://una-lang.org/en/learn/editions/an-edition-is-part-of-the-package/#s19-1) to `0.2`, and two things that `0.1` rejects become possible: a `for` loop with a `let edit` binding, and the interpolation of a whole list.

```diff include="steps/05-edition-0-1..steps/07-edition-0-2:una.toml" title="una.toml"
--- a/una.toml
+++ b/una.toml
@@ -1,7 +1,7 @@
 [package]
 name = "shelf"
 version = "0.1.0"
-edition = "0.1"
+edition = "0.2"
 
 [run]
 entry = "shelf"
```

```diff include="steps/05-edition-0-1..steps/07-edition-0-2:src/shelf.una" title="src/shelf.una"
--- a/src/shelf.una
+++ b/src/shelf.una
@@ -5,11 +5,17 @@
   sku: Text
   units: Int
 
---- The units of every line, added up.
-total(lines: List[Line]) -> Int = lines.fold(initial: 0, step: fn(sum, line) -> sum + line.units)
+--- The units of every line, added up by a loop.
+total(lines: List[Line]) -> Int
+=
+  let edit sum = 0
+  for line in lines
+    sum = sum + line.units
+  sum
 
 pub main() -> Unit
   uses @console: Console[print]
 =
   let lines = [Line(sku: "LAMP-01", units: 4), Line(sku: "DESK-02", units: 1)]
   @console.print("{lines.len} lines, {total(lines)} units")
+  @console.print("{lines}")
```

`una run .` prints:

```text include="steps/07-edition-0-2/expected/output.txt"
2 lines, 5 units
[Line(sku: "LAMP-01", units: 4), Line(sku: "DESK-02", units: 1)]
```

The code of [section 19.1](https://una-lang.org/en/learn/editions/an-edition-is-part-of-the-package/#s19-1) also checks, unchanged, with only the edition line moved to `0.2`: moving forward did not require touching it. The changes to the code are ones the new edition allows. `fold` is still there, and still right; the loop is simply easier to read for some code.

## 19.2.3 The constructs `0.2` adds

Edition `0.2` adds, among others:

| Construct | Where to read about it |
| --- | --- |
| `for` loops, `let edit`, `edit` and `take` parameters, and `if` without `else` as a statement | [Repeating: `for`](https://una-lang.org/en/learn/loops/), [`edit`](https://una-lang.org/en/learn/memory/passing-a-value-in-and-out-edit/#s16-2), [`take`](https://una-lang.org/en/learn/memory/giving-a-value-up-take/#s16-3), [`if` without `else`](https://una-lang.org/en/learn/choices/every-form-of-if/#s8-1) |
| `together` and `together for` | [Concurrency and parallelism](https://una-lang.org/en/learn/concurrency/) |
| `Map`, the text functions and `ParseError`, `Json` | [Maps](https://una-lang.org/en/learn/collections/maps/#s10-4), [the text functions](https://una-lang.org/en/learn/text-and-conditions/working-with-text-the-preludes-functions-and-method-calls/#s3-2), [`ParseError`](https://una-lang.org/en/learn/failure/failures-as-values-attempt-and-result/#s7-4), [JSON](https://una-lang.org/en/learn/collections/json/#s10-5) |
| Fixed-width integers such as `U8` and `I64`, with proven overflow | [Numbers](https://una-lang.org/en/learn/numbers/fixed-width-integers/#s2-3) |
| Constraints on generics such as `T: Ord`, and `sort` | [Constraints](https://una-lang.org/en/learn/kinds/generic-kinds-and-constraints/#s4-4), [`sort`](https://una-lang.org/en/learn/collections/lists/#sorting-sort) |
| `uses of p` and `fails of p`, header clauses for a function that takes another function as its parameter `p`: the function passed in may then use capabilities and fail, and the caller handles it | [`uses of`](https://una-lang.org/en/learn/capabilities/passing-authority-with-rebinding-and-narrowing/#authority-inside-a-function-argument-uses-of), [`fails of`](https://una-lang.org/en/learn/failure/declaring-a-failure-fails-and-fail/#failing-as-the-function-you-are-given-fails-of), [`uses` in the docs](https://una-lang.org/en/docs/language/capabilities/uses/) |
| The interpolation of any value that `==` compares, except a `Hashed`, a fingerprint of secret data that only a host capability computes and that a program cannot read | [Text and conditions](https://una-lang.org/en/learn/text-and-conditions/text/#s3-1) |
| The `Http` capability | [HTTP in the standard library](https://una-lang.org/en/docs/std/http/) |

## 19.2.4 The keywords `0.2` adds

Edition `0.2` makes four words keywords: `edit`, `take`, `old` and `together`. Each one starts a construct, so in `0.2` none of them can name a binding, a parameter or a field. `edit`, `take` and `together` were reserved in `0.1` already, so no `0.1` package uses them as names. `old` was not, so a `0.1` package may use it, and must rename it to move, as [Why a language needs editions](https://una-lang.org/en/learn/editions/an-edition-is-part-of-the-package/#why-a-language-needs-editions) showed.

Edition `0.2` also reserves a word for a later edition: `weak`. In `0.1` it is an ordinary name, so a `0.1` package may use it, and must rename it to move. This package names a parameter `weak`, for a week when sales are slow. It checks and runs in `0.1`; in `0.2`, each of its three uses is U0103, the first:

```text include="steps/20-weak-0-2/expected/rendered.txt#L1-L10"
[U0103] Error: `weak` is reserved for a later edition (aliasing)
   ╭─[ src/restock.una:4:26 ]
   │
 4 │ weekly_order(units: Int, weak: Bool) -> Int = if weak then units / 2 else units
   │                          ──┬─
   │                            ╰─── `weak` is reserved for a later edition (aliasing)
   │
   │ Help: repair 1: rename it to `the_weak`; edit src/restock.una:4:26..4:30 to "the_weak"
   │
   │ Note: run `una explain U0103` for an explanation
```

The message says that the word is kept for a later edition, and for what: aliasing. Here the word is meant as a name, so the rename is right, and `una fix --dry-run .` lists it at every use:

```text include="steps/20-weak-0-2/expected/commands/fix.txt"
$ una fix --dry-run .
fixed src/restock.una:4:26 U0103 rename it to `the_weak`
fixed src/restock.una:4:50 U0103 rename it to `the_weak`
fixed src/restock.una:9:43 U0103 rename it to `the_weak`
```

`una fix .` applies the three renames, and the package checks in `0.2`. A better name, such as `slow_week`, works too.

One word goes the other way. `with` is a keyword in every edition, for `with @catalog = …` ([chapter 12](https://una-lang.org/en/learn/capabilities/passing-authority-with-rebinding-and-narrowing/#s12-4)). From edition `0.2` on, `with` right after a `.` is a name, the method of a map that adds an entry: `prices.with(key: sku, value: 1990)`.

## 19.2.5 The rules that changed

A few rules of `0.2` differ from `0.1`:

- **Built-in type names.** A kind, a variant or a capability cannot take the name of a built-in type such as `Text`, `List`, `Map` or `U8` (U1002). In `0.1`, a kind with a built-in type's name, even `Text`, shadows that type in its module. In `0.2` this is U1002.
- **Equality on type parameters.** A public generic function that compares two values of a type parameter `T` must write the constraint `[T: Eq]` (U2026, [chapter 4](https://una-lang.org/en/learn/kinds/generic-kinds-and-constraints/#s4-4)); `0.1` inferred it.
- **The prelude.** `min`, `max`, `sum` and `contains` become generic over constrained types, and `sort`, `set` and `empty_map` are new.
- **Recursive kinds,** kinds with a field of their own kind ([chapter 8](https://una-lang.org/en/learn/choices/kinds-that-contain-themselves/#s8-4)), no longer need that field inside a `List` or an `Option`, but must be able to end: some variant, such as a `Lit(value: Int)` in an expression kind, holds no value of the kind itself.
- **Test reports.** In `0.2`, a failed example's report shows labeled values, data marked secret or internal ([chapter 17](https://una-lang.org/en/learn/information-flow/)), in full. `0.1` hides only the labeled fields of a record, writing a level such as `<redacted:confidential>` in their place; a labeled value that is not a field, such as a `confidential Int` result, is shown in full there too.

## 19.2.6 What a move from `0.1` can need

So moving a `0.1` package to `0.2` can still need changes, in five places: a name that became a keyword, such as a binding called `old`; a name that `0.2` reserves, such as `weak`, which is U0103; a kind named like a built-in type, which is U1002 in `0.2`; a public generic function that compares values of a type parameter without `[T: Eq]`, which is U2026; and a call that relied on a prelude header of `0.1`. The checker reports each one at its place, with the code and a repair, so the move is a list of small, local changes rather than a search through the package.

## 19.2.7 Check yourself: a kind named `Map`

This package is in edition `0.1`. It declares a record named `Map`, for a floor map of the store, and it checks and runs:

```una include="steps/08-floor-map/src/shelf.una" title="steps/08-floor-map/src/shelf.una" verified="check, run"
module shelf

--- A floor map of the store: the aisle of a department.
kind Map
  department: Text
  aisle: Int

pub main() -> Unit
  uses @console: Console[print]
=
  let lamps = Map(department: "lamps", aisle: 4)
  @console.print("{lamps.department} in aisle {lamps.aisle}")
```

```text include="steps/08-floor-map/expected/output.txt"
lamps in aisle 4
```

Change only its edition to `0.2`. Does it still check?

:::answer Show the answer
No. From edition `0.2` on, `Map` is the built-in type of maps, and a kind cannot take its name:

```text include="steps/09-floor-map-0-2/expected/rendered.txt"
[U1002] Error: `Map` is a built-in type of maps from edition 0.2, so a kind cannot take its name
   ╭─[ src/shelf.una:4:6 ]
   │
 4 │ kind Map
   │      ─┬─
   │       ╰─── `Map` is a built-in type of maps from edition 0.2, so a kind cannot take its name
   │
   │ Note: run `una explain U1002` for an explanation
───╯
```

The mark is on the name in the declaration. Rename the kind, such as to `FloorMap`, and every use of it, and the package checks in `0.2`. The diagnostic has no exact edit, since the new name is a choice.
:::
