15 ms·
The author spends a lot of effort trying to make his functions point-free. For example, the author first writes: inexactMatches xs ys = matches xs ys - ex
by cakoose 12y ago
The author spends a lot of effort trying to make his functions point-free. For example, the author first writes:
inexactMatches xs ys = matches xs ys - exactMatches xs ys
then decides it's not very "nice", and ends up with this:
inexactMatches = pure2 (-) <**> matches <**> exactMatches
I can sympathize with this preference. When I first started learning Haskell, figuring out how to make something point-free was extremely satisfying. And it also increases DRY, which is generally a good thing.
But over time I realized I was overusing point-free style. It was fun to write, but harder to read. If I were actually writing "inexactMatches" for something real, I would strongly prefer the first over the second. From what I've read, I think many people take a similar path when learning Haskell.
That said, I think everyone has a different threshold. For example, I've heard many people say that a for loop is more clear than something like "map" or "fold". I would disagree with that, but maybe that's just because I've gotten used to "map" and "fold".
So maybe the author's brain is just able to handle point-free style better than mine can, but I do think this particular example if far enough on the spectrum that most Haskell programmers would prefer the first version (for real code).
So if you're considering learning Haskell, don't be scared away. You will have to start getting used to point-free style, but probably not to this extreme.
- lexi-lambda 12y agoYou're going to spend all that work using "the author" everywhere and still manage to get my gender wrong ("his")? Okay. I don't really expect any different in this field, but just noting that. Anyway, I'm well-aware of the temptation of writing point-free code. I did include the sentence "I can see the road to hell is paved with point-free style" myself, after all. I wouldn't prefer point-free style if it ends up looking indiscernible, but in this case I sort of wanted a way to express semi-declaratively "this function is the difference between these other two functions". Does the version I ended up with do that? Yes. But for all I knew there could have been a much better, more idiomatic way. But yes, that was both a quest to improve that code and a mere learning exercise. I'm satisfied with the version I ended up with, though I don't think it's perfect, either.
- Guthur 12y ago"Okay. I don't really expect any different in this field, but just noting that." What's being implied here? that because the OP is not omnipotent that there is gender conspiracy? Broadly making assumptions about everyone within a particular field is as bad if not worse than someone using an incorrect pronoun. Just as an aside; everyone has to deal with imbeciles in this field whether it be the pointy haired boss or just gross incompetence, it's not gender specific.
- lexi-lambda 12y agoEh, you're right, that came off as far too aggressive—I didn't really mean it to be. Of course the OP isn't going to be omnipotent, but then why default to male? I know English doesn't have singular gender-neutral pronouns, but I think "they" is acceptable now. And no, obviously I'm not saying people in the field of CS are all misogynist bigots. I'm just saying it's really, really male-dominated, so defaulting to "he" doesn't really cause problems. I'm not trying to attack anyone (and I agree it came off that way, I'm sorry), I just get frustrated when it's a perpetual thing I run into, y'know? Eventually I can get a little terse.
- MAGZine 12y agobecause for many people, not even in CS, 'he' is the default pronoun. There's a trend in writing now to actually use "she," when writing about a hypothetical person who is genderless, rather than "he." But not only could this be construed as sexist (i.e. akin to reverse-racism), but randomly breaking convention can be jarring to the reader. It isn't necessarily, but can be. I'm just saying that I've read some papers by leading feminist theatre art/drama scholars, and even they use the masculine pronoun. Also, I find it annoying that while you adknowledge OP's attempt to be gender neutral, you destroy her (see what I did there?) over a single pronoun, which happens to be gendered but is used neutrally.
- mrbrowning 12y agoConsider that the author spent one short paragraph to talk about the OP's choice of pronouns, while you spent an entire comment taking her to task for it; that her criticism was politely stated, while you employ rank hyperbole in describing that comment as "[destruction]"; that you're expecting someone to be polite and dispassionate who by her own admission has dealt repeatedly with the litany of disappointments and frustrations that come with being a woman in a male-dominated field, while not even meeting that standard of even-handedness in your own comment; and then maybe reconsider how you're devoting your efforts in this conversation. From here it looks like thou dost protest too much, methinks.
- draven 12y agoI guess it goes like this: at first you don't understand a particular construct (pointfree style, monads.) Then when you kinda get it you tend to apply this new tool to everything. After a while it just get "downgraded" to its right place: just another useful tool in your programmer's toolbox. In the case of pointfree style, there's a code golf aspect to it as well, it's kinda fun trying to rewrite a particular expression to eliminate variables and maximize the amount of non-alphanumeric characters!
- lexi-lambda 12y agoYeah, I'm quite willing to admit that point-free style seems to often be more harmful than helpful. The comments on r/haskell also pointed out ($) as an operator of possible over-use, which I think makes sense. I just don't want to abuse parentheses, since, coming from a Lisp background, that probably wouldn't be too difficult. :P
- cakoose 12y agoUgh, that didn't go as planned. 1. Sorry to everyone about the "his". Like most people guessed, I explicitly tried not to use gender, but I slipped up. 2. I didn't mean to imply you were bad at programming. The only goal of my comment was "if you're thinking about learning Haskell, don't be scared off by point-free style". I thought that providing more background would help people understand the temptation, but I should have divorced it more from your decision to use point-free style. (What's funny is that these were things I was aware of and tried to handle well, but still managed to screw up.)