# std/symbolmap

The symbol map of a generated module: for each exported symbol, the source declaration it stands for and any derived facts.

```vyrn
import { symbol, strField, mapJson, symbolMapFn } from "std/symbolmap"

```

The map is a `symbolMap<Slug>() -> String` export baked into the module, so the generator cache, keyed by content, cannot let it go stale. Third-party tools read this JSON:

```vyrn
{ "module": "client(./server/api)",
  "symbols": [ { "name": "pastes.list",
                 "origin": { "file": "server/api/pastes.vyrn", "line": 8,
                             "col": 11, "name": "list" },
                 "derived": { "kind": "rpc", "path": "/_/pastes/list" } } ] }

```

`derived` is whatever `Json` the generator puts there; an empty one is omitted.

## Symbol

`type`, at line 24.

```vyrn
type Symbol = { name: String, origin: Origin, derived: Array<JsonField> }
```

One mapped symbol. `origin` is the `Origin` reflection handed the generator, not one the generator reconstructed.

## symbol

`fn`, at line 27.

```vyrn
fn symbol(name: String, origin: Origin, derived: consume Array<JsonField>) -> Symbol
```

`derived` is `[]` for a symbol with nothing derived about it.

## strField

`fn`, at line 31.

```vyrn
fn strField(key: String, value: String) -> JsonField
```

## mapJson

`fn`, at line 49.

```vyrn
fn mapJson(module: String, symbols: Array<Symbol>) -> String
```

The map document for the generator call `module`, as compact JSON, symbols in emission order.

## symbolMapFn

`fn`, at line 111.

```vyrn
gen fn symbolMapFn(module: String, symbols: Array<Symbol>) -> String
```

The map declaration to append to a generated module.

The JSON goes through a code quote: `\{json}` sits in expression position, so the compiler's own escaping makes it a string literal, with no second escaper to disagree with the lexer. The reader finds the declaration by the `symbolMap` prefix, since `mapSlug` names it.

---

From https://vyrn-lang.github.io/docs/std/symbolmap.html — generated by `site/export.vyrn` from the Vyrn repository.
