reasonml / reasonml/reason

Syntax proposal `if let`

Open
#1,301 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Parser RFC
Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

In swift, there's this nice construct for simple destructuring

if case .someEnumVariant(let value) {
 ...
} else {
 ...
}

It's basically a one-armed match.
It would be super handy to have that for reason, and I imagine it would look like

if let [%pattern] = [%value] {
  // x
} else {
  // y
}

which we'd translate to

switch [%value] {
| [%pattern] => // x
| _ => // y
}

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by comparing the proposed if let form with the existing switch form described in the issue. The issue names no files, tests, or entry points. Done would require an agreed syntax and corresponding implementation and tests, but the work appears to be an open design proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.