haskellcommand-linehaskeline

Updating outputted text in haskeline


Haskeline provides the functions outputStr and outputStrLn, which output to stdout, but is there a way to update text that's already been outputted? I'm thinking of, for example, when an installer displays the current percentage installed -- the percentage number updates.

Am I going to need to use a curses binding?


Solution

  • delete n = putStr (replicate n '\b')
    

    This is (essentially) how QuickCheck does it and it works reasonably well. I use it in my own code for progress indicators and it gives me good results. Something more sophisticated will requires a curses binding (or equivalent).