Resources to Learn Haskell

Getting started

  • Learn you a Haskell. LYAH is easy to read cover to cover and is more about teaching language features rather than solving real world problems (i.e. it doesn’t spend too long on IO).
  • The Haskell Book is a good source to start your learning. It’s designed for programmers new to FP. Very easy to understand.
  • cis194 spring 2013. More rigorous approach than Learn you a Haskell, it is also a little bit less accessible due to the fact that it is intended to be presented in a classroom where students can ask questions.
  • Real World Haskell. RWH on the other hand is better for just dipping into the odd chapter but it is really useful for more advanced topics that crop up in the real world; it proved particularly useful for example with profiling/fixing memory leaks, learning about Haskell’s concurrency model and error handling.
  • Try Haskell is an online interactive Haskell tutorial which makes it easier to follow along.

Exercises

References

  • Hoogle is by far the best tool to look up anything Haskell related, even type signatures! Blog post
  • What I wish I knew when learning Haskell is a good read once you’ve read the above literature.

Community

  • As far as community goes, there are IRC channels such as #haskell-beginners, the Haskell subreddit and there are also tons of meetups which are great for face-to-face conversations, experience sharing, etc. Covering all the material above will take a while, but do not give up. Your efforts will be truly worth it. Last but not least, the Haskell community is incredibly nice, welcoming, and helpful. And they are very smart. In fact, we received incredibly valuable feedback from the last blog posts we published on the subject.

To summarise

  • Read Learn you a Haskell cover to cover.
  • Dip in and out of Real World Haskell as and when necessary.
  • Read Chris Allen’s recommended path to learning Haskell.

What is Functional Programming?

In a restricted sense, functional programming means programming without mutable variables, assignments, loops and control structures.

In a wider sense, functional programming paradigm focuses on functions. When we focus on functions, we think about what is to be done rather than how.

Example:

Suppose you have to calculate sum of the squares.

In an imperative style you would start thinking about initializing the sum variable as 0, iterating over 1 to n, squaring each number and adding these squares to the sum variable on each iteration.

There is iteration and mutable variables.

In functional thinking you would identify functions to be used.

There are three words in this program: takemap and sum. Each of these words refers to a function. The “.” simply means- call the following function and the give it, the result of current function as the argument.

The take function’s responsibility is to emit a list of integers from 1 to n. map function maps each element of this list to its squares and produces another list. sum function takes this list and returns the sum.

That’s it.

Each function does only one job and we solve the problem in terms of functions and not in steps.

So, functional programming is about applying function to data rather than bringing data to functions.

In a way, it’s similar to using axe(function) to cut the wood(data) rather than bringing the wood to axe.

Natural. Isn’t it?