git.iko.soy/typeable/attoparsec
on master help sign in
Merge
039bdf1Bryan O'Sullivan
Data/Attoparsec/Combinator.hs+8−3
@@ -182,7 +182,9 @@ sepBy1' p s = scan
182-- > simpleComment = string "<!--" *> manyTill anyChar (try (string "-->"))
182-- > simpleComment = string "<!--" *> manyTill anyChar (try (string "-->"))
183--
183--
184-- Note the overlapping parsers @anyChar@ and @string \"<!--\"@, and
184-- Note the overlapping parsers @anyChar@ and @string \"<!--\"@, and
185−-- therefore the use of the 'try' combinator.
185+-- therefore the use of the 'try' combinator. (This is not strictly required
186+-- because Attoparsec backtracks automatically, but recommended anyway for
187+-- compatibility with Parsec.)
186manyTill :: Alternative f => f a -> f b -> f [a]
188manyTill :: Alternative f => f a -> f b -> f [a]
187manyTill p end = scan
189manyTill p end = scan
188 where scan = (end *> pure []) <|> liftA2 (:) p scan
190 where scan = (end *> pure []) <|> liftA2 (:) p scan
@@ -198,8 +200,11 @@ manyTill p end = scan
198-- > simpleComment = string "<!--" *> manyTill' anyChar (try (string "-->"))
200-- > simpleComment = string "<!--" *> manyTill' anyChar (try (string "-->"))
199--
201--
200-- Note the overlapping parsers @anyChar@ and @string \"<!--\"@, and
202-- Note the overlapping parsers @anyChar@ and @string \"<!--\"@, and
201−-- therefore the use of the 'try' combinator. The value returned by @p@
203+-- therefore the use of the 'try' combinator. (This is not strictly required
204+-- because Attoparsec backtracks automatically, but recommended anyway for
205+-- compatibility with Parsec.)
206+--
202−-- is forced to WHNF.
207+-- The value returned by @p@ is forced to WHNF.
203manyTill' :: (MonadPlus m) => m a -> m b -> m [a]
208manyTill' :: (MonadPlus m) => m a -> m b -> m [a]
204manyTill' p end = scan
209manyTill' p end = scan
205 where scan = (end >> return []) `mplus` liftM2' (:) p scan
210 where scan = (end >> return []) `mplus` liftM2' (:) p scan