Generate enums with template haskell.

The TH is a little complicated but I think definitely worth it to keep
the code DRY.

Overall this change comes with 1448 deletions and only 635 insertions.

Lemmih - let me know how you feel about adding TH to the package. I think it's the best tool for the job in this case.