Type-Safe Runtime Code Generation with (Typed) Template Haskell
gmainland.blogspot.co.uk