Merge pull request #1917 from josephcsible/thenskip

Simplify thenSkip, and use in another location
This commit is contained in:
Vidar Holen 2020-04-12 15:26:36 -07:00 committed by GitHub
commit 413f0048b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -373,10 +373,7 @@ parseNoteAtId id c l a = do
parseNoteAtWithEnd start end c l a = addParseNote $ ParseNote start end c l a
--------- Convenient combinators
thenSkip main follow = do
r <- main
optional follow
return r
thenSkip main follow = main <* optional follow
unexpecting s p = try $
(try p >> fail ("Unexpected " ++ s)) <|> return ()
@ -420,7 +417,7 @@ acceptButWarn parser level code note =
parsecBracket before after op = do
val <- before
(op val <* optional (after val)) <|> (after val *> fail "")
op val `thenSkip` after val <|> (after val *> fail "")
swapContext contexts p =
parsecBracket (getCurrentContexts <* setCurrentContexts contexts)