Apply a function N times in Haskell