---
title: "Result"
url: https://una-lang.org/en/docs/std/prelude/Result/
release: v0.4.0
edition: "0.1 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# Result

A kind of the prelude, in scope in every module. Edition 0.1 and later.

```una
pub kind Result[T, E] = Ok(value: T) | Err(failure: E)
```

Either `Ok(value)`, which holds the success value of `T`, or `Err(failure)`, which holds the failure of `E` (`spec/14 §1`).

## Variants

- `Ok(value)`: the operation succeeded; `value` is the success value
- `Err(failure)`: the operation failed; `failure` is the failure

## See also

[`is_ok`](https://una-lang.org/en/docs/std/prelude/is_ok/)

## Example

`src/shop.una`

```una
module shop

--- A quantity checked without failing: the outcome is a value.
checked_quantity(units: Int) -> Result[Int, Text] = if units > 0 then Ok(units) else Err("no units")

describe(units: Int) -> Text
=
  when checked_quantity(units)
    is Ok(n) -> "{n} units"
    is Err(failure) -> failure

pub main() -> Unit
  uses @console: Console[print]
=
  @console.print(describe(3))
  @console.print(describe(0))
```

`una run .` prints:

```text
3 units
no units
```

## Specification

- [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
