summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-11-14 19:30:50 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-16 14:50:06 -0500
commit37cfe3c0f4fb16189bbe3bb735f758cd6e3d9157 (patch)
treef4084bab4c1d5a71a24d8b67677bef5061a6b08a /ghc
parent08bf28819b78e740550a73a90eda62cce8d21c90 (diff)
downloadhaskell-37cfe3c0f4fb16189bbe3bb735f758cd6e3d9157.tar.gz
Misc cleanup
* Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs26
1 files changed, 10 insertions, 16 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 3e1bc227d1..9327ac6da7 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -3864,7 +3864,7 @@ continueCmd argLine = withSandboxOnly ":continue" $
where
contSwitch :: [String] -> Either SDoc (Maybe Int)
contSwitch [ ] = Right Nothing
- contSwitch [x] = getIgnoreCount x
+ contSwitch [x] = Just <$> getIgnoreCount x
contSwitch _ = Left $
text "After ':continue' only one ignore count is allowed"
@@ -3992,30 +3992,24 @@ ignoreCmd argLine = withSandboxOnly ":ignore" $ do
result <- ignoreSwitch (words argLine)
case result of
Left sdoc -> printForUser sdoc
- Right (loc, mbCount) -> do
+ Right (loc, count) -> do
let breakInfo = GHC.BreakInfo (breakModule loc) (breakTick loc)
- count = fromMaybe 0 mbCount
setupBreakpoint breakInfo count
-ignoreSwitch :: GhciMonad m => [String] -> m (Either SDoc (BreakLocation, Maybe Int))
+ignoreSwitch :: GhciMonad m => [String] -> m (Either SDoc (BreakLocation, Int))
ignoreSwitch [break, count] = do
sdoc_loc <- getBreakLoc break
pure $ (,) <$> sdoc_loc <*> getIgnoreCount count
ignoreSwitch _ = pure $ Left $ text "Syntax: :ignore <breaknum> <count>"
-getIgnoreCount :: String -> Either SDoc (Maybe Int)
+getIgnoreCount :: String -> Either SDoc Int
getIgnoreCount str =
- let checkJust :: Maybe Int -> Either SDoc (Maybe Int)
- checkJust mbCnt
- | (isJust mbCnt) = Right mbCnt
- | otherwise = Left $ sdocIgnore <+> text "is not numeric"
- checkPositive :: Maybe Int -> Either SDoc (Maybe Int)
- checkPositive mbCnt
- | isJust mbCnt && fromJust mbCnt >= 0 = Right mbCnt
- | otherwise = Left $ sdocIgnore <+> text "must be >= 0"
- mbCnt :: Maybe Int = readMaybe str
- sdocIgnore = (text "Ignore count") <+> quotes (text str)
- in Right mbCnt >>= checkJust >>= checkPositive
+ case readMaybe str of
+ Nothing -> Left $ sdocIgnore <+> "is not numeric"
+ Just cnt | cnt < 0 -> Left $ sdocIgnore <+> "must be >= 0"
+ | otherwise -> Right cnt
+ where
+ sdocIgnore = text "Ignore count" <+> quotes (text str)
setupBreakpoint :: GhciMonad m => GHC.BreakInfo -> Int -> m()
setupBreakpoint loc count = do