squeeze 1.0.4.12 → 1.0.4.13
raw patch · 14 files changed
+69/−57 lines, 14 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.markdown +7/−0
- debian/DEBIAN/control +1/−1
- man/man1/squeeze.1 +1/−1
- squeeze.cabal +21/−10
- squeeze.spec +1/−1
- src-exe/Main.hs +7/−14
- src-exe/Squeeze/Test/Performance.hs +1/−1
- src-lib/Squeeze/Control/Concurrent/DivideAndConquer.hs +1/−1
- src-lib/Squeeze/Data/File.hs +2/−2
- src-lib/Squeeze/Data/FileCombination.hs +18/−19
- src-lib/Squeeze/Squeeze.hs +6/−4
- src-test/Squeeze/Test/QuickCheck/Data/CommandOptions.hs +1/−1
- src-test/Squeeze/Test/QuickCheck/Data/FileCombinations.hs +1/−1
- src-test/Squeeze/Test/QuickCheck/Squeeze.hs +1/−1
changelog.markdown view
@@ -154,3 +154,10 @@ ## 1.0.4.11 * Checked pre-processor directives are defined. ## 1.0.4.12+* Re-factored pre-processor directive in **Main.hs**.+## 1.0.4.13+* Performance-improvements.+* Added default RTS-options to **squeeze.cabal**.+* Replaced 'Data.List.genericLength' with the more efficient @fromIntegral . length@.+* Removed dependency on **Distribution.Package.PackageName**+
debian/DEBIAN/control view
@@ -1,5 +1,5 @@ Package: squeeze-Version: 1.0.4.12-1+Version: 1.0.4.13-1 Section: utils Priority: optional Architecture: amd64
man/man1/squeeze.1 view
@@ -115,7 +115,7 @@ .SS Example 3 If we're prepared to add individual files from another artist: .IP-.B squeeze -M 700000000 -m 0.9999999 ArabStrap BobDylan/* JeffBuckley JohnMartyn JoniMitchell ReservoirDogsOST $(find RichardThompson -type f) SethLakeman SusheelaRaman TeddyThompson Vangelis +RTS -N+.B squeeze -M 700000000 -m 0.9999999 ArabStrap BobDylan/* JeffBuckley JohnMartyn JoniMitchell ReservoirDogsOST $(find RichardThompson -type f) SethLakeman SusheelaRaman TeddyThompson Vangelis .nf 699999964 ["ArabStrap","BobDylan/Desire","BobDylan/Infidels","BobDylan/ModernTimes","BobDylan/OhMercy","BobDylan/SubterraneanHomesickBlues","BobDylan/TimeOutOfMind","JeffBuckley","JohnMartyn","JoniMitchell","ReservoirDogsOST","RichardThompson/FrontParlourBallads/RichardThompson-06-MySoulMySoul.ogg","RichardThompson/RumorAndSigh/RichardThompson-12-MotherKnowsBest.ogg","RichardThompson/TheOldKitBag/RichardThompson-01-Gethsemane.ogg","RichardThompson/TheOldKitBag/RichardThompson-11-OutsideOfTheInside.ogg","SethLakeman","SusheelaRaman","TeddyThompson","Vangelis"] 699999987 ["BobDylan/BlondeOnBlonde","BobDylan/BloodOnTheTracks","BobDylan/Desire","BobDylan/ModernTimes","BobDylan/OhMercy","BobDylan/StreetLegal","BobDylan/SubterraneanHomesickBlues","BobDylan/TimeOutOfMind","JoniMitchell","ReservoirDogsOST","RichardThompson/FrontParlourBallads/RichardThompson-01-LetItBlow.ogg","RichardThompson/IWantToSeeTheBrightLightsTonight/RichardAndLindaThompson-13-TheCalvaryCross[Live-Bonus].ogg","RichardThompson/TheOldKitBag/RichardThompson-01-Gethsemane.ogg","RichardThompson/TheOldKitBag/RichardThompson-06-FirstBreath.ogg","RichardThompson/TheOldKitBag/RichardThompson-11-OutsideOfTheInside.ogg","SethLakeman","SusheelaRaman","TeddyThompson","Vangelis"]
squeeze.cabal view
@@ -14,7 +14,7 @@ -- along with Squeeze. If not, see <http://www.gnu.org/licenses/>. Name: squeeze-Version: 1.0.4.12+Version: 1.0.4.13 Cabal-version: >= 1.10 Copyright: (C) 2010-2015 Dr. Alistair Ward License: GPL@@ -86,9 +86,13 @@ else GHC-prof-options: -auto-all -caf-all - if impl(ghc >= 7.0) && flag(llvm)- GHC-options: -fllvm+ if impl(ghc >= 7.0)+ if flag(llvm)+ GHC-options: -fllvm + if impl(ghc >= 8.0)+ GHC-options: -Wredundant-constraints+ Executable squeeze Default-language: Haskell2010 GHC-options: -O2 -Wall -fno-warn-tabs@@ -110,20 +114,24 @@ squeeze, toolshed >= 0.17 + if impl(ghc >= 7.0)+ if flag(llvm)+ GHC-options: -fllvm++ if flag(threaded)+ GHC-options: -rtsopts "-with-rtsopts=-N -H100M"++ if impl(ghc >= 8.0)+ GHC-options: -Wredundant-constraints+ if impl(ghc >= 7.4.1)- GHC-prof-options: -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs -with-rtsopts=-H100M else GHC-prof-options: -auto-all -caf-all if flag(threaded) GHC-options: -threaded - if impl(ghc >= 7.0)- GHC-options: -rtsopts-- if flag(llvm)- GHC-options: -fllvm- Test-Suite test Default-language: Haskell2010 GHC-options: -Wall -fno-warn-tabs@@ -144,4 +152,7 @@ QuickCheck >= 2.4, squeeze, toolshed >= 0.17++ if impl(ghc >= 8.0)+ GHC-options: -Wredundant-constraints
squeeze.spec view
@@ -21,7 +21,7 @@ Summary: Finds the optimal subset of the specified files, to fit into a limited space, with minimal wastage Name: squeeze-Version: 1.0.4.12+Version: 1.0.4.13 Release: 1 License: GPLv3 # From '/usr/share/doc/packages/rpm/GROUPS'.
src-exe/Main.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-}-#ifdef MIN_TOOL_VERSION_ghc+#ifdef MIN_TOOL_VERSION_ghc /* CAVEAT: early versions of Cabal don't define this */ #if MIN_TOOL_VERSION_ghc(8,0,1) {-# OPTIONS_GHC -freduction-depth=25 #-} #endif@@ -42,10 +42,7 @@ import qualified Data.List import qualified Data.Maybe import qualified Data.Version-import qualified Distribution.Package-import qualified Distribution.Text import qualified Distribution.Verbosity-import qualified Distribution.Version import qualified Factory.Math.Probability import qualified Paths_squeeze as Paths -- Either local stub, or package-instance autogenerated by 'Setup.hs build'. import qualified Squeeze.Data.CommandOptions as Data.CommandOptions@@ -64,7 +61,7 @@ import qualified ToolShed.SelfValidate import qualified ToolShed.System.TimeAction -#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0)+#if !MIN_VERSION_base(4,8,0) import Control.Applicative((<$>), (<*>)) #endif @@ -172,17 +169,13 @@ printVersion, printUsage :: IO (Data.CommandOptions.CommandOptions f) printVersion = System.IO.hPutStrLn System.IO.stderr (- showString (Distribution.Text.display packageIdentifier) . showString "\nCompiled by " . shows compiler . showString ".\nWritten by " . shows author . showString ".\nCopyright (C) 2010-2015 " $ showString author ".\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions."+ showString progName . showChar '-' . showsVersion Paths.version . showString "\n\nCompiled by " . showString System.Info.compilerName . showChar '-' . showsVersion System.Info.compilerVersion . showString ".\n\nCopyright (C) 2010-2017 " . showString author . showString ".\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by " $ showString author "." ) >> System.Exit.exitSuccess where- packageIdentifier :: Distribution.Package.PackageIdentifier- packageIdentifier = Distribution.Package.PackageIdentifier {- Distribution.Package.pkgName = Distribution.Package.PackageName progName, -- CAVEAT: coincidentally.- Distribution.Package.pkgVersion = Distribution.Version.Version (Data.Version.versionBranch Paths.version) []- }+ author :: String+ author = "Dr. Alistair Ward" - author, compiler :: String- author = "Dr. Alistair Ward"- compiler = System.Info.compilerName ++ "-" ++ Data.List.intercalate "." (map show $ Data.Version.versionBranch System.Info.compilerVersion)+ showsVersion :: Data.Version.Version -> ShowS+ showsVersion = foldr (.) id . Data.List.intersperse (showChar '.') . map shows . Data.Version.versionBranch printUsage = Text.Printf.hPrintf System.IO.stderr ( showString "Usage:\t%s [<File-path> ...]\n\nEBNF argument-format:" $ showString (
src-exe/Squeeze/Test/Performance.hs view
@@ -67,7 +67,7 @@ ceiling :: Double -> Integer -- File-sizes are integral. ) $ Factory.Math.Probability.generatePopulation probabilityDistribution randomGen - Control.Monad.when (Data.CommandOptions.getVerbosity commandOptions > minBound) . System.IO.hPutStrLn System.IO.stderr $ Data.List.intercalate "\n" logFile+ Control.Monad.unless (Data.CommandOptions.getVerbosity commandOptions == minBound) . System.IO.hPutStrLn System.IO.stderr $ Data.List.intercalate "\n" logFile Squeeze.distributeAndFindBestFit commandOptions acceptedFileSizeAndPathList
src-lib/Squeeze/Control/Concurrent/DivideAndConquer.hs view
@@ -40,7 +40,7 @@ import qualified Control.Monad import qualified Data.Maybe -#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0)+#if !MIN_VERSION_base(4,8,0) import Control.Applicative((<$>), (<*>)) #endif
src-lib/Squeeze/Data/File.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2010-2015 Dr. Alistair Ward+ Copyright (C) 2010-2016 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -74,7 +74,7 @@ -- | Sum the 'FileSize's in the specified list. aggregateSize :: [FileSizeAndPath] -> FileSize-aggregateSize = foldr ((+) . getSize) 0+aggregateSize = Data.List.foldl' (\acc (fileSize, _) -> acc + fileSize) 0 {- | * Returns the cumulative sequence of sizes, as each file is prepended to the specified list.
src-lib/Squeeze/Data/FileCombination.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2010 Dr. Alistair Ward+ Copyright (C) 2010-2016 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -100,9 +100,12 @@ :: Data.File.FileSizeAndPath -- ^ The new path to prepend to the incumbent file-combination. -> FileCombination -- ^ The incumbent combination of files. -> FileCombination-prepend (fileSize, filePath) fileCombination = MkFileCombination {- getAggregateFileSize = fileSize + getAggregateFileSize fileCombination,- getFilePathList = filePath : getFilePathList fileCombination+prepend (fileSize, filePath) MkFileCombination {+ getAggregateFileSize = aggregateFileSize,+ getFilePathList = filePathList+} = MkFileCombination {+ getAggregateFileSize = fileSize + aggregateFileSize,+ getFilePathList = filePath : filePathList } -- | Predicate used to determine whether a specific file-combination matches a size-related requirement.@@ -111,7 +114,7 @@ :: (Data.File.FileSize -> Bool) -- ^ The predicate. -> FileCombination -- ^ The input datum to be tested. -> Bool-hasSizeBy predicate = predicate . getAggregateFileSize+hasSizeBy predicate MkFileCombination { getAggregateFileSize = aggregateFileSize } = predicate aggregateFileSize -- | Progressively raises the selection-criterion as each match is found, to produce monotonically increasing file-combinations. risingFilter@@ -119,11 +122,9 @@ -> [FileCombination] -- ^ The input list of files to filter. -> [FileCombination] -- ^ The resulting list of files, which have met rising criterion. risingFilter _ [] = []-risingFilter minimumSize (x : xs)- | aggregateFileSize >= minimumSize = x : risingFilter aggregateFileSize xs- | otherwise = risingFilter minimumSize xs- where- aggregateFileSize = getAggregateFileSize x+risingFilter minimumSize (fileCombination@MkFileCombination { getAggregateFileSize = aggregateFileSize } : fileCombinations)+ | aggregateFileSize >= minimumSize = fileCombination : risingFilter aggregateFileSize fileCombinations+ | otherwise = risingFilter minimumSize fileCombinations {- | * Merges two lists of monotonically increasing values, into a single monotonically increasing list, by dropping values which compare less than results already found.@@ -139,16 +140,14 @@ risingMerge cmp = slave nullFileCombination where lessThan bar = (== LT) . (`cmp` bar) - slave bar [] r = dropWhile (lessThan bar) r- slave bar l [] = dropWhile (lessThan bar) l- slave _ (x : xs) (y : ys)- | o == GT = x : slave x xs ys- | o == LT = y : slave y xs ys- | otherwise = x : y : slave x xs ys- where- o = x `cmp` y+ slave bar [] r = dropWhile (lessThan bar) r+ slave bar l [] = dropWhile (lessThan bar) l+ slave _ (x : xs) (y : ys) = case x `cmp` y of+ GT -> x : slave x xs ys+ LT -> y : slave y xs ys+ _ -> x : y : slave x xs ys --- Compares two /file-combination/s by their aggregate file-size.+-- | Compares two /file-combination/s by their aggregate file-size. comparingAggregateFileSize :: FileCombination -> FileCombination -> Ordering comparingAggregateFileSize = Data.Ord.comparing getAggregateFileSize
src-lib/Squeeze/Squeeze.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2010-2015 Dr. Alistair Ward+ Copyright (C) 2010-2016 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -82,12 +82,14 @@ ) where binaryChoice :: Data.FileCombination.FileCombination -> [Data.FileCombination.FileCombination] -> [Data.FileCombination.FileCombination]- binaryChoice combinationExcluding- | Data.FileCombination.hasSizeBy (<= maximumCombinationSize) combinationIncluding = (combinationExcluding :) . (combinationIncluding :)- | otherwise = (combinationExcluding :)+ binaryChoice combinationExcluding combinations+ | Data.FileCombination.hasSizeBy (> maximumCombinationSize) combinationIncluding = combinations'+ | otherwise = combinationIncluding : combinations' where combinationIncluding :: Data.FileCombination.FileCombination combinationIncluding = Data.FileCombination.prepend fileSizeAndPath combinationExcluding++ combinations' = combinationExcluding : combinations -- | Orders the files by decreasing size, calls 'findCombinations', calls 'Data.FileCombination.risingFilter' to select progressively better solutions. findBestFit
src-test/Squeeze/Test/QuickCheck/Data/CommandOptions.hs view
@@ -32,7 +32,7 @@ import qualified Squeeze.Data.CommandOptions as Data.CommandOptions import Squeeze.Test.QuickCheck.Data.Verbosity() -#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0)+#if !MIN_VERSION_base(4,8,0) import Control.Applicative((<$>), (<*>)) #endif
src-test/Squeeze/Test/QuickCheck/Data/FileCombinations.hs view
@@ -34,7 +34,7 @@ instance Test.QuickCheck.Arbitrary Data.FileCombination.FileCombination where arbitrary = do filePathList <- Data.List.nub `fmap` (Test.QuickCheck.elements [0 .. 99] >>= Test.QuickCheck.vector)- aggregateFileSize <- Test.QuickCheck.elements [0 .. Data.List.genericLength filePathList] -- Assume files of size either zero or one byte.+ aggregateFileSize <- Test.QuickCheck.elements [0 .. fromIntegral $ length filePathList] -- Assume files of size either zero or one byte. return $ Data.FileCombination.mkFileCombination aggregateFileSize filePathList
src-test/Squeeze/Test/QuickCheck/Squeeze.hs view
@@ -64,7 +64,7 @@ fileSizeAndPathList = mkFileSizeAndPathList integers prop_uniqueFileNames integers = Test.QuickCheck.label "prop_uniqueFileNames" . all (- all ((== 1) . length) . ToolShed.Data.Foldable.gather . Data.FileCombination.getFilePathList+ not . ToolShed.Data.Foldable.hasDuplicates . Data.FileCombination.getFilePathList ) $ Squeeze.findBestFit (0, fromIntegral (maxBound :: Int)) fileSizeAndPathList where fileSizeAndPathList = mkFileSizeAndPathList integers