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

Should ReScript move more towards explicit control flow?

$
0
0

I think it should move towards being more explicit, especially as we build out the web APIs. I think you have to have getUnsafe to make things easier sometimes when you know what you are doing, and hopefully rewatch can help flag these unhandled exceptions.

If i use fetch I would like for it to return a Result<unknown, FetchError>, and have FetchError be a variant type for the different type errors fetch can throw.

This would be amazing:

let? Ok(response) = await fetch("api/data")
let? Ok(json) = await response->Response.json
let? Ok(data) = json->parseData

No try / catch or .then or .catch but full error handling. It would mean that internal bindings would have to have some amount of runtime code, but we’re all going to write that anyway when using things like fetch. I see no reason to have that burden exist every time I want to use fetch and it would be preferable to have it baked into the official bindings.


Viewing all articles
Browse latest Browse all 2592

Trending Articles