1. new in this version
  2. build a web 2.0 app in happstack
  3. why happstack is cool
  4. getting started with happstack
  5. prerequisites
  6. cabal install me
  7. first shot at happstack
  8. url handling
  9. basic HTML inclusion
  10. templates
  11. stringtemplate basics
  12. debugging
  13. form data: get and post
  14. form data: file uploads
  15. cookies
  16. introduction to macid
  17. first steps with macid
  18. scaling with multimaster
  19. using macid safely
  20. macid dummy data
  21. changing the data model
  22. macid stress test
  23. limitations of macid
  24. foreign characters
  25. IxSets
  26. cron jobs
  27. thanks
  28. appendix (floundering in ghci)

Look Ma, No Database

There are a lot of advantages to programming in a typed functional language like Haskell. Certain bugs, like misuse of global variables, are virtually impossible unless you bend over backwards to do things wrong. Code tends to be incredibly short, and modular. The Haskell community is very friendly, and with coders in every time zone the #haskell irc channel seems well populated seemingly 24 hours a day.

However, in this tutorial we'll be talking about Happstack, not Haskell in general.

Happstack has its origins in the HAppS project. Happstack is a successor to HAppS under the leadership of Matthew Elder and the work of the Happstack team.

An argument for Happstack is that as modern software systems tend toward ever increasing complexity, database usage is an unnecessary source of complication that should be factored out where possible.

Ruby's Rails and Python's Django have become popular largely because of their object relational mapping systems, which hide the complexity of database engines by converting application data manipulation logic into sql. When I first used an ORM, it felt like a huge improvement over writing sql statements every time I wanted to manipulate an application's state. Pretty soon ORMs started seeming hackish to me too. At some point, the metaphors I wanted to use just broke down.

Happstack is Haskell's answer to Rails and Django (and Perl's Catalyst, and PHP). With Happstack, there is no wrangling data structures into and out of the database, because there is no database. You use whatever data structures are natural to your application, and serialize them transparently using powerful machinery that's running behind the scenes. If there are existing databases that you need to connect to, you can do that too -- you're not locked in to using Happstack's state management system, MACID, for everything.

Still, MACID is no vanilla serialization layer that will start acting in weird ways when an application has many concurrent users doing possibly conflicting things. By leveraging Haskell's type system, you get the same ACID guarantees that normally only come with a database.

There are some limitations to using MACID as a datastore that you should familiarize yourself with if you are looking into using Happstack for heavy-usage transactional applications. In the long term, Happstack with MACID looks promising enough that the original author started using it as a platform for building commercial web 2.0 type apps such as patch-tag.

In short, Happstack is awesome, and webmonkeys everywhere should use it.

Let's get started.