summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-08-25 00:28:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-08-25 01:27:19 -0400
commit678726c10c13481c082743808a5188d28567e2b3 (patch)
treea5052eb5b20444e10d3f5d467281ef4c0f5975d1 /Remote.hs
parent20259c2955e408a72e0960207fc8be4cbeec2e21 (diff)
code simplification thanks to applicative functors
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Remote.hs b/Remote.hs
index 1a5006f6f..2c883f1a8 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -29,11 +29,12 @@ module Remote (
forceTrust
) where
-import Control.Monad (filterM, liftM2)
+import Control.Monad (filterM)
import Data.List
import qualified Data.Map as M
import Data.String.Utils
import Data.Maybe
+import Control.Applicative
import Types
import Types.Remote
@@ -111,10 +112,10 @@ nameToUUID "." = getUUID =<< Annex.gitRepo -- special case for current repo
nameToUUID n = do
res <- byName' n
case res of
- Left e -> return . fromMaybe (error e) =<< byDescription
+ Left e -> fromMaybe (error e) <$> byDescription
Right r -> return $ uuid r
where
- byDescription = return . M.lookup n . invertMap =<< uuidMap
+ byDescription = M.lookup n . invertMap <$> uuidMap
invertMap = M.fromList . map swap . M.toList
swap (a, b) = (b, a)
@@ -124,10 +125,10 @@ prettyPrintUUIDs uuids = do
here <- getUUID =<< Annex.gitRepo
-- Show descriptions from the uuid log, falling back to remote names,
-- as some remotes may not be in the uuid log
- m <- liftM2 M.union uuidMap $
- return . M.fromList . map (\r -> (uuid r, name r)) =<< genList
+ m <- M.union <$> uuidMap <*> availMap
return $ unwords $ map (\u -> "\t" ++ prettify m u here ++ "\n") uuids
where
+ availMap = M.fromList . map (\r -> (uuid r, name r)) <$> genList
prettify m u here = base ++ ishere
where
base = if not $ null $ findlog m u
@@ -147,7 +148,7 @@ remotesWithoutUUID rs us = filter (\r -> uuid r `notElem` us) rs
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-}
keyPossibilities :: Key -> Annex [Remote Annex]
-keyPossibilities key = return . fst =<< keyPossibilities' False key
+keyPossibilities key = fst <$> keyPossibilities' False key
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-