summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex/Ssh.hs2
-rw-r--r--Config.hs4
-rw-r--r--Git/Url.hs2
-rw-r--r--GitAnnex.hs2
-rw-r--r--Limit.hs2
-rw-r--r--Seek.hs2
-rw-r--r--Types/Key.hs4
-rw-r--r--Utility/Format.hs2
-rw-r--r--Utility/PartialPrelude.hs6
9 files changed, 13 insertions, 13 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index c05e23604..14ea74e53 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -101,7 +101,7 @@ hostport2socket host (Just port) = host ++ "!" ++ show port
socket2hostport :: FilePath -> (String, Maybe Integer)
socket2hostport socket
| null p = (h, Nothing)
- | otherwise = (h, readMaybe p)
+ | otherwise = (h, readish p)
where
(h, p) = separate (== '!') $ takeFileName socket
diff --git a/Config.hs b/Config.hs
index 83a84a1fe..349ddf67f 100644
--- a/Config.hs
+++ b/Config.hs
@@ -40,7 +40,7 @@ remoteConfig r key = "remote." ++ fromMaybe "" (Git.remoteName r) ++ ".annex-" +
remoteCost :: Git.Repo -> Int -> Annex Int
remoteCost r def = do
cmd <- getConfig r "cost-command" ""
- (fromMaybe def . readMaybe) <$>
+ (fromMaybe def . readish) <$>
if not $ null cmd
then liftIO $ snd <$> pipeFrom "sh" ["-c", cmd]
else getConfig r "cost" ""
@@ -78,7 +78,7 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies
where
use (Just n) = return n
use Nothing = perhaps (return 1) =<<
- readMaybe <$> fromRepo (Git.Config.get config "1")
+ readish <$> fromRepo (Git.Config.get config "1")
perhaps fallback = maybe fallback (return . id)
config = "annex.numcopies"
diff --git a/Git/Url.hs b/Git/Url.hs
index 6a893d92f..21b69dc7c 100644
--- a/Git/Url.hs
+++ b/Git/Url.hs
@@ -45,7 +45,7 @@ port :: Repo -> Maybe Integer
port r =
case authpart uriPort r of
":" -> Nothing
- (':':p) -> readMaybe p
+ (':':p) -> readish p
_ -> Nothing
{- Hostname of an URL repo, including any username (ie, "user@host") -}
diff --git a/GitAnnex.hs b/GitAnnex.hs
index bc3541676..4af10a9ce 100644
--- a/GitAnnex.hs
+++ b/GitAnnex.hs
@@ -119,7 +119,7 @@ options = Option.common ++
"skip files not using a key-value backend"
] ++ Option.matcher
where
- setnumcopies v = Annex.changeState $ \s -> s {Annex.forcenumcopies = readMaybe v }
+ setnumcopies v = Annex.changeState $ \s -> s {Annex.forcenumcopies = readish v }
setgitconfig :: String -> Annex ()
setgitconfig v = do
newg <- inRepo $ Git.Config.store v
diff --git a/Limit.hs b/Limit.hs
index 128ea0a27..0db418e6c 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -84,7 +84,7 @@ addIn name = addLimit $ check $ if name == "." then inAnnex else inremote
- of copies. -}
addCopies :: String -> Annex ()
addCopies num =
- case readMaybe num :: Maybe Int of
+ case readish num :: Maybe Int of
Nothing -> error "bad number for --copies"
Just n -> addLimit $ check n
where
diff --git a/Seek.hs b/Seek.hs
index 8e935c90c..b4e1218e2 100644
--- a/Seek.hs
+++ b/Seek.hs
@@ -36,7 +36,7 @@ withAttrFilesInGit attr a params = do
withNumCopies :: (Maybe Int -> FilePath -> CommandStart) -> CommandSeek
withNumCopies a params = withAttrFilesInGit "annex.numcopies" go params
where
- go (file, v) = a (readMaybe v) file
+ go (file, v) = a (readish v) file
withBackendFilesInGit :: (BackendFile -> CommandStart) -> CommandSeek
withBackendFilesInGit a params =
diff --git a/Types/Key.hs b/Types/Key.hs
index 165f814d4..f258f5c4c 100644
--- a/Types/Key.hs
+++ b/Types/Key.hs
@@ -69,8 +69,8 @@ readKey s = if key == Just stubKey then Nothing else key
findfields _ v = v
addbackend k v = Just k { keyBackendName = v }
- addfield 's' k v = Just k { keySize = readMaybe v }
- addfield 'm' k v = Just k { keyMtime = readMaybe v }
+ addfield 's' k v = Just k { keySize = readish v }
+ addfield 'm' k v = Just k { keyMtime = readish v }
addfield _ _ _ = Nothing
prop_idempotent_key_read_show :: Key -> Bool
diff --git a/Utility/Format.hs b/Utility/Format.hs
index d8b7e4549..79e94ae96 100644
--- a/Utility/Format.hs
+++ b/Utility/Format.hs
@@ -88,7 +88,7 @@ gen = filter (not . empty) . fuse [] . scan [] . decode_c
| c == '}' = foundvar f var (readjustify $ reverse p) cs
| otherwise = inpad (c:p) f var cs
inpad p f var [] = Const (novar $ p++";"++var) : f
- readjustify = getjustify . fromMaybe 0 . readMaybe
+ readjustify = getjustify . fromMaybe 0 . readish
getjustify i
| i == 0 = UnJustified
| i < 0 = LeftJustified (-1 * i)
diff --git a/Utility/PartialPrelude.hs b/Utility/PartialPrelude.hs
index dbdf4fa5c..6efa093fd 100644
--- a/Utility/PartialPrelude.hs
+++ b/Utility/PartialPrelude.hs
@@ -10,7 +10,7 @@ module Utility.PartialPrelude where
import qualified Data.Maybe
{- read should be avoided, as it throws an error
- - Instead, use: readMaybe -}
+ - Instead, use: readish -}
read :: Read a => String -> a
read = Prelude.read
@@ -42,8 +42,8 @@ last = Prelude.last
- readMaybe is available in Text.Read in new versions of GHC,
- but that one requires the entire string to be consumed.
-}
-readMaybe :: Read a => String -> Maybe a
-readMaybe s = case reads s of
+readish :: Read a => String -> Maybe a
+readish s = case reads s of
((x,_):_) -> Just x
_ -> Nothing