Skip to content

Commit 612583a

Browse files
committed
Action/Server: Disable unwanted warnings
Upstream does not think shadowing should be avoided, so let’s undo the changes to shadowing. Same with incomplete pattern warnings, we’ll just let it crash for now. Also drop the `Is*` prefix for the URL constructors.
1 parent 15bfb98 commit 612583a

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/Action/Server.hs

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards, ScopedTypeVariables, PatternGuards #-}
22
{-# LANGUAGE OverloadedStrings #-}
33
{-# LANGUAGE MultiWayIf #-}
4-
{-# OPTIONS_GHC -Wall #-}
4+
{-# OPTIONS_GHC -Wall -Wno-incomplete-patterns -Wno-name-shadowing #-}
55
{-# LANGUAGE NamedFieldPuns #-}
66

77
module Action.Server(actionServer, actionReplay, action_server_test_, action_server_test) where
@@ -33,7 +33,7 @@ import System.Time.Extra
3333
import Data.Time.Clock
3434
import Data.Time.Calendar
3535
import System.IO.Unsafe
36-
import Numeric.Extra hiding (log)
36+
import Numeric.Extra
3737
import System.Info.Extra
3838

3939
import Output.Tags
@@ -48,7 +48,7 @@ import Action.Search
4848
import Action.CmdLine
4949
import Control.Applicative
5050
import Data.Monoid
51-
import Prelude hiding (log)
51+
import Prelude
5252

5353
import qualified Data.Aeson as JSON
5454

@@ -65,10 +65,9 @@ actionServer cmd@Server{..} = do
6565
putStrLn . showDuration =<< time
6666
_ <- evaluate spawned
6767
dataDir <- maybe getDataDir pure datadir
68-
haddock' <- maybe (pure Nothing) (fmap Just . canonicalizePath) haddock
68+
haddock <- maybe (pure Nothing) (fmap Just . canonicalizePath) haddock
6969
withSearch database $ \store ->
70-
server log cmd $ replyServer log local links haddock' store cdn home (dataDir </> "html") scope
71-
actionServer _ = error "should not happen"
70+
server log cmd $ replyServer log local links haddock store cdn home (dataDir </> "html") scope
7271

7372
actionReplay :: CmdLine -> IO ()
7473
actionReplay Replay{..} = withBuffering stdout NoBuffering $ do
@@ -83,7 +82,6 @@ actionReplay Replay{..} = withBuffering stdout NoBuffering $ do
8382
evaluate $ rnf res
8483
putChar '.'
8584
putStrLn $ "\nTook " ++ showDuration t ++ " (" ++ showDuration (t / intToDouble (repeat_ * length qs)) ++ ")"
86-
actionReplay _ = error "should not happen"
8785

8886
{-# NOINLINE spawned #-}
8987
spawned :: UTCTime
@@ -111,9 +109,9 @@ replyServer log local links haddock store cdn home htmlDir scope Input{..} = cas
111109
let (q2, results) = search store q
112110

113111
let urlOpts = if
114-
| Just _ <- haddock -> IsHaddockUrl
115-
| local -> IsLocalUrl
116-
| otherwise -> IsOtherUrl
112+
| Just _ <- haddock -> HaddockUrl
113+
| local -> LocalUrl
114+
| otherwise -> OtherUrl
117115
let body = showResults urlOpts links (filter ((/= "mode") . fst) inputArgs) q2 $
118116
takeAndGroup 25 (\t -> t{targetURL="",targetPackage=Nothing, targetModule=Nothing}) results
119117
case lookup "mode" inputArgs of
@@ -154,8 +152,8 @@ replyServer log local links haddock store cdn home htmlDir scope Input{..} = cas
154152
["log"] -> do
155153
OutputHTML <$> templateRender templateLog []
156154
["log.js"] -> do
157-
log' <- displayLog <$> logSummary log
158-
OutputJavascript <$> templateRender templateLogJs [("data",html $ H.preEscapedString log')]
155+
log <- displayLog <$> logSummary log
156+
OutputJavascript <$> templateRender templateLogJs [("data",html $ H.preEscapedString log)]
159157
["stats"] -> do
160158
stats <- getStatsDebug
161159
pure $ case stats of
@@ -210,7 +208,7 @@ takeAndGroup n key = f [] Map.empty
210208
| otherwise = f (k:keys) (Map.insert k [x] mp) xs
211209
where k = key x
212210

213-
data UrlOpts = IsHaddockUrl | IsLocalUrl | IsOtherUrl
211+
data UrlOpts = HaddockUrl | LocalUrl | OtherUrl
214212

215213
showResults :: UrlOpts -> Bool -> [(String, String)] -> [Query] -> [[Target]] -> Markup
216214
showResults urlOpts links args query results = do
@@ -285,10 +283,10 @@ showFroms urlOpts targets = mconcat $ intersperse ", " $ flip map pkgs $ \pkg ->
285283
pkgs = nubOrd $ map targetPackage targets
286284

287285
showURL :: UrlOpts -> URL -> String
288-
showURL IsHaddockUrl x = "haddock/" ++ dropPrefix "file:///" x
289-
showURL IsLocalUrl (stripPrefix "file:///" -> Just x) = "file/" ++ x
290-
showURL IsLocalUrl x = x
291-
showURL IsOtherUrl x = x
286+
showURL HaddockUrl x = "haddock/" ++ dropPrefix "file:///" x
287+
showURL LocalUrl (stripPrefix "file:///" -> Just x) = "file/" ++ x
288+
showURL LocalUrl x = x
289+
showURL OtherUrl x = x
292290

293291

294292
-------------------------------------------------------------

0 commit comments

Comments
 (0)