summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils
diff options
context:
space:
mode:
authorHécate <hecate+gitlab@glitchbra.in>2020-10-10 21:15:36 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-01 01:11:09 -0400
commitdfd27445308d1ed2df8826c2a045130e918e8192 (patch)
tree99fc01edeebc2924ddb7533864e0d4ca18cfe800 /compiler/GHC/Utils
parentbd4abdc953427e084e7ecba89db64860f6859822 (diff)
downloadhaskell-dfd27445308d1ed2df8826c2a045130e918e8192.tar.gz
Add the proper HLint rules and remove redundant keywords from compiler
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r--compiler/GHC/Utils/Binary.hs1
-rw-r--r--compiler/GHC/Utils/Error.hs81
-rw-r--r--compiler/GHC/Utils/Exception.hs3
-rw-r--r--compiler/GHC/Utils/GlobalVars.hs2
-rw-r--r--compiler/GHC/Utils/Misc.hs2
5 files changed, 41 insertions, 48 deletions
diff --git a/compiler/GHC/Utils/Binary.hs b/compiler/GHC/Utils/Binary.hs
index dbc2cdc195..1579eeb5a8 100644
--- a/compiler/GHC/Utils/Binary.hs
+++ b/compiler/GHC/Utils/Binary.hs
@@ -3,7 +3,6 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GADTs #-}
-{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
diff --git a/compiler/GHC/Utils/Error.hs b/compiler/GHC/Utils/Error.hs
index 2db4672f07..25da8be3de 100644
--- a/compiler/GHC/Utils/Error.hs
+++ b/compiler/GHC/Utils/Error.hs
@@ -1,6 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
-{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-
@@ -124,10 +123,6 @@ orValid IsValid _ = IsValid
orValid _ v = v
-- -----------------------------------------------------------------------------
--- Basic error messages: just render a message with a source location.
-
-
--- -----------------------------------------------------------------------------
-- Collecting up messages for later ordering and printing.
mk_err_msg :: DynFlags -> Severity -> SrcSpan -> PrintUnqualified -> ErrDoc -> ErrMsg
@@ -536,42 +531,42 @@ withTiming' :: MonadIO m
-> m a -- ^ The body of the phase to be timed
-> m a
withTiming' dflags what force_result prtimings action
- = do if verbosity dflags >= 2 || dopt Opt_D_dump_timings dflags
- then do whenPrintTimings $
- logInfo dflags $ withPprStyle defaultUserStyle $
- text "***" <+> what <> colon
- let ctx = initDefaultSDocContext dflags
- eventBegins ctx what
- alloc0 <- liftIO getAllocationCounter
- start <- liftIO getCPUTime
- !r <- action
- () <- pure $ force_result r
- eventEnds ctx what
- end <- liftIO getCPUTime
- alloc1 <- liftIO getAllocationCounter
- -- recall that allocation counter counts down
- let alloc = alloc0 - alloc1
- time = realToFrac (end - start) * 1e-9
-
- when (verbosity dflags >= 2 && prtimings == PrintTimings)
- $ liftIO $ logInfo dflags $ withPprStyle defaultUserStyle
- (text "!!!" <+> what <> colon <+> text "finished in"
- <+> doublePrec 2 time
- <+> text "milliseconds"
- <> comma
- <+> text "allocated"
- <+> doublePrec 3 (realToFrac alloc / 1024 / 1024)
- <+> text "megabytes")
-
- whenPrintTimings $
- dumpIfSet_dyn dflags Opt_D_dump_timings "" FormatText
- $ text $ showSDocOneLine ctx
- $ hsep [ what <> colon
- , text "alloc=" <> ppr alloc
- , text "time=" <> doublePrec 3 time
- ]
- pure r
- else action
+ = if verbosity dflags >= 2 || dopt Opt_D_dump_timings dflags
+ then do whenPrintTimings $
+ logInfo dflags $ withPprStyle defaultUserStyle $
+ text "***" <+> what <> colon
+ let ctx = initDefaultSDocContext dflags
+ eventBegins ctx what
+ alloc0 <- liftIO getAllocationCounter
+ start <- liftIO getCPUTime
+ !r <- action
+ () <- pure $ force_result r
+ eventEnds ctx what
+ end <- liftIO getCPUTime
+ alloc1 <- liftIO getAllocationCounter
+ -- recall that allocation counter counts down
+ let alloc = alloc0 - alloc1
+ time = realToFrac (end - start) * 1e-9
+
+ when (verbosity dflags >= 2 && prtimings == PrintTimings)
+ $ liftIO $ logInfo dflags $ withPprStyle defaultUserStyle
+ (text "!!!" <+> what <> colon <+> text "finished in"
+ <+> doublePrec 2 time
+ <+> text "milliseconds"
+ <> comma
+ <+> text "allocated"
+ <+> doublePrec 3 (realToFrac alloc / 1024 / 1024)
+ <+> text "megabytes")
+
+ whenPrintTimings $
+ dumpIfSet_dyn dflags Opt_D_dump_timings "" FormatText
+ $ text $ showSDocOneLine ctx
+ $ hsep [ what <> colon
+ , text "alloc=" <> ppr alloc
+ , text "time=" <> doublePrec 3 time
+ ]
+ pure r
+ else action
where whenPrintTimings = liftIO . when (prtimings == PrintTimings)
eventBegins ctx w = do
@@ -776,8 +771,8 @@ type TraceAction = forall a. DynFlags -> String -> SDoc -> a -> a
-- | Default action for 'dumpAction' hook
defaultDumpAction :: DumpAction
-defaultDumpAction dflags sty dumpOpt title _fmt doc = do
- dumpSDocWithStyle sty dflags dumpOpt title doc
+defaultDumpAction dflags sty dumpOpt title _fmt doc =
+ dumpSDocWithStyle sty dflags dumpOpt title doc
-- | Default action for 'traceAction' hook
defaultTraceAction :: TraceAction
diff --git a/compiler/GHC/Utils/Exception.hs b/compiler/GHC/Utils/Exception.hs
index 49fa19bd47..46c1f9d37d 100644
--- a/compiler/GHC/Utils/Exception.hs
+++ b/compiler/GHC/Utils/Exception.hs
@@ -3,14 +3,13 @@
module GHC.Utils.Exception
(
- module Control.Exception,
+ module CE,
module GHC.Utils.Exception
)
where
import GHC.Prelude
-import Control.Exception
import Control.Exception as CE
import Control.Monad.IO.Class
import Control.Monad.Catch
diff --git a/compiler/GHC/Utils/GlobalVars.hs b/compiler/GHC/Utils/GlobalVars.hs
index 5556a7e4f1..f169d07161 100644
--- a/compiler/GHC/Utils/GlobalVars.hs
+++ b/compiler/GHC/Utils/GlobalVars.hs
@@ -95,7 +95,7 @@ global :: a -> IORef a
global a = unsafePerformIO (newIORef a)
consIORef :: IORef [a] -> a -> IO ()
-consIORef var x = do
+consIORef var x =
atomicModifyIORef' var (\xs -> (x:xs,()))
globalM :: IO a -> IORef a
diff --git a/compiler/GHC/Utils/Misc.hs b/compiler/GHC/Utils/Misc.hs
index 7436487739..07d4b721ff 100644
--- a/compiler/GHC/Utils/Misc.hs
+++ b/compiler/GHC/Utils/Misc.hs
@@ -1281,7 +1281,7 @@ getModificationUTCTime = getModificationTime
-- check existence & modification time at the same time
modificationTimeIfExists :: FilePath -> IO (Maybe UTCTime)
-modificationTimeIfExists f = do
+modificationTimeIfExists f =
(do t <- getModificationUTCTime f; return (Just t))
`catchIO` \e -> if isDoesNotExistError e
then return Nothing