Notes on codes, projects and everything

Picking Up Category Theory (and eventually Haskell)

I don’t quite remember when did I first heard about Category Theory, but the term stuck in my head for quite a while. Eventually I attempted to start looking for tutorials on the topic, but it is hard to find one that I actually understand. Most of them are either leaning too much to the Mathematics side, or too much to the Programming side.

Then I found this guy.

Dr. Spivak apparently did a small workshop in 2017, which started very easy, with enough mathematics

Though in the end things get tougher and more abstract, but this eventually prompted me to follow a proper lecturer on the topic. Plus, I was working from home and was stuck at home already anyway.

So the first lecture I followed was his Applied Category theory course (co-taught by Dr. Fong). Again, it started fine, but I got really lost towards the end. Then I found there was a new one (co-taught by Dr. Fong and Dr. Milewski), which was taught using Haskell, and I continued following the lecture.

The problem with learning this is that, everything inter-connected with each other, so if I miss one part of it, then it is impossible to follow the subsequent ones. Even if you ask me about earlier parts I vaguely understands, I can’t explain them in my own words.

I suppose, when I finally have some time to revisit (the same or different material), I probably would be able to understand better. It feels like the field of study requires some immersion heh.

Regardless the outcome, eventually I got intrigued by Haskell.

Setting up a working environment is a pain by itself (will probably cover this altogether in the next post, on how I set up my machine for work) but the whole learning experience was wonderful, much better than learning Rust (still struggle with the language at times).

While not my first functional language, Category Theory plays an important role in Haskell. It is close to impossible to find a tutorial with no mention of some basic category theory terms in it (e.g. Functors, Monad etc).

As usual, I learn a new language I start by solving puzzles. I am still slowly going through the exercism core exercises (where there would be a mentor assigned to help out), while doing so, I recorded the struggle by livestreaming the process too. The main text reference I use whenever I run into a problem is Learn You a Haskell for Great Good!

(Enjoy seeing me struggling to apply Monad stuff into a problem, I later found the proper solution with mentor’s help but have not recorded a follow up)

Meanwhile, I also followed another tutorial that offer some mentorship, which is called learn4haskell. This is significantly harder, as they crammed a lot more into the tutorial. However, it was also a fun experience. Having a mentor guiding me through the journey is certainly good.

One of the things that I really like about the language is how close it resembles mathematics.

It is always possible to evaluate an expression on a piece of paper (though I did it on my electronic tablet), as shown above.

However, I am not too sure how practical the language is in real life work (though my main language Python is not known being fast/efficient with the use of CPython), but so far I do like it a lot more than Rust. Only problem with this is that finding a job that uses this language is close to impossible in Malaysia (Only know one person in Malaysia doing this, and he is in Labuan, which is only reachable by flight).

On the other hand, as I am digging for more tutorials for a language, I discovered a lot more things that I took for granted in the past. When I was doing golang, the limit of the language made me discover what generic does in a language and how Rust provides that. Now I am currently finding out what Higher Kinded Type is and is figuring out what I miss in other languages like Python.

In the end, I guess learning more about Category Theory and Haskell would be my focus for 2021. It is rather interesting to find how much I thought about Rust when I learn about Haskell 😛 Oh speaking of that, we need to figure out how to revive the meetups next year too ):

leave your comment

name is required

email is required

have a blog?

This blog uses scripts to assist and automate comment moderation, and the author of this blog post does not hold responsibility in the content of posted comments. Please note that activities such as flaming, ungrounded accusations as well as spamming will not be entertained.


Click to change color scheme