Why doesn't GHC do the following optimisation?