@@ -26,6 +26,7 @@ import Data.Char
26
26
import qualified Data.Text as T
27
27
import qualified Data.Text.IO as TI
28
28
import Data.Attoparsec.Text hiding (try )
29
+ import Data.Attoparsec.Combinator (lookAhead )
29
30
import Text.Printf
30
31
import Distribution.PackageDescription
31
32
import Distribution.PackageDescription.Parse
@@ -237,6 +238,8 @@ computeDiffDownloadHoogleDB ComputeParams { .. } = do
237
238
putS " Parsing Hoogle DBs..."
238
239
[parsedDBA, parsedDBB] <- forM [dbA, dbB] $ \ db ->
239
240
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
240
243
-- Compare
241
244
putS " Comparing Hoogle DBs..."
242
245
return $ diffHoogleDB parsedDBA parsedDBB
@@ -495,10 +498,14 @@ hoogleDBParser = many parseLine
495
498
( (DBNewtype <$> takeTill (`elem` [ ' ' , ' \n ' ]) <* endOfLine <*> " " ) <|>
496
499
(DBNewtype <$> takeTill (== ' ' ) <* skipSpace <*> tillEoL)
497
500
)
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)
499
506
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 ' ('
502
509
DBFunction <$> takeTill (== ' ' ) <* string " :: " <*> tillEoL
503
510
parseInstance = do void $ string " instance "
504
511
line <- T. words <$> tillEoL
0 commit comments