reasonml / reasonml/reason

Unify GADT syntax

Open
#555 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

See the discussion here: https://github.com/facebook/reason/issues/491#issuecomment-222324029

We can make GADTs less scary, by making them a natural syntactic extension of regular variant declarations.

One proposal is as follows, but is more verbose, so if you have better ideas, please discuss here:

If regular variant definitions were as follows:

type something = 
  | Constructor (int, int) : something
  | Another (list int) : something;

Then creating a GADT is not such a huge step, and the syntax helps to explain what GADTs are in the first place.

type something 'a = 
  | Constructor (int, int) : something int
  | Another (list int) : something unit;

The only problem is that (as the first example shows), in the case of regular variant definitions, there is a lot of redundancy. I'm hoping someone has a good proposed solution for this.

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 with the linked discussion at https://github.com/facebook/reason/issues/491#issuecomment-222324029 and compare the regular variant and GADT syntax examples in this issue. No implementation files or tests are named. The work is done when a syntax proposal is agreed on and its required implementation and tests are identified.

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
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.