[Haskell-beginners] Why is this function that slow?