[Haskell-beginners] optimisation of code