9 ms·
Learn Haskell Fast and Hard
- anuragramdasan 13y agoI have been wanting to look into Haskell for a long time now. Never really got the time. Also the syntax was a bit off putting. Just skimmed through. I see that there is a bit of Javascript and C in the code too as reference matertial. Most people dont like such a way of teaching but it looks like the tutorial isnt really trying to teach Haskell in terms of Javascript or C. Really makes me want to look into this. Thanks for putting the efforts.
- IsTom 13y agoI'm a bit surprised that you say the syntax if offputting, most people I've met say otherwise. Could you point to something you specifically don't like?
- anuragramdasan 13y agoI didnt mean in a sense that it sucks. Its way different from the traditional C style or Lisp style syntax that I've used. Regardless of whether it is good or bad, it would have taken me some time to adjust to it and I never had that kind of time. Also as someone who doesn't know Haskell at all, I have great difficulty reading Haskell. I dont think I would have that kind of problem reading a language with a more traditional syntax.
- lucian1900 13y agoThe syntax is much closer to Lisp than C, really. The main differences from Lisp are lack of macros (so slightly more actual syntax) and function application (in particular infix functions). Most things you see are functions.
- Peaker 13y ago"slightly more actual syntax" is where all the syntax is, though :) "do", "let", "where", "case", "class", "instance", records, ... There's a lot more syntax to learn than in Lisp, but it is IMO the best designed syntax of all languages I've used prior to Haskell. It is much less noisy and less painful than the C-family syntax. I do remember it being so different was an obstacle for the first couple of weeks of learning Haskell, and even being grumpy about "why did they have to choose a syntax so foreign" at that point :)
- lucian1900 13y agoIt's still a tiny amount of syntax, even compared to the likes of Python (I'm not comparing to C++ as that wouldn't be fair). It is generally an actually designed syntax and works quite well. My point was that most of the unusual things are just function calls.
- dmytrish 13y agoDo you know any other functional language? If not, it's a problem not with syntax (Haskell syntax perfectly fits its semantics), but with what is actually going on in the program. Without firm grasp of FP concepts (recursion, currying, partial application, abstract data types, etc) almost any Haskell code seems to be alien. I find a lot of people complaining about Haskell syntax without understanding how deeply different this language is from "usual" languages.
- IsTom 13y agoI think the problem might be also things that look like syntax to somebody who is not used to Haskell, but are just usual functions like ($) (<*>) ($!) and whatnot.
- Peaker 13y agoI really wish Haskell syntax was extended to allow special forms ("case", "do", etc) to be ordinary function arguments and not just infix function arguments. This would remove a significant portion of the $ signs in Haskell programs, as so many of them are just padding for "do", "case", etc.
- cschneid 13y agoI agree. There are a fair number of symbols out there. And really, how do you pronounce: ">>=", "<<=", "<*>", ".", and such. I know them now, but discoverability is pretty low on those functions.
- bazzargh 13y agoAnd Control.Lens introduces around 20 more symbols like this. It does at times feel like reading perl without 'use English;'
- anuragramdasan 13y agoYes I do know FPs a great deal. I DO NOT harbor any kind of hate towards Haskell, just never found it easy to understand(or read, to be more specific). Also this link makes me want to learn it more than ever now.
- wtracy 13y agoThe syntax has more in common with Python than anything else I know of--it seems pretty readable to me. Now the structure of Haskell is going to be very alien if you're used to imperative languages (C, Python, what have you). You mention Lisp, so that should give you as good a background as anything else in terms of reading Haskell code.
- chongli 13y agoAlso as someone who doesn't know Haskell at all, I have great difficulty reading Haskell. I dont think I would have that kind of problem reading a language with a more traditional syntax. Right, but then you'd lose the benefit of Haskell being a very different language. To implement Haskell using C-style syntax would make it extremely awkward to make liberal use of Haskell's powerful features. In particular, Haskell's syntax is optimized to make fully/partially applying functions as quiet as possible. This really shines in conjunction with the ability to define your own operators -- including their fixity -- so you can wage an all-out assault on parentheses!
- anuragramdasan 13y agoOh dear lord, you misunderstand me. I dont want to implement Haskell in C-style. Haskell is good being haskell, I just had difficulty understanding it and never had enough time to dive deep into it. But now I may.
- chongli 13y agoThat's good of you. This problem (familiarity) plagues many upstart technologies. Taking the generality even further, it could be argued that the status quo bias is one of the most difficult-to-overcome aspects of human nature and that its effects on society are extremely widespread.
- lelf 13y agoSome Lisp: (defun foo (ls) (mapcar (lambda (x) (+ (f x) 2)) ls))) Trim unnecessary parenthesis (map is mapcar, \x -> … is lambda expr): foo ls = map (\x -> ((+) (f x) 2)) ls With infix syntax foo ls = map (\x -> f x + 2) ls And only if you really want it: foo = map (\x -> f x + 2) foo = map ((+2) . f)
- anuragramdasan 13y agoThank you. That is some good way to look at it. I think people here assumed that I hated haskell or something. This breakdown actually makes it a lot clear to me. Thanks :)
- doorhammer 13y agoI think some folks are misreading your comments a bit as an indictment of the language. I read it as saying, "Haskell doesn't have syntax that's similar to any language I know and that means I have to learn something I don't know, which takes time, and I don't have a lot of time." Personally, I'm with you. I've used other functional languages (F#, clojure, erlang), I'd say I'm pretty familiar with a lot of the ideas Haskell uses (comprehensions, partial application, anonymous functions, pure functions, pattern matching) and I actually really want to learn Haskell, but I have a hard time intuiting the meaning of a lot of Haskell syntax just based on other syntax that I know. I also realize that the syntax probably fits the language very well, which makes sense, and that it's a good thing. I wouldn't want it to compromise it's purity for familiarity. Just makes it more work to learn.
- thinkpad20 13y agoI'm with you, but you do get used to it. Basically if you just get your feet wet writing a few semi-significant programs in Haskell (e.g. a parser, which is a very common and pleasant task in Haskell), then you'll get familiar with it. The biggest hurdle for me came from being able to understand do-syntax (which is a bunch of applications of monadic bind).
- anuragramdasan 13y agoHah! yes. Maybe I should have put it the way you did. My view of Haskell is the same as a non-Lispers view of Lisp. Cry about too much parens and it making things difficult to understand. Doesn't mean the language needs to be changed. I am all in for learning Haskell although most introductions to haskell are really time consuming and dense, so I never just did it. Which is where I was really glad that this tutorial was put up. Hating any language which actually does serve its purpose is pretty stupid. If anyone actually has some issues understanding a sightly different but very well respected language, then the fault is mostly with that person and not the language.
- doorhammer 13y agoI think lisp is a really good example for how I feel with haskell, and one I'm more familiar with. When I first started learning lisp, the syntax was foreign, and while lisp syntax is arguably really really simple, composition with that syntax is a little weird if you're not used to it. Yet, at the same time, the syntax is a fundamental part of the language, especially with respect to homoiconicity, simplicity and macros. It was a time-sink to get used to it, but totally worth it.
- ludicast 13y agoThis is a tremendous resource, but may I suggest you rather point here: https://www.fpcomplete.com/school/haskell-fast-hard https://www.fpcomplete.com/school/haskell-fast-hard. It's the same course/series, but with interactivity, so Haskell can coded/evaluated from the browser. In fact, one "dir" up, you will find a bunch of similar tutorials here : https://www.fpcomplete.com/school https://www.fpcomplete.com/school.
- cies 13y agoI was going to say the same.. To me the Fast-and-Hard introduction made most sense off all intros I tried (pretty much every one I could find online). Thumbs-up to FP Complete for integrating it with their tutorial suite!
- deSouza 13y agoRegarding the site with the turotial suite: I am not a big fan of harvesting community knowledge, input and ideas and then go commercial On a second note, how many will use a platform like fpc's, where an external entity has immediate access to your code, for serious projects ?
- doorhammer 13y agoI'm a big conflicted about that as well. I think I'm ok with it as long as they have permission/cooperation from the author (a cursory glance looks like they do; could be wrong), especially since the introduction of inline code evaluation makes it so much easier to get into. I know the content probably would have gone into my bottomless "to read later" bookmarks folder if I couldn't knock some stuff out right then and there. Thinking about it, I guess that's just a licensing issue. Give the author the tools they need to decide how their work can and can't be used.
- aninhumer 13y agoSchool of Haskell is actually a website where people can create their own tutorials, so most likely the author added it themselves. (EDIT: I just checked, they were created by user Yann Esposito, which most likely belongs to the author.) Furthermore, while FPComplete are commercial, I don't believe they're monetising SoH in any way, other than its being good marketing for the company and Haskell in general.
- JonCox 13y agoIf you want to learn Haskell slow and easy, this is brilliant: http://learnyouahaskell.com/chapters http://learnyouahaskell.com/chapters
- 616c 13y agoI have been perusing Learn You a Haskell but I like this more. Fast and hard indeed. Will read this over tonight.
- merijnv 13y agoWord of warning, though. While this article looks pretty decent it's skipping over lots of tiny details that are covered in LYAH, which may lead to annoying gaps in your knowledge/understanding later.
- batgaijin 13y agoa monad is like a taco salad.
- AnthonBerg 13y agoPERFECT. Relaxed but intense. Perfect! ... for me. This is exactly the kind of tutorial that works best for me. (I'm sure many people will find it unusuable. But that's OK - we have as many ways to learn as we have learners.) The selection of artwork is pretty nice too. Very very good. Thank you author and poster.
- boothead 13y agoHow much interest would there be in a 0 to full Haskell development environment set of ansible scripts (and or Vagrantfile)? I'm working on a start up using Haskell at the moment and I've been capturing all of my set up in this way. If folks are interested I can make some of this stuff available.
- Keyframe 13y agoWhat do you install and setup apart from ghc/i?
- boothead 13y agoEmacs config. Latest versions of cabal cabal-install. A work around for the brokenness of the Haskell platform on ubuntu 13.04. Threadscope. Proper cabal setup for testing. Jenkins setup for CI from the start. Also investigation dockerizing Haskell services too.
- Keyframe 13y agoI'd be more than interested to see what you got. I want to introduce Haskell to our production soon, but am still not sure about the whole process of managing it at scale. This would definitely help as an info if nothing else.
- Peaker 13y agoDo you have a good ~/.cabal/config auto-installed with library profiling enabled?
- boothead 13y agoYes, but I have moved to doing most stuff in sandboxes now and cabal repl is not playing nice with profiling at the moment.
- dmmalam 13y agothis would be very interesting
- alkonaut 13y agoLearning a functional language is a great idea especially if you never intend to use one after you've learned it. It's like speaking a second language. Has a great effect on the understanding of your own language. At university the first thing everyone had to (in programming) do was a Haskell course. Felt weird at the time, but in hindsight it was fantastic. It meant everyone had to throw their preconceptions about programming out the window. It didn't occur to me until recently (10-15 years later), that functional concepts are actually a good thing to apply in any language; that it makes code parallelizable, modular, maintainable, testable, and so on. I just thought functional was functional (i.e. elegant but hard) whereas imperative was imperative (inelegant but easy). Much like the difference between algebra and arithmetic. So go learn a second language, or even a third. Even if you intend to speak english and Java for the rest of your life. I'd choose Haskell and Spanish.
- 6ren 13y agoASIDE: I've been using learn you a haskell for great good! http://learnyouahaskell.com/ http://learnyouahaskell.com/, and found it helpful, insightful and the examples nicely paced so you can treat them as exercises as you go.... up until the module chapter, which is more like a reference, very long, detailed, tedious. I got up to here http://learnyouahaskell.com/modules#data-char http://learnyouahaskell.com/modules#data-char (check out how small the scroll bar slider is on the right - this is a big chapter). Did this stop you or how did get past it? How does Learn Haskell Fast and Hard compare?
- efraglebagga 13y agoyeah, it's definitely more of a reference. Personally, I just skimmed through it and moved on. The purpose of a chapter like that is to give you a rough idea of what's out there. When you'll actually need something, you'll be looking it up anyway. Just move on to the next chapter if you find it tedious. The book goes back to the original style in the subsequent chapters.
- merijnv 13y agoAfter that chapter it goes on the same way as before. I think the chapter is just a reference for "good places for beginners to get acquainted with".
- asgard1024 13y agoI really like the art images in the tutorial. Nice touch. Although I am not sure about the premise - I doubt Haskell, as a language close to mathematics, can be learned fast. This tutorial seems quite shallow on some things, like monads.
- asdasf 13y agoIt does sort of bail on you instead of explaining what monads are. A couple of examples of monads is not the same as understanding what the underlying abstraction is. That said, it isn't hard or long to learn monads. A monad is something that can be mapped over and concatenated.
- asgard1024 13y ago> That said, it isn't hard or long to learn monads. I am not sure any definition does that justice. It's similar with concept of recursion - it's easy to define (function calls itself), but to put it into programming practice (writing all loops as recursion), that's a lot harder. I read "Learn Yourself a Haskell" as a tutorial (which is in my opinion great) and still it was a lot of work to figure out this: http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/ http://blog.tmorris.net/posts/20-intermediate-haskell-exerci... Then I started reading http://www.haskell.org/haskellwiki/All_About_Monads http://www.haskell.org/haskellwiki/All_About_Monads but didn't finish it yet (I was playing with Haskell, just figuring out how to structure the application). IMHO, unless you understand all that, how to put monad concept into practice, you don't really know monads.
- RyanZAG 13y agoI haven't seen this Haskell syntax before: [1,3..10] ⇔ [1,3,5,7,9] Imagine running into this one on a production system... Someone needs to make a 'Haskell: the good parts' or at least a lint.
- merijnv 13y agoHow is that weird, it's just uses the increment from the first to second value as step and repeat as long as it's smaller than the end value. Python does the exact same thing: Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> range(1, 10, 2) [1, 3, 5, 7, 9]
- deleted 13y ago[deleted]
- pja 13y agoYou'll see that in a lot of languages that include list comprehensions as part of their syntax.
- freyrs3 13y ago> Someone needs to make a 'Haskell: the good parts' or at least a lint. Someone needs to write a book about the good parts because you haven't learned the language? It's documented right in the Prelude[1] what this desugars into. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:enumFromThenTo http://www.haskell.org/ghc/docs/latest/html/libraries/base/P...
- nbouscal 13y agoThere is a linter, called hlint, which is extremely useful. It doesn't flag that, though, nor do I see any reason it should.
- Tehnix 13y agoAre you implying it's complex? Because a lot of languages have list comprehensions[1] (list comprehensions are awesome!). Haskells is very close to the mathmatical set-builder notation[2]. An example of a more advanced one would be >> [2*x | x <- [0,1..25], x^2 `rem` 3 == 0] [0,6,12,18,24,30,36,42,48] Also, there is HLint for Haskell linting purposes... [1] http://en.wikipedia.org/wiki/List_comprehension#Examples_in_different_programming_languages http://en.wikipedia.org/wiki/List_comprehension#Examples_in_... [2] http://en.wikipedia.org/wiki/Set-builder_notation#Parallels_in_programming_languages http://en.wikipedia.org/wiki/Set-builder_notation#Parallels_...
- Hearty 13y agoWith such a large font learning Haskell must be easy!
- dllthomas 13y ago"Instead of being in your way like in C, C++ or Java, the type system is here to help you." I'd still say the type system is there to help you in C, C++, and Java, it just doesn't do nearly as good a job of it, and winds up in your way more often because it's less expressive.
- tieTYT 13y agoI'd go as far as to say it doesn't get in your way at all except for verbosity, I just wish it were better and could do more. I'd love for the type system to prevent null pointers. I'm only speaking from Java experience here.
- danieldk 13y agoIf you are using Java and the JVM: Kotlin[1], a JVM language that attempts to improve on Java, has non-nullable references. http://kotlin.jetbrains.org/ http://kotlin.jetbrains.org/
- danieldk 13y agoI'd still say the type system is there to help you in C, C++, and Java, it just doesn't do nearly as good a job of it, Are you sure? :) Couldn't match type `b0' with `Step Builder IO a' because type variable `a' would escape its scope This (rigid, skolem) type variable is bound by a type expected by the context: Enumerator Builder IO a The following variables have types that mention b0 [...] I do love Haskell :) and usually the type system is there to help you.
- virtualwhys 13y agoPretty awesome, I've steered clear of Haskell preferring Scala instead (easier syntax for me to grok), but this tutorial makes Haskell far more accessible. Off topic but does anyone know of a Rails/Play + Linq to SQL/ScalaQuery equivalent in Haskell? Beyond that just being able to generate PDF invoices, send out emails and have access to a decent date/time library (like JodaTime) would cover the essentials for web development.
- ocharles 13y agoFor Rails/Play, we have three web frameworks: * Snap * Yesod * Happstack I think all of these have techniques to build web sites in a modular fashion, but I have only used Snap myself. For querying, I personally just use postgresql-simple and write SQL strings, but this tends to be a major source of runtime bugs so I'm reconsidering that. For type safe alternatives, we have things like HaskellDB (http://chrisdone.com/posts/haskelldb-tutorial http://chrisdone.com/posts/haskelldb-tutorial) and esqueleto (http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Database-Esqueleto.html http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Da...). We have a fairly decent date time library in time (http://hackage.haskell.org/package/time http://hackage.haskell.org/package/time) but I don't know if that matches JodaTime (because I don't JVM libraries). For PDF generation I'm actually not sure at all - but have a search on http://hackage.haskell.org http://hackage.haskell.org and there may be something.
- virtualwhys 13y agoThanks, I did check out Yesod and HaskellDB a while back when I was researching ways to escape from Grails hell (i.e. pre grails 2.0). Yesod looked promising, HaskellDB, not so much (IIRC was developed in early 2000s and not actively maintained). Definitely not interested in going back to string based SQL after working with ScalaQuery for the past couple of years. Anyway, the thrust of the question was, can you do full stack web dev with Haskell. The answer seems to be yes, but you have to dig around a bit. Would be a fun side project to hack together a site in Haskell, definitely a fan of the type system
- 13y ago
- XorNot 13y agoOk so here's the problem I'm having with trying to get into Haskell, and it's a problem Carmack identified: there's way too many "toy examples" out there. I've always learned languages because I need them for something. C/C++ because I wanted to write a game. Python because it's the complex scripting language of choice in Ubuntu. JavaScript for obvious reasons. What I really really need is something which walks me through doing something significant with Haskell - like, a GUI app on Linux or something (my current focus: I've never really done it, but if I'm learning something new I'd like there to be a practical product at the end). A bunch of language constructs, while technically interesting, don't help me to grok the language at all.
- gonnakillme 13y agoYou'll really need to be able to use Monad and monad transfromers before you'll be able to use an idiomatic Haskell library, though. There is "Write Yourself a Scheme in 48 Hours"[1]. [1]: http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...
- efnx 13y agoGUIs in haskell are currently a hot topic. Some of the older libraries like wxHaskell are a bit behind the times and need updating and the newer ones are very new and need vetting. If you're interested I'd check out threepenny-gui or learn opengl and use GLFW-b with the opengl bindings and write your own. #haskell and #haskell-game on irc.freenode.net are great hubs for gui related talk.
- freyrs3 13y agoCheck out jekor's channel here he does walkthroughs of building full Haskell applications and deconstructing existing ones: https://www.youtube.com/user/jekor/videos https://www.youtube.com/user/jekor/videos
- asgard1024 13y agoSounds good, but I really hate the video format (article or book would be better).
- ufo 13y agoMinor nitpick: Using pattern matching instead of `if xs == []` is not just to make code prettier and cleaner. First of all, you should be using the `null` function instead of `== xs` because the `==` operator only works if your list contents are Eq-able. But the most important thing is that pattern matching is more type safe. If you use `head` and `tail` you, as a programmer, need to make sure that you only call them on a non-empty lists or else you get an error. On the other hand, if you use pattern matching the compiler helps you make sure that you always covered all the possible cases (empty vs non-empty) and you never need to worry about calling the unsafe head and tail functions.
- arunc 13y agoThinking about Haskell, reminds me of this http://www.xent.com/pipermail/fork/Week-of-Mon-20070219/044101.html http://www.xent.com/pipermail/fork/Week-of-Mon-20070219/0441...
- ssivark 13y agoI tried dipping my hands into Haskell over the summer. I fell in love with two resources: 1. Yann Esposito's Haskell Fast and Hard (on FPcomplete -- https://www.fpcomplete.com/user/yogsototh/haskell-fast-hard https://www.fpcomplete.com/user/yogsototh/haskell-fast-hard) 2. Learn you a Haskell by Miran Lipovaca http://learnyouahaskell.com/ http://learnyouahaskell.com/ The latter author decided to write the book based on his experience in learning Haskell. It's definitely one of the simplest and clearest programming books I've read.
- AndreasFrom 13y agoI just started on #2 with Clojure ande F# experience and it seems really good so far. Now I'm really looking forward to reading it!
- SkyMarshal 13y ago/second LYAH, Lipovaca has a talent for explaining complex concepts clearly. One of the best learn-programming books I've read.
- GhotiFish 13y agodid you get all the way through it? If you did, you are a substantially smarter person than I.
- jnbiche 13y agoYeah, I got bogged down in monads, but I've promised myself I'll finish it this year. Learn Yourself a Haskell[...] is extremely well-written and entertaining, so it deserves completion.
- GhotiFish 13y agoI've said the same thing, unfortunately. All the resources I've seen for Haskell start the same They are insanely easy to follow at the start, so simple that even first time programmers won't have much trouble following. Then the type algebra hits and everything goes out the window. I've made 3 attempts to get through it. I can even see situations in my work where monads and monoids may very well be applicable. I still can't work with Haskell, nor get through any resource that discusses them. It's possible I'm an idiot, but I suspect my co-workers would fare worse, and it damns the language in my book.
- pa5tabear 13y agoCommenting to bookmark.
- Jtsummers 13y agoIf you upvote an article on HN then it shows up via the "Saved Stories"[1] link in your profile (not visible to others). https://news.ycombinator.com/saved?id=pa5tabear https://news.ycombinator.com/saved?id=pa5tabear
- fmax30 13y agoOkay so i completed this tutorial in about 5 hours , gave everything due , but still i only understand like 30 % of it and that too of the starting part.
- carterschonwald 13y agoNB: if you're trying out haskell and you're on a mac with xcode 5, you'll be hitting some weird CPP related errors due to GHC 7.6 and older not playing nice with Clang's CPP. I shared a number of work arounds with the general haskell community a few weeks ago here: http://www.haskell.org/pipermail/haskell-cafe/2013-September/110320.html http://www.haskell.org/pipermail/haskell-cafe/2013-September... (there are alternative work arounds, but I only listed the ones which are simple and easy to communicate with other people and be able to expect them to follow the steps correctly.)
- tieTYT 13y agoI'd like one of these beginner tutorials to have a chapter named, "learning cabal and using a library". That was a pain point for me (especially developing on windows). Well, not so much a pain point as a mortal wound.
- tlo 13y agoNice tutorial, but old story: https://news.ycombinator.com/item?id=3806841 https://news.ycombinator.com/item?id=3806841
- cnu 13y agoCheck out http://learnxinyminutes.com/ http://learnxinyminutes.com/. Loads of languages/tools to learn.