[Haskell-beginners] function not working as expected, type issues