----------------------------------------------------------------------------- -- | -- Module : ProgressBar -- Copyright : (c) Austin Seipp 2009 -- License : BSD3 -- -- Maintainer : mad.one@gmail.com -- Stability : provisional -- Portability : portable -- -- A Progress bar -- ----------------------------------------------------------------------------- module ProgressBar ( Progress(..) -- :: * , mkProgress -- :: Handle -> IO Progress ) where import Control.Concurrent.Reactive import Control.Concurrent import System.IO -- | Progress bar meter. data Progress = Progress { pr_inc :: IO () -- ^ This increments the progressbar , pr_done :: IO () -- ^ This finishes the progressbar /NOTE/: it is -- unusable after this } -- | Create a progress bar mkProgress :: Handle -> IO Progress mkProgress h = reactiveObjectIO 0 $ \ _pid req act done -> Progress { pr_inc = do hPutStr h "." hFlush h , pr_done = do hPutStr h "!\n" hFlush h done }