Closest pairs algorithm (for a list of pairs/coordinates) implemented in Haskell