1
1
{-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards, ScopedTypeVariables, PatternGuards #-}
2
2
{-# LANGUAGE OverloadedStrings #-}
3
3
{-# LANGUAGE MultiWayIf #-}
4
- {-# OPTIONS_GHC -Wall #-}
4
+ {-# OPTIONS_GHC -Wall -Wno-incomplete-patterns -Wno-name-shadowing #-}
5
5
{-# LANGUAGE NamedFieldPuns #-}
6
6
7
7
module Action.Server (actionServer , actionReplay , action_server_test_ , action_server_test ) where
@@ -33,7 +33,7 @@ import System.Time.Extra
33
33
import Data.Time.Clock
34
34
import Data.Time.Calendar
35
35
import System.IO.Unsafe
36
- import Numeric.Extra hiding ( log )
36
+ import Numeric.Extra
37
37
import System.Info.Extra
38
38
39
39
import Output.Tags
@@ -48,7 +48,7 @@ import Action.Search
48
48
import Action.CmdLine
49
49
import Control.Applicative
50
50
import Data.Monoid
51
- import Prelude hiding ( log )
51
+ import Prelude
52
52
53
53
import qualified Data.Aeson as JSON
54
54
@@ -65,10 +65,9 @@ actionServer cmd@Server{..} = do
65
65
putStrLn . showDuration =<< time
66
66
_ <- evaluate spawned
67
67
dataDir <- maybe getDataDir pure datadir
68
- haddock' <- maybe (pure Nothing ) (fmap Just . canonicalizePath) haddock
68
+ haddock <- maybe (pure Nothing ) (fmap Just . canonicalizePath) haddock
69
69
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
72
71
73
72
actionReplay :: CmdLine -> IO ()
74
73
actionReplay Replay {.. } = withBuffering stdout NoBuffering $ do
@@ -83,7 +82,6 @@ actionReplay Replay{..} = withBuffering stdout NoBuffering $ do
83
82
evaluate $ rnf res
84
83
putChar ' .'
85
84
putStrLn $ " \n Took " ++ showDuration t ++ " (" ++ showDuration (t / intToDouble (repeat_ * length qs)) ++ " )"
86
- actionReplay _ = error " should not happen"
87
85
88
86
{-# NOINLINE spawned #-}
89
87
spawned :: UTCTime
@@ -111,9 +109,9 @@ replyServer log local links haddock store cdn home htmlDir scope Input{..} = cas
111
109
let (q2, results) = search store q
112
110
113
111
let urlOpts = if
114
- | Just _ <- haddock -> IsHaddockUrl
115
- | local -> IsLocalUrl
116
- | otherwise -> IsOtherUrl
112
+ | Just _ <- haddock -> HaddockUrl
113
+ | local -> LocalUrl
114
+ | otherwise -> OtherUrl
117
115
let body = showResults urlOpts links (filter ((/= " mode" ) . fst ) inputArgs) q2 $
118
116
takeAndGroup 25 (\ t -> t{targetURL= " " ,targetPackage= Nothing , targetModule= Nothing }) results
119
117
case lookup " mode" inputArgs of
@@ -154,8 +152,8 @@ replyServer log local links haddock store cdn home htmlDir scope Input{..} = cas
154
152
[" log" ] -> do
155
153
OutputHTML <$> templateRender templateLog []
156
154
[" 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 )]
159
157
[" stats" ] -> do
160
158
stats <- getStatsDebug
161
159
pure $ case stats of
@@ -210,7 +208,7 @@ takeAndGroup n key = f [] Map.empty
210
208
| otherwise = f (k: keys) (Map. insert k [x] mp) xs
211
209
where k = key x
212
210
213
- data UrlOpts = IsHaddockUrl | IsLocalUrl | IsOtherUrl
211
+ data UrlOpts = HaddockUrl | LocalUrl | OtherUrl
214
212
215
213
showResults :: UrlOpts -> Bool -> [(String , String )] -> [Query ] -> [[Target ]] -> Markup
216
214
showResults urlOpts links args query results = do
@@ -285,10 +283,10 @@ showFroms urlOpts targets = mconcat $ intersperse ", " $ flip map pkgs $ \pkg ->
285
283
pkgs = nubOrd $ map targetPackage targets
286
284
287
285
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
292
290
293
291
294
292
-------------------------------------------------------------
0 commit comments