3 ms·
I just thought of one more thing. I really like -fdefer-type-errors in GHC and wish Rust has something similar. Both Rust and Haskell are very opinionated in t
by kccqzy 2y ago
I just thought of one more thing. I really like -fdefer-type-errors in GHC and wish Rust has something similar.
Both Rust and Haskell are very opinionated in the way the program is organized. Adding a seemingly small feature can often result in larger-than-expected refactoring. (In Haskell, one might need a new monad transformer layer or convert non-monadic code to monadic; in Rust one might have to rethink ownership patterns or add Rc to many places.) In GHC, type errors can be deferred until run time, until the point where the expression containing the type error is forced. If the expression containing the type error is never evaluated, the program works; if it is, you get an exception raised. This combines especially well with laziness: for example one can find the length of a list even though evaluating the element of the list would result in runtime exceptions. This is useful when I'm halfway through a large refactoring, when there are plenty of errors remaining, but I want to run my test suite to determine whether the parts without compiler errors actually pass their tests.
- mcguire 2y agoAs long as you remember to turn it off after you're finished refactoring. :-) (Yeah, I'm the guy with the co-worker who kept turning off -Wall in C++ because "nobody has time for that".)