Safe HaskellSafe

Worm

Contents

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.

Synopsis

Showing Progress

data Progress Source #

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.

Constructors

Progress_ p ⇒ Progress p 

Instances

class Progress_ p where Source #

Class for formattable progress information types.

Minimal complete definition

formatProgress

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.

wormProgress ∷ [Progress] → IO Canceller Source #

Starts worm animation with given progress information; gives you a Canceller to invoke when finished.

main ∷ IO () Source #

An example of basic usage.