Hacker News new | ask | show | jobs
by earth_walker 1754 days ago
You are absolutely right and I missed the point!

I believe there are a couple of things in the standard library which should have returned a Maybe (or even better taken a NonZero as an argument). The community Extra libraries tend to offer safe versions of these cases, so it's easy to avoid if you know about it.

Another gotcha that will give a runtime error is the stack overflow if you have too many recursions in a function. You can get around it by using builtins like maps and folds, or refactoring for tail-calls.

Since recursion is often taught to FP beginners as the go-to replacement for loops without explaining TCO, I think many users are surprised by this early on, and with just the compiler they would otherwise have no warning of this without knowing how and when to test for it.

I believe Elm-review is coming out with a method to warn about these cases, so it will be detectable with standard tools.

On the whole, though, these are the few avoidable edge cases, and the promise does hold the rest of the time.