How is this Generic-based instance implementation optimized by GHC?