refactor
This commit is contained in:
parent
b5930f6d07
commit
64672c6262
5 changed files with 6 additions and 12 deletions
|
@ -24,3 +24,4 @@ import Utility.Conditional as X
|
|||
import Utility.SafeCommand as X
|
||||
import Utility.Path as X
|
||||
import Utility.Directory as X
|
||||
import Utility.Monad as X
|
||||
|
|
|
@ -89,11 +89,7 @@ gitAnnexLocation key r
|
|||
annexLocation key hashDirMixed
|
||||
where
|
||||
go dir locs = fromMaybe (dir </> head locs) <$> check dir locs
|
||||
check _ [] = return Nothing
|
||||
check dir (l:ls) = do
|
||||
let f = dir </> l
|
||||
e <- doesFileExist f
|
||||
if e then return (Just f) else check dir ls
|
||||
check dir = firstM $ \f -> doesFileExist $ dir </> f
|
||||
|
||||
{- The annex directory of a repository. -}
|
||||
gitAnnexDir :: Git.Repo -> FilePath
|
||||
|
|
|
@ -13,7 +13,6 @@ import qualified Git
|
|||
import Config
|
||||
import Logs.Web
|
||||
import qualified Utility.Url as Url
|
||||
import Utility.Monad
|
||||
|
||||
remote :: RemoteType Annex
|
||||
remote = RemoteType {
|
||||
|
|
|
@ -9,12 +9,6 @@ module Utility.Conditional where
|
|||
|
||||
import Control.Monad (when, unless)
|
||||
|
||||
untilTrue :: Monad m => [v] -> (v -> m Bool) -> m Bool
|
||||
untilTrue [] _ = return False
|
||||
untilTrue (v:vs) a = do
|
||||
ok <- a v
|
||||
if ok then return ok else untilTrue vs a
|
||||
|
||||
whenM :: Monad m => m Bool -> m () -> m ()
|
||||
whenM c a = c >>= flip when a
|
||||
|
||||
|
|
|
@ -24,3 +24,7 @@ firstM p (x:xs) = do
|
|||
- stopping once one is found. -}
|
||||
anyM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool
|
||||
anyM p = liftM isJust . firstM p
|
||||
|
||||
{- Runs an action on values from a list until it succeeds. -}
|
||||
untilTrue :: (Monad m) => [a] -> (a -> m Bool) -> m Bool
|
||||
untilTrue = flip anyM
|
||||
|
|
Loading…
Reference in a new issue