Skip to content

feat: support string-keyed maps #50

@danwt

Description

@danwt

Summary

Specl only supports integer-range-keyed dictionaries (Dict[0..N, T]). String keys are not available, requiring manual mapping of named entities to integer indices.

Problem

Quint and TLA+ use string-keyed maps naturally:

// Quint
const resourceManagers: Set[str]  // {"rm1", "rm2", "rm3"}
var states: str -> ResourceManagerState
states.get("rm1") == Working

// Specl today
var rmState: Dict[0..2, 0..3]  // 0=rm1, 1=rm2, 2=rm3
rmState[0] == 0  // what is 0? which RM? which state?

Impact

Minor compared to sum types and sets — the integer-index encoding works fine mechanically. The main cost is readability: named entities like "rm1", "wolf", "goat" become anonymous integers.

Desired Behavior

Support string literal keys in dictionaries, or at minimum named constants that can serve as dictionary keys.

Context

Identified during Quint-to-Specl benchmark translation. All 7 translated specs used integer indices. See sidequests/quint-apalache-benchmark/README.md Section 3.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions