From 980e7d3ca8aa19977ca517b846e2d2cff4fb1c5d Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Sat, 30 Dec 2023 14:49:26 -0500 Subject: [PATCH] Use <$> instead of >>= and return --- src/ShellCheck/CFG.hs | 2 +- src/ShellCheck/Parser.hs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ShellCheck/CFG.hs b/src/ShellCheck/CFG.hs index ed6a8f8..5d018c8 100644 --- a/src/ShellCheck/CFG.hs +++ b/src/ShellCheck/CFG.hs @@ -997,7 +997,7 @@ handleCommand cmd vars args literalCmd = do (names, flags) = partition (null . fst) pairs flagNames = map fst flags literalNames :: [(Token, String)] -- Literal names to unset, e.g. [(myfuncToken, "myfunc")] - literalNames = mapMaybe (\(_, t) -> getLiteralString t >>= (return . (,) t)) names + literalNames = mapMaybe (\(_, t) -> (,) t <$> getLiteralString t) names -- Apply a constructor like CFUndefineVariable to each literalName, and tag with its id unsetWith c = newNodeRange $ CFApplyEffects $ map (\(token, name) -> IdTagged (getId token) $ c name) literalNames diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs index 04bdbc4..37a9b86 100644 --- a/src/ShellCheck/Parser.hs +++ b/src/ShellCheck/Parser.hs @@ -1195,7 +1195,7 @@ readDollarBracedPart = readSingleQuoted <|> readDoubleQuoted <|> readDollarBracedLiteral = do start <- startSpan - vars <- (readBraceEscaped <|> (anyChar >>= \x -> return [x])) `reluctantlyTill1` bracedQuotable + vars <- (readBraceEscaped <|> ((\x -> [x]) <$> anyChar)) `reluctantlyTill1` bracedQuotable id <- endSpan start return $ T_Literal id $ concat vars @@ -1557,7 +1557,7 @@ readGenericLiteral endChars = do return $ concat strings readGenericLiteral1 endExp = do - strings <- (readGenericEscaped <|> (anyChar >>= \x -> return [x])) `reluctantlyTill1` endExp + strings <- (readGenericEscaped <|> ((\x -> [x]) <$> anyChar)) `reluctantlyTill1` endExp return $ concat strings readGenericEscaped = do @@ -2371,7 +2371,7 @@ readPipeSequence = do return $ T_Pipeline id pipes cmds where sepBy1WithSeparators p s = do - let elems = p >>= \x -> return ([x], []) + let elems = (\x -> ([x], [])) <$> p let seps = do separator <- s return $ \(a,b) (c,d) -> (a++c, b ++ d ++ [separator])