---
title: Std.Ref
---

Mutable references via an algebraic effect, with process-local and ETS-backed handlers.

## Types

### MutRef

```saga
opaque type MutRef a
```

Opaque mutable reference handle. At runtime this is an Erlang reference
used as a key into either the process dictionary or an ETS table,
depending on which handler is attached.

## Effects

### Ref

```saga
effect Ref {
  fun new : a -> MutRef a
  fun get : MutRef a -> a
  fun set : MutRef a -> a -> Unit
  fun modify : MutRef a -> a -> a -> a
}
```

Mutable reference effect. Provides create, read, write, and
read-modify-write operations on typed mutable cells.

## Handlers

### beam_ref

```saga
handler beam_ref for Ref
```

Process-dictionary-backed handler. Fast, single-process, no setup needed.
Refs are scoped to the current process and cleaned up on process exit.

### ets_ref

```saga
handler ets_ref for Ref
```

ETS-backed handler. Refs are stored in a shared ETS table, accessible
across processes. Useful when refs need to survive process boundaries.

