packages feed

squeeze 1.0.4.1 → 1.0.4.2

raw patch · 10 files changed

+59/−22 lines, 10 files

Files

changelog view
@@ -90,3 +90,8 @@ 	* 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.+
debian/DEBIAN/control view
@@ -1,5 +1,5 @@ Package:	squeeze-Version:	1.0.4.1-1+Version:	1.0.4.2-1 Section:	utils Priority:	optional Architecture:	i386
makefile view
@@ -42,7 +42,7 @@ 	PATH=~/.cabal/bin:$$PATH runhaskell Setup $@ --hyperlink-source --executables	#Amend path to find 'HsColour', as required for 'hyperlink-source'.  hlint:-	@$@ -i 'Reduce duplication' src/+	@$@ -i 'Reduce duplication' src/ +RTS -N  sdist: 	runhaskell Setup $@
man/man1/squeeze.1 view
@@ -14,10 +14,10 @@ rather than waiting until the optimal solution is known (which might take an inordinately long time). .SH OPTIONS .TP-\fB--verbosity=\fR\fBSilent\fR|\fBNormal\fR|\fBVerbose\fR|\fBDeafening\fR+\fB--verbosity=\fR(\fBSilent\fR|\fBNormal\fR|\fBVerbose\fR|\fBDeafening\fR) Produces additional explanatory output where appropriate. .br-CAVEAT: to be effective, this option must precede other options.+CAVEAT: to be effective, this option must precede others. .SS "Generic Program-information" .TP \fB-v\fR, \fB--version\fR@@ -146,7 +146,7 @@ .IP \(bu Home-page: \fBhttp://functionalley.eu\fR .IP \(bu-Source-documentation is generated by \fBHaddock\fR, & is available in the distribution.+Source-documentation is generated by "\fBHaddock\fR", & is available in the distribution. .IP \(bu .B http://www.haskell.org/haddock/ .IP \(bu
squeeze.cabal view
@@ -1,8 +1,8 @@---Package-properties+-- Package-properties Name:			squeeze-Version:		1.0.4.1+Version:		1.0.4.2 Cabal-Version:		>= 1.6-Copyright:		(C) 2010-2013 Dr. Alistair Ward+Copyright:		(C) 2010-2014 Dr. Alistair Ward License:		GPL License-file:		LICENSE Author:			Dr. Alistair Ward@@ -11,13 +11,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:		Utils-Tested-With:		GHC == 7.4+Tested-With:		GHC == 7.4, GHC == 7.6 Homepage:		http://functionalley.eu Maintainer:		squeeze <at> functionalley <dot> eu Bug-reports:		squeeze <at> functionalley <dot> eu Data-files: Extra-Source-Files:	changelog copyright changelog.Debian debian/DEBIAN/control makefile man/man1/squeeze.1 squeeze.spec +-- Turn on using: 'runhaskell ./Setup.hs configure -f llvm'. flag llvm     Description:	Whether the 'llvm' compiler-backend has been installed and is required for code-generation.     manual:		True
squeeze.spec view
@@ -22,7 +22,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.1+Version:	1.0.4.2 Release:	1 License:	GPLv3 #From '/usr/share/doc/packages/rpm/GROUPS'.
src/Main.hs view
@@ -52,6 +52,7 @@ import qualified	System.IO 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@@ -108,7 +109,7 @@ --				 String	[String]		(G.ArgDescr CommandLineAction)			String 			G.Option "?"	["help"]		(G.NoArg $ const printUsage)			"Display this help, & then exit.", 			G.Option ""	["verbosity"]		(-				setVerbosity `G.ReqArg` show [minBound :: Distribution.Verbosity.Verbosity .. maxBound]+				setVerbosity `G.ReqArg` ToolShed.Data.List.showListWith listDelimiters [minBound :: Distribution.Verbosity.Verbosity .. maxBound] "" 			)											("Define the log-level; default '" ++ show (Data.CommandOptions.getVerbosity defaultCommandOptions) ++ "'. CAVEAT: to be effective, it must precede other options." 			), 			G.Option "v"	["version"]		(G.NoArg $ const printVersion)			"Print version-information, & then exit.",@@ -124,6 +125,8 @@ 				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." 		 ] where+			listDelimiters	= ('(', '|', ')')+ 			defaultMaximumBytes	= Data.CommandOptions.getMaximumBytes defaultCommandOptions  			setMaximumBytes, setMinimumUsageRatio, setVerbosity, testPerformanceContinuous, testPerformanceDiscrete :: String -> CommandLineAction
src/Squeeze/Data/CommandOptions.hs view
@@ -40,6 +40,7 @@ -- * Functions 	solutionSizeBounds, 	deriveMinimumBytes,+	subtractFile, -- ** Constructors 	mkCommandOptions ) where@@ -58,7 +59,7 @@ 	getMaybeRandomSeed	:: Maybe Int,				-- ^ Optionally seed the random-number generator to produce a repeatable pseudo-random sequence. 	getMinimumUsageRatio	:: ratio,				-- ^ The minimum acceptable usage-ratio of 'getMaximumBytes'. 	getVerbosity		:: Distribution.Verbosity.Verbosity	-- ^ Set the threshold for ancillary information-output.-} deriving Show+} deriving (Eq, Show)  instance Fractional f => ToolShed.Defaultable.Defaultable (CommandOptions f)	where 	defaultValue	= MkCommandOptions {@@ -77,7 +78,17 @@ 	 ]  -- | Smart constructor.-mkCommandOptions :: (Ord ratio, Real ratio) => Bool -> Data.File.FileSize -> Maybe Int -> ratio -> Distribution.Verbosity.Verbosity -> CommandOptions ratio+mkCommandOptions+	:: (+		Ord ratio,+		Real ratio+	)+	=> Bool+	-> Data.File.FileSize+	-> Maybe Int+	-> ratio+	-> Distribution.Verbosity.Verbosity+	-> CommandOptions ratio mkCommandOptions includeEmpty maximumBytes maybeRandomSeed minimumUsageRatio verbosity 	| ToolShed.SelfValidate.isValid commandOptions	= commandOptions 	| otherwise					= error $ "Squeeze.Data.CommandOptions.mkCommandOptions:\t" ++ ToolShed.SelfValidate.getFirstError commandOptions@@ -87,6 +98,26 @@ -- | Derives the minimum number of bytes, from other options. deriveMinimumBytes :: RealFrac ratio => CommandOptions ratio -> Data.File.FileSize deriveMinimumBytes	= floor . uncurry (*) . (getMinimumUsageRatio &&& realToFrac . getMaximumBytes)++-- | Reduce the requirements by the specified file-size.+subtractFile+	:: RealFrac ratio+	=> Data.File.FileSize+	-> CommandOptions ratio+	-> CommandOptions ratio+subtractFile fileSize commandOptions+	| fileSize < 0		= error $ "Squeeze.Data.CommandOptions.subtractFile:\tnegative file-size=" ++ show fileSize+	| maximumBytes' < 0	= error $ "Squeeze.Data.CommandOptions.subtractFile:\tfile-size=" ++ show fileSize  ++ " > maximum=" ++ show maximumBytes+	| maximumBytes' == 0	= commandOptions {+		getMaximumBytes		= 0,+		getMinimumUsageRatio	= 1	-- CAVEAT: calculation below would yield 0 / 0.+	}+	| otherwise		= commandOptions {+		getMaximumBytes		= maximumBytes',+		getMinimumUsageRatio	= fromIntegral (max 0 $ deriveMinimumBytes commandOptions - fromIntegral fileSize) / fromIntegral maximumBytes'+	} where+		maximumBytes	= getMaximumBytes commandOptions+		maximumBytes'	= maximumBytes - fileSize  -- | The bounds on the aggregate size of the set of files. solutionSizeBounds :: RealFrac f => CommandOptions f -> Factory.Data.Interval.Interval Data.File.FileSize
src/Squeeze/Squeeze.hs view
@@ -95,7 +95,7 @@ 	:: Factory.Data.Interval.Interval Data.File.FileSize	-- ^ The closed interval of acceptible sizes for file-combinations. 	-> [Data.File.FileSizeAndPath]				-- ^ The input list of file-names & sizes. 	-> [Data.FileCombination.FileCombination]		-- ^ A reduced list of increasingly suitable file-combinations.-findBestFit solutionSizeBounds	= Data.FileCombination.risingFilter (Factory.Data.Interval.getMinBound solutionSizeBounds) . findCombinations solutionSizeBounds . Data.File.orderByDecreasingSize {-which makes findCombinations faster-} +findBestFit solutionSizeBounds	= Data.FileCombination.risingFilter (Factory.Data.Interval.getMinBound solutionSizeBounds) . findCombinations solutionSizeBounds . Data.File.orderByDecreasingSize {-which makes findCombinations faster-}  {- | 	* Recursively bisects the task, distributing the sub-tasks to 'findBestFit', to utilise the available CPU-cores.@@ -128,17 +128,14 @@  		fileCombinationsExcludingSelected	<- recurse commandOptions' {-i.e the original space-} remainingFileSizeAndPaths	--This is about half the total task. -		let maximumBytes'	= Data.CommandOptions.getMaximumBytes commandOptions' - Data.File.getSize selectedFileSizeAndPath+		let	+			commandOptions''	= Data.CommandOptions.subtractFile (Data.File.getSize selectedFileSizeAndPath) commandOptions' --Reduce the requirements by the size of the selected file. -		if maximumBytes' < 0+		if Data.CommandOptions.getMaximumBytes commandOptions'' < 0 			then return {-to IO-monad-} fileCombinationsExcludingSelected	--The selected file won't fit. 			else map ( 				Data.FileCombination.prepend selectedFileSizeAndPath	--Prepend the selected file to all file-combinations.-			) <$> recurse (-				commandOptions' {-					Data.CommandOptions.getMaximumBytes	= maximumBytes'-				} --Reduce the maximum size; there's no need to account for the minimum, since this is defined as a ratio of the maximum.-			) remainingFileSizeAndPaths >>= Control.Concurrent.DivideAndConquer.divideAndConquer Data.FileCombination.risingMergeByAggregateFileSize fileCombinationsExcludingSelected	--Merge the part-solutions.+			) <$> recurse commandOptions'' remainingFileSizeAndPaths >>= Control.Concurrent.DivideAndConquer.divideAndConquer Data.FileCombination.risingMergeByAggregateFileSize fileCombinationsExcludingSelected	--Merge the part-solutions.  in Control.Concurrent.getNumCapabilities >>= (\numCapabilities -> slave numCapabilities commandOptions $ Data.File.orderByIncreasingSize fileSizeAndPathList)  {- |
src/Squeeze/Test/Data/CommandOptions.hs view
@@ -27,7 +27,7 @@ 	CommandOptions ) where -import			Control.Applicative((<$>), (<*>)) +import			Control.Applicative((<$>), (<*>)) import qualified	Test.QuickCheck import qualified	Squeeze.Data.CommandOptions	as Data.CommandOptions import			Squeeze.Test.Data.Verbosity()