equal-files 0.0.3 → 0.0.4
raw patch · 3 files changed
+22/−27 lines, 3 filesdep +filemanipdep +transformersdep +utility-htdep −FileManipdep −mtldep ~basedep ~explicit-exception
Dependencies added: filemanip, transformers, utility-ht
Dependencies removed: FileManip, mtl
Dependency ranges changed: base, explicit-exception
Files
- equal-files.cabal +8/−7
- src/EqualFiles.hs +3/−5
- src/Main.hs +11/−15
equal-files.cabal view
@@ -1,10 +1,10 @@ Name: equal-files-Version: 0.0.3+Version: 0.0.4 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de>-Homepage: http://code.haskell.org/~thielema/equal-files+Homepage: http://code.haskell.org/~thielema/equal-files/ Category: Console Synopsis: Shell command for finding equal files Description:@@ -45,11 +45,12 @@ Executable equal-files Build-Depends:- FileManip >= 0.3.2 && <0.4,- explicit-exception >= 0.0.2 && < 0.1,- mtl >= 1.1 && < 1.2,- bytestring >= 0.9 && <0.10,- base >= 3+ filemanip >=0.3.5 && <0.4,+ explicit-exception >=0.1 && <0.2,+ transformers >=0.2 && <0.4,+ utility-ht >=0.0.1 && <0.1,+ bytestring >=0.9 && <0.10,+ base >=3 && <5 GHC-Options: -Wall Hs-source-dirs: src
src/EqualFiles.hs view
@@ -6,12 +6,10 @@ import System.IO (openBinaryFile, hClose, IOMode(ReadMode), ) import Control.Exception (bracket, evaluate, ) -import Data.List (groupBy, sort, )-import Data.Function (on, )-+import Data.List (sort, )+import Data.List.HT (groupBy, )+import Data.Eq.HT (equating, ) -equating :: Eq a => (b -> a) -> b -> b -> Bool-equating = on (==) groupEqualElems :: (Ord key, Ord elem) => [(elem, key)] -> [[key]] groupEqualElems xs =
src/Main.hs view
@@ -8,11 +8,10 @@ import System.Console.GetOpt (getOpt, ArgOrder(..), OptDescr(..), ArgDescr(..), usageInfo, ) import System.Environment (getArgs, getProgName, ) import System.Exit (exitWith, ExitCode(..), )-import System.IO.Error (isFullError, )-import Control.Exception (try, ioErrors, )+import System.IO.Error (isFullError, try, ) import Control.Monad (liftM, when, )-import Control.Monad.Trans (lift, )+import Control.Monad.Trans.Class (lift, ) import qualified Control.Monad.Exception.Synchronous as Exc @@ -31,16 +30,13 @@ elaborateOnExhaustedHandles action = Exc.catchT (Exc.fromEitherT $ try $ action)- (\e ->- (case ioErrors e of- Just ioe ->- when (isFullError ioe)- (Exc.throwT $ unlines $- show e :- "--presort option may help against too many open files." :- [])- _ -> return ()) >>- Exc.throwT (show e))+ (\ioe -> do+ when (isFullError ioe)+ (Exc.throwT $ unlines $+ show ioe :+ "--presort option may help against too many open files." :+ [])+ Exc.throwT (show ioe)) data Flags =@@ -48,13 +44,13 @@ optHelp :: Bool, optRecursive :: Bool, optPreSort :: Int- }+ } options :: [OptDescr (Flags -> Exc.Exceptional String Flags)] options = Option ['h'] ["help"] (NoArg (\flags -> return $ flags{optHelp = True})) "show options" : Option ['r'] ["recursive"] (NoArg (\flags -> return $ flags{optRecursive = True})) "descent recursively into directories" :- Option ['p'] ["presort" ]+ Option ['p'] ["presort"] (ReqArg (\str flags -> fmap (\n -> flags{optPreSort = n}) $ Exc.mapException ("presort option:\n"++) $ parseCard str) "N") "Sort all files according to their first N bytes in a first go.\nThis reduces the number of simultaneously open files.\nThe suggested size value is 512." : []