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

Rescript frustration

$
0
0

I may not have expressed myself clearly, I fully support the use of results and options. In fact, I use them all the time and find them highly beneficial.

I’m just saying that if there are some results you use only to short-circuit to their ok value and check the error cases only on the boundaries, it’s a smell you might be better off using a more direct style and use exceptions instead of result for these values. Especially given their exceptions can be statically tracked in rescript with reanalyze. In my experience, those cases are the most common use cases for ? or equivalent operators.

Using early returns instead of pattern matching with exhaustiveness check can reduce the help you get from the compiler. When you add a case to your error variant, the early return would just swallow it while the compiler would force you to handle it with pattern matching.

Using a more direct programming style and simpler types also make error messages easier to read for example, code easier to grasp, etc.

I know that when dealing with code that uses “advanced” features like complex monadic infix or let* operators, I need much more time to get familiar with it, so I’d rather use advanced concepts as little as possible.


Viewing all articles
Browse latest Browse all 2592

Trending Articles