top | item 17812713

Learn You a Haskell for Great Good

322 points| tosh | 7 years ago |learnyouahaskell.com

145 comments

order
[+] DonaldPShimoda|7 years ago|reply
I tried LYAH before I had any real functional experience, and it went poorly. I think I wasn't dedicated enough.

I took a programming languages class taught in Racket, and by the end of that semester I felt like I had finally "gotten" what functional programming was all about.

Tried LYAH again and... it still didn't quite stick. Not sure why. But I was determined, because I'd heard about Haskell so much on the internet.

So I took a follow-up "class" where we just implemented projects in the functional languages of our choice, and I chose to do everything in Haskell. I asked my research advisor (I work in a PL research lab) for guidance, and that's when Haskell really started to make sense for me. I'm not sure why LYAH wasn't good for me, when it's touted as being a great starting place for so many people, but now Haskell is one of my favorite languages by far.

[+] BoiledCabbage|7 years ago|reply
> I'm not sure why LYAH wasn't good for me, when it's touted as being a great starting place

It's not. It's a terrible starting resource. Majority of people I anecdotally hear gave up on Haskell seem to mention LYAH. Yes the material is there, but it's not presented in a way that generally sticks and fits pieces together. I guarantee someone will reply to this thread and say it worked for them, but in general people seem to be unsuccessful with it.

There are better options out there.

[+] ghayes|7 years ago|reply
I really enjoyed programming in Elm as a starting point. Elm avoids type-classes, which tend to be the biggest hurdle when starting to learn Haskell. Plus, you can design a nice web app in the process (versus, say, process CSV files). After I became comfortable with Elm, learning Haskell, type-classes, lazy evaluation, etc., made significantly more sense to me. For instance, `do` syntax is great, but it's not obvious what it really is doing, at first, unless you've programmed pure functional languages without using `do`.

Also, learning Idris is another great learning exercise if you want to stretch the ways to think about programming.

[+] sevensor|7 years ago|reply
I've bounced off LYAH more than once because it spends so much time in the REPL. I'm not interested in the REPL as an end in itself, only insofar as it can help me develop an actual program. Outside of image-based environments, what you do in the interactive shell doesn't reflect how actual code gets written. It feels trivial, and it doesn't help you build up a library of examples to refer back to later.
[+] tirumaraiselvan|7 years ago|reply
I concur. LYAH may be seen as an intuitive and easy read for getting started but I felt I was incapable of understanding real Haskell code with just that background. I finally got my hands dirty by hacking around on existing Haskell code which is when things started making sense.
[+] jSherz|7 years ago|reply
Are there any similar resources with practical examples (other than the book Real World Haskell)?
[+] _ezrr|7 years ago|reply
LYAH was my first taste of functional programming. Before that I only had 2-3 years of experience using PHP and Ruby. I read this book and quickly fell in love with FP and category theory, for the first time really started to enjoy programming to the fullest. This book is also the reason I was able to land a job as an Erlang developer, and teach a little bit of Haskell to others. Now, 5 years later, I continue my studies with languages such as Emacs Lisp, Guile, Clojure, Elixir, Elm, Hy.

I know this book isn't really popular (reading these comments) but to me it holds a lot of emotional value and I felt obligated to share my experience. I'll always be grateful for what this book taught me, and thankful to Miran for writing it.

[+] icc97|7 years ago|reply
> to me it holds a lot of emotional value

For me too. I had some experience of FP and was also a PHP programmer. It's one of the funniest programming books I've ever read, references to Avril Lavigne amongst category theory appeals to my sort, but clearly it's not a book for everyone.

So I found it fun to learn and the concept of Applicative Functors in between Monoids and Monads has stuck. As well as the examples of monads, such as walking on a tight rope with birds landing either side.

I'm still not doing pure FP and so I forget much of the content, but its a pleasure to pick up and re-read.

[+] dmix|7 years ago|reply
What are you building with Erlang? If you don't mind sharing. I always love hearing about it being used in production... Usually it's used in interesting ways. Unfortunately not to many jobs available (not that I've tried very hard to find one).
[+] oalessandr|7 years ago|reply
Another good (imho better) option is the Haskell book https://haskellbook.com/
[+] myegorov|7 years ago|reply
Not to start a flame war, but imho this is my definition of a "terrible book". Of the everything and the kitchen sink variety. By contrast, I very much enjoyed LYAH, not least for its self-effacing humor. Hutton was too dry for me. There's a less well-known "Thinking Functionally with Haskell" book by Richard Bird that is concise and targets the mathematically inclined crowd.
[+] zxexz|7 years ago|reply
I can't recommend this book highly enough. Very practical, and the way the chapters are organized really feels right. The excercises and examples really help drive the concepts home.

In my opinion, Learn You A Haskell is a poor resource to learn the language and for some readers seems to be actually counterproductive (I have two friends who got through LYAH and then tried actually using Haskell, realized they have no idea how to actually use the language, and give up on Haskell altogether :( If only they'd used The Haskell Book...)

[+] sridca|7 years ago|reply
I read more than half of this book, and sadly I did not enjoy it at all. Read it only if you enjoy long-winded verbose explanations. Hutton's or Bird's is concise yet explanatory.
[+] vram22|7 years ago|reply
Currently:

>This site can’t be reached >haskellbook.com refused to connect.

HN readers hitting the site?

[+] integricho|7 years ago|reply
It seems that it's development is stagnating, no visible updates for a long time, though I'm eagerly waiting for the release of it's final printed edition.
[+] anon907412467|7 years ago|reply
Agreed. Now that I found I like org-mode plus org-babel-tangle I'm planning to re-read it solving the exercises.

LYAH however is a few days read. It lets you to get closer to start learning haskell, but not even in the same league.

[+] chasedehan|7 years ago|reply
Very good book! Definitely the best one out there
[+] sdinsn|7 years ago|reply
But it costs $59 dollars, and you don't have the option of buying a print book.

LYAH is more appealing for early learners, since it's free.

[+] dogweather|7 years ago|reply
LYAH also didn't do much for me.

I got started with Haskell Data Analysis Cookbook. As an experienced programmer, I LOVE the "cookbook" format. E.g., "Keeping and representing data from a CSV file" or "Examining a JSON file with the aeson package". If you need to actually USE the language, this is a great way to get started. Complete programs are shown.

Unfortunately, most books dive into the language _implementation_ instead of teaching its _interface_. (This probably points to a Haskell design weakness: deep learning of the impl. is nec. for success.)

But my REAL wish: Because I'm like many people and have experience with dozens of languages. I want books that leverage that knowledge and experience. E.g., to explain monads, just say it's an interface specification, and give the API. It'll make sense to me.

[+] scottmsul|7 years ago|reply
This is my all-time favorite Haskell resource: https://en.wikibooks.org/wiki/Haskell

Just jump to the bottom and go through as many pages as possible. Going through Functors, Applicatives, and only then Monads puts everything in a broader context and makes Monads easier to understand.

[+] s_dev|7 years ago|reply
Still recall the advice form a classmate asking if I should learn Haskell -- he said "Just learn it because it'll change how you think about programming".

I think people should learn it for this exact reason -- it really does change how you program as well as thinking about programming even if on a daily basis you're not writing pure Haskell or Clean or Scheme or whatnot.

Common programming concepts like "iteration", "state", "formal methods", "parrallellism" are concepts that functional programming makes you reconsider from a new perspective.

[+] Barrin92|7 years ago|reply
I always think that this attitude is a little bit off. Obviously learning a new paradigm or a new language is great and expanding your horizon is very rarely bad, but I feel a little bit sad about shoehorning Haskell, or functional languages in general, still into this education category.

Haskell is a very solid production language and you can put industrial grade software in Haskell out there, and it is in fact used by a fairly serious amount of companies at this point.

Instead of just taking Haskell features and porting them into already adopted languages, I'd really like to see more companies just go directly with Haskell, or Clojure, or Ocaml and F#. It does work.

[+] dvlsg|7 years ago|reply
I think one of the most important things I learned from functional programming was how to consider and handle purity and side effects.

Not necessarily by wrapping everything in IO monads in my non-functional code or anything like that. But trying to keep bits of business logic in pure functions (where possible, of course) sure makes my job easier.

[+] khannate|7 years ago|reply
Based on my experiences using this as a reference while taking a class on functional programming, I think that while many of the explanations and examples are helpful, the ordering is a bit weird. For example, pushing off the explanation of higher-order functions for so long seems questionable, since they're a fundamental feature of the language.
[+] gh02t|7 years ago|reply
I agree, it's really disjointed. It spends a long time on relatively easy stuff and not much time on the hard things, IMO. I also have trouble with the style and I think it goes too far with the sort of informal, conversational tone. Ultimately Haskell is a language with a lot of formality at its core. You don't have to present it as all abstract category theory theorems and such, but that doesn't mean you should avoid formality entirely.
[+] nanook|7 years ago|reply
What do people think of Real Word Haskell (http://book.realworldhaskell.org/) ?
[+] egl2019|7 years ago|reply
Excellent except that it is dated. GHC, libraries, and tooling have moved on in ten+ years. I would buy a new edition instantly.
[+] lrc|7 years ago|reply
It's what I learned with. I thought it was pretty good, but I haven't tried any others. It gets you started, and seems best for a reader who knows a few other languages.
[+] ionforce|7 years ago|reply
Many years after my first exposure to this book and having learned more heavy-FP in Scala, I would not recommend this as a resource for learning either FP or Haskell.

But let that not be a pock on the overall great mission to make FP more accessible.

[+] Cieplak|7 years ago|reply
Haskell is hard, mainly because it's normally not a first language, and the first language people learn probably has Algol-like syntax (e.g. C, Java). I think Erlang is a bit easier to learn due to having fewer features, and for me was the gateway drug to Haskell. It let me learn to program with recursion instead of loops, and pattern matching instead of `if`s. The type system is the best part of Haskell, but unfortunately it makes it very easy to get stuck when starting out ("IO String" vs "String", "ByteString" vs "Text"). It's well worth the investment, though, to get a tool that lets you develop concise code like Python/Ruby but gives you strong guarantees of correctness. Also worth noting the incredible ecosystem of libraries and tooling, like stack and intero:

- https://docs.haskellstack.org

- https://commercialhaskell.github.io/intero/

[+] vapourismo|7 years ago|reply
I wouldn't really consider stack to be a great tool. There is Stackage which may be useful but the tool itself falls apart quickly when used to compile more than a single package executable.

That being said, one should have looked at these:

  - cabal Nix-style builds
  - ghicd for continuous type-checking
  - stylish-haskell for light code formatting
  - brittany for slightly more invasive code formatting
  - hlint for linting
[+] rs86|7 years ago|reply
I don't think Haskell is hard, but that's once you know it. It takes a lot of insights until you can see that it is really simple. A lot of code can look unreadable but that's just until you become familiar with the idioms.
[+] Swizec|7 years ago|reply
I read LYAH a few years ago and I enjoyed it. These days I'd probably find it tries too hard to be funny, but that's me getting older, not the book getting worse.

It is very much written by a (young) 20-something targeting other 20-somethings with a similar sense of humor. Came out in 2011, which puts the author at 24 years old. So ... you know.

Went to high school with the dude for 4 years. He's cool.

[+] jose_zap|7 years ago|reply
I wish this was shared less, it does a really bad job at teaching practical Haskell skills. For a long time this book left me with the feeling that I was unable to learn the language.
[+] Oreb|7 years ago|reply
People have different styles of learning. I loved LYaHfGG, but hated Haskell Programming from First Principles. As is evident from this thread, many others feel the opposite way. Both books deserve to exist and be shared frequently.
[+] wilsonfiifi|7 years ago|reply
What about "Get Programming with Haskell"[0] from Manning. Is it any good?

  [0]https://www.manning.com/books/get-programming-with-haskell
[+] Koshkin|7 years ago|reply
Yes, the book is true to its title.
[+] mbroncano|7 years ago|reply
It doesn’t seem to be the most popular opinion around, but I must say I got back into FP (which I came to profoundly despise after completing my CS education) thanks to this book.

It’s certainly not a book for the profane, despite its approachable aspect.

[+] dasil003|7 years ago|reply
It seems obvious to me that LYAH is an imitation of Why's Poignant Guide to Ruby, and that neither is actually a good learning resource. I don't mean to disparage these as works of art, but _why did it first, _why did it better, and if you actually want to learn either ruby or haskell neither should be your first stop.
[+] thom|7 years ago|reply
Yeah, I'm as much a fan of whimsy as the next guy, but every language wanting one of these twee storybook intros is increasingly grating (Clojure has Clojure for the Brave and True etc).
[+] Insanity|7 years ago|reply
I read LYAH and enjoyed it. But I did play around with Haskell a lot at the same time.

In addition, the IRC channel was immensely helpful along the way.

Nowadays I just use haskell for a few things at work or for toy projects, and the initial steps were taken with LYAH. (Beginner level though and I think I learned more from irc than the book in the end)

[+] lolive|7 years ago|reply
I won't comment the book. But my personal feeling is that you need a working environment first. And for that, you need to follow the advice at this resource: https://medium.com/@dogwith1eye/setting-up-haskell-in-vs-cod... with my comment (cf Olivier Rossel). If you are under Ubuntu, forget about the brew paragraph. Just curl -sSL https://get.haskellstack.org/ | sh

After all that, you will have an editor that can run/debug some Haskell.

[+] lolive|7 years ago|reply
I will quote (what i think is) an important part of the learning process: "Much of the difficulty in learning a new language is simply setting up the environment and getting comfortable with the tools to start programming." Having a kind of IDE to play around was immenselly useful in my case. I then could try to solve small problem i invented. And used the various Haskell resources in a non-linear way (how to do this? Cf SO, books, articles, etc. And then some theory articles to tell you why it is done this way. And that again for another topic required to solve my problem, and again, and again). Problem solving was my way to go to discover the Haskell way. Not just reading a book linearly.
[+] miguelrochefort|7 years ago|reply
First programming book I've ever read. I love it. I haven't done Haskell since.
[+] leshow|7 years ago|reply
Wouldn't be my first recommendation for a good Haskell book. I really enjoyed Haskell: first principles. I'm sure that will get mentioned a lot here.

Still, as a free resource it does cover some fun things. I just felt the book wasn't practical.