# `nupp`
`nupp` is an always available global table that declares the Nupp
standard library. It's available without a `require`.
```nupp
-- You can use nupp and nested modules without any `require` statements.
local text = nupp.codec.json.encode({ok = true})
nupp.log.info("wrote %d bytes", #text)
```
`nupp` and nested submodules within it are available using sub-property access
without the need to require anything. Submodules are loaded lazily on first
access.
See [Standard library](../../learn/runtime/data/standard-library/index.html) for what belongs here and what does not,
and [Modules](../../learn/language/modules/index.html) for how a declared module is reached.
## Submodules
| Module | Description |
| --- | --- |
| `nupp.bitset` | |
| `nupp.browser` | 1 module |
| `nupp.checksum` | Incremental numeric checksums for accidental corruption detection. |
| `nupp.codec` | 4 modules |
| `nupp.crypto` | Cryptographically secure randomness from the provider retained at module load. |
| `nupp.derive` | Generates checked members on a declaration while that declaration is checked. |
| `nupp.digest` | Provider-selected fixed-output message digests. |
| `nupp.events` | Addressed, synchronous events whose payloads are ordinary declarations. |
| `nupp.gpu` | Resident compute buffers over the selected GPU provider. |
| `nupp.hash` | General-purpose noncryptographic hashing. |
| `nupp.hotreload` | Cooperative development hot reload, installed by nupp run --watch. |
| `nupp.io` | nupp.io is bytes: storage for them, and the readers and writers that move them. |
| `nupp.log` | nupp.log is leveled logging whose disabled path is the one it is designed around. |
| `nupp.mac` | Keyed message authentication. |
| `nupp.math` | nupp.math adds the scalar, fixed-width and two-dimensional operations missing from Lua's built-in math table. |
| `nupp.mem` | C storage and the checked views over it. |
| `nupp.peg` | nupp.peg compiles textual parsing-expression grammars into reusable typed matchers. |
| `nupp.profile` | Two profiling channels: one for where the time went, one for whether it went there compiled. |
| `nupp.random` | Deterministic pseudo-random generation with explicit, serializable state. |
| `nupp.reflect` | Semantic type reflection and reflection-driven field codecs. |
| `nupp.runtime` | 5 modules |
| `nupp.serde` | nupp.serde separates logical data from its physical representation. |
| `nupp.services` | Typed service definitions and named implementations within one Lua state. |
| `nupp.simd` | |
| `nupp.store` | Typed keys and the stores they index. |
| `nupp.suspension` | |
| `nupp.system` | Facts about the environment executing the Nupp ABI. |
| `nupp.tasks` | An application task scope. |
| `nupp.test` | Assertions shared by Nupp's bundled test runner and project test suites. |
| `nupp.text` | 2 modules |
| `nupp.time` | |
| `nupp.types` | Compiler-only type inspection and construction inside comptime function declarations. |
| `nupp.uuid` | UUID generation using the implementation retained when this module loads. |
| `nupp.workers` | |
## Types
### `AliasError` _record_
```nupp
record nupp.AliasError
code: string
message: string
end
```
A failed operation on a managed alias.
#### Fields
##### `code`
```nupp
code: string
```
##### `message`
```nupp
message: string
```
### `Closeable` _interface_
```nupp
affine interface nupp.Closeable
terminal close: nosuspend function(takes self: nupp.Closeable): nil
end
```
A resource with a deterministic, consuming close operation.
Declaring `is nupp.Closeable` makes construction and bare type annotations carry the
close obligation automatically. A resource that publishes pending work declares
`flush` on its own contract; closing is the lifecycle common to all resources.
#### Methods
##### `close`
```nupp
close: nosuspend function(takes self: nupp.Closeable): nil
```
###### Arguments
| Name | Type | Description |
| --- | --- | --- |
| `takes self` | `nupp.Closeable` | |
###### Returns
| Type | Description |
| --- | --- |
| `nil` | |
### `Debug` _interface_
```nupp
interface nupp.Debug
debug: function(self): string
end
```
Values with deterministic compiler-generated debug formatting.
#### Methods
##### `debug`
```nupp
debug: function(self): string
```
###### Arguments
| Name | Type | Description |
| --- | --- | --- |
| `?` | `self` | |
###### Returns
| Type | Description |
| --- | --- |
| `string` | |
### `ManagedGroup` _interface_
```nupp
interface nupp.ManagedGroup is nupp.Closeable
flush: function(exclusive self: nupp.ManagedGroup): nil
adopt: function(exclusive self: nupp.ManagedGroup, takes cell: managed(T)): alias(T)
remove: function(exclusive self: nupp.ManagedGroup, handle: alias(T)): T
end
```
A runtime-sized heterogeneous owner group.
`managedGroup` adopts independently managed cells and closes every remaining
resource in reverse adoption order. It is ordinary library code over aliases;
the compiler does not give the group special ownership privileges.
#### Methods
##### `flush`
```nupp
flush: function(exclusive self: nupp.ManagedGroup): nil
```
Cells publish no pending data of their own. Their payloads decide what close
publishes.
###### Arguments
| Name | Type | Description |
| --- | --- | --- |
| `exclusive self` | `nupp.ManagedGroup` | |
###### Returns
| Type | Description |
| --- | --- |
| `nil` | |
##### `adopt`
```nupp
adopt: function(exclusive self: nupp.ManagedGroup, takes cell: managed(T)): alias(T)
```
Moves a managed cell into the group and returns its checked non-owning alias.
###### Arguments
| Name | Type | Description |
| --- | --- | --- |
| `exclusive self` | `nupp.ManagedGroup` | |
| `takes cell` | `managed(T)` | |
###### Returns
| Type | Description |
| --- | --- |
| `alias(T)` | |
##### `remove`
```nupp
remove: function(exclusive self: nupp.ManagedGroup, handle: alias(T)): T
```
Removes an adopted alias and restores its exact original owner.
###### Arguments
| Name | Type | Description |
| --- | --- | --- |
| `exclusive self` | `nupp.ManagedGroup` | |
| `handle` | `alias(T)` | |
###### Returns
| Type | Description |
| --- | --- |
| `T` | |