aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Utils.hs
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2008-12-07 19:58:53 +0000
committerDavid Waern <david.waern@gmail.com>2008-12-07 19:58:53 +0000
commit302651f5b7182061f0459d71cf3e17189bf2ca64 (patch)
treeb97cb96e5054405f9918aad75ad1053e857b4fe4 /src/Haddock/Utils.hs
parent3144024f2b768749b29f16a744dee6028577f0bf (diff)
Add verbosity flag and utils, remove "verbose" flag
Diffstat (limited to 'src/Haddock/Utils.hs')
-rw-r--r--src/Haddock/Utils.hs27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/Haddock/Utils.hs b/src/Haddock/Utils.hs
index 70421c23..3bab9edf 100644
--- a/src/Haddock/Utils.hs
+++ b/src/Haddock/Utils.hs
@@ -39,7 +39,11 @@ module Haddock.Utils (
-- FormatVersion, mkFormatVersion
-- * MTL stuff
- MonadIO(..)
+ MonadIO(..),
+
+ -- * Logging
+ parseVerbosity,
+ out
) where
import Haddock.Types
@@ -66,6 +70,8 @@ import System.Environment ( getProgName )
import System.Exit ( exitWith, ExitCode(..) )
import System.IO ( hPutStr, stderr )
import System.IO.Unsafe ( unsafePerformIO )
+import Distribution.Verbosity
+import Distribution.ReadE
#if __GLASGOW_HASKELL__ >= 609
import MonadUtils ( MonadIO(..) )
@@ -75,6 +81,25 @@ class Monad m => MonadIO m where
instance MonadIO IO where liftIO = id
#endif
+
+-- -----------------------------------------------------------------------------
+-- Logging
+
+
+parseVerbosity :: String -> Either String Verbosity
+parseVerbosity str = runReadE flagToVerbosity str
+
+
+-- | Print a message to stdout, if it is not too verbose
+out :: MonadIO m
+ => Verbosity -- ^ program verbosity
+ -> Verbosity -- ^ message verbosity
+ -> String -> m ()
+out progVerbosity msgVerbosity msg
+ | msgVerbosity <= progVerbosity = liftIO $ putStrLn msg
+ | otherwise = return ()
+
+
-- -----------------------------------------------------------------------------
-- Some Utilities