summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2020-03-28 14:25:44 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-31 10:55:37 -0400
commit09a36e80ecaefcfb60eccda98bd06461d0aeca70 (patch)
tree582ee9cb8515c85ca09be1cb4230f73386f47aa4
parent33f095511a8fce4c945bbcd4feb3910c854dcb61 (diff)
downloadhaskell-09a36e80ecaefcfb60eccda98bd06461d0aeca70.tar.gz
Simplify stderrSupportsAnsiColors
The combinator andM is used only once, and the code is shorter and simpler if you inline it.
-rw-r--r--compiler/main/SysTools/Terminal.hs19
1 files changed, 6 insertions, 13 deletions
diff --git a/compiler/main/SysTools/Terminal.hs b/compiler/main/SysTools/Terminal.hs
index 349f5c162c..d1262db531 100644
--- a/compiler/main/SysTools/Terminal.hs
+++ b/compiler/main/SysTools/Terminal.hs
@@ -32,20 +32,13 @@ import qualified System.Win32 as Win32
stderrSupportsAnsiColors :: IO Bool
stderrSupportsAnsiColors = do
#if defined(MIN_VERSION_terminfo)
- queryTerminal stdError `andM` do
- (termSupportsColors <$> setupTermFromEnv)
- `catch` \ (_ :: SetupTermError) ->
- pure False
-
+ stderr_available <- queryTerminal stdError
+ if stderr_available then
+ fmap termSupportsColors setupTermFromEnv
+ `catch` \ (_ :: SetupTermError) -> pure False
+ else
+ pure False
where
-
- andM :: Monad m => m Bool -> m Bool -> m Bool
- andM mx my = do
- x <- mx
- if x
- then my
- else pure x
-
termSupportsColors :: Terminal -> Bool
termSupportsColors term = fromMaybe 0 (getCapability term termColors) > 0