Skip to content

Instantly share code, notes, and snippets.

@louwers
Created April 4, 2020 18:53
Show Gist options
  • Save louwers/47af7abe6f9fbab69fa80c8475420ee3 to your computer and use it in GitHub Desktop.
Save louwers/47af7abe6f9fbab69fa80c8475420ee3 to your computer and use it in GitHub Desktop.
lookupHtmlForModule :: (FilePath -> FilePath -> FilePath) -> DynFlags -> Module -> IO (Maybe FilePath)
lookupHtmlForModule mkDocPath df m = do
let mfs = go <$> (listToMaybe =<< lookupHtmls df ui)
htmls <- filterM doesFileExist (concat . maybeToList $ mfs)
return $ listToMaybe htmls
where
go pkgDocDir = map (mkDocPath pkgDocDir) [mn, mns]
ui = moduleUnitId m
mn = map (\x -> if x == '.' then '-' else x) mns
mns = moduleNameString $ moduleName m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment