[Haskell-cafe] ANN: progress-meter 1.0.0

Ertugrul Söylemez esz at posteo.de
Mon Dec 25 01:15:11 UTC 2017


Hi everybody,

I have just released a complete API rewrite of the `progress-meter`
package:

  * <https://hackage.haskell.org/package/progress-meter>
  * <https://github.com/esoeylemez/progress-meter>

With this package you can easily add live diagnostics to any
long-running application from a simple progress bar to full task
monitoring.  The `System.Progress` module contains a tutorial.
Features:

  * update progress from multiple threads,

  * non-progress diagnostics that just scroll by (e.g. logging),

  * breaking the state apart for individual threads, so they can update
    their relevant portion of the progress bar without interfering with
    each other ("zooming"),

  * smart throttling (no updates drawn when nothing is happening, and
    only ever drawn at a maximum rate).

Here is a very simple example:

    import Control.Concurrent
    import System.Progress

    main = withProgress_ "" id $ \pm -> do
        -- Set the progress bar:
        setMeter pm "Working..."

        -- Do some "work":
        threadDelay 3000000

        -- Print something while temporarily hiding the progress bar:
        putMsgLn pm "Some extra diagnostics that scrolls by"

        setMeter pm "Almost done..."
        threadDelay 1000000
        putMsgLn pm "Done."

The first argument of 'withProgress_' is the initial state and the
second is a renderer for the current state:

    render :: Int -> String
    render p = "Progress: " ++ show p ++ "%"

    withProgress_ 0 render $ \pm -> do
        threadDelay 1000000
        setMeter pm 10
        threadDelay 8900000
        setMeter pm 99
        -- The famous last percent:
        threadDelay 10000000
        putMsgLn pm "Done."

Progress-meter will do The Right Thing when you update the state or
produce log messages from multiple threads.


Happy holidays
ertes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20171225/a8278719/attachment.sig>


More information about the Haskell-Cafe mailing list