Haskell Summer of Code : The Good, The Bad and The Ugly

As part of Haskell Summer of Code student, I am more than happy to share my experience while working on the project — Improvement of Hackage Matrix Builder — and how to handle most of the problem that I encounter over the summer. As in the title, it has the good, bad and ugly part that happened since it was my first time on Haskell Summer of Code.

TL;DR: this post is not about harassing or discrediting any other third party or people whom I contacted with while working on the project. Spending my time as HSOC student this summer was became unforgettable moment for me. The good part is I can finally working on a real project that use functional programming language— even though I spent too much on Purescript which is FUN!! — as its choice of language, being able to learn from my Mentor (HVR) as well as other people on both Haskell and Purescript community was very fantastic . Also, Hackage Matrix Builder is very interesting project with a great plan in the future. The bad part is the time that I had planned was messed up with my 3rd year project University. I didn’t know that will happened, but it’s been taken care of. The ugly part is when writing codes, It’s still hard for me to write code using KISS method. I tend to use complicated ways in my algorithm. In addition, as non-native English speaker, I found that my English skill is far from perfect.That’s it, if you interested to read about HSOC and Hackage Matrix Builder, please read below.

I am not going to open my blog post by introducing myself. Instead, I have made some post About Me if you are willing to read. I don’t know about other HSOC awardee, but this picture is all that I can say when receiving email from Jasper Van der Jeugt which telling me that I will be one of the HSOC 2017 student.

Surprisingly happy

At that time, I still don’t remember which proposal that got approved (since I applied more than one) and soon after I know that the approved proposal is about the Improvement of Hackage Matrix Builder mentored by Herbert Valerio Riedel (HVR).

I never thought I can got approved by the committee, as I am new to haskell and I only have one own project (using Reflex and Reflex-Dom) for my University project. However, I am not nervous but getting more excited by the announcement as I’d read someone’s quote about — more or less — :

Doing a real project will increase your knowledge on functional programming more than just reading some books without making any project

That’s it, I contacted my mentor and said to him that the project was approved and discuss with him about how we can make the project finished on time.

The Project

Hackage Matrix Builder is… well… what can I say, it was already well written in the project ideas. But let me quote here:

The Hackage matrix builder provides a build compatibility test service to the Haskell community for all the packages published on Hackage. Currently it answers the question “which versions of GHC does this package build with”, which includes checking the Cabal solver can find a solution and have that solution build successfully. It works by building all versions of all packages with several GHC versions. It relies on clever nix-style caching to make this reasonably efficient. So this is a kind of QA or CI service for everyone. There is also a lot of potential to use this kind of infrastructure for additional purposes.

Before I apply to HSOC, this project got my attention first. It is because as one of the Haskell beginner, I never thought that I can see package or library from the compiler perspective without having to compile it myself. Moreover, if I ever be a package owner (hopefully soon), I can see whether my package is able or not to satisfy all the GHC version and then I just need to fix it by looking at the build log report online.

As it’s actually should be posted in the first place, the project repository is located here. Also, I encourage anyone who has some idea on features that might help the project improved to post it here because I will continue to work on this project.

The Good

There are several good part happened during my HSOC. But what I explained here is only some of experience that might be helpful for the next HSOC’s student.

1. Diving Into Real Project

Making your own project when you are a “computer science” student who try to learn new language may not be always easy for everyone. Somehow you just don’t know what to build or where to start the idea. It become worst if you just depend on exercise or project example in the book you read. The truth is, it happened to me, especially when I try to learn Haskell and knowing that in my University, that word is not familiar or I can say students haven’t even heard at all.

Can’t find friend to discuss, to working some project together and just relying on forum or IRC to find the study materials. That’s what I feel when learning Functional Programming and Haskell.

I try to build my pet project (as I mentioned it as my 3rd year university project) but for me, it still feels not good enough. So when there is an announcement about Haskell Summer of Code (HSOC), I told myself that “This opportunity only comes once a year, so I need to try it”.

Participating in the summer of code event is foreign to me. I never thought about it before and local event like this is very rare in Indonesia. But when I got invited and start coding on real project, it feels very different. What I am doing in HSOC is to refactor the javascript codebase to Purescript, a functional programming language that compiles to JavaScript which the compiler itself wrote in Haskell.

So where is the Haskell part on it? Haskell used as the backend of the project, while for the frontend we choose to use Purescript. By the time I wrote this, I already made this contribution (it is amazing at least for me):

Hackage Matrix Builder Repository

As you can see, participating in HSOC or other summer of code forced you to write codes. It isn’t about giving you the idea because the project is already there and you must (whether you want it or not) continue to develop the project. So is there any other way better than this? I don’t think so.

2. Programming Language Choice

Why Purescript? When I choose between Reflex (with its Reflex-Dom library) and Purescript, I thought it will be better for me to go with Reflex as I am more familiar with it. But when given the choice between learning something new and use your existing knowledge, I will definitely choose the first one. Purescript is not different than Haskell in term of the syntax in general, so I found it very challenging if I can learn another functional programming language which has similarity with Haskell.

So where do I start when Purescript is the language choice? First, I looked into their official website and then I read the “PureScript by Example” book which you can read here. The book is the best introduction as it is written by Purescript author Phil Freeman. When refactoring the code, I use one of Purescript framework called Halogen, which is developed by SlamData team and it’s an open source project. I will not say much more about Purescript or what I learn when refactoring Hackage Matrix Builder’s old Javascript code here, as I will wrote it in another blog post.

3. Learn From Mentor and Community

Well when participate in HSOC, you cannot depend on your mentor because sometimes they are very busy with their day to day job. Herbert as my mentor always ask about the project progress and also discuss with me whenever I want to know a lot more about the project. Not only that, he also gives me the idea and its solution for some problem that I encountered during my work period especially when we try to upgrade the API version of Hackage Matrix Builder into version 2. I am very grateful for that, because I never had the chance to know how client-server communication between Haskell and Purescript. On the other hand, the other good part is we have the Community where you can ask or discuss with people that already familiar on what you are doing.

Getting help from other is one of the benefit on how it feels when contribute to real project. I remember when the first time Adam gave me explanation on the frontend side of the project since he is the one who write the 1st generation of Hackage Matrix Builder together with Herbert. He explained very briefly on what should I do and where to begin my work. He also allowed me to pick Halogen framework and refactor the existing Purescript code base that he wrote. Well, actually I just use his existing code on the API and Types as well as other useful function and combined it with the framework.

Other benefit that you can get in the community is they will response and sometimes help you whenever you get stuck or don’t know what to do. Since I use Halogen framework, I got help — a lot — from @kritzcreek and @natefaubion and #Purescript channel both in IRC and Slack. There will be some new technique that you can learn, such as when I try to generate matrix table which each row contained version number and each of them depend on previous version. That is when Christoph told me to look at function accumResult in the Pursuit (it is like hoogle for Haskell). And voila, using a simple code as below, I never realize that I can generate the table using this simple function.

Of course I have learned a lot more from him and it makes me finished refactor page quicker than the other page. This is important for student to actively ping/direct message someone you think can help your specific question especially for me who need to paste a lot of code. That is when I got advice from Nate about handling search box for package with the following code (I will explained it in another blog post).

That is when I realized how to integrate Halogen with another library. In summary being able to use Purescript in HSOC is FUN!!! In this post, I will not talked about the back-end as I am still in the process of preparing the front-end for API v2.

The Bad

Bad thing sometimes happened to everyone in any condition even though everything is already well-planned. That is what I believe when I start doing something. HSOC is very helpful to me as I start to understand some terminology and idioms. However, trying to meet the deadline is not only require good understanding but also need mitigation skills to handle some unexpected event.

1. When Your Plan Betray You

When I apply for HSOC, I am in the middle of doing my 3rd year university project. By the end of its deadline, I need to make presentation in front of lecturers. From my understanding, it will be scheduled after HSOC final evaluation, thus I didn’t have to worry about it. I finalized my university project 1 week before “Community bonding period begins” and discussed with my supervisor about the report and presentation.

Everything was very smooth, I passed my HSOC mid-term evaluation and complete my presentation. So I just need to wait the date when I will present my report to the lecturers. I know that I need to prepare the administration 7–14 days until the university project is totally finished. But suddenly, I got the presentation schedule in the middle of my final evaluation period. That is when you know that your plan was betraying you.

When you experienced this, be calm and discuss with your mentor about how to handle the situation. Luckily for me, Herbert give me time to finished my project first and advise me to reduce my time spent on Hackage Matrix Builder a little. One thing that I forgot was to tell Jasper about the situation. So in addition to mentor, you need to tell your committee too.

2. You Are Not Smart Enough

Do you ever feel that you are actually not smart enough to be selected? Well… it happened to me when I stuck for more than 3 days on how to refactor certain div from Javascript into Purescript. I didn’t ask anyone because I thought it is an easy task, anyone can do it without a blink at all. I waited for 3 days because I assume that 3 days is your limit to solve your code on your own. You need to start asking around when you can solve it more than 3 days. So I start talking to my mentor and told him that I think HSOC is not for me, or I am not smart enough to participate in event like this.

Again, he told me that HSOC is not for super brilliant student and it never was. It was meant for student who want to improve their skills in functional programming especially Haskell. So it is okay for you when “not smart enough” feeling came up in the middle of your project in HSOC. You just need to share it to your mentor so he knows that you are actually working on the project but got a little obstacle and try to solve it on your own. And also it is good to have mentor who not only tell you how to code but also embrace you to keep going.

The Ugly

I have two ugly part that I think one is for student in general, and the other is for every student in Indonesia that maybe interested to apply HSOC 2018.

1. Keep It Simple Student!!

Think simple is one of the skill that developer should have. It will help you solving some problem easily. You are not in the middle of “competitive programming”, so being simple will reduce your coding time for certain project a lot. That is where— as beginner — I am still bad on it. As a beginner, you always want to be perfect in your code especially when you have been granted as participant of a great event like HSOC. Also, sometimes you try to impress your skill to your mentor.

The ugly part that I feel in HSOC is I tried to be as perfect as I can. Sometime it makes me thinking too much on how my code should look like. I try to write 10 lines of code when it is actually only need 3–4 lines of code for certain algorithm. Being complicated not only will make your app slow, but it is also will kill your time which is very precious for the deadline. In this part, I can’t tell you how to work it out because I am still struggling on that too.

2. Non-native English Speaker

I don’t know which English level that other participant have. However, since I am not at “mother tongue” level, this is my ugly part on HSOC. Not because I can’t communicate with my mentor, but explaining something on plain English is not my best skill during HSOC period. I tend to misunderstand about certain library or explanation on how the Hackage Matrix Builder’s API works. It slows me a lot when I try to re read the library or understand the example on certain library.

Maybe this part is not for people who already have good skill at English. But for my Indonesian friends, I think you need to prepare yourself before applying HSOC by make yourself comfortable read a lot of library documentation as well as its example. Try not only read it, but write and test the example until you understand how the library works. After that, you need to start asking the community to get better understanding on certain documentation.

What’s Next?

If somebody asked me about what to do next, of course I will directly said, “write a lot of code both Haskell and Purescript”. As this is my last year study, maybe I will try to find some remote jobs in Haskell / Purescript to increase my skill. But beyond that, I have plan to spread Haskell and Purescript here in Indonesia. I feel that I need to gather more people to learn it together from basic to advance topics. I don’t know if I am able to explain what Monad is, or even Applicative and Functor. But I believe that by being part of HSOC student will gave more confidence to invite others to learn Haskell.