---
title: Std.Vec
---

Mutable vectors via an algebraic effect, backed by ETS composite keys.

## Types

### MutVec

```saga
opaque type MutVec a
```

Opaque mutable vector handle. At runtime this is an Erlang reference
used as a composite key prefix into an ETS table. Elements are stored
at {VecId, Index} and the length at {VecId, 'length'}.

## Effects

### Vec

```saga
effect Vec {
  fun vec_new : Unit -> MutVec a
  fun vec_push : MutVec a -> a -> Unit
  fun vec_get : MutVec a -> Int -> a
  fun vec_set : MutVec a -> Int -> a -> Unit
  fun vec_pop : MutVec a -> a
  fun vec_len : MutVec a -> Int
  fun freeze : MutVec a -> List a
  fun thaw : List a -> MutVec a
}
```

Mutable vector effect. Provides efficient O(1) indexed access and
mutation backed by ETS composite keys.

## Handlers

### beam_vec

```saga
handler beam_vec for Vec
```

ETS-backed handler. Elements are stored in a dedicated `saga_vec_store`
named ETS table with composite keys {VecId, Index}.

