7 ms·
Learn You a Haskell for Great Good
- misframer 13y agoAlso useful: Introduction to Haskell lecture slides - http://shuklan.com/haskell/ http://shuklan.com/haskell/ Real World Haskell - http://book.realworldhaskell.org/ http://book.realworldhaskell.org/
- tieTYT 13y agoThis is an amazing book. I highly recommend it as the first Haskell book you read. After it, you can check out Real World Haskell. To elaborate on why you shouldn't read (at least the online version of) Real World Haskell first: It has a lot of important topics that it covers that LYAH does not cover (like how to use cabal their package manager). But, it's not as good of a tutorial on the language and functional programming. It glosses over very complex topics, goes into a lot of depth on details that are not so important and worst of all, gives you some exercises that you aren't capable of answering yet. I tried learning Haskell three times from that book and gave up because it just killed my confidence. Then I discovered LYAH. It explains things very simply and at a very good pace. If you want to learn Haskell and/or functional programming, I can't recommend it more. Imagine one of the Head First books without all the corny. The only thing I wish it had was exercises.
- jordigh 13y agoI started reading the online version, enjoyed it so much, I went ahead and boug ht the treeware version. And it's awesome. I felt so loved as a customer of No Starch Press. They sent me the book, let me download the ebook in three free formats (no DRM), plus I got a bunch of freebie stickers. The book itself is also quite remarkable to me in that I can read it and understand Haskell without needing a computer. I am used to reading mathematics books, and while I don't think Haskell is a programming language for all mathematicians as is so often advertised, the language does have a certain appeal to it in that you can treat its programs as abstract exercises that you can do independently of a machine. The statelessness of the whole thing doesn't need me typing stuff into a machine to see what a particular line of code. This makes it great for offline reading, away from the computer. So yeah, get the treeware version. Support your favourite authors. :-)
- digitalzombie 13y ago=/ I never got freebie stickers from No Starch Press (probably cause I buy it through amazon). Their book quality is amazing, the paper and cover are very nice quality (unlike other publishers >=( ), I bought the learn you some erlang for great good, art of R programming, and the eloquent javascript.
- pnathan 13y agoOddly, I find real world haskell more useful when I'm fussing with Haskell. /me shrug
- tieTYT 13y agoOnce you're past the, "what is functional programming?" stage, I'd probably agree with you. It's a much better reference and much more thorough.
- gtani 13y agoI think there's a dozen or so free haskell books: http://www.reddit.com/r/haskell/comments/1af3iw/9_best_free_haskell_books/ http://www.reddit.com/r/haskell/comments/1af3iw/9_best_free_... http://www.linuxlinks.com/article/20130316105209238/BestFreeHaskellBooks.html http://www.linuxlinks.com/article/20130316105209238/BestFree...
- ikkyu 13y agoHaskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see it mentioned on Reddit but I have yet to come across any notable project written with it. Could somebody with experience give me some reasons for me to learn it?
- evincarofautumn 13y ago> 'why do I need it?' For the same reasons you need any programming language—to write useful software in! > Currently I am learning Java…and Ruby These are both good ideas. Java is widely used, reliable, and well tested for developing large applications. Ruby is simply a lot of fun to use, and one of the things you’ll discover while using Ruby is that it places a lot of functional programming idioms in an object-oriented context. The issue with many popular languages is that they fall into much the same paradigm, namely imperative and either procedural or object-oriented, with some functional features borrowed for working with lists. It’s worthwhile to see that not all languages are like this, and learning a new language is not just about new syntax and APIs. > but what about Haskell? I am genuinely curious what Haskell can offer. Haskell will teach you to think about structuring your program in terms of simple data and transformations on that data. Object-oriented programming is about coupling data with behaviour, whereas a big part of learning Haskell is learning how to recognise high-level patterns in data structures and functions separately. In doing so, you can avoid the work of reimplementing common operations yourself. You begin to say, oh, this is a data structure I can map a function over; I’d better make it an instance of Functor. And hey, I could use this data structure to represent this kind of computation, maybe it should be an Applicative and a Monad so I get some nice syntax for dealing with it. This function has a type signature that looks an awful lot like that other type signature—I wonder if I could implement one in terms of the other? And so on. The type system and succinct syntax also make it very easy to create new data types, and you learn how this can help avoid bugs—don’t use a Boolean here, use an enumeration with two values; then you can’t mess up. Java discourages this by requiring more syntactic effort to create a new datatype. A useful and oft-cited example of this is in the context of web frameworks: if you have separate data types for strings and HTML, that one simple thing eliminates a whole class of injection attacks. If you represent your links in the type system, then you can statically ensure that your site does not have any broken links. Simply put, quite a lot of bad things can be caught at compile time if you have a type system expressive enough to talk about them. > I have yet to come across any notable project written with it. There are more notable projects out there, but here’s my self-promotion. At my old job[1] I maintained a compiler for ActionScript 3 in Haskell, as well as a build system that coordinated the compiler and other build tools to convert Flash games to iOS and Android applications. Haskell is excellent at manipulating data structures—if that sounds ridiculously general, that’s because it is. The compiler is very nearly feature complete and, even with a certain amount of technical debt, was an order of magnitude smaller and easier to refactor than it would have been in an imperative language. So there you go. From a recovering professional Haskeller, why you should learn Haskell. And, for that matter, the answer to “should I learn this language?” is always “yes”; but some languages should be higher on your list than others. ;) [1]: http://spaceport.io/ http://spaceport.io/
- dchuk 13y agoIs the name of this book some sort of inside joke or something?
- jerf 13y agoI believe the title is a riff off of "Learn You Some Erlang for Great Good!" Some other books or online tutorials have taken that form of title. I don't really know why, though I suppose the silliness offsets the otherwise heavy nature of the content. (Learning Erlang is probably easier than learning Haskell for most people, but it can still be a mind stretcher if you've never done a functional language before.)
- minaguib 13y agoIt's actually the other way around. Fred Hebert, author of LYSE, named it after Miran's LYAH.
- stonemetal 13y agoIt is a gamer|anime|comic book joke. There is a lot of cheaply written entertainment with poorly defined motivations ascribed to the heroes and villains. So what battle cry is used by an overly generic hero? Why an overly generic cry of "For great justice!" of course. Throw in a joke a about poor translations and you get their title.
- burke 13y agoIt's just a faux-poor-translation because it sounds amusing, I think. It's a playful book with a playful title.
- ashika 13y agoThe author is a very funny/insane guy. Exhibit A is his twitter account (https://twitter.com/bonus500 https://twitter.com/bonus500). I wouldn't call it an inside joke, but rather a general feature of good comedy where it feels familiar yet distant.
- dragandj 13y agoIt is a joke, but not an inside joke as much as a joke that would be understood by people from Balkan countries (Serbia, Croatia, Bosnia). Miran (the author of LYAH) is, judging from his first and last name, from this region. In the local language (Serbian, Croatian and Bosnian are basically the dialects of the same common language), the most commonly used word for teach and learn is the same word, uciti, although there are separate words for these activities. Basically, whether you speak of teaching someone, or learning something is judged by the context. Then, Learn you a haskell vs. teach you haskell is a wordplay in that sense. A similar joke from the region: "Can you translate me to the other page of the street?"
- platz 13y agoI'll reccomend Erik Meijer's videos on introductory Haskell. I haven't gotten though them all but I appreciate his style and depth of knowledge on the matter; he also points out many things that a Java or C# dev would naturally be curious about how to interpret Haskell. http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1 http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Func...
- hawkw 13y agoI'm fairly certain I've seen this posted to HN before... good book, though!
- jamesbritt 13y agoGood book. Previous discussion on HN: https://news.ycombinator.com/item?id=535675 https://news.ycombinator.com/item?id=535675 https://news.ycombinator.com/item?id=336085 https://news.ycombinator.com/item?id=336085
- ilaksh 13y agoAnyone interested in functional programming might also be interested in LiveScript http://livescript.net/ http://livescript.net/
- rhizome31 13y agoWhat I find confusing with Haskell is that the keywords don't seem to be consistent with the concepts they're meant to express. As someone new to Haskell I learnt that the `class` keyword doesn't express the object-oriented concept of class, but the concept of type class, which is different. Fair enough. What about declaring types then? That must be `type`, right? Nope, `type` is for creating type aliases. OK, surely that must be `newtype` then? Wrong again, `newtype` is also for declaring aliases. All right, to declare a new type, you don't use `newtype` nor `type` you use `data`. But be careful, the part that has the `data` keyword is still called a type constructor, whereas the part that does not have the `data` keyword is called a data constructor. OK so let's recap, you create a new type with `data`, which is formed of a type constructor that starts with the keyword `data` and a data constructor which doesn't start with `data`. To create aliases you use `type` and `newtype` and to create type classes you use `class`. Now how do you call the type class of things that can be mapped over? Surely that must be something like `mappable`?
- adimitrov 13y agoThe designers of Haskell (and Haskell is one of the few successful design-by-committee languages,) were not doing things "your way" (where I assume you are a working programmer, with knowledge of some or even many traditional imperative languages.) They were PL researchers. Used to ML, Common Lisp, Ada, and, most importantly, Mathematics and Category and Type Theory. `data` introduces an algebraic data type, so it makes sense to use data as a keyword. `type` and `newtype`, on the other hand, are programmer's conveniences: both carry no runtime cost, they are not actually part of the semantics of the backend language. `map` is a function that's really just a specialization of `fmap`. Now, my category theory is a bit weak, but if I'm thinking correctly here, `fmap f` is an endofunctor in the category of functors, and so it makes perfect sense to call "mappable" Functor. There's also "Traversable," which works pretty much like a fully-fledged "mappable" with all extras, but also requires a Functor instance. Keywords, and idiosyncrasies of a syntactic nature are really just superficial. The actual elegance of the language is its type system. (The actual warts of the language are, for the most part, also in the type system; records for example.) The latter criticism about `mappable` is really just due to the fact that you haven't gotten used to the underlying theory (and I don't blame you, it's hard.) But getting used to it can be rewarding. I'm not saying it's going to make you a better programmer (I'm not necessarily of that opinion,) but it's rewarding in its own right. Oh, and the difference between data constructors, type names, and, later, kind names (with promotion, since 7.4,) can be confusing. I sometimes find it an oversight that they are not distinguished syntactically, I think that would greatly help most newbies, and sometimes even make things easier to read and understand for veterans, too.
- 6d0debc071 13y agoI didn't like LYaHfGG. Take this in p52 for instance: maximum' :: (Ord a) => [a] -> a maximum' [] = error "Maximum of empty list!" maximum' [x] = x maximum' (x:xs) = max x (maximum xs) Now, you may think that implies that you could do something like this to print a string one character at a time: rsoat (x:xs) = show x (rsoat xs) Buy you can't. If you try that Haskell complains "The function 'show' is applied to two arguments, but its type 'a0 -> String' has only one...." Fair enough, one might reason - you're just passing max two things when it wants one so we can do something like this: rsoat [] = [] rsoat [x] = show x rsoat (x:xs) = rsoat xs But no, that just gets you the tail of your string because x:xs doesn't match x so it never prints the other bits. What you may end up doing is something like this: rsoat [] = [] rsoat [x] = [x] rsoat (x:xs) = show x ++ (rsoat xs) But that's still not really doing what you wanted to do in the first place. It's sticking all your characters into a string and then reading that string all at once. And it's not a particularly obvious solution either if you don't know the language. This may seem a silly example. But what happens when, as is frequently the case, someone wants to retrieve the nth element of a list? (list !! n) Haskell, as learnt through Learn You a Haskell, can easily be expected to drive someone up the wall who starts asking such questions - it's not a whole bunch of fun to play with.
- oggy 13y agoTo be honest, it does not seem you did a very good job of reading the book. If you're rooted in imperative languages, it takes some effort. I read the book when I had already had some basic functional programming experience, so my experience might not be so representative, but I've heard quite a few positive reviews from people for whom it was the first introduction to FP. You seem to start off from a wrong premise that the show function prints things. It doesn't - it simply converts whatever value (of type a) you give it to a String (provided a is an instance of the Show typeclass). So seeing that you already have a string, a function which converts things to strings will probably not be very useful. > rsoat [] = [] > rsoat [x] = show x > rsoat (x:xs) = rsoat xs > But no, that just gets you the tail of your string because x:xs doesn't match x so it never prints the other bits. Uh, no. It doesn't give you the tail of the string, it gives you a list containing just the last element of the argument (if the argument's not empty), or the empty list (if the argument is empty) - which you can read directly from your definition. Furthermore, " x:xs doesn't match x" doesn't make a whole lot of sense - it's not supposed to match x, it's supposed to match a non-empty list. Which it does, and the first element of such a list gets bound to the parameter x - but you do not use the parameter in your right-hand side of the definition, so you effectively discard it. Note that both pattern matching and the Show typeclass (and the corresponding function) are discussed in the book prior to the minimum example.
- GhotiFish 13y agoI really liked LYAH, but it only starts out good. Once you hit Chapter 9. I/O. Prepare to fall off the rails. It only gets worse and worse and worse from that point onwards. I don't think that's really the books fault as much as it is Haskells. I also think it's why you hear ALOT of people swearing Haskell is actually very easy, because everything up to chapter 9 is not very complicated at all. I'm sure there are some very tallented people where this isn't true, but I get the impression that the people who are saying it's easy haven't gotten to the point where you can actually do things with Haskell, or developed a program with Haskell, or inter-operate with other libraries using Haskell, or tested their metal against the Parsing Combinators in Haskell (let alone making your own set), or ect. ect. ect. Chapters 1-8 aren't complicated in the slightest. Chapter 9 is when it starts. Haskell isn't easy.