[Haskell-beginners] adding state handing to existing code