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

Rescript frustration

$
0
0

you can’t, afaik. they have to be able to share a common type.

i’m just now building the prototype for a bigger project and i decided we are going to explore resscript, but tbh without ? or any form of early returns, using results basically turns the entire project into an endless amount of nested switches. it’s just not feasible, so we might have to start using exceptions to signal errors instead. which isn’t really the route i had imagined.

also, please check out rust’s option and result and just compare the ergonomics with rescript. this should be a rather trivial thing to address because not much code is missing, but we don’t have result’s andThen or options getOrElse in rescript. these are by no means required, but improve the ergonomics of using them.

however, having no if-let (ok, switch can do this but it’s cumbersome), no while-let (again, can be done but quickly becomes convoluted), no break (convoluted), no early return (wreaks havoc on your code base) is becoming more and more difficult, and it makes me feel i constantly have to fight the language. i recall there’s some library (rescript-future or whatever) that sort of helps the situation a little bit, but it turns your functions into sections of maps and flatmaps instead so doesn’t really fix it.

the problem with having no early return is that you can’t “jump out” a few levels of your nested code and thus you have to keep digging yourself deeper and then handle all the return cases at the end of your function. this works if you fragment your functions into really small pieces, but it becomes very cumbersome. early returns are really useful for sanity checks, and combining sanity checks with actual function return results (which you have to do when you have no early returns, since you have to lump them together at the end of the function) makes your code MUCH more difficult to understand


Viewing all articles
Browse latest Browse all 1837

Trending Articles