on master help sign in
Fix ifdefs in Hakyll.Check

Fixes #518

commit95578246e6d6ea35be5936f3106e59bc8e594512 authorJasper Van der Jeugt <m@jaspervdj.be> dateMon 23 Jan 2017, 15:53 (10 years ago) parent0790ebd
1 file changed+13−15
src/Hakyll/Check.hs+13−15
src/Hakyll/Check.hs+13−15
@@ -8,8 +8,13 @@ module Hakyll.Check
88
99
1010--------------------------------------------------------------------------------
11−import Control.Monad (forM_, foldM)
12−import Control.Monad.Reader (ask, ReaderT, runReaderT)
11+import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar,
12+ readMVar)
13+import Control.Exception (SomeAsyncException (..),
14+ SomeException (..), throw, try)
15+import Control.Monad (foldM, forM_)
16+import Control.Monad.Reader (ReaderT, ask, runReaderT)
17+import Control.Monad.State (StateT, get, modify, runStateT)
1318import Control.Monad.Trans (liftIO)
1419import Control.Monad.Trans.Resource (runResourceT)
1520import Data.ByteString.Char8 (unpack)
@@ -21,16 +26,11 @@ import System.Directory (doesDirectoryExist,
2126import System.Exit (ExitCode (..))
2227import System.FilePath (takeDirectory, takeExtension,
2328 (</>))
24−import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar,
25− readMVar)
2629import qualified Text.HTML.TagSoup as TS
2730
2831
2932--------------------------------------------------------------------------------
3033#ifdef CHECK_EXTERNAL
31−import Control.Exception (SomeAsyncException (..),
32− SomeException (..), try, throw)
33−import Control.Monad.State (get, modify, StateT, runStateT)
3434import Data.List (intercalate)
3535import Data.Typeable (cast)
3636import Data.Version (versionBranch)
@@ -186,7 +186,7 @@ skip :: URL -> Maybe String -> Checker ()
186186skip url maybeReason = do
187187 logger <- checkerLogger <$> ask
188188 case maybeReason of
189− Nothing -> return ()
189+ Nothing -> return ()
190190 Just reason -> Logger.debug logger reason
191191 putCheckResult url mempty {checkerOk = 1}
192192
@@ -241,19 +241,14 @@ checkExternalUrl url = do
241241 Left (SomeException e) ->
242242 case (cast e :: Maybe SomeAsyncException) of
243243 Just ae -> throw ae
244− _ -> faulty url (Just $ showException e)
244+ _ -> faulty url (Just $ showException e)
245245 Right _ -> ok url
246246 where
247247 -- Convert exception to a concise form
248248 showException e = case cast e of
249249 Just (Http.HttpExceptionRequest _ e') -> show e'
250− _ -> head $ words $ show e
251−#else
252−checkExternalUrl url = skip url Nothing
253−#endif
250+ _ -> head $ words $ show e
254251
255−
256−--------------------------------------------------------------------------------
257252requestExternalUrl :: URL -> Checker (Either SomeException Bool)
258253requestExternalUrl url = liftIO $ try $ do
259254 mgr <- Http.newManager Http.tlsManagerSettings
@@ -273,6 +268,9 @@ requestExternalUrl url = liftIO $ try $ do
273268 -- Nice user agent info
274269 ua = fromString $ "hakyll-check/" ++
275270 (intercalate "." $ map show $ versionBranch Paths_hakyll.version)
271+#else
272+checkExternalUrl url = skip url Nothing
273+#endif
276274
277275
278276--------------------------------------------------------------------------------