Closed as not planned
Closed as not planned
Description
This is a feature request.
Example of what I mean (using ReScript 11.1.0-rc.5, uncurried mode, ReScript Core, from my work on rescript-lang/rescript-core#201):
let values: array<JSON.t> = [String("test"), Number(42.)]
// Multiple bindings
@val external stringify: JSON.t => string = "JSON.stringify"
// etc.
// 1. this works fine
let x = values->Array.map(stringify)
// Single binding with optional parameters
@unboxed
type replacer = Array(array<string>) | Function((string, JSON.t) => JSON.t)
@val external stringify: (JSON.t, ~replacer: replacer=?, ~indent: int=?) => string = "JSON.stringify"
// 2. doesn't compile
let y = values->Array.map(stringify)
// 3. but this does
let z = values->Array.map(x => stringify(x))
Would it be possible to make 2. compile and work, too?
We will run into such situations more often when we change the standard library to follow this style for bindings (single binding for with optional arguments instead of multiple bindings for a JS function).
I already ran into this in practice with Core's Int.fromString
which has an optional radix
argument.
In TypeScript, this works fine BTW:
const x = ['test', 42].map(JSON.stringify);
It would be interesting to explore if we can make it work in ReScript, too.
Metadata
Metadata
Assignees
Type
Projects
Status
Done