What’s Wrong with Learning Haskell

The Haskell Logo. There’s also a public domain...

Image via Wikipedia

This is in response to the recent State of  Haskell survey. They asked what Haskell’s main weakness or blind spot was and I couldn’t stop typing. Instead of leaving a comment on the survey, I thought I’d write it down here.

First of all, I like Haskell a lot. I’m the Thompson in “Thompson-Wheeler Logo.” That cute shape that cleverly combines the lambda and monad bind shapes? My idea. The irony is not lost on me. That Haskell logo of mine is used all over the world, and yet I’m barely a mediocre Haskell programmer.

I’m getting better at using Haskell to accomplish things I care about. But I think my experience in learning the language has been a little harder than it needed to be. I don’t want to imply that this is anyone’s fault but my own. But perhaps my experience can serve as a warning to someone. See that hole? It is, indeed, a dark hole. It is not of interest to you, programmer.

In order to communicate not only to programmers like me but also to some of the Haskell “formalists,” I’ll try to map my informal statements to some formal writing tools. Now I’ll be the first to admit that all the pairs in the mapping will contain informal terms, which ruins the formality of it all. Hopefully you formal folks will find it helpful. If you didn’t or barely understood that, it wasn’t for you, which is a point we’ll revisit many times here.

(Motivation)

I’ve been around a lot of language communities. Haskell’s is my clear favorite. Haskell people are happy and helpful, which is unheard of for a programming community.

Despite this, for me it has still often been difficult to find answers to my questions. I think this is largely due to the fact that, when discussing things with the average (serious) Haskell programmer, I feel like I have a fourth grade education. I took some discrete math as part of my CS education, but I have too little math background to understand a lot of what I hear.

I think especially early on that I could have had an easier time. Some mechanism to steer me away from some Haskell resources would have helped. I’m not sure what that mechanism might have looked like, so I handwave over the details here. Perhaps you formalists know handwaving over the details as the “Axiom of Choice,” no? I hearby invoke it.

For instance, (Or in formal terms, Example 1.1)  I tried to get in tune with the current practice of Haskell by lurking on Haskell-Cafe. It worked when I was learning Ruby. Not here. This was a bad idea. I learned nothing and it made me feel bad. Yeah, poor me.

Another time (Example 1.2) I tried to read the Comonad Reader blog. Another bad idea.

As a relative Haskell newbie, whose not-Haskell day job is web development, integrating systems, build engineering, tormenting managers, and sometimes just writing a lot shell scripts, Haskell-Cafe and the Comonad Reader are, and this important, don’t miss this: not for me.

Let’s be a bit more formal and state this as an axiom.

(Axiom 1) Again, I’m not sure how I could have known this, but it would have been nice if there was some way (Axiom of Choice?) that I could have known that these resources were, here it is: not for me. Those are for other people with different backgrounds and extremely different goals. We’ll call this the Axiom of Not for You. The italics are important. We don’t want confuse this axiom with the similar axioms of not for you, not for you, or the less emphatic not for you. This is the Axiom of not for you.

(Axiom 2) Despite the relatively small size of Haskell community compared to others, it’s ratio of diversity to headcount is higher than one might expect coming from, say, the Ruby community. This the Axiom of Not All Haskell Programs are Programs.

(Example 1.3) For instance, I’m a Ruby programmer. As someone who does his share of Ruby programming, I can take anything I read about Ruby and understand what it means to me.

And it’s easy to see why. Because at the end of the day, when people write Ruby programs, they are hoping to end up with a program. It’s is a program. You feed it to a computer which runs it. The computer, as a result does some useful work. I understand that.

Works on My MachineBut, it turns out, Not All Haskell Programs are Programs. There are people, I kid you not, who write these super elaborate Haskell programs, compile them, and consider their work done. I know. Inconceivable! They don’t even get a “Works on My Machine” sticker, because they don’t even know!

But when you understand that Not All Haskell Programs are Programs, it’s perfectly clear. Apparently those programs are really proofs encoded into Haskell’s type system, which is neat. If it compiles, and if you followed a few rules and understand a little Denotational Semantics, well then, you win! Yay! I can’t begin to tell you how happy I am for you. But the Axiom of Not for You applies here. I don’t need to understand that proof, maybe not ever. Those people are not programming, they are proving stuff. Proving stuff is not programming. Curry-Howard isomorphism notwithstanding, for my practical purposes, proofs are not programs.

(Example 1.4) Imagine that a nice girl with a dual background in programming in Haskell and driving steam rollers realized one day that some Haskell programs are steam rollers, and could, in fact, be used to steam roll. Roads. She also has a blog and writes this up. I stumble across this article. Using the previous axioms I would clearly understand that while it is an interesting and possibly revolutionary discovery that some Haskell programs can be used to steam roll, steam rolling is not programming. A steam roller is not a program and applications of steam rolling are not for me.

As to the mechanism to solve this, I think we need to realize that there are some workaday programmers like me looking to get a leg up on some of our harder problems. We value Haskell’s type system. Watching a program work perfectly the first time it compiles is a foreign yet pleasant experience. Getting more reliable code with less unit testing overhead is fabulous. Quick check is so neat I ported it to JavaScript.  And having an LOC count the size of a Python program but running with the performance of a C++ program is what motivated me to look at Haskell in the first place. Even slow unoptimized Haskell seems scary fast to me.

But, people like me need to be both steered to right learning resources, such as Learn You a Haskell or Real World Haskell, and steered away from the writings of Logicians and Type Theoreticians. My problem was that, not only did those two good books not exist yet, there wasn’t, and still isn’t, a mechanism to steer workaday programmers like me away from stuff we aren’t ready for yet.

So my humble suggestion, in all seriousness, is for the community to help the noobs not only with positive advice, like read LYAH, but also to steer clear of, or at least not worry about, say, automatic differentiation of types.

Thanks for reading.

About these ads
Explore posts in the same categories: Uncategorized

22 Comments on “What’s Wrong with Learning Haskell”

  1. Jinwoo Lee Says:

    Good writing! This is why I used to love Haskell but now I’m away from it. Too many experimental/theoretical things hurt my brain. Recently I started to learn Ocaml and it feels much easier to grasp and much more practical than Haskell though its syntax is less clean and more verbose.


    • I’m not planning on leaving Haskell any time soon, if anything I plan to work at it more. I find using it uniquely pleasant, at least on good days. I took at look at ML, probably not a long enough look, but it didn’t push my buttons. I can appreciate the practicality of it though.


  2. Thanks — that’s useful! I’m just starting out in Haskell and am also regularly frightened by the fact that much of the material on Haskell online seems to have been written by and for people with four more brains than me. I’m really very pleasantly assured by the fact that you designed the logo and can also confess to being confused by things periodically.

  3. James Britt Says:

    Thanks for writing this, it’s good to hear from people learning Haskell. However, while reading it could not understand why you were italicizing the word “for” in “not for me”.

    What was the purpose in that? Why the emphasis on the word “for”?


    • Putting the emphasis on ‘for’ would seem to set Comonad Reader and haskell-cafe in contrast against some other application of a preposition with respect to ‘me,’ such as “about me,” “from me,” or even “against me.”

      The tone of the article would indicate that this supposition is erroneous, thus I assume Thompson actually meant to put the emphasis and contrast on ‘me,’ with alternatives being “for logicians” or “for type theoreticians.”

  4. Deech Says:

    As a fellow novice Haskeller I appreciate you posting this.

    But I really hope you follow it up with more concrete examples of exactly what you found challenging. Chances are other people are wondering about the same thing.

    I think these kinds of examples would really help the teachers in the community understand the newcomers a bit better. These could form the basis for a much needed Haskell FAQ.

    Just as an example I don’t understand why in a monad transformer stack I need to write “liftIO e” to execute some ‘e’ in the ‘IO’ monad when functions like ‘get’ and ‘tell e’ work in the “ReaderT” and “WriterT” monad without being told.

  5. James Says:

    Yup! Haskell is better than lisp, and just as worse. Instead of the lispy “wait, you aren’t smart enough to understand my unwritten conventions?”, instead, it’s a language by and for programming language theorists who were tired of language capabilities getting in the way of their theory, and so set out to create a lingua france for all their poster presentations.

    And yet, in the end, you still end up with a bunch of conventions that boil down to “because that’s the way they did it”, except now you need to know the difference between and initial algebra and a natural transformation to understand why it’s so much betterworse.

  6. illissius Says:

    Yay for vaguely off-topic technical answers:
    Deech:
    It’s because the type of ‘get’ and ‘tell’ are like ‘MonadWriter w m => w -> m ()’, where the type of the monad is abstract and constrained by a type class. Stacks with WriterT in them are automatically members of MonadWriter, so you can use tell in them. By constrast, most IO functions are like ‘String -> IO ()’, where the ‘IO’ type is specified concretely, and ‘IO’ is very plainly not the same type as ‘WriterT Whatever’. So you need to use liftIO to translate it. If their type were ‘MonadIO m => String -> m ()’ instead (most likely by using liftIO internally), you wouldn’t need to.

  7. Clint Moore Says:

    You don’t have to know everything to get things done in haskell. Just as many people happily play chess without ever knowing or caring what a Sicilian Defense is, I write Haskell professionally and have for a couple of years now and I still haven’t needed to write a monad, learned GADTs, or care about whatever ‘natural transformation’ is.

    I guess it’s possible that I don’t know enough to know how much it sucks, but I think I can live with that.

  8. Cale Gibbard Says:

    I recommend all beginners in Haskell come and join the IRC channel: #haskell on irc.freenode.net, or if you’re too lazy to install an IRC client, http://webchat.freenode.net?channels=haskell&uio=d4

    There’s discussion at all levels of skill and practicality, but beginner questions are always welcome.


  9. > But, people like me need to be both steered to right learning resources, such as Learn You a Haskell or Real World Haskell, and steered away from the writings of Logicians and Type Theoreticians.

    A noble suggestion, but ultimately futile. It’s impossible to shield newbies from the mathematical side of Haskell, it’s simply part of the culture. Sooner or later, they will encounter it.

    The right approach to the problem of learning Haskell is to recognize that it’s a universal problem: learning another culture is difficult. You are well versed in the culture of imperative programming, but what about signal processing and Fourier transformation, engineering and partial differential equations, semiconductor physics and quantum mechanics? It’s equally or more difficult to learn these without a mentor and years of study.

    Of course, any culture can do a lot to invite new members. I think that the Haskell community is doing well here, though it can always be better. But it’s not foolproof: some people learn successfully, some fail, and a few write really angry blogposts afterwards (not you). Last but not least, it’s also a question of cost and resource allocation: you get what you pay for, for instance LAYH or RWH.

    • Mitch Skinner Says:

      I don’t think the proposal is to *shield* people from the mathematical side of things, so much as it is to *label* the more mathematical stuff. And then communicate that it’s relatively advanced or less practically-motivated.

      When you start learning a large, new body of knowledge, it helps to have tools to *prioritize* that learning. The mathematically sophisticated stuff is beautiful, but it’s not the right place to *start* unless you have a particular background coming in.

      The people doing theoretical stuff in an academic context often write for their peers, and assume a particular background and a particular set of goals. But as the haskell community grows, it’s acquiring members with more varied backgrounds and goals, and that makes communicating about those things more important.


      • What I mean is that you can’t force people, say, from an academic context to attach warning signs like “not suitable for Haskell beginners” to their writings, because they didn’t think that beginners would be their audience in the first place.

        If anything, that labeling has to come from a third party, but that means that you have to discover that third party first, and hope that their suggestions help your learning.

        The point is: if you want prioritize learning, you need to go to a place where learning is prioritized for you, for instance a Haskell course at university. (The problem with the latter is, of course, that access to these is fairly limited.) Or maybe buy LAYH and RWH.

        In other words, there is no magical fairy that prioritizes the culture specifically for each beginner and their needs. And if there were, it wouldn’t be a magical fairy, but just another website / learning resource in the vast realm of Haskell.

  10. Paul Johnson Says:

    I think I would modify your axiom to “not for me *yet*”, and the “yet” applies in both directions.

    Conventional languages (Ruby, Python, Java etc) have a kind of glass ceiling on abstraction: you can kind of see the shape of more abstract things above the ceiling, but you can’t say them in the language. Which is where Design Patterns come in, of course; they are the shapes you can see through the glass.

    Haskell lifts that ceiling way higher than any other language. That doesn’t stop you from staying down at the level you used to live at, but now you find yourself climbing upwards; the patterns you used to see through the glass suddenly become actual tools you can use (e.g. the Visitor pattern becomes the Functor and Traversable classes). And you also see astronauts doing stuff up above the clouds, at altitudes you never dreamed possible.

    The thing is, the stuff those astronauts are doing are not actually irrelevant to everyday programming, its just that nobody (including them) has necessarily figured out how it applies to everyday coding of web apps. Once they do figure it out then libraries will appear on Hackage and maybe, once the community is big enough, tutorials will turn up showing how to build web apps with bifunctorial continuation monad combinators. The type properties they proved by running the compiler suddenly become a guarantee that an entire class of bug has been eradicated. And once again you will realise that you can get the same functionality with less code and more type safety than you could before.

    In the meantime though, I do agree with your basic want: there needs to be a roadmap for the newcomer to follow. But rather than saying “not *for* you”, it needs to say “not for you *yet*”.

  11. Chris Dornan Says:

    I have been programming Haskell from the beginning and I earn my living writing Haskell. I have only had the time to skim the article and read the conclusion.

    As far as I can see you are dead right.

    To be fair Haskell and GHC were always intended to act as research vehicles as well as platforms for getting stuff done. But there is a culture of cleverness and over-complicationg things that should be simple(r).

  12. Dave Bayer Says:

    Many people conclude early in their programming careers that it would be worth ten years training in an advanced language, if that language made them much more productive. Then we encounter said hard language, which takes nowhere near ten years to master, and scream in pain. I could say “be careful what you wish for” except this was spot-on exactly the right wish. Living is about embracing challenges that are barely possible; it’s hell but one experiences thrills only the obsessed, like Olympic athletes, know.

    Part of managing this challenge is understanding you’re not inferior. The brain is a muscle, it just takes time. The trap with Haskell is the usual moth-to-the-flame trap of many intellectual endeavors, familiar to mathematicians: Zealots get intoxicated with categorical formalizations that may or may not help develop the concise, powerful idioms we have long craved and dreamed for. Haskell is a fertile breeding ground for these idioms; the idioms themselves can be explained to high school students. Same in math, some people can actually reason better with extreme formality, but most students just need to learn powerful gut intuitions, working from example. The formalism comes last. Our brains are naturally wired to recognize patterns, we’re just terrible at describing these patterns in words to each other.

    Go take a breather programming Scheme, then come back and program in a similar subset of Haskell. Haskell is the most beautiful functional language ever, if one can suppress these distracting pyschological reactions.

  13. whoops Says:

    i put a lot of mental effort into learning haskell. i contributed to hackage. i blogged and evagelized. now i realize that most of it was a waste of time. haskell is truly the new lisp – loved by a fringe of truly intelligent, dedicated coders who appreciate the high art of programming…but thats all. like lisp, people will spend years talking it up, but in the end its just a curiosity. the bulk of coders are never going to climb up the haskell learning curve. it just isn’t going to happen.


    • I used to think like that but I stopped. What stopped me was another interest of mine, following NBA basketball.

      A lot of people, media personalities, most fans, and especially front offices of teams, have wrong ideas about what makes teams win. This was shown conclusively by Dave Berri in his books “The Wages of Wins” and “Stumbling on Wins.” Basketball is unique in sports in that the box score statistics do a good job of explaining wins and losses and player performance is stable over time. His systems aren’t designed to predict winners, but they are one of the best in existence for doing so.

      I found it maddening that my Indiana Pacers continue to be mediocre when the information needed to win is readily available, and ignored. One of sports stats community set me straight. Instead of waiting for my team to win, I should find an inefficient basketball betting market, like the WNBA, look for mismatches between the market prediction and my prediction, and put some money on the line.

      I didn’t do it. Okay? So first of all, let’s get that out of the way. And the person didn’t so much say that right out but imply it. But I learned my lesson. Learning Haskell for me isn’t about fixing the world, it’s about fixing myself and making stuff.

      I don’t want my story to be this: I advocated and no one came and that totally bummed me out.

      I want my story to be that I was right. I built stuff, and Haskell was a big force multiplier. The rest of the world kept doing things the hard way. That’s their loss.

  14. mmlacak Says:

    You seem to be right, there is no royal path into Haskell. Anyway, you’re developer, just as I am. So, if something is not right, we do it better. Now, if you think about it, how would you design FP language which has all the benefits of Haskell, yet without such a steep (and long) learning curve?

    I tried to come up with something, but no matter what I try, I always end up with Haskell, only with a bit different syntax. You see, to have polymorphic functions, you have to have Hindley–Milner type system. Once you have that in place you’d certainly like to have some morphisms on types. Thus, you’ll end up with having Monads. From there on, it’s very short trip to full blown Haskell.

    Still, if you can come up with something that is pure FP (no cheating here like in Clean!), but without Monads (or equivalent burden!), I’d like to hear from you.

    • hydo Says:

      “but without Monads (or equivalent burden!)”

      Pointers in C are a far more difficult idea to grasp than Monads.

      • Dave Says:

        Pointers are only difficult if you’ve never programmed in assembly. Monads are difficult if you haven’t understood advanced mathematics.

        As such, I would say there’s more homework to be done to understand Monads than Pointers in C.

  15. haskderp Says:

    Thanks for the good write. I’m thinking of learning (been for a while) a FP. I find Haskell to be the one but meh where ever I go I feel I’m in an advanced discrete math class. Not sure where to begin.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: