Haskell is magic and it is not as difficult to program as you may think. You can be productive very early if you use a high-level library for your domain problem.
There are two programming levels in industrial Haskell: one in which programmers create Embedded Domain Specific Languages (EDSLs), and one in which programmers simply use the EDSLs without much concern about what is below. A mature and efficient development ecosystem needs both levels; you shouldn’t need to know about compiler theory to use a compiler.
This tutorial assumes that you have no knowledge of Haskell, but you are interested. You are probably following a basic course like learn you a Haskell, but you have no time and you need to be able to develop browser applications from the beginning.
So there is a lot of interest and effort put into using Haskell for the client side. Browser programming is probably the easiest and most casual way to enter the world of Haskell, and one of the most promising ways to enter into the industry. A program running in the browser can be distributed and executed in any place and on any device, without the need for anything else. A Haskell development environment that runs on the web is immediately accessible to anyone.
There are also a lot of programmers investing many hours of effort trying to overcome the main problems of client-side development:
- How to avoid the explosive complexity of the callback programming model.
- How to easily create dynamic layouts by taming the HTML DOM tree.
Haskell has a lot to contribute these issues. For example, the Haskell type system is the best tool for debugging, integration and factorization.
Integration and factorization in Haskell is like plugging connectors into appliances: you know that if the socket does not accept the plug, it is not in the right place or you need an adapter.
Writing Haskell is like sculpting in stone. Once the program compiles, it works; especially if the program is coded in a high-level EDSL.
When it comes to callback hell, the user can program imperative statements; Haskell will generate callbacks under the hood. That is what the hplayground library does. It also manages form inputs and events within this imperative-like style.
These events can perform modifications on the HTML DOM using a high-level library that makes writing new DOM elements on the fly as easy as writing plain HTML code. This is the work done by the perch library.
In this tutorial, we will use the Haste compiler plus some libraries that bring a high-level EDSL for the creation of client-side web applications. We will illustrate how to do it by creating a personal finance application.
The complete code and application is running at http://tryplayg.herokuapp.com/try/mybudget.hs/edit