From 3e17a2096595f004534ae29920be60f239e31fab Mon Sep 17 00:00:00 2001
From: "Joseph C. Sible" <josephcsible@users.noreply.github.com>
Date: Sat, 11 Apr 2020 17:29:28 -0400
Subject: [PATCH] Simplify thenSkip, and use in another location

---
 src/ShellCheck/Parser.hs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs
index 64d75c6..b96aee7 100644
--- a/src/ShellCheck/Parser.hs
+++ b/src/ShellCheck/Parser.hs
@@ -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)