Quantcast
Channel: ReScript Forum - Latest posts
Browsing all 2592 articles
Browse latest View live

Proposing new syntax for zero-cost unwrapping options/results

sure, here’s some from one of my rescript code bases: ... /** Parses three parsers in sequence, returning a triple of their results. All must succeed. */ let seq3 = (p1, p2, p3): parser<_> =>...

View Article


Proposing new syntax for zero-cost unwrapping options/results

Amazing; can’t wait to see this ship!

View Article


Image may be NSFW.
Clik here to view.

Proposing new syntax for zero-cost unwrapping options/results

zth: Before/after code? sorry i missed this. i don’t have it, but you can imagine nesting 5 switches for seq4 im not sure we want to put that into text ever again!

View Article

Proposing new syntax for zero-cost unwrapping options/results

Here is a great example: github.com nkrkv/jzon/blob/master/src/Jzon.res#L2993-L3213 let object25 = ( destruct, construct, field1, field2, field3, field4, field5, field6, field7, field8, field9,...

View Article

Proposing new syntax for zero-cost unwrapping options/results

Maybe not the most common thing in a code base, but I guess it illustrates the point very well.

View Article


Promise helper name

Hi folks, I would like to add helper function to the standard library for Promises: module Promise = { let xyz = ms => Promise.make((resolve, _) => setTimeout(resolve, ms)->ignore) } Usage:...

View Article

Promise helper name

wait (adding characters to reach minimum)

View Article

Promise helper name

I have a PromiseUtils.delay in multiple codebases.

View Article


Image may be NSFW.
Clik here to view.

Type annotation of a variadic function

Hi folks! I need help writing a type that annotates a Javascript variadic function. Maybe this is the wrong angle, so any suggestion is welcomed. I’m currently writing some bindings for Bun’s SQL API....

View Article


Type annotation of a variadic function

Will this work? module SQLQuery = { type t<'a> = promise<'a> } @unboxed type rec param = Boolean(bool) type t type t_query = (array<string>, array<param>) =>...

View Article

Type annotation of a variadic function

Thanks! But that doesn’t work because you loose the variadic output: You suggestion outputs: tx(["strings", "string"], ["param1", "param2"]) // <- params as one array But it needs to output:...

View Article

Confusion about React.useImperativeHandle() first parameter type

I would have expected the first parameter of React.useImperativeHandle() (i.e., the reference) to be of type React.ref<Js.Nullable.t<'value>>. This way, the value can be set by...

View Article

Image may be NSFW.
Clik here to view.

Type annotation of a variadic function

Yeah unfortunately we don’t support this yet ! I’d love to fix this at some point. Don’t hesitate to take a stab at it if you’re motivated

View Article


Promise helper name

What about the obvious sleep ?

View Article

Promise helper name

definitely sleep. what i would ask you to do however is make it cancelable: from one of our internal projects: /*** Async helpers. Utilities for timeouts, cancelable sleeps, and racing promises...

View Article


Promise helper name

Yeah, another thought I had was to pass an AbortSignal. Might make sense to have two helpers really.

View Article

[RFC] @unboxed NaN and infinities

Forgetting to handling NaN and infinities is a common problem when working with floating point numbers. In order to make it easier to handle all cases, we should allow for these unboxed values:...

View Article


Consecutively array map with async

There is a standard JS function called Array.fromAsync. @scope("Array") @val external fromAsync: (array<'a>, 'a => promise<'b>) => promise<array<'b>> = "fromAsync" This...

View Article

Rational numbers

I’ve just started experimenting with Rescript and couldn’t find support for rational numbers, either built into the language or as a library, but I was able to add a quick-and-dirty LLM-generated...

View Article

Rational numbers

There is a hidden feature in ReScript that allows you to overload the basic arithmetic operators. You can add an Infix module to your Rational library and overload them like this: // In Rational.res...

View Article
Browsing all 2592 articles
Browse latest View live