ascii-progress - a simple progress bar package for haskell

Cool! I'm personally a big fan of the vty library and vty-ui widgets -- perhaps this library could either utilize or add to those? They're really great for making complex command-line interfaces, but I don't know whether they're any good for small things.

That said, if you can't output multiple progress bars, you may want to rethink the interface. Right now it seems like I could do:

main = do
   let fmt = currentProgress % "/" % totalProgress % " [" % barProgress % "]" 
   pg <- newProgressBar def { pgFormat = fmt }
   pg' <- newProgressBar def { pgFormat = fmt }
   forever $ tick pg >> tick pg' -- or something

Instead, perhaps you could not expose newProgressBar, and instead expose an interface that makes it clear that only one progress bar could exist. A potential might look like this:

import System.Console.AsciiProgress as Progress
main = do
   Progress.setFormat fmt
   Progress.tickN
   where fmt = currentProgress % "/" % totalProgress % " [" % barProgress % "]" 

That said, that is a very imperative-style interface, but I don't know if there's a way around that, since ultimately you can only have a single progress bar (due to the fact that there's literally just one space in the command line). Maybe another option would be to expose some low-level primitives, perhaps something like renderProgressBar :: ProgressBar -> IO () which prints out a progress bar and clearProgressBar :: IO () which clears whichever progress bar was printed last (I don't know if such primitives could actually be made). That way, the user could decide how they actually manage things, and it's clear what the API can and can't do.

As an aside, please don't take all these musings about library design as criticism! This seems like a great library that's already pretty solid, and I don't mean to rag on it at all -- I just like thinking about ways in which we can use the Haskell language to very precisely express what a library / API does (I think that this enables the sort of "learn-library-by-looking-at-the-types" exploration that Haskell is great at and that I really miss in many other languages).

/r/haskell Thread Link - github.com