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)

Introduction To MACID

For now we're going to step away from Happstack.Server and making web applications with Happstack. Instead, we'll be talking about the persistant state system provided by Happstack.State: MACID.

MACID is the Happstack storage mechanism that allows you to use whatever data structure you want to hold your permanent data, without worrying about getting it into and out of tabular form fit for storage in a traditional rdbms.

Before delving into how it works let's learn a bit about it from an operational perspective. Assuming you have the tutorial installed and running locally:

  • Register a new user with username "testuser" and password "testpassword"
  • Optionally, fill out profile information for your new test user, and/or make some job posts.

The data you entered is stored on your filesystem in a directory under your running executable, called _local.

~/happs-tutorial>ls _local/happs-tutorial_state/
current-0000000000 events-0000000000 events-0000000001 events-0000000002

You can grep for it too.

thartman@thartman-laptop:~/happs-tutorial>grep -ra testuser _local
_local/happs-tutorial_state/events-0000000000:ß$6¡·¢:1525374391 696985193?AppState1.AddUsertestuser e1 ... (and lots more lines of binary data)

Hm... let's see, can we be sneaky and grep for the password?

Try it, you can't. Because the password is stored as an md5 hash, out of respect for the privacy of your users. See the newUserPage function in ControllerPostActions if you're curious.

Now it's time for your first application.