diff options
author | Hécate <hecate+gitlab@glitchbra.in> | 2020-09-18 20:07:49 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-23 20:44:24 -0400 |
commit | 31fea307499009977fdf3dadedc98cfef986077a (patch) | |
tree | cac7edf234b82d16c3edd53fc38539fcc2766cb5 /libraries/base/Text | |
parent | a997fa01d907fc1992dc8c3ebc73f98e7a1486f7 (diff) | |
download | haskell-31fea307499009977fdf3dadedc98cfef986077a.tar.gz |
Remove redundant "do", "return" and language extensions from base
Diffstat (limited to 'libraries/base/Text')
-rw-r--r-- | libraries/base/Text/ParserCombinators/ReadP.hs | 8 | ||||
-rw-r--r-- | libraries/base/Text/Printf.hs | 2 | ||||
-rw-r--r-- | libraries/base/Text/Read/Lex.hs | 27 |
3 files changed, 19 insertions, 18 deletions
diff --git a/libraries/base/Text/ParserCombinators/ReadP.hs b/libraries/base/Text/ParserCombinators/ReadP.hs index e6dcab55e0..d01dd931c8 100644 --- a/libraries/base/Text/ParserCombinators/ReadP.hs +++ b/libraries/base/Text/ParserCombinators/ReadP.hs @@ -278,9 +278,9 @@ string :: String -> ReadP String -- ^ Parses and returns the specified string. string this = do s <- look; scan this s where - scan [] _ = do return this + scan [] _ = return this scan (x:xs) (y:ys) | x == y = do _ <- get; scan xs ys - scan _ _ = do pfail + scan _ _ = pfail munch :: (Char -> Bool) -> ReadP String -- ^ Parses the first zero or more characters satisfying the predicate. @@ -291,7 +291,7 @@ munch p = scan s where scan (c:cs) | p c = do _ <- get; s <- scan cs; return (c:s) - scan _ = do return "" + scan _ = return "" munch1 :: (Char -> Bool) -> ReadP String -- ^ Parses the first one or more characters satisfying the predicate. @@ -315,7 +315,7 @@ skipSpaces = skip s where skip (c:s) | isSpace c = do _ <- get; skip s - skip _ = do return () + skip _ = return () count :: Int -> ReadP a -> ReadP [a] -- ^ @count n p@ parses @n@ occurrences of @p@ in sequence. A list of diff --git a/libraries/base/Text/Printf.hs b/libraries/base/Text/Printf.hs index 3aeb0be789..216c29d9e3 100644 --- a/libraries/base/Text/Printf.hs +++ b/libraries/base/Text/Printf.hs @@ -292,7 +292,7 @@ instance (a ~ ()) => PrintfType (IO a) where -- | @since 4.7.0.0 instance (a ~ ()) => HPrintfType (IO a) where - hspr hdl fmts args = do + hspr hdl fmts args = hPutStr hdl (uprintf fmts (reverse args)) -- | @since 2.01 diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs index 7568f9afaf..7da09164fb 100644 --- a/libraries/base/Text/Read/Lex.hs +++ b/libraries/base/Text/Read/Lex.hs @@ -273,7 +273,7 @@ lexCharE = do c1 <- get if c1 == '\\' then do c2 <- lexEsc; return (c2, True) - else do return (c1, False) + else return (c1, False) where lexEsc = lexEscChar @@ -341,7 +341,7 @@ lexCharE = _ -> pfail lexAscii = - do choice + choice [ (string "SOH" >> return '\SOH') <++ (string "SO" >> return '\SO') -- \SO and \SOH need maximal-munch treatment @@ -404,9 +404,9 @@ lexString = do _ <- char '\\' c <- get case c of - '&' -> do return () + '&' -> return () _ | isSpace c -> do skipSpaces; _ <- char '\\'; return () - _ -> do pfail + _ -> pfail -- --------------------------------------------------------------------------- -- Lexing numbers @@ -429,13 +429,14 @@ lexHexOct lexBaseChar :: ReadP Int -- Lex a single character indicating the base; fail if not there -lexBaseChar = do { c <- get; - case c of - 'o' -> return 8 - 'O' -> return 8 - 'x' -> return 16 - 'X' -> return 16 - _ -> pfail } +lexBaseChar = do + c <- get + case c of + 'o' -> return 8 + 'O' -> return 8 + 'x' -> return 16 + 'X' -> return 16 + _ -> pfail lexDecNumber :: ReadP Lexeme lexDecNumber = @@ -471,8 +472,8 @@ lexDigits base = where scan (c:cs) f = case valDig base c of Just n -> do _ <- get; scan cs (f.(n:)) - Nothing -> do return (f []) - scan [] f = do return (f []) + Nothing -> return (f []) + scan [] f = return (f []) lexInteger :: Base -> ReadP Integer lexInteger base = |