[Git][ghc/ghc][master] Simplify stderrSupportsAnsiColors
Marge Bot
gitlab at gitlab.haskell.org
Tue Mar 31 14:55:49 UTC 2020
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00
Simplify stderrSupportsAnsiColors
The combinator andM is used only once, and the code is shorter and
simpler if you inline it.
- - - - -
1 changed file:
- compiler/main/SysTools/Terminal.hs
Changes:
=====================================
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
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09a36e80ecaefcfb60eccda98bd06461d0aeca70
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09a36e80ecaefcfb60eccda98bd06461d0aeca70
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200331/8aee12a8/attachment-0001.html>
More information about the ghc-commits
mailing list