[Haskell-beginners] type error in sub-function