We are working programmers. Even though we are carried away by the beauty and formalism of functional languages, at the end of the day we still need to get the job done. The Haskell community has been accused during the years of navel gazing, and usually the misconception is that “Haskell is an academic language, but you can’t tackle real world problem with it”.
Despite internet is full of fantastic resources for learning Haskell (including the awesome and recently-released School of Haskell) I wanted to use a peculiar approach: I tried to create a web application in a similar fashion of what I would have done during my everyday job in Scala, to see if I was able to replicate a large subset of the features normally present in my Scala apps. Not only was the experiment a success, but I finally had the chance of experimenting with a lot of cool libraries which were in my “to-play-with-list” for a while. So without further ado I’m happy to announce The Pragmatic Haskeller, a collection of small building blocks for creating a full-fledged webapp:
As you might notice, we have a lot of small subfolders. Each folder is a self-contained, working, incremental example experimenting with a new library or technique. Even though you could rush and play with each app all at once, I aim to write a dedicated blog post to each sub-project, introducing the used library, in a similar way of what Oliver Charles did with 24 days of Hackage, with the difference we’ll use the same example episode after episode, until transforming our naive bunch of modules into a complete app.
The Pragmatic Bakery
We couldn’t be Cake Solutions without a bakery, so here we go! What we’ll accomplish, at the end of this journey, is create a small DSL to create recipes, which will be serialised into Haskell records and finally encoded to JSON. Eager to see how the final product will look like? You can take a peek to this live demo, which is hosted on my Amazon Micro Tier:
It uses Snap under the hook, along with a couple of other cool libraries. It’s still a bit rough under the corner, but it should work pretty well. Try to click the red button, and voilà, you get some JSON back! And we have also some naive syntax checking (try to remove a quote from a string!)
Well, I hope this will be enough to whet your appetite! Each subfolder should work,but I’ll refactor each example when a new episode will be published, so feel free to submit pull requests or bug report, because I’m pretty sure to have broken something along the way (small example, I was using my custom fork of snaplet-mongodb-minimalistic but now my patch got merged so I need to refactor the code to reflect the fact we’ll use the hackage version). I think that’s all for now, I hope you will enjoy your baking!