Purely functional programming languages like Haskell do not allow mutable state or other side effects in plain functions. A popular misconception says that this could make real-life tasks like programming graphical user interfaces (GUI) more difficult. This is not the case. The aim of this tutorial is to show that Haskell is, in fact, well-suited for GUI programming.
In this tutorial, I will give a hands-on introduction to writing GUI applications with Haskell using my GUI library “Threepenny”. This library is easy to install, because it uses the web browser as a display. First, I will give a brief overview of the library architecture. Then, I will present the basic concepts of GUI programming in Haskell by walking through a few example programs. At the end, we will look at how the paradigm of functional reactive programming (FRP), a radical departure from the traditional imperative paradigm, can simplify GUI programming.
Heinrich Apfelmus has been programming in Haskell for more than 10 years, and develops several open source libraries, currently focusing on graphical user interfaces (GUI) and functional reactive programming (FRP). Heinrich has studied mathematics and currently works in theoretical physics. As a student, he has participated in international programming competitions.