rescript-lang / rescript-lang/rescript

Dict : Accessing items with bracket, like an array or object

Open
#8,163 3 comments 0 reactions 1 assignee View on GitHub

@zth is already working on this.

Since Apr 19, 2026.

Dominant language
OCaml
Stars
7.5k
Forks
485
Avg merge
1d 2h
Merged PRs (30d)
55

Description

For adict{}, we can access a value only by using Dict.get

let d = dict{"A": 5, "B": 6, "C": 7}

let a = d->Dict.get("A")

The goal is to also using a bracket syntax, like with arrays or objects (without removing Dict.get, just like Array.get and Object.get still exist)

let d = dict{"A": 5, "B": 6, "C": 7}

let a = d["A"]

This would allow some bindings to use dict{} instead of {..} while keeping the same ease of access to values.


The next step could be variable keys but I created this feature request to propose a smaller step that can already be really useful, without having to wait for variable keys.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.