diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-14 17:43:34 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-14 17:43:34 -0400 |
commit | 60ab3d84e188b8dd3a284d962df25bbee41ff1cb (patch) | |
tree | 768d4f632bab0152dbc1ca72f81fc3b9c7915c0a /Remote.hs | |
parent | a4f72c9625486786a4549cf4db1b542ea89da7c7 (diff) |
added ifM and nuked 11 lines of code
no behavior changes
Diffstat (limited to 'Remote.hs')
-rw-r--r-- | Remote.hs | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -70,19 +70,13 @@ addName desc n - (Or it can be a UUID.) Only finds currently configured git remotes. -} byName :: Maybe String -> Annex (Maybe Remote) byName Nothing = return Nothing -byName (Just n) = do - res <- byName' n - case res of - Left e -> error e - Right r -> return $ Just r +byName (Just n) = either error Just <$> byName' n byName' :: String -> Annex (Either String Remote) byName' "" = return $ Left "no remote specified" -byName' n = do - match <- filter matching <$> remoteList - if null match - then return $ Left $ "there is no git remote named \"" ++ n ++ "\"" - else return $ Right $ Prelude.head match +byName' n = handle . filter matching <$> remoteList where + handle [] = Left $ "there is no git remote named \"" ++ n ++ "\"" + handle match = Right $ Prelude.head match matching r = n == name r || toUUID n == uuid r {- Looks up a remote by name (or by UUID, or even by description), |