Use applicative style in Parsec

This commit also moves `eol` into the `parseTermMatch` parser, which should be
safe since `parseTermMatches` is the only place that `parseTermMatch` is used.
This commit is contained in:
Gabe Berke-Williams 2016-05-12 11:43:17 -04:00 committed by Joshua Clayton
parent 3ff26fceea
commit 985d876ff5

View File

@ -21,15 +21,7 @@ responseFromParse =
fmap $ Map.fromList . map (second $ calculateLikelihood . resultsFromMatches) . groupBy tmTerm
parseTermMatches :: Parser [TermMatch]
parseTermMatches = do
tm <- many1 $ do
m <- parseTermMatch
void eol
return m
eof
return tm
parseTermMatches = many1 parseTermMatch <* eof
parseTermMatch :: Parser TermMatch
parseTermMatch = do
@ -38,6 +30,7 @@ parseTermMatch = do
path' <- pathParser
colonSep
occurrences' <- occurrenceParser
void eol
return $ TermMatch term' path' $ toInt occurrences'
where