Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>I'd hardly call it unidiomatic though, you just normally use "read" instead of "unsafeRead", etc.

Isn't "idiomatic" defined by what you "normally" use?



Does using a less commonly used function for its intended purpose make the code unidiomatic?


If the goal of using the less commonly used functions is performance, then it probably does.

I mean: it's not like the specific problem domain needed a "less commonly used function" (e.g. you need a function to do X, where X is something that you rarely need to perform).

Rather it's: "we need to code A, but we will use less commonly used functions instead of what we'd normally use for A, just to get more performance".

Plus, it's not like you merely exchange function f with g, while all other factors stay the same. The choice of those "less commonly used functions" also affects other aspects of the program's design (e.g. making it into a more imperative style, going for unsafe, opting for mutability, etc).

So the interesting question to call it idiomatic or not, for me, is:

"If ultimate performance wasn't a factor, would a Haskell programmer write this program in the same way?"


>Plus, it's not like you merely exchange function f with g, while all other factors stay the same

Yes, it is exactly like that. That was the point. It is literally changing out the name of a function. It has absolutely no effect on the rest of the code. Which is why the code is idiomatic by any reasonable definition.


If the only differences between the functions are the names and the performance characteristics, then why even bother having the slower versions? There has to be some difference somewhere, right?


Are you serious? Read the thread.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: