diff options
| author | bjorn <bjorn@bringert.net> | 2008-05-28 15:56:37 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-05-28 15:56:37 +0000 |
| commit | 2fcc77a884b5a440f2378fcc2e67bdcab812fcfb (patch) | |
| tree | bbf8e26d4fea0a437d8b00cfe6a6f5f0d0a85fca /src-3.0/GF/Infra/UseIO.hs | |
| parent | a5cf2afccf67c45cf68d1a2b3bba197d63f4ce2f (diff) | |
Some printing / verbosity fixes.
Diffstat (limited to 'src-3.0/GF/Infra/UseIO.hs')
| -rw-r--r-- | src-3.0/GF/Infra/UseIO.hs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src-3.0/GF/Infra/UseIO.hs b/src-3.0/GF/Infra/UseIO.hs index dcc0c62ca..f7563ed2c 100644 --- a/src-3.0/GF/Infra/UseIO.hs +++ b/src-3.0/GF/Infra/UseIO.hs @@ -40,15 +40,11 @@ putShow' f = putStrLn . show . length . show . f putIfVerb :: Options -> String -> IO () putIfVerb opts msg = - if beVerbose opts - then putStrLn msg - else return () + when (verbAtLeast opts Verbose) $ putStrLn msg putIfVerbW :: Options -> String -> IO () putIfVerbW opts msg = - if beVerbose opts - then putStr (' ' : msg) - else return () + when (verbAtLeast opts Verbose) $ putStr (' ' : msg) errOptIO :: Options -> a -> Err a -> IO a errOptIO os e m = case m of @@ -245,17 +241,9 @@ putStrLnE = ioeIO . putStrLnFlush putStrE :: String -> IOE () putStrE = ioeIO . putStrFlush --- this is more verbose -putPointE :: Options -> String -> IOE a -> IOE a -putPointE = putPointEgen beSilent - --- this is less verbose -putPointEsil :: Options -> String -> IOE a -> IOE a -putPointEsil = putPointEgen (not . beVerbose) - -putPointEgen :: (Options -> Bool) -> Options -> String -> IOE a -> IOE a -putPointEgen cond opts msg act = do - when (cond opts) $ ioeIO $ putStrFlush msg +putPointE :: Verbosity -> Options -> String -> IOE a -> IOE a +putPointE v opts msg act = do + when (verbAtLeast opts v) $ ioeIO $ putStrFlush msg t1 <- ioeIO $ getCPUTime a <- act >>= ioeIO . evaluate @@ -265,10 +253,6 @@ putPointEgen cond opts msg act = do return a --- | forces verbosity -putPointEVerb :: Options -> String -> IOE a -> IOE a -putPointEVerb = putPointEgen (const False) - -- ((do {s <- readFile f; return (return s)}) ) readFileIOE :: FilePath -> IOE BS.ByteString readFileIOE f = ioe $ catch (BS.readFile f >>= return . return) |
