Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

How to compose async results?

$
0
0

Imho, the problem here has nothing to do with rescript, but rather the function coloring that happens with async in particular. The reason this doesn’t become as apparent in e.g. js or ts is because the typing is basically non-existent in both those languages (ts typing is broken).

The solution would be an async pipeline (specifically tailored for async function composition or chaining). It’s rather trivial, you could basically just replicate Result and replace or add async functions, such as mapAsync which does the await explicitly (or uses Promise.then, or whatever you like).

If there’s any criticism to direct toward rescript here, it’s likely that the stdlib is a bit lackluster in certain areas. compare Result/Optiion with equivalents in rust - rust provides a much better toolbox here. this is even worse for async functionality in rescript: the language provides async constructs on a syntax level (fairly recent tbf), but the stdlib is not up to par to support that. so you have to roll your own functional extensions here.


Viewing all articles
Browse latest Browse all 2592

Trending Articles