From 09a36e80ecaefcfb60eccda98bd06461d0aeca70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Sat, 28 Mar 2020 14:25:44 +0300 Subject: Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. --- compiler/main/SysTools/Terminal.hs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'compiler') 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 -- cgit v1.2.1