Hacker News new | past | comments | ask | show | jobs | submit login
Learning Haskell – A Racket programmer's foray into the land of Haskell (lexi-lambda.github.io)
132 points by lexi-lambda on March 11, 2015 | hide | past | favorite | 94 comments



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.


You'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.


> You're going to spend all that work using "the author" everywhere and still manage to get my gender wrong ("his")?

As you notice, the poster to whom you are replying clearly goes to a lot of effort to say "the author" repeatedly, rather than 'he' or 'she'. I think that it's fair to assume that one slip-up after such work is a result of innocent inattention rather than a perpetuation of gender biases.


This whole ridiculous subthread is about programmers aggressively refusing to fix bugs. (Misgendering.)


"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.


Eh, 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.


I would be annoyed too if people consistently assume something about me which I'm not, on the other hand, the second meaning of 'he' is to refer to a person without reference to sex.[1]

[1]http://dictionary.reference.com/browse/he

I hope I'm not explaining in a patronising manner.


True, but follow me on a brief hypothetical journey. This takes place in a world where the word "Asian" is defined as people whose ancestors are primarily from Asia, but the second definition is "people regardless of ethnicity."

I can't speak for you, but I'd find it puzzling at best, and a little upsetting at worst.


Already occurs - The word Asian is used for people from East Asia, as well as people from anyhere in Asia regardless of which specific part with no regards to ethnicity.

The word 'Aboriginal' also means Indigenous Australians, with an alternate meaning the indigenous people of a non-specific land.

I'm Asian myself. Might I get annoyed with the word? It's a possibility in another universe. Would I be annoyed by people who use it because they use it differently to what I expect? No.

English is just another language. In javascript you might be annoyed scope for variables is different depending on whether var is present. Are you going to be annoyed at people who use the presence or absence of var to designate whether the variable is local or global, instead of using window.myvar exclusively for global variables?

Well that is your choice, and personally I'd rather be fine with it than to get angry at anyone who use the word Asian or Aboriginal or write javascript differently to what I expect, otherwise I'd be angry a lot, making myself and others more upset than is necessary.

Anyways it was my attempt to empathise with both of them.


Why default to male? Because multiple generation of us got our writing marked wrong if we used a plural pronoun for a singlaur and "he" was the generic. We used he for unknowns and she for the thing we loved (e.g. ships). I would love for an agreed upon generic, and they is just a bad choice.



It wasn't in my high school English book and I doubt there would be so many people using he if it wasn't taught that way.


Why is they a bad choice? It's worked forever and is already part of the language. Languages evolve.


We trade one dimension of uncertainty for two (count) when we know the count. I just write s/he or avoid pronouns altogether.


We did/do that in German too. Some people still ended up being offended.

Go figure.


And as soon as everyone starts using s/he, bigender people get annoyed that heshe wasn't used. It's language...it's difficult to get everyday usage "normalized" into a different direction.


I nowadays just use he or she (or rather: try to stick to that - I fumble at times when writing casually), in german and in english. The german form is longer, because the noun also has a gender there.


> Eh, 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.

I really don't think you came off as far too aggressive at all. You called out a damaging trend and people interested in keeping privilege around didn't like it.


> but then why default to male?

You know the answer: decades (centuries?) of usage defaulting to male.

OP went to great lengths to use neutral pronouns everywhere and you ding him (or her) for one slip up? One of the few people aware of the issues and trying to do good, someone in your camp?

And because of that obsession of yours, a good part of the entire discussion is now derailed.

You need to realize that you are part of the problem.


> You need to realize that you are part of the problem.

Oh my God. It's responses like yours that starkly remind me of how imbalanced it is for a woman in this industry and indeed in life.


I admit it was a bit melodramatic.

In this season of Survivor, there is this deaf woman who wears a Cochlear implant. She can hear okay and it doesn't seem to handicap her much, but she's been bringing it up all the time to her teammates to the point that she's under the constant impression that she's being discriminated against because she's deaf, while the reality is just that she's a subpar competitor and her team is getting tired of her bringing up her deafness all the time while the simple truth is that they really don't care.

Basically, the only person on the show who's making a big deal of her deafness is herself.

Seems to me OP is doing the same thing here.


because 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.


Consider 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.


> the author spent one short paragraph to talk about the OP's choice of pronouns

which was completely unnecessary and added nothing meaningful to the discussion.

(In fact, it was self-contradictory given the insinuation that the OP had to be male in "I don't expect any different from this field.")


I know I default to 'he', personally. I have become increasingly aware of it because I work in a call center at my college and I have to consciously refer to a parent's students as 'he or she'.


What's wrong with "they" as singular 3rd person pronoun? [0]

0. https://en.wikipedia.org/wiki/They_(singular)


I think it's something that's worth pointing out occasionally. Male programmers tend to assume that all other programmers are male. Even if they don't actually think that, it slips out in their language (as in this case).

In this case the error is a little perplexing since the OP's name is "Lexi" which is almost never used as a male name!


Not a lie: I have never encountered the name Lexi before. I would have assumed it to be a made-up pseudonym. Or a reference to a post-modern sci-fi / futuristic book.

If it's short for "Alexis," which is a claim you edited out of your comment, then I'm even more confused, as that name seems to be male preferred within the US.


This conversation got really out of hand really quickly, so I've stayed out of it, but is Alexis really male-preferred? That's an honest question; I don't know. Wolfram Alpha seems to find the opposite.

http://www.wolframalpha.com/input/?i=Alexis

http://www.wolframalpha.com/input/?i=Alexis&a=*C.Alexis-_*Gi...


Definitely didn't register that as a name until you mentioned it. I thought it was just clever alliteration of some reference that I was missing.

I feel silly now.


Fun fact. I have a daughter who goes by Lexi and a former (male) co-worker (Aleksey) who went by Lexy.


This required a throwaway?


No - I just use a throwaway account by default (actually, several of them on different machines) because (a) sometimes I do want to comment on something without having my name attached to it, and (b) it's too much effort to switch between accounts depending on what I want to say.


> Broadly making assumptions about everyone within a particular field is as bad if not worse than someone using an incorrect pronoun.

Not really, minorities have to face stuff like this on a more frequent basis. Gendered pronouns are more than incorrect and are harmful.

> 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.

You can't just sweep away sexism under a rug.


> You can't just sweep away sexism under a rug.

Stereotypes are different than sexism. Some stereotypes are sexist, but assuming that someone is a man when it is likely that he/she is isn't sexist.

Maybe irritating, and rash judgement - but that's stereotypes in general.

Sexism is a belief that one gender is better than the other, or that some gender is bad in some way. Does assuming that someone is a male programmer make them sexist? Not really - not unless you _also_ assume other implications like "women can't program", or other such nonsense. But that's a leap to make.


> Does assuming that someone is a male programmer make them sexist? Not really - not unless you _also_ assume other implications like "women can't program", or other such nonsense. But that's a leap to make.

In my experience I've found people who assume genders to have a reason for assuming. The most common reason is they don't believe women can program as well as men.


You do realize that by saying "in my experience, people do X are more likely to be Y", you're doing the exact same thing you're criticizing?


"(Minorities) who do X are more likely to be Y"

and

"(Privileged) are more likely to reinforce their privilege (because the don't see their privilege and/or want to keep it)"

are two different things.

At face value these to things look the same, but upon examination it's only a convenient simplification.


The first post (who you were assuming stuff about) said nothing about any minorities.

The fact is, regardless of how you paint it, you're making prejudiced assumptions about him/her based the fact that (s)he belongs to the group of "people who write 'he' when talking about coders of unknown gender".

Assuming that (s)he is "privileged" is just yet another prejudice, not a fact upon which to base your opinion.


> Assuming that (s)he is "privileged" is just yet another prejudice, not a fact upon which to base your opinion.

???

Men are more privileged than women, that is fact.


I'd argue a simpler reason is that the vast majority are male.

"Never attribute to malice that which is adequately explained by stupidity."

- As an aside, while I firmly believe that both genders have equal _potentials_, I think that due to various socioeconomic and cultural pressures, genders are _not_ equal at everything in execution, on average. It might take a while for that to happen.


    > You're going to spend all that work using "the author"
    > everywhere and still manage to get my gender wrong
    > ("his")?
Where would you have had the commenter go to establish your gender? You haven't attached your name to the article, but even if you had, it's a name that in many countries is male anyway. Would you have rather the commenter have said 'their'?


> Would you have rather the commenter have said 'their'?

As the poster demonstrated (by using "the author" in almost all places), it is often possible to go without pronouns entirely, at the expense of some repetitiveness or awkwardness. In this case, all that would have been required would have been to change

> The author spends a lot of effort trying to make his functions point-free.

to

> The author spends a lot of effort trying to make functions point free.

or, if the possessive is really important, the awkward

> The author spends a lot of effort trying to make the author's [or just "his or her"] functions point free.

However, as I have said elsethread, I think that this was almost certainly inattentiveness rather than any attempt to perpetuate gender biases.


I personally would have gone with:

> The author spends a lot of effort trying to make their functions point free.


Then your answer to peteretep's question (https://news.ycombinator.com/item?id=9188477) "Would you have rather the commenter have said 'their'?" is 'yes', which is fine.

I agreed with what I took (emphasis: my interpretation, not endorsed by peteretep) to be the subtext of that question, namely that the use of 'their' in that context is undesireable, and argued that it was not the only alternative to a gendered pronoun.


> Would you have rather the commenter have said 'their'?

Yes, of course.


The sentence in question is:

"The author spends a lot of effort trying to make his functions point-free."

You can simply remove the word "his".


Maybe the poster isn't even a primary English speaker and their language uses masculine as the default. BUT sorry that most people when they see anything aggressive from a female they get all worked up. It is a strange phenomenon when most never sees any bias in themselves because they like their mom and sister and they only dislike that woman and that other one oh and maybe the other one. It is so strange.


> You'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.

Wow, you got some really hostile reactions for your politely worded comment. Some of those responses belong on @shithnsays


> But yes, that was both a quest to improve that code and a mere learning exercise.

What was there to improve? It's totally sensible and readable, and you even mention that you had people on IRC tell you the function was fine as it is.


If your first focus is on the usage of "his" in the response then maybe the next language you should consider studying is English.

For starters you might want to read up on gender neutral pronouns. He/She or his/hers can be used in a gender neutral manner, however traditionally the masculine form is used in English when gender neutral is intended.


> maybe the next language you should consider studying is English

Personal swipes are not allowed in Hacker News comments, regardless of how annoying or provocative some other comment may have been.

(I'm inclined to say that pronoun wars shouldn't be, either, considering the madness that this thread devolved into.)


Gender neutral pronouns can only refer to abstract persons

> "The student will have to read this book carefully if he wishes to do well." - OK

> "A student is expected to attend 90% of the lectures, or he will be in trouble." - WRONG, if your audience has women

> "Julia thought she did well on the exam and he was right." - WRONG

> "Julia thought she did well on the exam and they were right." - WRONG


Wow, that's some extraordinary condescension.

They/them/their has been seeing broad adoption as a, y'know, actually gender-neutral pronoun, and it should be encouraged. I know some people prefer he/him/his but

a) many people think that reeks of implicit sexism

b) even ignoring a), elevating that to The One Correct English Way is ridiculous overreach


Claiming that the author is sexist for using "he" in a gender neutral setting, which has been standard practice for decades, is an over-reach.

Is "they" or "him/her" a better way forward? Sure. Is it standard practice? No. Can you infer anything about the author's attitudes by his use of standard English grammar? No.


Meh, I like 'hen'[0] a lot, wouldn't mind seeing a concerted effort to introduce it in English as well. I doubt it would go over well in the states, however.

[0] http://en.wikipedia.org/wiki/Hen_%28pronoun%29


Unfortunately, pronouns are a closed class[1] in English; the possibility of getting people to adopt a new one is vanishingly unlikely. Fortunately, we already have “they”, which has been used as a gender-neutral pronoun in the singular for at least half a millennium.

[1]: https://en.wikipedia.org/wiki/Part_of_speech#Open_and_closed...


Interesting, hadn't heard about closed/open classes in speech. I agree that "they" serves the purpose well, but it's nice to see an explicit, consciousness-raising fix (though it's the ultimate bikeshed politically, everyone feels they're qualified to comment - even me!)


Interesting how you focused on "he/him/his" when I said "He/She" and "his/hers", noting that either gender based term can be used in a gender neutral manner, but that "traditionally the masculine form is used". My point was to indicate that it is common enough that insult should not have been taken to the original post.

I certainly never said anything about "The One Correct English Way".

As for the condescension; yes that was intended. The response was overly hostile and out of line so the condescension was deserved IMHO. Don't worry yourself though Mike; I spread around the condescension equally to all genders.


> I spread around the condescension equally

Please don't spread any more condescension on Hacker News. Although I'm sure you don't mean to, it's one of the worst things you could do to damage this community.


I think I've only seen "they" used as a gender-neutral pronoun once or twice, outside of contexts where the topic itself is gender neutral pronouns. So going by that experience, I don't have much faith in broad adoption if the term can't seem to penetrate usage in writing outside of contexts where people are actively discussing the term itself.


Shakespeare good enough for you? http://itre.cis.upenn.edu/~myl/languagelog/archives/002748.h... or Jane Austen? http://www.crossmyt.com/hc/linghebr/austhlis.html

For more fun facts and rants about gender-neutral they, see: http://itre.cis.upenn.edu/~myl/languagelog/archives/005423.h...

-----

Note: there's a strong difference between gender-neutral they when the gender is unknown, and singular they when the gender is known. Some people actually prefer being referred to with 'they/their' in sentences such as "Mary finished their ph.d. at Oxford". I doubt you'll find much historic precedence for that usage, but the use of 'their' when the gender is unknown/unspecified has a long history.

Well, each to their own.


I myself use they as a neutral pronoun, but I'd suggest that Shakespeare and Austen aren't great examples, especially the former, as the poster was looking for widespread adoption and those authors[1] both use language in ways that are very uncommon.

[1]: this right here is why 'they' as neutral is problematic, as I would have been able to use 'they' unambiguously (instead of 'those authors') had 'they' not grown a singular meaning. It's the point made above about two dimensions rather than one of uncertainty.


Maybe not the best examples, but people do tend to think of the usage as something new, while it's been around forever.

I wouldn't say "they both" is very number-ambiguous, though sure you can always find ambiguous examples, but then language is full of ambiguity and humans still seem to manage fine.


> Maybe not the best examples, but people do tend to think of the usage as something new, while it's been around forever.

To bad then that I never said anything about history, but just widespread adoption. So there is not much need to condescendingly point out Shakespeare and Austen, when they are just tangentially related.


> I don't have much faith in broad adoption if the term can't seem to penetrate usage in writing outside of contexts where people are actively discussing the term itself.

The usage doesn't need to spread beyond discussions of the term itself, because it was already being used long before these discussions. That's why I linked to the articles about Shakespeare's and Austen's usage, they are data. I find it a bit of a stretch to interpret that as me saying "you obviously haven't read Shakespeare and Austen" (in any case, I've never read Austen myself and definitely can't remember what pronouns Shakespeare used from what little we read in school; I leave it to the historical linguists to dig out the usage examples).

Back to the matter at hand, if you want something definitely contemporary, of the five first tweets at https://twitter.com/search?q=they I see two which could have been replaced with "he" ("if someone wants to follow you {he,they}'ll follow", "Never miss an opportunity to tell someone how much {he,they} mean to you.").


> The usage doesn't need to spread beyond discussions of the term itself, because it was already being used long before these discussions.

My mistake. I should have known that someone would take the opportunity to mince words when we're on the topic of language and communication, if it would suit their goal.

To be more concrete: I meant penetrate usage in writing in a contemporary setting. I don't know if it penetrated usage over a hundred years ago if it isn't relevant to written communication today. I communicate with people in this era, not with people from the past. Debating whether using a gendered pronoun obscures meaning or not implicitly refers to communication in this day and age, not the past.


Is that supposed to prove something? Well, I guess it proves that I don't read such classic authors, which is right. My background and experience is more humble, mostly to do with writing and reading things in online forums like this or other contemporary settings.

But if you want to be an elitist and dismiss my experience over not being literate with the classics, go ahead.


(Only on Hacker News -- a discussion on point-free style devolves into a discussion on gender-free style!)


I 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!


Yeah, 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


Ugh, 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.)


> It feels a little redundant to have to manually list out all the elements when the information is known statically, and updating the list will be necessary if the Peg type changes. In Racket, writing a macro for this would be trivial, but alas, this is Haskell. Perhaps there is a way, I’m just not aware of it.

A reasonably clean way would be to define

  data Color = Red | Green | Blue | Yellow | Orange | Purple
    deriving (Enum, Bounded, Show)
and then (e.g. in ghci) you can do

  >> [minBound .. maxBound] :: [Color]
  [Red,Green,Blue,Yellow,Orange,Purple]
I often define the useful function

  enumerate :: (Enum a, Bounded a) => [a]
  enumerate = [minBound .. maxBound]
for exactly this purpose.


Yep, I posted this on r/haskell and someone pointed this out, which is cool. The provided type for Peg didn't derive Enum or Bounded, but it's a good trick to know.


I'm kind of surprised that `enumerate` isn't defined in any standard libraries (as far as I know) since I need it pretty often.

After a while spent programming in Haskell you would probably develop your own mini-library of functions that make your life easier. Another one I often find useful is

  (.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
  (.:) f g = \x y -> f (g x y)
which e.g. allows you to define the absolute distance function

  dist :: (Num a) => a -> a -> a
  dist = abs .: (-)
A fun challenge is figuring out why the definition of (.:) is equivalent to

  (.:) = fmap . fmap

!


> A fun challenge is figuring out why the definition of (.:) is equivalent to

> (.:) = fmap . fmap

> !

Of course it's not really equivalent, since the most general type of the LHS is as you have said, whereas that of the RHS involves functor constraints; but inlining the definition of `fmap` for arrows gives the amusing definition:

    (.:) = (.) . (.)
I tend to figure this sort of thing out by successive eta conversion:

    \f g x y -> f (g x y)
    \f g x y -> (f . g x) y
    \f g x   -> f . g x
    \f g x   -> ((f .) . g) x
    \f g     -> (f .) . g
    \f g     -> ((f .) .) g
    \f       -> ((f .) .)
    \f       -> (.) (f .)
    \f       -> (.) ((.) f)
    \f       -> ((.) . (.)) f
                (.) . (.)
Is there a better way?


Seems like a better name for it would be

  (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
since

  (...) = (.) . (.)

.


    (.:) f g = (f .) . g
This can interestingly be generalized(in a way) to get

    (.::) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> d
    (.::) f g = ((f .) .) . g
and so on.

Since fmap = (.), substitution would get your point free form.


The downside of using (.:) is that it is used heavily in other libraries (Aeson for instance) in a very different context (field accessors, similar in look to json's `:`).


Great read. I've finally taken the plunge and have spent the last 3 weeks extensively studying Haskell in the evenings. My first attempt was a couple years ago, but somewhere between then and now I've grokked something mysterious and it's been easier to dig into. The last 6 months or so has been something like Common Lisp -> Racket -> Haskell, which may have contributed a little.

My long term goal is to write a realtime game server with it, however, I keep flopping back and forth between wrapping my head around the high learning curve and jumping to something more familiar to Get Things Done. It seems the payoff for learning Haskell is intrinsic in and of itself even if I never end up using it, yet I can't help but wonder if I'm spending my time wisely.


This was a great read, I'll be passing it along to anyone wanting to learn Haskell so they can get a good feel for what it's like.

You had some advantages though since you've used Racket in the past.

I feel like your Racket experience helped you draw conclusions that many wouldn't have otherwise. Great work though, I hope you write about more of your experiences.


I'm curious what conclusions you'd say those are... and if they're good or bad conclusions?

That said, I'm sure I'm totally influenced by various languages I've tried in the past. And FWIW, Racket was also plenty far from my first experience with functional programming. I know so many programming languages that I've gotten pretty used to being able to just "pick them up" in a couple of days (Racket pretty much included).

Haskell... not so much.


A little tired, but here are a few things that gave you a very big advantage in your Haskell endeavour IMO.

- Knowing to start from scratch and assuming it's some install issue with ghc-mod (this probably saved you a lot of time) - already knowing partial application and that you can use backticks to take advantage of it in Haskell - just knowing what pointfree means - knowing about hoogle - knowing how to search hoogle and what type of function you needed - having an interest in the asthetics of your code leading to experimentation that seems pointless but teaches you a lot - having confidence/knowledge of being able to just plugin functions/types.

As far as conclusions, I'm mostly commenting on the conclusions you simply made from the types... what people sometimes call "type tetris". Knowing you needed `(a, a) -> Bool`, searching hoogle, then coming to the conclusion of I'll implement it myself and moving on.

For a while it seemed like you were going to get caught in "point free hell" and give up on your task... something I've sadly done in the past.

Then knowing to ask for help in #haskell and /r/haskell really helped you.

I know I haven't really answered your question of "what conclusions you'd say they are"... what I was really trying to say is you made a lot of conceptual leaps I wouldn't expect someone with very little Haskell experience to make.

If I remember I'll try to come back to this tomorrow and look for a few examples of those conceptual leaps.


I know what you mean here, especially wrt Haskell, however I've been recently ploughing through the Standard ML videos hosted by Washington University (which also later apparently goes into Racket and Ruby), and found it has aided my understanding greatly. I'd certainly suggest having a look too, if only for the SML stuff, then maybe having another go at Haskell.

I'd also poke about at the wiki-book 'Write a scheme in 48 hours' (in Haskell) which I've also found useful (although the pdf version has some errors, so I've been preferring the HTML version http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H... )

Apologies if you've already been through these materials! :)

http://courses.cs.washington.edu/courses/cse341/13wi/


It was the same for me. I had two years of production erlang experience before trying Haskell on and it was a rough ride but very worth it (we now use it exclusively in production).


I really enjoyed reading what you've written so far, and I'm hoping you continue to write more.

It was really refreshing to see somebody write about the struggle to pick up Haskell - indeed, I had a lot of the same issues. I often feel the Haskell community is burdened with this stigma of "if you have to ask questions, you're probably too stupid to get it". This is despite the fact that there is actually a really great group of people always willing to help in #haskell. It's primarily an image problem, one a lot of FP languages suffer from.

We need more articles talking about the pain points of Haskell so we can get better at making this stuff accessible. We need to be honest with new starters, tell them it's okay to find this stuff challenging and show them where to find help. More than that, though, we need to think about what we can do in the language to fix some of these pain points in a way that the community is happy with.


Looking forward to reading this too. For the opposite trajectory (Haskell towards Racket) see this page from a little while back: http://artyom.me/learning-racket-1


Yep, that was the inspiration for this. :) I actually linked to it in the short intro bit at the beginning.


Aha! I thoroughly enjoyed reading all that, and do hope you continue. It sounds like you're at or slightly ahead of my level of Haskell experience (I knew you'd need Eq before you did! But then the Applicative stuff was beyond me...), so this is very insightful for me as I wonder whether to try picking it up again.

"Fine. It's good enough. Moving On." made me laugh! It seems like you thought that could be refactored in a much simpler way. Not knowing (much) Racket, it didn't appear super obvious to me how. Were you alluding to a macro or something? How would you do it in Racket?


Ah, no, I probably wouldn't do it any simpler in Racket. Racket tends to de-emphasize more complicated function composition, which tends to serve it just fine. I've always adopted a somewhat pro-functional approach in my usage of the language, but even here there wouldn't really be a distinctly better way to do it.

I guess I was just hoping that Haskell, being a more composition-oriented language in many ways, would have some nice built-in to do that for me.


In concatenative programming languages, composition is the default, and it makes point-free code much easier to write. In Factor, for example, you could write your example as:

    : inexact-matches ( x y -- n )
      [ matches ] [ exact-matches ] 2bi - ;
That is, run both “matches” and “exact-matches” on both inputs, then take the difference of the results. If Haskell had functions of multiple parameters and results, 2bi’s type would look like this:

    (a, b, ((a, b) -> c), ((a, b) -> d)) -> (c, d)


That was an interesting read for me, because I started off with How to Design Programs + Racket, before switching to Haskell.

(I would count Haskell as my first 'proper' language, and prior to all this, I had zero coding experience.)

I experienced a lot of the same detours that you have gone through.

re: point-free code

There's a plug in that you can use, called pointfree (cabal install pointfree). I found that it was more useful to me for experimenting with point-free style than writing my own code in that way.


From a PHP background, I've also been trying out haskell in the evenings, my guide being the learn you a haskell book[1]. So far so good, I've started a little blog[2] to clarify bits that sort of seem confusing to me.

[1] http://learnyouahaskell.com [2] http://haskellrecipes.tumblr.com


Yeah, that feel when Cabal has the wrong version of the dependencies...




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

Search: