| Safe Haskell | Safe |
|---|
Worm
Description
This module is a library to maybe keep command-line tool users slightly happier, by whimsically illustrating progress in slow-running parallel processes with a mildly entertaining animated worm that crawls slowly from left to right and back again, while displaying textual progress from flexible sources of input.
- data Progress = Progress_ p ⇒ Progress p
- class Progress_ p where
- rawProgress ∷ MVar String → Progress
- collectingProgress ∷ MVar Int → MVar Int → Progress
- type Canceller = IO ()
- wormProgress ∷ [Progress] → IO Canceller
- main ∷ IO ()
Showing Progress
The Progress type is a general wrapper for Control.Concurrent.MVar-ish things we can read and show next to the animation, while another (worker) thread updates them.
To add another form of showable progress information, declare a new type which implements Progress_, and a constructor (like rawProgress) to wrap that type in Progress.
class Progress_ p where Source #
Class for formattable progress information types.
Minimal complete definition
Methods
formatProgress ∷ p → IO String Source #
A function that should (quickly) produce formatted progress information, for example by reading it from a wrapped MVar.
rawProgress ∷ MVar String → Progress Source #
Displays (in brackets) a 'Control.Concurrent.MVar.MVar String' that you're free to update any way you choose.
collectingProgress ∷ MVar Int → MVar Int → Progress Source #
Displays as (43/200), where either side of the fraction-wall can be independently updated.
Performing Animation
type Canceller = IO () Source #
Action you can invoke to atomically stop/erase the worm before outputting real information, so your output goes unmangled.