on master help sign in
Don't spam the console with duplicate messages
cde6c32Steven Robertson
Network/Wai/Handler/DevelServer.hs+9−3
@@ -28,6 +28,8 @@ import System.Directory (doesDirectoryExist,
28 doesFileExist, getDirectoryContents)
28 doesFileExist, getDirectoryContents)
29import Control.Applicative ((<$>))
29import Control.Applicative ((<$>))
30
30
31+import Data.List (nub)
32+
31type FunctionName = String
33type FunctionName = String
32
34
33run :: Port -> ModuleName -> FunctionName -> [FilePath] -> IO ()
35run :: Port -> ModuleName -> FunctionName -> [FilePath] -> IO ()
@@ -77,12 +79,16 @@ fillApp modu func mqueue dirs =
77 threadDelay 1000000
79 threadDelay 1000000
78 go newError newFiles
80 go newError newFiles
79 reload prevError = do
81 reload prevError = do
82+ case prevError of
80− putStrLn "Attempting to interpret your app..."
83+ Nothing -> putStrLn "Attempting to interpret your app..."
84+ _ -> return ()
81 loadingApp' prevError mqueue
85 loadingApp' prevError mqueue
82 res <- theapp modu func
86 res <- theapp modu func
83 case res of
87 case res of
84 Left err -> do
88 Left err -> do
89+ if show (Just err) /= show prevError
85− putStrLn $ "Compile failed: " ++ showInterpError err
90+ then putStrLn $ "Compile failed: " ++ showInterpError err
91+ else return ()
86 loadingApp' (Just $ toException err) mqueue
92 loadingApp' (Just $ toException err) mqueue
87 return (Just $ toException err, [])
93 return (Just $ toException err, [])
88 Right (app, files') -> E.handle onInitErr $ do
94 Right (app, files') -> E.handle onInitErr $ do
@@ -100,7 +106,7 @@ fillApp modu func mqueue dirs =
100
106
101showInterpError :: InterpreterError -> String
107showInterpError :: InterpreterError -> String
102showInterpError (WontCompile errs) =
108showInterpError (WontCompile errs) =
103− concat $ map (\(GhcError msg) -> '\n':'\n':msg) errs
109+ concat . nub $ map (\(GhcError msg) -> '\n':'\n':msg) errs
104showInterpError err = show err
110showInterpError err = show err
105
111
106fileList :: FilePath -> IO [FilePath]
112fileList :: FilePath -> IO [FilePath]