diff options
author | Joey Hess <joey@kitenet.net> | 2011-08-25 00:28:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-08-25 01:27:19 -0400 |
commit | 678726c10c13481c082743808a5188d28567e2b3 (patch) | |
tree | a5052eb5b20444e10d3f5d467281ef4c0f5975d1 /Command.hs | |
parent | 20259c2955e408a72e0960207fc8be4cbeec2e21 (diff) |
code simplification thanks to applicative functors
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Command.hs b/Command.hs index d3c1640ee..21c50f9c0 100644 --- a/Command.hs +++ b/Command.hs @@ -11,6 +11,7 @@ import Control.Monad.State (liftIO) import System.Directory import System.Posix.Files import Control.Monad (filterM, liftM, when) +import Control.Applicative import System.Path.WildMatch import Text.Regex.PCRE.Light.Char8 import Data.List @@ -183,7 +184,7 @@ withNothing a [] = return [a] withNothing _ _ = error "This command takes no parameters." backendPairs :: CommandSeekBackendFiles -backendPairs a files = liftM (map a) $ Backend.chooseBackends files +backendPairs a files = map a <$> Backend.chooseBackends files {- Filter out files those matching the exclude glob pattern, - if it was specified. -} @@ -204,7 +205,7 @@ wildsRegex ws = compile regex [] {- filter out symlinks -} notSymlink :: FilePath -> IO Bool -notSymlink f = liftM (not . isSymbolicLink) $ liftIO $ getSymbolicLinkStatus f +notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f {- Descriptions of params used in usage messages. -} paramRepeating :: String -> String @@ -271,4 +272,4 @@ preserveOrder orig new = collect orig new - of git file list commands, that assumption tends to hold. -} runPreserveOrder :: ([FilePath] -> IO [FilePath]) -> [FilePath] -> IO [FilePath] -runPreserveOrder a files = liftM (preserveOrder files) (a files) +runPreserveOrder a files = preserveOrder files <$> a files |