rescript-lang / rescript-lang/rescript

Better callable subtyping for optional parameters

Open
#8,228 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If a function has N required params & additional optional params, it cannot be used in a place that expects a function with N params.

To give a concrete example: Int.toString cannot be directly used with Option.map because of the optional radix argument, so it has to be wrapped in another function.

https://rescript-lang.org/try?version=v12.1.0&module=esmodule&code=DYUwLgBGIM6QvBAFADwFwQPYAcwEtMA7AHj0LAD4BKCeCiAbwCgIIUBaCgeVwMIDoAtgENsSAJLl+YTAGUwAJzIBzKkwC+TJqEjQ4AJlrJ0WXkVLlqtes1YduZgSLEprESWGlzFK1FTXqQA

Tested in sandbox v12.1

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 with the linked ReScript sandbox and reproduce the Int.toString and Option.map example in version v12.1. Investigate the compiler's callable-subtyping behavior for required and optional parameters. Done means Int.toString can be passed directly to Option.map without a wrapper while existing required-parameter behavior remains correct.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.