I've tried to learn Haskell about 3 separate times, and it's just now, after reading this tutorial, that it seems to really be taking. It was apparent to me immediately that Haskell was extremely powerful, but frustrating because ultimately the only reason I bother to learn any programming language or technique is because I want to use it to do something. The other Haskell documentation/books/tutorials I've read all just seem to delve into syntax and more reasons WHY haskell is powerful, but totally miss the point of "here's how you build a program in Haskell." Which, for me anyway, is the whole point. The Haskell community is a little frustrating too, as many times they seem content to write research papers on how Haskell could be applied to a problem instead of actually building a program with Haskell.

I also found this reference helpful, but despite its name, I only found it useful as a reference for syntax to complement the other tutorial.

What's so cool about Haskell? Contrary to a lot of tutorials, the reason it's cool has nothing to do with this:
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
Sure, that's a compact way to write a function that generates the Fibonacci numbers, but compact, confusing one-liners are not impressive to me (sorry perl).

This is why Haskell is cool:
calc :: String -> [Float]
calc = foldl f [] . words
f (x:y:zs) "+" = (y + x):zs
f (x:y:zs) "-" = (y - x):zs
f (x:y:zs) "*" = (y * x):zs
f (x:y:zs) "/" = (y / x):zs
f xs y = read y : xs

This is the entire and complete definition of a Reverse Polish Notation calculator. Haskell has an awesome strong static type system, first-class functions, and all kinds of generic polymorphism. All those add up to being able to do things that are really hard or complicated in other languages in a generalized, compact, and clear way. In addition, it compiles to native binary code and is therefore quite fast.

Comments are closed.

Dev Journal and Project Hosting