Our getInt function can be defined as follows where ask puts a message on the console asking for a nonnegative integer and return_or_recurse either returns an Int or restarts getInt.

getInt = 
   ask >> 
      getLine >>= 
         return_or_uecurse