3 ms·
That does not warn about using `head`. It wouldn't even warn about an attempt to define `head`, so long as you do so with a call to `undefined` or `error` (whi
by dllthomas 10y ago
That does not warn about using `head`. It wouldn't even warn about an attempt to define `head`, so long as you do so with a call to `undefined` or `error` (which is effectively what's done in the base libraries).
- wyager 10y ago>That does not warn about using `head`. You're right, I didn't realize that. Thankfully, `head` is one of the few common functions that's incomplete, and it's usually pretty obvious what they are. > It wouldn't even warn about an attempt to define `head`, so long as you do so with a call to `undefined` or `error` 1. It's syntactically quite simple to avoid these two. 2. If you're using these, you're obviously aware your program can fail. 3. fdefer-typed-holes was introduced as a better alternative to undefined that warns you when used.
- dllthomas 10y agoIt's syntactically quite simple to avoid those two in your own code. You're not necessarily aware that a library you're using is using these. That said, the community is pretty good at nudging people toward total functions, particularly in commonly used libraries (Prelude notwithstanding). And as you say, it helps that it is generally obvious when non-totality is newly introduced - infinite loops being the biggest exception, but that's unavoidable anywhere you don't have an actual totality checker.