diff options
author | alexbiehl <alex.biehl@gmail.com> | 2017-04-18 16:45:32 +0200 |
---|---|---|
committer | Alex Biehl <alexbiehl@gmail.com> | 2017-04-25 10:08:48 +0200 |
commit | 70885ce16e1b0b9bf19fe0efb85a48daa0e5c281 (patch) | |
tree | 97616aa480ce473386bc6f7cf2d58d8f74ac28f1 /haddock-api/src/Haddock.hs | |
parent | 99ec96e57ea6b002394c923201d46a67ecfb8e16 (diff) |
Travis: Use ghc-8.2.1 on master
Diffstat (limited to 'haddock-api/src/Haddock.hs')
-rw-r--r-- | haddock-api/src/Haddock.hs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs index 6af0874a..dec85b79 100644 --- a/haddock-api/src/Haddock.hs +++ b/haddock-api/src/Haddock.hs @@ -426,15 +426,22 @@ getHaddockLibDir flags = #ifdef IN_GHC_TREE getInTreeDir #else - d <- getDataDir -- provided by Cabal - doesDirectoryExist d >>= \exists -> case exists of - True -> return d - False -> do - -- If directory does not exist then we are probably invoking from - -- ./dist/build/haddock/haddock so we use ./resources as a fallback. - doesDirectoryExist "resources" >>= \exists_ -> case exists_ of - True -> return "resources" - False -> die ("Haddock's resource directory (" ++ d ++ ") does not exist!\n") + -- if data directory does not exist we are probably + -- invoking from either ./haddock-api or ./ + let res_dirs = [ getDataDir -- provided by Cabal + , pure "resources" + , pure "haddock-api/resources" + ] + + check get_path = do + p <- get_path + exists <- doesDirectoryExist p + pure $ if exists then Just p else Nothing + + dirs <- mapM check res_dirs + case [p | Just p <- dirs] of + (p : _) -> return p + _ -> die "Haddock's resource directory does not exist!\n" #endif fs -> return (last fs) |