Merge pull request #1826 from josephcsible/nofromjust

Use the Identity monad to avoid unnecessary uses of fromJust
This commit is contained in:
Vidar Holen 2020-02-10 18:05:36 -08:00 committed by GitHub
commit d0beac6d0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 16 deletions

View file

@ -1057,9 +1057,7 @@ checkNumberComparisons params (TC_Binary id typ op lhs rhs) = do
checkStrings =
mapM_ stringError . find isNonNum
isNonNum t = fromMaybe False $ do
s <- getLiteralStringExt (const $ return "") t
return . not . all numChar $ s
isNonNum t = not . all numChar $ onlyLiteralString t
numChar x = isDigit x || x `elem` "+-. "
stringError t = err (getId t) 2170 $
@ -2578,7 +2576,7 @@ checkTildeInPath _ (T_SimpleCommand _ vars _) =
warn id 2147 "Literal tilde in PATH works poorly across programs."
checkVar _ = return ()
hasTilde t = fromMaybe False (liftM2 elem (return '~') (getLiteralStringExt (const $ return "") t))
hasTilde t = '~' `elem` onlyLiteralString t
isQuoted T_DoubleQuoted {} = True
isQuoted T_SingleQuoted {} = True
isQuoted _ = False