rescript-lang / rescript-lang/rescript-lang.org

Document objects, row polymorphism and constraints

Open
#394 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
MDX
Stars
1.9k
Forks
260
Avg merge
3d 9h
Merged PRs (30d)
17

Description

For example a document explaining these would be useful

type userLike<'a> = {.."name": string} as 'a

let extractName: userLike<_> => string = user => user["name"]

let name = extractName({"name": "John", "age": 20})
let name' = extractName({"name": "John", "age": 20, "username": "siever"})
 
let name'' = extractName({"age": 20, "username": "siever"}) // type error shuold have "name" field


type user = {"name": string}
let user = {"name": "John"}

type userWithAge = {"name": string, "age": int}

let userWithAge = {"name": "John", "age": 21}

// Printing name for a type with subtypes
[user, (userWithAge :> user)]
    ->Array.map(user => user["name"])
    ->Array.forEach(Js.log)

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.

Research direction

Start from the issue's two ReScript examples and identify how the documentation currently covers document objects, row polymorphism, constraints, and subtype-like records. Explain the successful cases and the expected type error for the missing name field, with examples that make the behavior and completion criteria clear.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.