Haskell diary #1
2014-12-06

I’m learning functional programming and writing things down as I go. Some of my understanding may be incomplete or wrong, and I expect to refine it in the fullness of time.

This is my diary of learning Haskell (and possibly FP in other languages too). I don’t have a particular goal, but I’m studying with the an eye out for practical use of Haskell and FP in general. My hope is that functional programming can provide a superior approach to writing software compared to OOP.

I started out by quickly viewing the [Haskell Fundamentals course on Pluralsight] to become familiar with the syntax of the language.

I really liked a few things:

  • How concise the syntax is.
  • How explicit type annotations are largely unnecessary (although it appears that the accepted style is to spell out function types for the purposes of documentation).
  • How currying and partial application are baked right into the language. As soon as I got that, my bewilderment about writing function signatures as a -> b -> c -> d (without distinguishing parameters and return type) disappeared. It’s actually a really neat idea!
  • Algebraic data types make a lot of sense (I’m now wondering why mainstream languages don’t have them)
  • I liked that there is little distinction between functions and operators; from a mathematical point of view, it makes a lot of sense.

I was reading Elements of Programming by Alexander Stepanov and Paul McJones at the time, and I had a clever idea to do the exercises in the book in Haskell instead of C++. I had to do a tactical retreat quite soon as I realised that while the book emphasises value types and pure functions, replacing stateful algorithms with stateless implementations is far from trivial. Moreover, I was just not used to thinking that way.

I had to reconsider my options, and decided to take a more traditional approach by doing some beginner exercises in Haskell.

I went on to review this list of Haskell resources and chose the CIS194 course homework as a starting point.

That’s it for today!