diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-07-07 21:34:17 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-07-07 21:34:49 +0100 |
commit | 12ed5c2bd257e0753326b563f0f9b7619fb67b38 (patch) | |
tree | ffb8ebb85b1d32b0cfa198f04ecc4c88f0943c29 /ghc | |
parent | b16cb73f0122a3692a90f2353baad18e60999b0b (diff) | |
download | haskell-12ed5c2bd257e0753326b563f0f9b7619fb67b38.tar.gz |
Fix build
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index a2cd876eaf..9a284809d3 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -2323,14 +2323,17 @@ completeCmd argLine0 = case parseLine argLine0 of -- syntax: [n-][m] with semantics "drop (n-1) . take m" parseRange :: String -> Maybe (Maybe Int,Maybe Int) - parseRange s - | all isDigit s = Just (Nothing, bndRead s) -- upper limit only - | not (null n1), sep == '-', all isDigit n1, all isDigit n2 = - Just (bndRead n1, bndRead n2) -- lower limit and maybe upper limit - | otherwise = Nothing + parseRange s = case span isDigit s of + (_, "") -> + -- upper limit only + Just (Nothing, bndRead s) + (s1, '-' : s2) + | all isDigit s2 -> + Just (bndRead s1, bndRead s2) + _ -> + Nothing where - (n1,sep:n2) = span isDigit s - bndRead s = if null s then Nothing else Just (read s) + bndRead x = if null x then Nothing else Just (read x) |