squeeze 1.0.4.8 → 1.0.4.12
raw patch · 22 files changed
+440/−381 lines, 22 filesdep +data-defaultdep ~toolshedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: data-default
Dependency ranges changed: toolshed
API changes (from Hackage documentation)
- Squeeze.Data.CommandOptions: instance GHC.Real.Fractional f => ToolShed.Defaultable.Defaultable (Squeeze.Data.CommandOptions.CommandOptions f)
+ Squeeze.Data.CommandOptions: instance GHC.Real.Fractional f => Data.Default.Class.Default (Squeeze.Data.CommandOptions.CommandOptions f)
Files
- .ghci +1/−0
- README.markdown +16/−7
- changelog.Debian +4/−4
- changelog.markdown +133/−96
- copyright +1/−1
- debian/DEBIAN/control +2/−2
- man/man1/squeeze.1 +10/−6
- squeeze.cabal +25/−18
- squeeze.spec +3/−3
- src-exe/Main.hs +27/−21
- src-lib/Squeeze/Control/Concurrent/DivideAndConquer.hs +2/−2
- src-lib/Squeeze/Data/CommandOptions.hs +5/−5
- src-lib/Squeeze/Squeeze.hs +1/−1
- src-test/Main.hs +5/−10
- src-test/Squeeze/Test/Data/CommandOptions.hs +0/−54
- src-test/Squeeze/Test/Data/FileCombinations.hs +0/−51
- src-test/Squeeze/Test/Data/Verbosity.hs +0/−30
- src-test/Squeeze/Test/QuickCheck/Data/CommandOptions.hs +54/−0
- src-test/Squeeze/Test/QuickCheck/Data/FileCombinations.hs +51/−0
- src-test/Squeeze/Test/QuickCheck/Data/Verbosity.hs +30/−0
- src-test/Squeeze/Test/QuickCheck/Squeeze.hs +70/−0
- src-test/Squeeze/Test/Squeeze.hs +0/−70
+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc-lib:src-exe:src-test:dist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
README.markdown view
@@ -1,6 +1,8 @@-# **Squeeze**.+# **Squeeze** -This is **Squeeze**, an application which searches for combinations of the specified files to store in a given space,+[](https://hackage.haskell.org/package/squeeze) [](https://travis-ci.org/functionalley/Squeeze)++This is "**Squeeze**", an application which searches for combinations of the specified files to store in a given space, without wasting an unacceptable proportion. ## Installation@@ -8,17 +10,24 @@ It can be built and installed using [Cabal](https://www.haskell.org/cabal/users-guide/installing-packages.html). ## Documentation--* The directory **man/** contains the documentation.-* More information about this application can be found at [Squeeze](http://functionalley.eu/Squeeze/squeeze.html).+* The directory "**man/**" contains the documentation.+* More information about this application can be found at [Squeeze](http://functionalley.eu/Squeeze/squeeze.html). ## License -For information on copying and distributing this package, see the file **LICENSE** in this directory.+For information on copying and distributing this package, see the file "**LICENSE**" in this directory. ## Bug-reporting -Bug-reports should be emailed to <squeeze *at* functionalley *dot* eu>.+Bug-reports should be emailed to <squeeze@functionalley.eu>.++## Testing++The test-suite can be run using:++ cabal configure --enable-tests;+ cabal build;+ cabal test --show-details=always; ## Author
changelog.Debian view
@@ -2,18 +2,18 @@ * New release. - -- Alistair Ward <squeeze at functionalley dot eu> Wed, 12 Jan 2011 00:00:00 +0000+ -- Alistair Ward <squeeze@functionalley.eu> Wed, 12 Jan 2011 00:00:00 +0000 squeeze (1.0.1.4-1) experimental; urgency=low - * Uploaded to <http://hackage.haskell.org/packages/hackage.html>.+ * Uploaded to <http://hackage.haskell.org/package/squeeze>. - -- Alistair Ward <squeeze at functionalley dot eu> Wed, 12 Jan 2011 00:00:00 +0000+ -- Alistair Ward <squeeze@functionalley.eu> Wed, 12 Jan 2011 00:00:00 +0000 squeeze (1.0.4.1-1) experimental; urgency=low * Re-calculated "Installed-size". - -- Alistair Ward <squeeze at functionalley dot eu> Wed, 24 Jul 2013 12:00:00 +0000+ -- Alistair Ward <squeeze@functionalley.eu> Wed, 24 Jul 2013 12:00:00 +0000 squeeze (1.0.4.8-1) experimental; urgency=low
changelog.markdown view
@@ -1,119 +1,156 @@-# 2010-11-18 Dr. Alistair Ward <squeeze at functionalley dot eu>+# 2010-11-18 Dr. Alistair Ward <squeeze@functionalley.eu> ## 1.0.0.0- * First version of the package.+* First version of the package.+ ## 1.0.0.1- * Created **src/Squeeze/** sub-directory & then modified module-names accordingly.- * Pacified **hlint**.- * Added a makefile.+* Created sub-directory "**src/Squeeze/**" & then modified module-names accordingly.+* Pacified **hlint**.+* Added a makefile.+ ## 1.0.0.2- * Tested with ghc-7.0.1- * Added *.spec*-file.+* Tested with **ghc-7.0.1**.+* Added *.spec*-file.+ ## 1.0.1.0- * Improved the basic algorithm, by permitting the file-list to be bisected; each file-combination resulting from the LHS, is then concatenated with each of those resulting from the recursively bisected RHS.- * Used **Control.Parallel.Strategies** to parallelize the concatenation of each combination from the LH-list, with each of those from the RH-list.- * Added default values of command-line flags, to usage-message.- * Used new **ToolShed.Package**-module.- (1.0.1.1)- * Replaced `Data.List.subsequences` with a tailored version which terminates combinations when they've grown too large, providing a better and more predictable performance-gain than recursive list-bisection.- * Reduced recursive list-bisection to a single bisection, for the sole purpose of facilitating parallelisation.- * Added module **Squeeze.QC** to define **Test.QuickCheck** tests and command-line option **--verbose**, to govern level of output.- * Partitioned into new modules; **Squeeze.File**, **Squeeze.FileSizeBounds** and **Squeeze.FileCombination**.+* Improved the basic algorithm, by permitting the file-list to be bisected; each file-combination resulting from the LHS, is then concatenated with each of those resulting from the recursively bisected RHS.+* Used module "**Control.Parallel.Strategies**" to parallelize the concatenation of each combination from the LH-list, with each of those from the RH-list.+* Added default values of command-line flags, to usage-message.+* Used new module "**ToolShed.Package**".+(1.0.1.1)+* Replaced `Data.List.subsequences` with a tailored version which terminates combinations when they've grown too large, providing a better and more predictable performance-gain than recursive list-bisection.+* Reduced recursive list-bisection to a single bisection, for the sole purpose of facilitating parallelisation.+* Added module "**Squeeze.QC**" to define **Test.QuickCheck**-tests and command-line option "**--verbose**", to govern level of output.+* Partitioned into new modules; "**Squeeze.File**", "**Squeeze.FileSizeBounds**" and "**Squeeze.FileCombination**".+ ## 1.0.1.2- * Fixed typo in CPP-statement in **Squeeze.QC**.- * Fixed negated reference to unparenthesised CPP-macro **MIN_VERSION**.- * Protected reference in **Main**, to `Test.QuickCheck.verboseCheck`, using CPP-statement.+* Fixed typo in CPP-statement in module "**Squeeze.QC**".+* Fixed negated reference to unparenthesised CPP-macro "**MIN_VERSION**".+* Protected reference in module "**Main**", to `Test.QuickCheck.verboseCheck`, using CPP-statement.+ ## 1.0.1.3- * Amended *.spec*-file to define RPM-package, to install under **/usr**, rather than **/usr/local**.- * Renamed package from **Squeeze** to **squeeze**, for compatibility with Debian's *.deb*-format.- * Added directory-structure required to build *.deb*-package.+* Amended *.spec*-file to define RPM-package, to install under directory "**/usr**", rather than "**/usr/local**".+* Renamed package from "**Squeeze**" to "**squeeze**", for compatibility with Debian's *.deb*-format.+* Added directory-structure required to build *.deb*-package.+ ## 1.0.1.4- * Corrected command-line processing of the special file **-**, which reads standard-input as requested, but disregarded any other command-line options.- * Refined man-page to be an **extra-source-file** in the *.cabal*-file and the *.spec*-file.- * Ported to compile against alternative integral definitions of `Squeeze.File.FileSize`.- * Added manually controlled **llvm** flag to the *.cabal*-file.- * Replaced references to the module **ToolShed.Package** with **Distribution.Package**.- * Reacted to the creation of module **ToolShed.Defaultable**.- * Uploaded to [Hackage](http://hackage.haskell.org/packages/hackage.html).+* Corrected command-line processing of the special file "**-**", which reads standard-input as requested, but disregarded any other command-line options.+* Refined man-page to be an "**extra-source-file**" in the *.cabal*-file and the *.spec*-file.+* Ported to compile against alternative integral definitions of `Squeeze.File.FileSize`.+* Added manually controlled flag "**llvm**" to the *.cabal*-file.+* Replaced references to the module "**ToolShed.Package**" with "**Distribution.Package**".+* Reacted to the creation of module "**ToolShed.Defaultable**".+* Uploaded to [Hackage](http://hackage.haskell.org/package/squeeze).+ ## 1.0.2.0- * Reimplemented `Squeeze.File.aggregateSize` using `foldr` rather than `foldl`.- * Removed use of `Control.Parallel.Strategies` from **Squeeze.Squeeze**, which ruined performance on one core and had no obvious benefit on two.- * Changed the definition of `Squeeze.FileCombinations.FileCombinations` from a `Pair` to a record-style data-type with selective strictness-annotation.- * Renamed `Squeeze.FileCombination.concatenate` to `(Squeeze.FileCombination.<+>)` and `Squeeze.FileCombination.prepend` to `(Squeeze.FileCombination.+>)`.- * Used new module **ToolShed.TimeAction**, to permit measurement of the CPU-time required to find the best fit.- * Added the number, mean file-size and standard-deviation, to the output, when flag **--verbose** is specified; and as a side-effect, created a dependency on the package **factory**.- * Replaced module **Squeeze.FileSizeBounds** with **Factory.Data.Interval**, requiring use of **toolshed-0.12.0.0**.- * Made the data-type `CommandOptions.CommandOptions` polymorphic in terms of the *ratio*-type fields.- * Inserted new layers **Data** and **Test** into the module-hierarchy, and relocated existing modules accordingly.- * Added module **Squeeze.Test.Performance** to test with randomly generated virtual files.+* Reimplemented `Squeeze.File.aggregateSize` using `foldr` rather than `foldl`.+* Removed use of `Control.Parallel.Strategies` from **Squeeze.Squeeze**, which ruined performance on one core and had no obvious benefit on two.+* Changed the definition of `Squeeze.FileCombinations.FileCombinations` from a `Pair` to a record-style data-type with selective strictness-annotation.+* Renamed `Squeeze.FileCombination.concatenate` to `(Squeeze.FileCombination.<+>)` and `Squeeze.FileCombination.prepend` to `(Squeeze.FileCombination.+>)`.+* Used new module "**ToolShed.TimeAction**", to permit measurement of the CPU-time required to find the best fit.+* Added the number, mean file-size and standard-deviation, to the output, when flag "**--verbose**" is specified; and as a side-effect, created a dependency on the package "**factory**".+* Replaced module "**Squeeze.FileSizeBounds**" with **Factory.Data.Interval**, requiring use of **toolshed-0.12.0.0**.+* Made the data-type `CommandOptions.CommandOptions` polymorphic in terms of the *ratio*-type fields.+* Inserted new layers **Data** and **Test** into the module-hierarchy, and relocated existing modules accordingly.+* Added module "**Squeeze.Test.Performance**" to test with randomly generated virtual files.+ ## 1.0.2.1- * Added check for zero file-names when reading from stdin.- * Corrected the syntax required when specifying ratios, in the man-page.+* Added check for zero file-names when reading from stdin.+* Corrected the syntax required when specifying ratios, in the man-page.+ ## 1.0.2.2- * Renamed `Squeeze.Data.File.order` to `Squeeze.Data.File.orderBySize`.- * Used **Paths_squeeze.version** in **Main**, rather than hard-coding it.- * Added `Squeeze.Data.CommandOptions.getErrors` to permit better error-diagnosis.- * Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in toolshed-0.13.0.0.- * Replaced use of `Control.Exception.bracket` with `System.IO.withFile`, in `Squeeze.Data.File.findSize`.- * Replaced `System` with `System.Environment` and `System.Exit`.- * Removed dependency on **haskell98**.+* Renamed `Squeeze.Data.File.order` to `Squeeze.Data.File.orderBySize`.+* Used **Paths_squeeze.version** in **Main**, rather than hard-coding it.+* Added `Squeeze.Data.CommandOptions.getErrors` to permit better error-diagnosis.+* Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in toolshed-0.13.0.0.+* Replaced use of `Control.Exception.bracket` with `System.IO.withFile`, in `Squeeze.Data.File.findSize`.+* Replaced `System` with `System.Environment` and `System.Exit`.+* Removed dependency on **haskell98**.+ ## 1.0.2.3- * Added class `Show` to context for `Squeeze.Test.Performance.run`, for migration to **ghc-7.4.1**.+* Added class `Show` to context for `Squeeze.Test.Performance.run`, for migration to **ghc-7.4.1**.+ ## 1.0.2.4- * Added details to any failure to parse the command-line arguments.- * Defined package's name using program's name & enhanced usage-message, in **Main.hs**.- * Re-implemented logging using `Control.Monad.Writer.Writer` & renamed `Squeeze.Squeeze.findBestFitM` to `Squeeze.Squeeze.findBestFitWriter`.- * Implemented **verbose** functionality in **Squeeze.Test.Performance**.- * Added command-line flag **includeEmpty**, to allow one to include empty files & directories in any solution.+* Added details to any failure to parse the command-line arguments.+* Defined package's name using program's name & enhanced usage-message, in **Main.hs**.+* Re-implemented logging using `Control.Monad.Writer.Writer` & renamed `Squeeze.Squeeze.findBestFitM` to `Squeeze.Squeeze.findBestFitWriter`.+* Implemented **verbose** functionality in **Squeeze.Test.Performance**.+* Added command-line flag "**includeEmpty**", to allow one to include empty files & directories in any solution.+ ## 1.0.3.0- * Changed **Main** to replace calls to `error` from inside the IO-monad, with `Control.Monad.fail`.- * Changed **Main**; by adding a command-line option to define the seed for the random-generator used for performance-testing; to permit **includeEmpty** to take an optional Boolean argument, rather than a mandatory one; to read `Squeeze.Data.CommandOptions.getMinimumUsageRatio` as a `Double`, rather than a `Rational`.- * Renamed the accessors in **Squeeze.Data.CommandOptions**, & removed `bisectionRatio` & associated code.- * Added **Squeeze.Control.Concurrent.DivideAndConquer**, called from **Main** to utilise multiple CPU-cores where available.- * Trapped command-line arguments to which garbage has been appended.- * Changed **Data.CommandOptions** to use `Distribution.Verbosity.Verbosity`.+* Changed **Main** to replace calls to `error` from inside the IO-monad, with `Control.Monad.fail`.+* Changed **Main**; by adding a command-line option to define the seed for the random-generator used for performance-testing; to permit **includeEmpty** to take an optional Boolean argument, rather than a mandatory one; to read `Squeeze.Data.CommandOptions.getMinimumUsageRatio` as a `Double`, rather than a `Rational`.+* Renamed the accessors in **Squeeze.Data.CommandOptions**, & removed `bisectionRatio` & associated code.+* Added **Squeeze.Control.Concurrent.DivideAndConquer**, called from **Main** to utilise multiple CPU-cores where available.+* Trapped command-line arguments to which garbage has been appended.+* Changed **Data.CommandOptions** to use `Distribution.Verbosity.Verbosity`.+ ## 1.0.4.0- * Corrected the Copyright-statement in `Main.main.optDescrList.printVersion`.- * Renamed **Squeeze.Test.QC** to **Squeeze.Test.QuickChecks**; migrating its tests to a new module **Squeeze.Test.Squeeze**, & added new tests `prop_monotonicFileSize` & `prop_uniqueFileNames`, requiring package **toolshed-0.14.0.0**; added module **Squeeze.Test.Data.FileCombinations**.- * Amended the log-messages printed by **Main**.- * Removed the command-line option **graphPerformance**, which printed only CPU-seconds rather than elapsed time, & therefore didn't correctly represent the multi-threaded implementation.- * Removed the printing of CPU-seconds when not testing performance; this is better left to **/usr/bin/time**.- * Compensated for the potential rejection of some virtual files after generation of a test-population.- * Used new class `Factory.Math.Probability.Distribution` & bumped required version to **factory-0.2.1.0**.- * Replaced the command-line option **--testPerformance**, with **--testPerformanceContinuous** & **--testPerformanceDiscrete**.+* Corrected the Copyright-statement in `Main.main.optDescrList.printVersion`.+* Renamed **Squeeze.Test.QC** to **Squeeze.Test.QuickChecks**; migrating its tests to a new module "**Squeeze.Test.Squeeze**", & added new tests `prop_monotonicFileSize` & `prop_uniqueFileNames`, requiring package "**toolshed-0.14.0.0**"; added module "**Squeeze.Test.Data.FileCombinations**".+* Amended the log-messages printed by **Main**.+* Removed the command-line option "**graphPerformance**", which printed only CPU-seconds rather than elapsed time, & therefore didn't correctly represent the multi-threaded implementation.+* Removed the printing of CPU-seconds when not testing performance; this is better left to **/usr/bin/time**.+* Compensated for the potential rejection of some virtual files after generation of a test-population.+* Used new class `Factory.Math.Probability.Distribution` & bumped required version to **factory-0.2.1.0**.+* Replaced the command-line option "**--testPerformance**", with "**--testPerformanceContinuous**" & "**--testPerformanceDiscrete**".+ ## 1.0.4.1- * Removed `ToolShed.SelfValidate.isValid commandOptions` from `Main.runQuickChecks`; since the command-options aren't used.- * Added **changelog.Debian** to the *.cabal*-file.- * Relocated `Main.distribute` to `Squeeze.Squeeze.distributeAndFindBestFit` & added check on whether maximum size has been exceeded.- * Added `Squeeze.Squeeze.partitionEmptyFilesAndDistributeAndFindBestFit`, to efficiently account for empty files, & relocated calculation of file-statistics to this function.- * Amended `Test.Performance.run`, replacing call to `Squeeze.Squeeze.findBestFit` with `Squeeze.Squeeze.distributeAndFindBestFit`, to permit multi-threaded performance-tests.- * Added function `Squeeze.Data.CommandOptions.mkCommandOptions` & modules **Squeeze.Test.Data.Verbosity** & **Squeeze.Test.Data.CommandOptions** for future QuickChecks.- * Extracted `Squeeze.Data.File.expandDirectory` from `Squeeze.Data.File.findSize` to clarify the logic. Symlinks are also now permissible input files.- * Added `Squeeze.Data.File.findDuplicates`, & trapped duplicate files implicit within those directories specified.+* Removed `ToolShed.SelfValidate.isValid commandOptions` from `Main.runQuickChecks`; since the command-options aren't used.+* Added file "**changelog.Debian**" to the *.cabal*-file.+* Relocated `Main.distribute` to `Squeeze.Squeeze.distributeAndFindBestFit` & added check on whether maximum size has been exceeded.+* Added `Squeeze.Squeeze.partitionEmptyFilesAndDistributeAndFindBestFit`, to efficiently account for empty files, & relocated calculation of file-statistics to this function.+* Amended `Test.Performance.run`, replacing call to `Squeeze.Squeeze.findBestFit` with `Squeeze.Squeeze.distributeAndFindBestFit`, to permit multi-threaded performance-tests.+* Added function `Squeeze.Data.CommandOptions.mkCommandOptions` & modules **Squeeze.Test.Data.Verbosity** & **Squeeze.Test.Data.CommandOptions** for future QuickChecks.+* Extracted `Squeeze.Data.File.expandDirectory` from `Squeeze.Data.File.findSize` to clarify the logic. Symlinks are also now permissible input files.+* Added `Squeeze.Data.File.findDuplicates`, & trapped duplicate files implicit within those directories specified.+ ## 1.0.4.2- * Improved the syntax of **verbosity** in the usage-message.- * Tested with **haskell-platform-2013.2.0.0**.- * Added a function `Data.CommandOptions.subtractFile` to adjust `Data.CommandOptions.CommandOptions` after removing a file from the problem; previously done incorrectly, causing an error when running with **+RTS -N2**.+* Improved the syntax of **verbosity** in the usage-message.+* Tested with **haskell-platform-2013.2.0.0**.+* Added a function `Data.CommandOptions.subtractFile` to adjust `Data.CommandOptions.CommandOptions` after removing a file from the problem; previously done incorrectly, causing an error when running with options "**+RTS -N2**".+ ## 1.0.4.3- * Changed the value of `0/0` to **0** rather than **1** in `Data.CommandOptions.subtractFile`.+* Changed the value of `0/0` to **0** rather than **1** in `Data.CommandOptions.subtractFile`.+ ## 1.0.4.4- * Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between **Control.Applicative** & **Prelude** which (from **base-4.8**) also exports this symbol, or hid the symbol when importing the **Prelude**.- * In module **Main**, redirected version-message to stderr.+* Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between modules "**Control.Applicative**" & "**Prelude**" which (from package "**base-4.8**") also exports this symbol, or hid the symbol when importing the module "**Prelude**".+* In module "**Main**", redirected version-message to *stderr*.+ ## 1.0.4.5- * Added the compiler to the output returned for the command-line option **version**.- * Specified compiler-option **context-stack** in **Main.hs**, to account for call to `printf`.+* Added the compiler to the output returned for the command-line option "**version**".+* Specified compiler-option "**context-stack**" in module "**Main**", to account for call to `printf`.+ ## 1.0.4.6- * Minimised the explicit size of compiler's 'context-stack' in module **Main.hs**.- * In module **Squeeze.Data.File.hs**, replaced the use of the package **unix** with the package **directory**, for compatibility with Windows.+* Minimised the explicit size of compiler's 'context-stack' in module "**Main**".+* In module "**Squeeze.Data.File.hs**", replaced the use of the package "**unix**" with the package "**directory**", for compatibility with **Windows**.+ ## 1.0.4.7- * Increased the specified value of compiler-option **context-stack** in module **Main.hs**, to account for call to `printf`.+* Increased the specified value of compiler-option "**context-stack**" in module "**Main**", to account for call to `printf`.+ ## 1.0.4.8- * Changed flag **threaded** in the *.cabal*-file to **manual**.- * Added **Default-language**-specification to the *.cabal*-file.- * Added file **README.markdown**.- * Converted this file to markdown-format.- * Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.- * Moved the entry-point to the test-suite from **Main.hs** to **Test.hs**, both to integrate with **cabal** & to minimise the dependencies of the executable.- * Partitioned the source-files into **src-lib**, **src-exe**, & **src-test** directories, & referenced them individually from the *.cabal*-file to avoid repeated compilation.- * Used **CPP** to control the import of symbols from **Control.Applicative**.- * Changed default **minimumUsageRatio** in module **Squeeze.Data.CommandOptions** from 99% to 90%.+* Changed flag "**threaded**" in the *.cabal*-file to **manual**.+* Added "**Default-language**"-specification to the *.cabal*-file.+* Added file "**README.markdown**".+* Converted this file to markdown-format.+* Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.+* Moved the entry-point to the test-suite from module **Main** to module **Test**, both to integrate with **cabal** & to minimise the dependencies of the executable.+* Partitioned the source-files into directories "**src-lib**", "**src-exe**", & "**src-test**", & referenced them individually from the *.cabal*-file to avoid repeated compilation.+* Used CPP to control the import of symbols from **Control.Applicative**.+* Changed default **minimumUsageRatio** in module "**Squeeze.Data.CommandOptions**" from **99%** to **90%**.++## 1.0.4.9+* Amended the help-message for options "**testPerformanceContinuous**" & "**testPerformanceDiscrete**".+* Corrected the markdown-syntax in this file.+* Reverted to calling "**error**" rather than "**Control.Monad.fail**", since the **String**-argument for the latter is discarded in **Monad**-implementations other than **IO**.+* Uploaded to [GitHub](https://github.com/functionalley/Squeeze.git).+* Simplified file **src-test/Main.hs**.+* Added file **.travis.yml** to control testing by <https://docs.travis-ci.com>.+* Added file **.ghci**.+* Replaced use of module **ToolShed.Defaultable** with **Data.Default**.+* Tested with **ghc-8.0.1**.+## 1.0.4.10+* Amended pre-processor directive **MIN_TOOL_VERSION_ghc** in **Main.hs**.+## 1.0.4.11+* Checked pre-processor directives are defined.+## 1.0.4.12
copyright view
@@ -1,5 +1,5 @@ Author:- Dr. Alistair Ward <squeeze at functionalley dot eu>.+ Dr. Alistair Ward <squeeze@functionalley.eu>. Copyright: Copyright (C) 2010-2013 Dr. Alistair Ward. All Rights Reserved.
debian/DEBIAN/control view
@@ -1,11 +1,11 @@ Package: squeeze-Version: 1.0.4.8-1+Version: 1.0.4.12-1 Section: utils Priority: optional Architecture: amd64 Depends: libc6 Installed-size: 2576-Maintainer: Dr. Alistair Ward <squeeze at functionalley dot eu>+Maintainer: Dr. Alistair Ward <squeeze@functionalley.eu> Provides: Homepage: http://functionalley.eu/Squeeze/squeeze.html Description: Finds the optimal subset of the specified files, to fit into a limited space.
man/man1/squeeze.1 view
@@ -97,12 +97,12 @@ 699998310 .fi .PP-NB: "\fBdu\fR" will return a slightly larger size, since it includes the space required for directory-structures.+N.B.: "\fBdu\fR" will return a slightly larger size, since it includes the space required for directory-structures. .SS Example 2 We can improve on that result if we're prepared to split some of the artist-specific directories into individual albums. With the expectation of more solutions from which to select, we'll also raise the bar for what is acceptable. .br-NB: from version \fB1.0.3.0\fR, the runtime can be passed a "\fB-N\fR" flag to request parallel execution on multiple cores,+N.B.: from version \fB1.0.3.0\fR, the runtime can be passed a "\fB-N\fR" flag to request parallel execution on multiple cores, which as a side-effect, alters the selection of sub-optimal solutions to return. Whether this option actually results in reduced execution-time, depends on the file-size frequency-distribution & on the available hardware. .IP@@ -130,7 +130,7 @@ Written by Dr. Alistair Ward. .SH BUGS .SS "REPORTING BUGS"-Report bugs to <\fBsqueeze\fR \fIat\fR \fBfunctionalley\fR \fIdot\fR \fBeu\fR>.+Report bugs to <\fBsqueeze@functionalley.eu\fR>. .SH COPYRIGHT Copyright \(co 2010-2015 Dr. Alistair Ward .PP@@ -141,12 +141,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see \fB<http://www.gnu.org/licenses/>\fR. .SH "SEE ALSO" .IP \(bu-Home-page: \fBhttp://functionalley.eu/Squeeze/squeeze\fR+Home-page: \fBhttp://functionalley.eu/Squeeze/squeeze.html\fR .IP \(bu+.B http://hackage.haskell.org/package/squeeze+.IP \(bu+.B https://github.com/functionalley/Squeeze+.IP \(bu Source-documentation is generated by "\fBHaddock\fR", & is available in the distribution. .IP \(bu .B http://www.haskell.org/haddock/ .IP \(bu-.B http://en.wikipedia.org/wiki/Log-normal_distribution+.B https://en.wikipedia.org/wiki/Log-normal_distribution .IP \(bu-.B http://en.wikipedia.org/wiki/Poisson_distribution+.B https://en.wikipedia.org/wiki/Poisson_distribution
squeeze.cabal view
@@ -14,7 +14,7 @@ -- along with Squeeze. If not, see <http://www.gnu.org/licenses/>. Name: squeeze-Version: 1.0.4.8+Version: 1.0.4.12 Cabal-version: >= 1.10 Copyright: (C) 2010-2015 Dr. Alistair Ward License: GPL@@ -25,13 +25,14 @@ Build-type: Simple Description: Returns progressively better subsets of the specified files, selected to fit into a limited space, without wasting more than the specific ratio. Category: Application, Utils-Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10+Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10.1, GHC == 8.0.1 Homepage: http://functionalley.eu/Squeeze/squeeze.html-Maintainer: mailto <colon> squeeze <at> functionalley <dot> eu-Bug-reports: mailto <colon> squeeze <at> functionalley <dot> eu+Maintainer: mailto:squeeze@functionalley.eu+Bug-reports: mailto:squeeze@functionalley.eu -- None of these files are needed at run-time. Extra-source-files:+ .ghci changelog.markdown changelog.Debian copyright@@ -40,6 +41,10 @@ README.markdown squeeze.spec +source-repository head+ type: git+ location: https://github.com/functionalley/Squeeze+ -- Enable using: 'cabal configure -f llvm'. flag llvm Description: Whether the 'llvm' compiler-backend has been installed and is required for code-generation.@@ -53,7 +58,7 @@ Library Default-language: Haskell2010- GHC-options: -Wall -O2 -fno-warn-tabs+ GHC-options: -O2 -Wall -fno-warn-tabs Hs-source-dirs: src-lib Exposed-modules:@@ -68,24 +73,25 @@ Build-depends: base == 4.*,+ data-default, Cabal >= 1.10, directory, factory >= 0.2.1.0, filepath, mtl,- toolshed >= 0.16+ toolshed >= 0.17 if impl(ghc >= 7.4.1)- GHC-prof-options: -prof -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs else- GHC-prof-options: -prof -auto-all -caf-all+ GHC-prof-options: -auto-all -caf-all if impl(ghc >= 7.0) && flag(llvm) GHC-options: -fllvm Executable squeeze Default-language: Haskell2010- GHC-options: -Wall -O2 -fno-warn-tabs+ GHC-options: -O2 -Wall -fno-warn-tabs Hs-source-dirs: src-exe Main-is: Main.hs @@ -96,17 +102,18 @@ Build-depends: base == 4.*, Cabal >= 1.10,+ data-default, factory >= 0.2.1.0, filepath, mtl, random, squeeze,- toolshed >= 0.16+ toolshed >= 0.17 if impl(ghc >= 7.4.1)- GHC-prof-options: -prof -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs else- GHC-prof-options: -prof -auto-all -caf-all+ GHC-prof-options: -auto-all -caf-all if flag(threaded) GHC-options: -threaded@@ -117,7 +124,7 @@ if flag(llvm) GHC-options: -fllvm -Test-Suite quickCheck+Test-Suite test Default-language: Haskell2010 GHC-options: -Wall -fno-warn-tabs Hs-source-dirs: src-test@@ -126,15 +133,15 @@ -- Required for 'cabal sdist'. Other-modules:- Squeeze.Test.Data.CommandOptions- Squeeze.Test.Data.FileCombinations- Squeeze.Test.Data.Verbosity- Squeeze.Test.Squeeze+ Squeeze.Test.QuickCheck.Data.CommandOptions+ Squeeze.Test.QuickCheck.Data.FileCombinations+ Squeeze.Test.QuickCheck.Data.Verbosity+ Squeeze.Test.QuickCheck.Squeeze Build-depends: base == 4.*, factory >= 0.2.1.0, QuickCheck >= 2.4, squeeze,- toolshed >= 0.16+ toolshed >= 0.17
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.8+Version: 1.0.4.12 Release: 1 License: GPLv3 # From '/usr/share/doc/packages/rpm/GROUPS'.@@ -35,7 +35,7 @@ Returns progressively better subsets of the specified files, to fit into a limited space, without wasting more than the specific ratio. %prep-# NB: CWD has changed to %_builddir+# N.B.: CWD has changed to %_builddir echo 'package="%package", prefix="%prefix", _builddir="%_builddir", buildroot="%buildroot"' (cd $OLDPWD && cabal sdist) && tar -zxf $OLDPWD/dist/%tarBall # Make a source-distribution & unpack it into the build-directory. cd '%package/' && cabal configure --user --prefix='%prefix' --docdir='%_docdir' # Tell cabal to use the user's personal package-database, to generate an appropriate "Paths" module, & where to place the documentation.@@ -62,6 +62,6 @@ %attr(0644, root, root) %doc %_mandir/man1/%name.1.gz %changelog-* Wed May 09 2012 Alistair Ward <squeeze at functionalley dot eu> 1.0.2.4-1+* Wed May 09 2012 Alistair Ward <squeeze@functionalley.eu> 1.0.2.4-1 First cut.
src-exe/Main.hs view
@@ -1,5 +1,11 @@ {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fcontext-stack=24 #-}+#ifdef MIN_TOOL_VERSION_ghc+#if MIN_TOOL_VERSION_ghc(8,0,1)+{-# OPTIONS_GHC -freduction-depth=25 #-}+#endif+#else+{-# OPTIONS_GHC -fcontext-stack=25 #-}+#endif {- Copyright (C) 2010-2015 Dr. Alistair Ward @@ -32,6 +38,7 @@ import qualified Control.Monad import qualified Control.Monad.Writer+import qualified Data.Default import qualified Data.List import qualified Data.Maybe import qualified Data.Version@@ -54,11 +61,10 @@ import qualified System.IO.Error import qualified Text.Printf import qualified ToolShed.Data.List-import qualified ToolShed.Defaultable import qualified ToolShed.SelfValidate import qualified ToolShed.System.TimeAction -#if !MIN_VERSION_base(4,8,0)+#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0) import Control.Applicative((<$>), (<*>)) #endif @@ -104,7 +110,7 @@ let defaultCommandOptions :: CommandOptions'- defaultCommandOptions = ToolShed.Defaultable.defaultValue+ defaultCommandOptions = Data.Default.def defaultRandomSeed :: Int defaultRandomSeed = 0@@ -124,10 +130,10 @@ G.Option "r" ["randomSeed"] (G.OptArg setRandomSeed "<Int>") ("Seed the random number-generator with the specified integer, to produce a repeatable pseudo-random sequence as required for performance-testing. If this option is unspecified then the seed is unpredictable, but if only its argument is unspecified then the seed defaults to '" ++ show defaultRandomSeed ++ "'. CAVEAT: to be effective, it must precede either 'testPerformanceContinuous' or 'testPerformanceDiscrete'."), G.Option "" ["testPerformanceContinuous"] ( testPerformanceContinuous `G.ReqArg` "(<Int>, <ContinuousDistribution>)"- ) "Measure the CPU-seconds required to find the best fit, for the specified number of randomly generated virtual files, the size of which conform to the specified continuous probability-distribution; & then exit.",+ ) "Measure the CPU-seconds (accumulated over all CPU-cores) required to find the best fit, for the specified number of randomly generated virtual files, the size of which conform to the specified continuous probability-distribution; & then exit.", G.Option "" ["testPerformanceDiscrete"] ( testPerformanceDiscrete `G.ReqArg` "(<Int>, <DiscreteDistribution>)"- ) "Measure the CPU-seconds required to find the best fit, for the specified number of randomly generated virtual files, the size of which conform to the specified discrete probability-distribution; & then exit."+ ) "Measure the CPU-seconds (accumulated over all CPU-cores) required to find the best fit, for the specified number of randomly generated virtual files, the size of which conform to the specified discrete probability-distribution; & then exit." ] where listDelimiters = ('(', '|', ')') @@ -139,7 +145,7 @@ setVerbosity arg commandOptions = return {-to IO-monad-} commandOptions { Data.CommandOptions.getVerbosity = readCommandArg arg } testPerformanceContinuous arg commandOptions- | not $ ToolShed.SelfValidate.isValid commandOptions = fail $ ToolShed.SelfValidate.getFirstError commandOptions+ | not $ ToolShed.SelfValidate.isValid commandOptions = error $ ToolShed.SelfValidate.getFirstError commandOptions | otherwise = do ToolShed.System.TimeAction.printCPUSeconds $ Test.Performance.run commandOptions fileCount probabilityDistribution >>= mapM_ print {-force evaluation-} @@ -150,7 +156,7 @@ (fileCount, probabilityDistribution) = readCommandArg arg testPerformanceDiscrete arg commandOptions- | not $ ToolShed.SelfValidate.isValid commandOptions = fail $ ToolShed.SelfValidate.getFirstError commandOptions+ | not $ ToolShed.SelfValidate.isValid commandOptions = error $ ToolShed.SelfValidate.getFirstError commandOptions | otherwise = do ToolShed.System.TimeAction.printCPUSeconds $ Test.Performance.run commandOptions fileCount probabilityDistribution >>= mapM_ print {-force evaluation-} @@ -166,7 +172,7 @@ printVersion, printUsage :: IO (Data.CommandOptions.CommandOptions f) printVersion = System.IO.hPutStrLn System.IO.stderr (- Distribution.Text.display packageIdentifier ++ "\n\nCompiled by " ++ show compiler ++ ".\n\nCopyright (C) 2010-2015 " ++ author ++ ".\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by " ++ author ++ "."+ 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." ) >> System.Exit.exitSuccess where packageIdentifier :: Distribution.Package.PackageIdentifier packageIdentifier = Distribution.Package.PackageIdentifier {@@ -179,12 +185,12 @@ compiler = System.Info.compilerName ++ "-" ++ Data.List.intercalate "." (map show $ Data.Version.versionBranch System.Info.compilerVersion) printUsage = Text.Printf.hPrintf System.IO.stderr (- "Usage:\t%s %s\n\nEBNF argument-format:" ++ concat (- replicate 9 "\n\t%-22s = %s;" -- Argument-types & their EBNF-definition.- ) ++ "\n\nE.g.\n\t%s\n\t%s\n\t%s\n"+ showString "Usage:\t%s [<File-path> ...]\n\nEBNF argument-format:" $ showString (+ concat $ replicate 9 "\n\t%-22s = %s;" -- Argument-types & their EBNF-definition.+ ) "\n\nE.g.\n\t%s\n\t%s\n\t%s\n" ) ( G.usageInfo progName optDescrList- ) "[<File-path> ...]" "Bool" "\"True\" | \"False\"\t(* case-sensitive *)" "ContinuousDistribution" "LogNormalDistribution location scale^2" "DiscreteDistribution" "PoissonDistribution lambda" "File-path" (+ ) "Bool" "\"True\" | \"False\"\t(* case-sensitive *)" "ContinuousDistribution" "LogNormalDistribution location scale^2" "DiscreteDistribution" "PoissonDistribution lambda" "File-path" ( "File-name ('" ++ [System.FilePath.pathSeparator] ++ "' File-name)*" ) "Float" "Int ('.' Int)?" "Int" "[0-9]+" "lambda" "Float\t(* the mean & variance of the distribution *)" "location" "Float\t(* the mean of the log of the distribution *)" "scale^2" "Float\t(* the variance of the log of the distribution *)" ( progName ++ " --verbosity=Verbose -M 700000000 *.ogg +RTS -N\t#Find the best-fit for the globbed file-names, into the space available on a CD, using multiple CPU-cores where available."@@ -192,7 +198,7 @@ progName ++ " -r --testPerformanceContinuous='(100, LogNormalDistribution " ++ show (log ((fromIntegral defaultMaximumBytes / 12) / sqrt 2) :: Float) {-location-} ++ " " ++ show (log 2 :: Float) {-scale^2-} ++ ")'\t#Test performance." ) ( progName ++ " -r --testPerformanceDiscrete='(100, PoissonDistribution " ++ show (defaultMaximumBytes `div` 12) {-lambda-} ++ ")'\t#Test performance."- ) >> System.Exit.exitSuccess -- CAVEAT: requires increase to default context-stack.+ ) >> System.Exit.exitSuccess -- CAVEAT: requires increase to default context-stack; see GHC-option at top of file. args <- System.Environment.getArgs @@ -200,13 +206,13 @@ case G.getOpt G.RequireOrder optDescrList args of (commandLineActions, nonOptions, [{-errors-}]) -> do commandOptions <- Data.List.foldl' (>>=) (- return {-to IO-monad-} ToolShed.Defaultable.defaultValue+ return {-to IO-monad-} Data.Default.def ) {-transform using CommandLineAction-mutators-} commandLineActions -- ie: do o1 <- CommandLineAction[0] commandOptions[0]; o2 <- CommandLineAction[1] o1; ... if not $ ToolShed.SelfValidate.isValid commandOptions- then fail $ ToolShed.SelfValidate.getFirstError commandOptions+ then error $ ToolShed.SelfValidate.getFirstError commandOptions else if null nonOptions- then fail "zero file-paths specified"+ then error "zero file-paths specified." else let standardInputProxy = "-" in do@@ -223,25 +229,25 @@ filePaths <- (filter (/= standardInputProxy) nonOptions ++) <$> getFilePaths if null filePaths- then fail "zero file-paths"+ then error "zero file-paths." else return filePaths else {-real fileNames-} return {-to IO-monad-} nonOptions implicitDuplicateFilePaths <- Data.File.findDuplicates filePaths - Control.Monad.unless (Data.CommandOptions.getVerbosity commandOptions == minBound || null implicitDuplicateFilePaths) . System.IO.hPutStrLn System.IO.stderr $ "WARNING: there are duplicate files implicit within those directories specified; " ++ show implicitDuplicateFilePaths ++ "."+ Control.Monad.unless (Data.CommandOptions.getVerbosity commandOptions == minBound || null implicitDuplicateFilePaths) . System.IO.hPutStrLn System.IO.stderr . showString "WARNING: there are duplicate files implicit within those directories specified; " $ shows implicitDuplicateFilePaths "." (acceptedFileSizeAndPathList, logFile) <- Control.Monad.Writer.runWriter . Data.File.selectSuitableFileSizes (<= Data.CommandOptions.getMaximumBytes commandOptions) <$> Data.File.findSizes filePaths Control.Monad.unless (Data.CommandOptions.getVerbosity commandOptions == minBound || null logFile) . System.IO.hPutStrLn System.IO.stderr $ Data.List.intercalate "\n" logFile if null acceptedFileSizeAndPathList- then fail "there are zero suitable files"+ then error "there are zero suitable files." else let aggregateSize = Data.File.aggregateSize acceptedFileSizeAndPathList minimumBytes = Data.CommandOptions.deriveMinimumBytes commandOptions in if aggregateSize < minimumBytes- then fail $ "the aggregate size of all suitable files (" ++ show aggregateSize ++ " bytes), is insufficient to satisfy the minimum " ++ show minimumBytes ++ " bytes required"+ then error . showString "the aggregate size of all suitable files (" . shows aggregateSize . showString " bytes), is insufficient to satisfy the minimum " $ shows minimumBytes " bytes required." else Squeeze.partitionEmptyFilesAndDistributeAndFindBestFit commandOptions acceptedFileSizeAndPathList >>= mapM_ print {-lazy evaluation-} (_, _, errors) -> System.IO.Error.ioError . System.IO.Error.userError $ concatMap init {-chop-} errors
src-lib/Squeeze/Control/Concurrent/DivideAndConquer.hs view
@@ -26,7 +26,7 @@ module Squeeze.Control.Concurrent.DivideAndConquer( -- * Types--- * Type-synonyms+-- ** Type-synonyms -- TerminatedChannel, -- * Functions -- writeListToChan,@@ -40,7 +40,7 @@ import qualified Control.Monad import qualified Data.Maybe -#if !MIN_VERSION_base(4,8,0)+#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0) import Control.Applicative((<$>), (<*>)) #endif
src-lib/Squeeze/Data/CommandOptions.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2010-2014 Dr. Alistair Ward+ Copyright (C) 2010-2015 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@@ -41,15 +41,15 @@ solutionSizeBounds, deriveMinimumBytes, subtractFile,--- ** Constructors+-- ** Constructor mkCommandOptions ) where import Control.Arrow((&&&))+import qualified Data.Default import qualified Distribution.Verbosity import qualified Factory.Data.Interval import qualified Squeeze.Data.File as Data.File-import qualified ToolShed.Defaultable import qualified ToolShed.SelfValidate -- | Declares a record to contain command-line options.@@ -61,8 +61,8 @@ getVerbosity :: Distribution.Verbosity.Verbosity -- ^ Set the threshold for ancillary information-output. } deriving (Eq, Show) -instance Fractional f => ToolShed.Defaultable.Defaultable (CommandOptions f) where- defaultValue = MkCommandOptions {+instance Fractional f => Data.Default.Default (CommandOptions f) where+ def = MkCommandOptions { getIncludeEmpty = False, getMaximumBytes = 4700000000, -- DVD-size; just under 4.4GiB. getMaybeRandomSeed = Nothing,
src-lib/Squeeze/Squeeze.hs view
@@ -164,7 +164,7 @@ | otherwise {-exclude empty files-} = do Control.Monad.unless (Data.CommandOptions.getVerbosity commandOptions == minBound || null emptyFiles) . System.IO.hPutStrLn System.IO.stderr $ "WARNING: rejecting empty files; " ++ show emptyFiles ++ "." - Control.Monad.when (null nonEmptyFilePathAndSizeList) $ fail "there are zero non-empty files"+ Control.Monad.when (null nonEmptyFilePathAndSizeList) $ error "there are zero non-empty files." printStatistics nonEmptyFilePathAndSizeList
src-test/Main.hs view
@@ -24,22 +24,17 @@ module Main(main) where -import Control.Arrow((***)) import qualified Control.Monad-import qualified Squeeze.Test.Data.FileCombinations as Test.Data.FileCombinations-import qualified Squeeze.Test.Squeeze as Test.Squeeze+import qualified Squeeze.Test.QuickCheck.Data.FileCombinations as Test.QuickCheck.Data.FileCombinations+import qualified Squeeze.Test.QuickCheck.Squeeze as Test.QuickCheck.Squeeze import qualified System.Exit import qualified ToolShed.Test.QuickCheck.Result -- | Entry-point. main :: IO () main = mapM_ (- snd {-exit-status-} . (- putStrLn . (++ ":") *** (- >>= (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful- )- )+ (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful =<< ) [- ("Data.FileCombinations", Test.Data.FileCombinations.results),- ("Squeeze", Test.Squeeze.results)+ Test.QuickCheck.Data.FileCombinations.results,+ Test.QuickCheck.Squeeze.results ]
− src-test/Squeeze/Test/Data/CommandOptions.hs
@@ -1,54 +0,0 @@-{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-- Copyright (C) 2013-2015 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- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Data.CommandOptions.CommandOptions'.--}--module Squeeze.Test.Data.CommandOptions(--- * Types--- ** Type-synonyms- CommandOptions-) where--import qualified Test.QuickCheck-import qualified Squeeze.Data.CommandOptions as Data.CommandOptions-import Squeeze.Test.Data.Verbosity()--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative((<$>), (<*>))-#endif--instance (- Enum ratio,- Fractional ratio,- Ord ratio,- Real ratio,- Test.QuickCheck.Arbitrary ratio- ) => Test.QuickCheck.Arbitrary (Data.CommandOptions.CommandOptions ratio) where- arbitrary = Data.CommandOptions.mkCommandOptions <$> Test.QuickCheck.arbitrary {-includeEmpty-} <*> (- abs <$> Test.QuickCheck.arbitrary -- maximumBytes.- ) <*> Test.QuickCheck.arbitrary {-maybeRandomSeed-} <*> (- recip . succ . abs <$> Test.QuickCheck.arbitrary -- minimumUsageRatio.- ) <*> Test.QuickCheck.arbitrary {-verbosity-}---- | Defines a concrete type for testing.-type CommandOptions = Data.CommandOptions.CommandOptions Double-
− src-test/Squeeze/Test/Data/FileCombinations.hs
@@ -1,51 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-- Copyright (C) 2010-2015 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- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Defines tests to dynamically verify the module "Squeeze.Data.FileCombinations" against arbitrary data.--}--module Squeeze.Test.Data.FileCombinations(--- * Constants- results-) where--import Control.Arrow((&&&))-import qualified Data.List-import qualified Squeeze.Data.FileCombination as Data.FileCombination-import qualified Test.QuickCheck--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.-- return $ Data.FileCombination.mkFileCombination aggregateFileSize filePathList---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results = mapM Test.QuickCheck.quickCheckResult [prop_risingFilter, prop_risingFilter', prop_risingMergeByAggregateFileSize] where- prop_risingFilter, prop_risingFilter', prop_risingMergeByAggregateFileSize :: [Data.FileCombination.FileCombination] -> Test.QuickCheck.Property- prop_risingFilter = Test.QuickCheck.label "prop_risingFilter" . uncurry (==) . (id &&& Data.List.sort) . map Data.FileCombination.getAggregateFileSize . Data.FileCombination.risingFilter 0- prop_risingFilter' = Test.QuickCheck.label "prop_risingFilter'" . uncurry (==) . (id &&& Data.FileCombination.risingFilter 0) . Data.List.sortBy Data.FileCombination.comparingAggregateFileSize-- prop_risingMergeByAggregateFileSize = Test.QuickCheck.label "prop_risingMergeByAggregateFileSize" . uncurry (==) . (- id &&& map head . Data.List.group . uncurry Data.FileCombination.risingMergeByAggregateFileSize . (id &&& id)- ) . Data.FileCombination.risingFilter 0-
− src-test/Squeeze/Test/Data/Verbosity.hs
@@ -1,30 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-- Copyright (C) 2013 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- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Distribution.Verbosity.Verbosity'.--}--module Squeeze.Test.Data.Verbosity() where--import qualified Distribution.Verbosity-import qualified Test.QuickCheck--instance Test.QuickCheck.Arbitrary Distribution.Verbosity.Verbosity where- arbitrary = Test.QuickCheck.elements [minBound .. maxBound]
+ src-test/Squeeze/Test/QuickCheck/Data/CommandOptions.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+ Copyright (C) 2013-2015 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+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Data.CommandOptions.CommandOptions'.+-}++module Squeeze.Test.QuickCheck.Data.CommandOptions(+-- * Types+-- ** Type-synonyms+ CommandOptions+) where++import qualified Test.QuickCheck+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)+import Control.Applicative((<$>), (<*>))+#endif++instance (+ Enum ratio,+ Fractional ratio,+ Ord ratio,+ Real ratio,+ Test.QuickCheck.Arbitrary ratio+ ) => Test.QuickCheck.Arbitrary (Data.CommandOptions.CommandOptions ratio) where+ arbitrary = Data.CommandOptions.mkCommandOptions <$> Test.QuickCheck.arbitrary {-includeEmpty-} <*> (+ abs <$> Test.QuickCheck.arbitrary -- maximumBytes.+ ) <*> Test.QuickCheck.arbitrary {-maybeRandomSeed-} <*> (+ recip . succ . abs <$> Test.QuickCheck.arbitrary -- minimumUsageRatio.+ ) <*> Test.QuickCheck.arbitrary {-verbosity-}++-- | Defines a concrete type for testing.+type CommandOptions = Data.CommandOptions.CommandOptions Double+
+ src-test/Squeeze/Test/QuickCheck/Data/FileCombinations.hs view
@@ -0,0 +1,51 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+ Copyright (C) 2010-2015 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+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Defines tests to dynamically verify the module "Squeeze.Data.FileCombinations" against arbitrary data.+-}++module Squeeze.Test.QuickCheck.Data.FileCombinations(+-- * Constants+ results+) where++import Control.Arrow((&&&))+import qualified Data.List+import qualified Squeeze.Data.FileCombination as Data.FileCombination+import qualified Test.QuickCheck++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.++ return $ Data.FileCombination.mkFileCombination aggregateFileSize filePathList++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results = mapM Test.QuickCheck.quickCheckResult [prop_risingFilter, prop_risingFilter', prop_risingMergeByAggregateFileSize] where+ prop_risingFilter, prop_risingFilter', prop_risingMergeByAggregateFileSize :: [Data.FileCombination.FileCombination] -> Test.QuickCheck.Property+ prop_risingFilter = Test.QuickCheck.label "prop_risingFilter" . uncurry (==) . (id &&& Data.List.sort) . map Data.FileCombination.getAggregateFileSize . Data.FileCombination.risingFilter 0+ prop_risingFilter' = Test.QuickCheck.label "prop_risingFilter'" . uncurry (==) . (id &&& Data.FileCombination.risingFilter 0) . Data.List.sortBy Data.FileCombination.comparingAggregateFileSize++ prop_risingMergeByAggregateFileSize = Test.QuickCheck.label "prop_risingMergeByAggregateFileSize" . uncurry (==) . (+ id &&& map head . Data.List.group . uncurry Data.FileCombination.risingMergeByAggregateFileSize . (id &&& id)+ ) . Data.FileCombination.risingFilter 0+
+ src-test/Squeeze/Test/QuickCheck/Data/Verbosity.hs view
@@ -0,0 +1,30 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+ Copyright (C) 2013 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+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Distribution.Verbosity.Verbosity'.+-}++module Squeeze.Test.QuickCheck.Data.Verbosity() where++import qualified Distribution.Verbosity+import qualified Test.QuickCheck++instance Test.QuickCheck.Arbitrary Distribution.Verbosity.Verbosity where+ arbitrary = Test.QuickCheck.elements [minBound .. maxBound]
+ src-test/Squeeze/Test/QuickCheck/Squeeze.hs view
@@ -0,0 +1,70 @@+{-+ Copyright (C) 2010-2015 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+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Defines tests to dynamically verify the module "Squeeze.Squeeze" against arbitrary data.+-}++module Squeeze.Test.QuickCheck.Squeeze(+-- * Constants+ results+) where++import Control.Arrow((&&&))+import qualified Data.List+import qualified Factory.Data.Interval+import qualified Squeeze.Data.File as Data.File+import qualified Squeeze.Data.FileCombination as Data.FileCombination+import qualified Squeeze.Squeeze as Squeeze+import qualified Test.QuickCheck+import qualified ToolShed.Data.Foldable+import qualified ToolShed.Data.List++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results = mapM Test.QuickCheck.quickCheckResult [prop_totalCombinations, prop_fileSizeBounds, prop_allFiles, prop_monotonicFileSize, prop_uniqueFileNames] where+ mkFileSizeAndPathList :: (Integral i, Show i) => [i] -> [Data.File.FileSizeAndPath]+ mkFileSizeAndPathList = take 12 . Data.List.nubBy (ToolShed.Data.List.equalityBy snd) . map (toInteger . abs &&& show) -- CAVEAT: may be shorter than requested.++ prop_totalCombinations, prop_fileSizeBounds, prop_allFiles, prop_monotonicFileSize, prop_uniqueFileNames :: [Integer] -> Test.QuickCheck.Property+ prop_totalCombinations integers = Test.QuickCheck.label "prop_totalCombinations" $ (length . Data.List.nub . Squeeze.findCombinations (0, fromIntegral (maxBound :: Int)) $ Data.File.orderByDecreasingSize fileSizeAndPathList) == 2 ^ length fileSizeAndPathList where+ fileSizeAndPathList = mkFileSizeAndPathList integers++ prop_fileSizeBounds integers = Test.QuickCheck.label "prop_fileSizeBounds" . all ((`Factory.Data.Interval.elem'` fileSizeBounds) . Data.FileCombination.getAggregateFileSize) . Squeeze.findCombinations fileSizeBounds $ Data.File.orderByDecreasingSize fileSizeAndPathList where+ fileSizeAndPathList = mkFileSizeAndPathList integers++ fileSizeBounds :: Factory.Data.Interval.Interval Data.File.FileSize+ fileSizeBounds = (minimumBytes, maximumBytes) where+ maximumBytes, minimumBytes :: Data.File.FileSize+ maximumBytes = round $ fromIntegral (Data.File.aggregateSize fileSizeAndPathList) / (4.0 :: Double) -- Arbitrarily.+ minimumBytes = maximumBytes `div` 2 -- Arbitrarily.++ prop_allFiles integers = Test.QuickCheck.label "prop_allFiles" . (== aggregateSize) . last . map Data.FileCombination.getAggregateFileSize $ Squeeze.findBestFit (Factory.Data.Interval.precisely aggregateSize) fileSizeAndPathList where+ fileSizeAndPathList = mkFileSizeAndPathList integers++ aggregateSize :: Data.File.FileSize+ aggregateSize = Data.File.aggregateSize fileSizeAndPathList++ prop_monotonicFileSize integers = Test.QuickCheck.label "prop_monotonicFileSize" . uncurry (==) . (id &&& Data.List.sort {-stable-}) . map Data.FileCombination.getAggregateFileSize $ Squeeze.findBestFit (0, fromIntegral (maxBound :: Int)) fileSizeAndPathList where+ fileSizeAndPathList = mkFileSizeAndPathList integers++ prop_uniqueFileNames integers = Test.QuickCheck.label "prop_uniqueFileNames" . all (+ all ((== 1) . length) . ToolShed.Data.Foldable.gather . Data.FileCombination.getFilePathList+ ) $ Squeeze.findBestFit (0, fromIntegral (maxBound :: Int)) fileSizeAndPathList where+ fileSizeAndPathList = mkFileSizeAndPathList integers+
− src-test/Squeeze/Test/Squeeze.hs
@@ -1,70 +0,0 @@-{-- Copyright (C) 2010-2015 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- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Defines tests to dynamically verify the module "Squeeze.Squeeze" against arbitrary data.--}--module Squeeze.Test.Squeeze(--- * Constants- results-) where--import Control.Arrow((&&&))-import qualified Data.List-import qualified Factory.Data.Interval-import qualified Squeeze.Data.File as Data.File-import qualified Squeeze.Data.FileCombination as Data.FileCombination-import qualified Squeeze.Squeeze as Squeeze-import qualified Test.QuickCheck-import qualified ToolShed.Data.Foldable-import qualified ToolShed.Data.List---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results = mapM Test.QuickCheck.quickCheckResult [prop_totalCombinations, prop_fileSizeBounds, prop_allFiles, prop_monotonicFileSize, prop_uniqueFileNames] where- mkFileSizeAndPathList :: (Integral i, Show i) => [i] -> [Data.File.FileSizeAndPath]- mkFileSizeAndPathList = take 12 . Data.List.nubBy (ToolShed.Data.List.equalityBy snd) . map (toInteger . abs &&& show) -- CAVEAT: may be shorter than requested.-- prop_totalCombinations, prop_fileSizeBounds, prop_allFiles, prop_monotonicFileSize, prop_uniqueFileNames :: [Integer] -> Test.QuickCheck.Property- prop_totalCombinations integers = Test.QuickCheck.label "prop_totalCombinations" $ (length . Data.List.nub . Squeeze.findCombinations (0, fromIntegral (maxBound :: Int)) $ Data.File.orderByDecreasingSize fileSizeAndPathList) == 2 ^ length fileSizeAndPathList where- fileSizeAndPathList = mkFileSizeAndPathList integers-- prop_fileSizeBounds integers = Test.QuickCheck.label "prop_fileSizeBounds" . all ((`Factory.Data.Interval.elem'` fileSizeBounds) . Data.FileCombination.getAggregateFileSize) . Squeeze.findCombinations fileSizeBounds $ Data.File.orderByDecreasingSize fileSizeAndPathList where- fileSizeAndPathList = mkFileSizeAndPathList integers-- fileSizeBounds :: Factory.Data.Interval.Interval Data.File.FileSize- fileSizeBounds = (minimumBytes, maximumBytes) where- maximumBytes, minimumBytes :: Data.File.FileSize- maximumBytes = round $ fromIntegral (Data.File.aggregateSize fileSizeAndPathList) / (4.0 :: Double) -- Arbitrarily.- minimumBytes = maximumBytes `div` 2 -- Arbitrarily.-- prop_allFiles integers = Test.QuickCheck.label "prop_allFiles" . (== aggregateSize) . last . map Data.FileCombination.getAggregateFileSize $ Squeeze.findBestFit (Factory.Data.Interval.precisely aggregateSize) fileSizeAndPathList where- fileSizeAndPathList = mkFileSizeAndPathList integers-- aggregateSize :: Data.File.FileSize- aggregateSize = Data.File.aggregateSize fileSizeAndPathList-- prop_monotonicFileSize integers = Test.QuickCheck.label "prop_monotonicFileSize" . uncurry (==) . (id &&& Data.List.sort {-stable-}) . map Data.FileCombination.getAggregateFileSize $ Squeeze.findBestFit (0, fromIntegral (maxBound :: Int)) fileSizeAndPathList where- fileSizeAndPathList = mkFileSizeAndPathList integers-- prop_uniqueFileNames integers = Test.QuickCheck.label "prop_uniqueFileNames" . all (- all ((== 1) . length) . ToolShed.Data.Foldable.gather . Data.FileCombination.getFilePathList- ) $ Squeeze.findBestFit (0, fromIntegral (maxBound :: Int)) fileSizeAndPathList where- fileSizeAndPathList = mkFileSizeAndPathList integers-