@@ -26,6 +26,7 @@ import Data.Char
2626import qualified Data.Text as T
2727import qualified Data.Text.IO as TI
2828import Data.Attoparsec.Text hiding (try )
29+ import Data.Attoparsec.Combinator (lookAhead )
2930import Text.Printf
3031import Distribution.PackageDescription
3132import Distribution.PackageDescription.Parse
@@ -237,6 +238,8 @@ computeDiffDownloadHoogleDB ComputeParams { .. } = do
237238 putS " Parsing Hoogle DBs..."
238239 [parsedDBA, parsedDBB] <- forM [dbA, dbB] $ \ db ->
239240 either throwError return $ parseOnly (hoogleDBParser <* endOfInput) db
241+ -- Debug parser in GHCi: parseOnly hoogleDBParser <$> TI.readFile "base.txt" >>=
242+ -- \(Right db) -> mapM_ (putStrLn . show) db
240243 -- Compare
241244 putS " Comparing Hoogle DBs..."
242245 return $ diffHoogleDB parsedDBA parsedDBB
@@ -495,10 +498,14 @@ hoogleDBParser = many parseLine
495498 ( (DBNewtype <$> takeTill (`elem` [ ' ' , ' \n ' ]) <* endOfLine <*> " " ) <|>
496499 (DBNewtype <$> takeTill (== ' ' ) <* skipSpace <*> tillEoL)
497500 )
498- parseCtor = do peekChar' >>= flip unless (fail " lowercase" ) . isAsciiUpper
501+ -- TODO: At some point Hoogle DBs started to have Ctors and functions
502+ -- names wrapped in brackets. Not sure what's up with that, just
503+ -- parse them as part of the name so the parser doesn't stop
504+ parseCtor = do void . lookAhead $ satisfy isAsciiUpper <|>
505+ (char ' [' *> satisfy isAsciiUpper)
499506 DBCtor <$> takeTill (== ' ' ) <* string " :: " <*> tillEoL
500- parseFunction = do peekChar' >>=
501- flip unless ( fail " uppercase " ) . ( \ c -> isAsciiLower c || c == ' (' )
507+ -- TODO: This doesn't parse function lists correctly
508+ parseFunction = do void . lookAhead $ satisfy isAsciiLower <|> char ' [ ' <|> char ' ('
502509 DBFunction <$> takeTill (== ' ' ) <* string " :: " <*> tillEoL
503510 parseInstance = do void $ string " instance "
504511 line <- T. words <$> tillEoL
0 commit comments