Learn Haskell Fast and Hard
yannesposito.com
yannesposito.com
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.
Thumbs-up to FP Complete for integrating it with their tutorial suite!
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 ?
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.
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.
I would say, though, that it should be (and really is) up to the author where their work can or can't be displayed.
I think it would be good for the community either way, but if an author doesn't want their work in any way tied to a commercial interest, then it's their right to apply licensing in such a way to ensure that, and for others to respect that (though I'm not saying you're implying otherwise; just clarifying).
The monetization here would be brand exposure and site traffic to the domain/website, using the works of others (which I'm not inherently against).
The tutorials are offered for free, right?
And even if they make some money of some purchasable tutorials: they have to pay for hosting too.
> 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 ?
You mean their Haskell Center offering?
This one: http://www.youtube.com/watch?v=ZHSBwlm5C8U
I think it is awesome. It makes the simple stuff dead simple (get a decent IDE with one-click web-deploy integrated up and running in <5mins, with an example app); while the hard stuff is still as easy as it was before (you can deploy to your own hardware, using your own desktop text editor and local compilation).
You say "serious", that's a strechable concept. But if serious could mean: doing some green-field web app consulting gigs (which can make serious money); then i think it is already-ready for "serious".
Then considering they are such a young company -- I'm really interested where they will head for :)
I think Haskell Center will turn out to be a game changer, a next-gen development environment (that graciously degrades back into old-skool native code producing DIY deployed stuff).
1. Yann Esposito's Haskell Fast and Hard (on FPcomplete -- https://www.fpcomplete.com/user/yogsototh/haskell-fast-hard)
2. Learn you a Haskell by Miran Lipovaca 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.
If you did, you are a substantially smarter person than I.
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.
I don't want to start a flame war, but I view types as being sort of peripheral to the task of getting the computer to do things. If type systems are getting in the way of programming, priorities are getting mixed up.
No, you're definitely not an idiot. Haskell's type system is a completely different language, semantically speaking, from its language of terms. This type language is much more like a logic programming language than a functional one. Type variables are unified by the type inference engine, a concept with which most people are unfamiliar. Type constructors are easily mistaken for data constructors (they often use the same name). A lot of Haskell tutorials gloss over these details which is unfortunate.
Please don't get discouraged. Once you start to grok the type system you'll be amazed at how powerful it is. It's pretty incredible how well it works at inferring all the types and catching countless errors. The oft-cited claim that Haskell programs "just work" once they pass the type-checker is true in the vast majority of cases. The amount of work it saves you by not having to write (and maintain) unit tests is staggering.
That's just the thing: Haskell's type system catches many, many bugs that would be runtime errors in most other languages. It can even provide static guarantees against extremely tricky bugs such as race conditions!
sloppy coding
Everybody is guilty of sloppy coding some of the time. Having a powerful sanity check against it is extremely helpful.
ones where you made an error in thinking
Haskell can actually help here, too. Its rigid purity forces you to think more carefully before you act and its powerful expressiveness enables you to build highly composable abstractions that are simply not possible in other languages.
Edit: Check out this talk on someone's personal experience with static typing in real projects at work:
Types in Haskell are used not just to represent data, but represent data as it is transformed and processed.
So often a type error in haskell represents an error in thinking, rather than an error in typing. This is one aspect of the language I really like.
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.
There is "Write Yourself a Scheme in 48 Hours"[1].
[1]: http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...
Spoiler alert: you can't really get anything signifant+useful done with that book, because Haskell is a language where only experts can get anything significant done.
If you just want the mindblow experience of Haskell: http://conway.rutgers.edu/~ccshan/wiki/blog/posts/WordNumber...
In fact, the chapter on building a Syslog server was incredibly useful, as the first piece of the system I'm building processes events which look a lot like Syslog (with some JSON embedded in the messages).
I will say that I had a hard time getting through the book as my only Haskell book. I ended up using Hutton's "Programming in Haskell" as a supplemental resource (selected mostly because it's a very small book).
I am not sure what you mean. Tutorials can only deal with toy examples. Once you understand them, then you can (and you should) write bigger projects. About Carmack, that's exactly what he did, he implemented Wolf3D in Haskell to have a real impression about Haskell. (Assuming you're talking about this video where he discuss functional programming for games)
Aren't you just being lazy? :)
Edit: that video:
http://functionaltalks.org/2013/08/26/john-carmack-thoughts-...
99% of the time I spend coding does not deal with data structures or algorithms, but basic business logic.
How does Haskell perform there? I don't know, but I know Haskell's quicksort oneliners are pretty (and pretty meaningless too).
I know my way around monads, I'm fluent in functional programming and grasped typeclasses... but I still can't see what's so great about Haskell beyond algorithmic beauty. I'd really like to be taught real-world-Haskell just like I was taught real-world-Lisp.
But the author doesn't seem to be very well aware of that. Quoting the article: "Haskell is very different. The language uses a lot of concepts I had never heard about before."
All that to say that if you already know some functional programming this probably isn't for you.
Edit: clarity.
Don't get me wrong, I don't think that most Haskell tutorials are inherently bad, I just couldn't find a good introduction to Haskell targeted at programmers which are already familiar with functional programming concepts.
I can't tell if this is a functional programming joke or not...
Then he proceeds to run some basic vision filters in realtime using OpenGL, OpenCL, and OpenCV all together just to show off all in under 150 lines.
Then after that he talks about how his team built a robot doing realtime grasping and lifting of non-uniform, unpredictable, difficult to grasp, random dollar store objects that are coming at it on a conveyor belt moving at 33cm/sec. The visual processing all in Haskell from the noisy sensor of a Kinect.
The examples aren't immediately there to follow as it's not a tutorial, but it's a good look into the space of some real, complex hacking going on.
Also investigation dockerizing Haskell services too.
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.
I'm only speaking from Java experience here.
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.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.
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.
* 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) and esqueleto (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) 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 and there may be something.
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
The PostgreSQL query optimizer can fix them in the simple cases but the MySQL and Oracle optimizers can't and it causes performance to drop off a cliff. HaskellDB suffers from a similar problem.
For Slick, yes, but for ScalaQuery 0.10, absolutely not.
All of my ScalaQuery generated SQL is semantically _exactly_ what I would have written by hand, and completely typesafe, with generated prepared statements to boot. This includes outer join based queries, subselects, and other operations that cause Slick to generate nightmare SQL (why I'm avoiding Slick until the library is stable on the performance front).
I love ScalaQuery, but Slick, TBD, they have a ways to go yet, the new Scala collections syntax with groupBy and sortBy is particularly hideous compared to ScalaQuery's SQL based groupBy and sortBy.
The Slick team will sort things out, hopefully sooner rather than later (for example, I'd love to have Slick 2.0's composable parameterized query snippet functionality, that alone is a huge boilerplate WIN).
That's one of the reasons why being on the JVM with Scala, Clojure, etc. makes one's coding life simpler: huge ecosystem to draw on with minimal effort (i.e. rarely need to roll your own).
It's a godsend given the built-in Java alternative.
However, yes, for complex type hierarchies, heavily curried functions, and other higher level approaches, Haskell obviously wins, equivalent Scala code is a mess in comparison.
Odersky recently tweeted an EPFL paper addressing simplification of the type system (that got Scala FP devotees up in arms); i.e. in the not too distant future we may have fewer ways to do the same-ish thing (a good thing, IMO, if the language can be trimmed down, at a minimum that bodes well for current portability issues).
Before I learned about either, I had most experience with Java. Though I'm biased since I learned Haskell first (and I wouldn't say that I 'know' Scala).
Did this stop you or how did get past it?
How does Learn Haskell Fast and Hard compare?
Just move on to the next chapter if you find it tedious. The book goes back to the original style in the subsequent chapters.
The selection of artwork is pretty nice too.
Very very good. Thank you author and poster.
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... (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.)
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.
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.
"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 :)
It is generally an actually designed syntax and works quite well. My point was that most of the unusual things are just function calls.
I find a lot of people complaining about Haskell syntax without understanding how deeply different this language is from "usual" languages.
This would remove a significant portion of the $ signs in Haskell programs, as so many of them are just padding for "do", "case", etc.
I know them now, but discoverability is pretty low on those functions.
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.
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!
(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)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.
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.
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.
It concisely covers most of the syntax and some common idioms with prelude functions (such as using `$` and `.` to get rid of parenthesis)
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.
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.
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-exerci...
Then I started reading 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.
[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. 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]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/P...
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_...
[2] http://en.wikipedia.org/wiki/Set-builder_notation#Parallels_...