Use Template Haskell to compute distance look-up table