Synchronize with 0.3.1 on hackage and fix build with TH >= 2.8