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

# Nat

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

```una
pub kind Nat = Int where it >= 0
```

An `Int` that is at least zero: an `Int` flows into `Nat` where the bound is proved (`spec/14 §1`, `spec/03 §2`).

## Definition

`Int where it >= 0`: an `Int` that is at least zero\; an `Int` becomes a `Nat` where the checker proves the bound.

## See also

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

## Example

`src/shop.una`

```una
module shop

--- The units left on a shelf, which can never be negative.
remaining(stock: Nat, sold: Nat) -> Nat = if sold > stock then 0 else stock - sold

pub main() -> Unit
  uses @console: Console[print]
=
  let left = remaining(12, sold: 5)
  @console.print("{left} left")
  let empty = remaining(3, sold: 5)
  @console.print("{empty} left")
```

`una run .` prints:

```text
7 left
0 left
```

## Specification

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

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).
