In modern web applications, the client can do far more than simply showing data retrieved from the server. Clients are powerful enough to perform complex tasks without assistance from the server. The result is a greatly improved experience for the user: Network roundtrips can be avoided by local processing, improving responsiveness, and the application might remain usable even during intermittent loss of connectivity.

Bringing more responsibilities to the client requires the functionality to be duplicated for the browser environment. Additionally, to effectively deal with network latency and service interruptions, the application has to be designed around managing local state on the clients and effectively synchronizing this state with the server.

On some platforms, this would be a daunting task, requiring major chunks of code to be rewritten to make them work on the client. Fortunately, for Haskell we have GHCJS, allowing us to do everything from a single codebase. Haskell’s static type system and strong focus on purity and concurrency make it ideally suited for this type of application.

The talk will show how we can use Haskell and GHCJS to optimally distribute computations between the client and server, relying on Cloud Haskell for type-safe communication. The end result is a heterogeneous distributed system that decides where to perform computations depending on throughput and latency requirements and availability of data. Additionally we will explore how to work with local state on the client and what properties we need from our data structures for effectively dealing with synchronization.