added support for message types

Ignore-this: c341870e54604151242389bbb0916d81

You can now give messages a type. There is also a function app:when_message(type,callback)
which allows you to set which functions are called when a message of the type is specified.

This should simplify a common pattern which is setting a "t" key and then having an
if, else if, else block switching on type.

darcs-hash:20140417225128-c21fe-ad06d1a99ac7b9403f127bfb0afb42dcf4ebc81f