Haskell dynamic performance

I have a simple command line interface with inserts in DB and now it writes a lot of information for stdout, for example:

... record 856/1000: 85% record 857/1000: 85% record 858/1000: 85% ... 

but I want to have 1 dynamic row with updating the current row parameters

  status |T | C | A | E --------------------------------------- inserting |1000 | 857 | 85% | 96 

How can i achieve this?

+5
source share
2 answers

If this is only one line, you can use \r to fast forward the cursor to the beginning of the line.

Here is an example:

 import Control.Concurrent import Control.Monad import Text.Printf main :: IO () main = do forM_ [10, 9 .. 1] $ \seconds -> do printf "\rLaunching missiles in %2d..." (seconds :: Int) threadDelay $ 1 * 1000 * 1000 putStrLn "\nBlastoff!" 
+11
source

The Joey Hess concurrent-output library is designed to output progress like this (and more complex options).

http://hackage.haskell.org/package/concurrent-output

https://joeyh.name/blog/entry/a_tiling_region_manager_for_the_console/

+3
source

Source: https://habr.com/ru/post/1236388/


All Articles