toolshed 0.15.0.0 → 0.15.0.1
raw patch · 21 files changed
+71/−136 lines, 21 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Setup.hs +2/−2
- changelog +6/−0
- makefile +3/−3
- src/Main.hs +7/−8
- src/ToolShed/Data/Foldable.hs +1/−1
- src/ToolShed/Data/List.hs +3/−3
- src/ToolShed/Data/Pair.hs +1/−1
- src/ToolShed/SelfValidate.hs +2/−2
- src/ToolShed/System/File.hs +7/−8
- src/ToolShed/System/Random.hs +3/−3
- src/ToolShed/System/TimePure.hs +4/−22
- src/ToolShed/Test/Data/Foldable.hs +1/−2
- src/ToolShed/Test/Data/List.hs +4/−6
- src/ToolShed/Test/Data/List/Splits.hs +3/−14
- src/ToolShed/Test/QuickCheck/Arbitrary/Array.hs +4/−17
- src/ToolShed/Test/QuickCheck/Arbitrary/ArrayElem.hs +2/−8
- src/ToolShed/Test/QuickCheck/Arbitrary/Map.hs +2/−8
- src/ToolShed/Test/QuickCheck/Arbitrary/Set.hs +2/−8
- src/ToolShed/Test/SelfValidate.hs +2/−3
- src/ToolShed/Test/System/Random.hs +5/−5
- toolshed.cabal +7/−12
Setup.hs view
@@ -1,5 +1,5 @@ #!/usr/bin/env runhaskell -import qualified Distribution.Simple+import qualified Distribution.Simple -main = Distribution.Simple.defaultMain+main = Distribution.Simple.defaultMain
changelog view
@@ -73,3 +73,9 @@ * Added an instance for '(,,)', to "ToolShed.Defaultable.Defaultable". * Corrected version-string in "Main" used in '--version' option. * Corrected the output of 'Main.main.optDescrList.printVersion'.+0.15.0.1+ * Tested with 'haskell-platform-2013.2.0.0'.+ * Replaced preprocessor-directives with 'build-depends' constraints in 'toolshed.cabal'.+ * In module "ToolShed.System.File", replaced 'Control.Exception.throw' with 'Control.Exception.throwIO'.+ * Replaced all instances of '(<$>)' with 'fmap' to avoid ambiguity between "Control.Applicative" & "Prelude" which (from 'base-4.8') also exports this symbol.+
makefile view
@@ -1,4 +1,4 @@-# Copyright (C) 2010 Dr. Alistair Ward+# Copyright (C) 2010-2014 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@@ -40,10 +40,10 @@ PATH=~/.cabal/bin:$$PATH runhaskell Setup $@ --hyperlink-source #Amend path to find 'HsColour', as required for 'hyperlink-source'. hlint:- @$@ src/+ @$@ -i 'Use &&' src/ +RTS -N sdist:- runhaskell Setup $@+ TAR_OPTIONS='--format=ustar' runhaskell Setup $@ check: sdist cabal upload --check --verbose=3 dist/*.tar.gz;
src/Main.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -31,22 +31,21 @@ import qualified Distribution.Package import qualified Distribution.Text import qualified Distribution.Version-import qualified Paths_toolshed as Paths --Either local stub, or package-instance autogenerated by 'Setup.hs build'.+import qualified Paths_toolshed as Paths -- Either local stub, or package-instance autogenerated by 'Setup.hs build'. import qualified System.Console.GetOpt as G import qualified System.Environment import qualified System.Exit import qualified System.IO import qualified System.IO.Error-import qualified ToolShed.Defaultable import qualified ToolShed.Test.QuickChecks -- | Used to thread user-defined command-line options, though the list of functions which implement them.-type CommandLineAction = () -> IO () --Supplied as the type-argument to 'G.OptDescr'.+type CommandLineAction = () -> IO () -- Supplied as the type-argument to 'G.OptDescr'. -- | Parses the command-line arguments, to determine 'Test.CommandOptions.CommandOptions'. main :: IO () main = do- System.IO.hClose System.IO.stdin --Nothing is read from standard input.+ System.IO.hClose System.IO.stdin -- Nothing is read from standard input. progName <- System.Environment.getProgName @@ -54,7 +53,7 @@ usageMessage :: String usageMessage = "Usage:\t" ++ G.usageInfo progName optDescrList ---Define the command-line options, and the 'CommandLineAction's used to handle them.+-- Define the command-line options, and the 'CommandLineAction's used to handle them. optDescrList :: [G.OptDescr CommandLineAction] optDescrList = [ -- String [String] (G.ArgDescr CommandLineAction) String@@ -66,7 +65,7 @@ printVersion = System.IO.hPutStrLn System.IO.stderr (Distribution.Text.display packageIdentifier ++ "\n\nCopyright (C) 2010-2013 " ++ 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 ++ ".") >> System.Exit.exitWith System.Exit.ExitSuccess where packageIdentifier :: Distribution.Package.PackageIdentifier packageIdentifier = Distribution.Package.PackageIdentifier {- Distribution.Package.pkgName = Distribution.Package.PackageName progName, --CAVEAT: coincidentally.+ Distribution.Package.pkgName = Distribution.Package.PackageName progName, -- CAVEAT: coincidentally. Distribution.Package.pkgVersion = Distribution.Version.Version (Data.Version.versionBranch Paths.version) [] } @@ -81,5 +80,5 @@ -- G.getOpt :: G.ArgOrder CommandLineAction -> [G.OptDescr Action] -> [String] -> ([Action], [String], [String]) case G.getOpt G.RequireOrder optDescrList args of (commandLineActions, _, []) -> Data.List.foldl' (>>=) (return {-to IO-monad-} ()) commandLineActions >> System.Exit.exitWith System.Exit.ExitSuccess- (_, _, errors) -> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usageMessage --Throw.+ (_, _, errors) -> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usageMessage -- Throw.
src/ToolShed/Data/Foldable.hs view
@@ -33,7 +33,7 @@ import qualified Data.Map {- |- * Group equal (though not necessarily adjacent; c.f. 'Data.List.groupBy') elements, according to the specified comparator.+ * Group equal (though not necessarily adjacent; cf. 'Data.List.groupBy') elements, according to the specified comparator. * The groups are returned in ascending order, whilst their elements remain in their original order. -}
src/ToolShed/Data/List.hs view
@@ -79,7 +79,7 @@ :: Int -- ^ The index. -> [a] -- ^ The polymorphic input list. -> [a] -- ^ The same list, with the indexed element removed.-excise 0 = tail --Just for efficiency.+excise 0 = tail -- Just for efficiency. excise i = uncurry (++) . Control.Arrow.second tail . splitAt i -- | The type of function required by 'findConvergenceBy', 'permutationsBy'.@@ -112,7 +112,7 @@ -} permutationsBy :: Matches a -> [[a]] -> [[a]] permutationsBy matches lists- | any null lists = [] --Required for efficiency, to catch the case [bigList1, bigList2 ... null]+ | any null lists = [] -- Required for efficiency, to catch the case [bigList1, bigList2 ... null] | otherwise = slave lists where slave (xs : xss) = [x : xs' | x <- xs, xs' <- slave $ map (filter $ matches x) xss]@@ -148,7 +148,7 @@ -- | Converts a list of /Pairs/, into a narrower list. linearise :: [(a, a)] -> [a] linearise [] = []-linearise ((l, r) : remainder) = l : r : linearise remainder --Recurse.+linearise ((l, r) : remainder) = l : r : linearise remainder -- Recurse. {- | * Merge two sorted lists, according to the specified order, to product a single sorted list.
src/ToolShed/Data/Pair.hs view
@@ -30,7 +30,7 @@ {- | * Apply the same transformation to both halves of a /Pair/. - * CAVEAT: the pair is required to have identical types.+ * CAVEAT: even though the function may be polymorphic, the pair is required to have identical types. -} mirror :: (a -> b) -> (a, a) -> (b, b) mirror f = f *** f
src/ToolShed/SelfValidate.hs view
@@ -37,7 +37,7 @@ getErrors :: v -> [String] -- ^ Return either null, or the reasons why the data is invalid. isValid :: v -> Bool -- ^ The data which implements this interface should return 'True' if internally consistent.- isValid = null . getErrors --Default implementation.+ isValid = null . getErrors -- Default implementation. instance (SelfValidator v) => SelfValidator (Maybe v) where getErrors (Just v) = getErrors v@@ -69,7 +69,7 @@ where errors = getErrors selfValidator --- | Filters failed tests amongst those specified.+-- | Extracts the failed tests from those specified. extractErrors :: [(Bool, String)] -> [String] extractErrors = map snd . filter fst
src/ToolShed/System/File.hs view
@@ -1,6 +1,6 @@ {-- Copyright (C) 2011 Dr. Alistair Ward+ Copyright (C) 2011-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@@ -35,7 +35,6 @@ getData ) where -import Control.Applicative((<$>)) import qualified Control.Exception import qualified Control.Monad import qualified Data.List@@ -57,12 +56,12 @@ locate :: System.FilePath.FilePath -> SearchPath -> IO [System.FilePath.FilePath] locate fileName searchPath | System.FilePath.isRelative fileName' = Control.Monad.filterM System.Directory.doesFileExist . filter System.FilePath.isValid . Data.List.nubBy System.FilePath.equalFilePath $ map (System.FilePath.normalise . (</> fileName')) searchPath- | not $ System.FilePath.isValid fileName' = Control.Exception.throw . System.IO.Error.userError $ "Invalid filename; " ++ fileName'+ | not $ System.FilePath.isValid fileName' = Control.Exception.throwIO . System.IO.Error.userError $ "Invalid filename; " ++ fileName' | otherwise = do fileExists <- System.Directory.doesFileExist fileName' if not fileExists- then Control.Exception.throw . System.IO.Error.mkIOError System.IO.Error.doesNotExistErrorType "No such file" Nothing $ Just fileName'+ then Control.Exception.throwIO . System.IO.Error.mkIOError System.IO.Error.doesNotExistErrorType "No such file" Nothing $ Just fileName' else return {-to IO-monad-} [fileName'] where fileName' = System.FilePath.normalise fileName@@ -87,10 +86,10 @@ filePaths <- locate fileName directories if null filePaths- then Control.Exception.throw . System.IO.Error.mkIOError System.IO.Error.doesNotExistErrorType ("Can't find in " ++ show directories) Nothing $ Just fileName+ then Control.Exception.throwIO . System.IO.Error.mkIOError System.IO.Error.doesNotExistErrorType ("Can't find in " ++ show directories) Nothing $ Just fileName else {-located-} let- filePath = head filePaths --Discard any subsequent paths.- in (,) filePath <$> readFile filePath+ filePath = head filePaths -- Discard any subsequent paths.+ in (,) filePath `fmap` readFile filePath {- | * Returns the polymorphic data, read from the first matching file on the /search-path/, along with the path from which it was read.@@ -102,6 +101,6 @@ (filePath, fileContents) <- getFile fileName directories case reads fileContents of- [(x, _)] -> return {-to IO-monad-} (filePath, x) --CAVEAT: discards any unconsumed text.+ [(x, _)] -> return {-to IO-monad-} (filePath, x) -- CAVEAT: discards any unconsumed text. _ -> fail $ "ToolShed.System.File.fromFile:\tfailed to parse file=" ++ show filePath
src/ToolShed/System/Random.hs view
@@ -47,8 +47,8 @@ * The input list is traversed, but the items aren't evaluated. -} shuffle :: System.Random.RandomGen randomGen => randomGen -> [a] -> [a]-shuffle _ [] = [] --Not strictly necessary.-shuffle _ singleton@[_] = singleton --Not strictly necessary.+shuffle _ [] = [] -- Not strictly necessary.+shuffle _ singleton@[_] = singleton -- Not strictly necessary. shuffle randomGen l = slave randomGen s (pred $ Data.Sequence.length s) where s = Data.Sequence.fromList l @@ -66,7 +66,7 @@ -} generateSelection :: System.Random.RandomGen randomGen => randomGen -> [a] -> [a] generateSelection _ [] = error "ToolShed.System.Random.generateSelection:\tnull list"-generateSelection _ [x] = repeat x --Not strictly necessary, but more efficient.+generateSelection _ [x] = repeat x -- Not strictly necessary, but more efficient. generateSelection randomGen l = map (l !!) $ System.Random.randomRs (0, pred $ length l) randomGen -- | Return a randomly selected element from the specified list.
src/ToolShed/System/TimePure.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {- Copyright (C) 2010 Dr. Alistair Ward @@ -28,38 +27,21 @@ printCPUSeconds ) where +import qualified Control.DeepSeq import qualified System.CPUTime import qualified System.IO -{-- The function used to force evaluation of the pure expression 'rnf',- and the type-class which the polymorphic data must implement 'NFData',- has been relocated from module "Control.Parallel.Strategies" to "Control.DeepSeq".--}-#ifdef HAVE_DEEPSEQ-import Control.DeepSeq(NFData, deepseq)-#else-import Control.Parallel(pseq)-import Control.Parallel.Strategies(NFData, rnf)-#endif- {- | * Time the specified pure expression, returning the required number of CPU-seconds and the result, as a 'Pair'. * CAVEAT: as a side-effect, the expression is /deep/ evaluated. -}-getCPUSeconds :: (Fractional seconds, NFData expression)+getCPUSeconds :: (Fractional seconds, Control.DeepSeq.NFData expression) => expression -- ^ Arbitrary polymorphic expression. -> IO (seconds, expression) -- ^ The original expression, tagged with the CPU-seconds taken. getCPUSeconds expression = do start <- System.CPUTime.getCPUTime- end <--#ifdef HAVE_DEEPSEQ- expression `deepseq`-#else- rnf expression `pseq`-#endif- System.CPUTime.getCPUTime+ end <- expression `Control.DeepSeq.deepseq` System.CPUTime.getCPUTime return {-to IO-monad-} (fromInteger (end - start) / 1e12 {-convert from pico-seconds-}, expression) @@ -68,7 +50,7 @@ * CAVEAT: as a side-effect, the expression is /deep/ evaluated. -}-printCPUSeconds :: NFData expression => expression -> IO expression+printCPUSeconds :: Control.DeepSeq.NFData expression => expression -> IO expression printCPUSeconds expression = do (cpuSeconds, result) <- getCPUSeconds expression
src/ToolShed/Test/Data/Foldable.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -31,7 +31,6 @@ import qualified ToolShed.Data.Foldable import qualified ToolShed.Data.List import qualified Test.QuickCheck-import Test.QuickCheck((==>)) -- | Defines invariant properties. quickChecks :: IO ()
src/ToolShed/Test/Data/List.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -26,8 +26,6 @@ ) where import qualified Data.List-import qualified Data.Ord-import qualified Data.Set import qualified ToolShed.Data.List import qualified Test.QuickCheck import Test.QuickCheck((==>))@@ -53,13 +51,13 @@ prop_permutations, prop_permutations', prop_permutationsBy :: [[Int]] -> Test.QuickCheck.Property prop_permutations l = not (null l') ==> Test.QuickCheck.label "prop_permutations" $ length (ToolShed.Data.List.permutations l') == product (map length l') where- l' = take 6 $ map (take 6) l --Limit the task.+ l' = take 6 $ map (take 6) l -- Limit the task. prop_permutations' l = not (null l') && all (not . null) l' ==> Test.QuickCheck.label "prop_permutations'" . (== 1) . length . Data.List.nub . map length $ ToolShed.Data.List.permutations l' where- l' = take 7 $ map (take 5) l --Limit the task.+ l' = take 7 $ map (take 5) l -- Limit the task. prop_permutationsBy l = and [not $ null l', all (not . null) l', not $ null permutations] ==> Test.QuickCheck.label "prop_permutationsBy" . (== 1) . length . Data.List.nub $ map (length . Data.List.nub) permutations where- l' = take 8 $ map (take 4) l --Limit the task.+ l' = take 8 $ map (take 4) l -- Limit the task. permutations = ToolShed.Data.List.permutationsBy (/=) l' prop_permutationsBy' :: Int -> Test.QuickCheck.Property
src/ToolShed/Test/Data/List/Splits.hs view
@@ -1,6 +1,5 @@-{-# LANGUAGE CPP #-} {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -27,25 +26,15 @@ ) where import Control.Arrow((***))-import qualified Data.List-import qualified Data.Ord-import qualified Data.Set+import qualified Data.Tuple import qualified ToolShed.Data.List.Splits import qualified Test.QuickCheck import Test.QuickCheck((==>)) -#if MIN_VERSION_base(4,3,0)-import Data.Tuple(swap)-#else--- | Swap the components of a pair.-swap :: (a, b) -> (b, a)-swap (a, b) = (b, a)-#endif- -- | Defines invariant properties. quickChecks :: IO () quickChecks = Test.QuickCheck.quickCheck prop_splitsFrom where prop_splitsFrom :: Int -> [Int] -> Test.QuickCheck.Property- prop_splitsFrom i l = not (null l) ==> Test.QuickCheck.label "prop_splitsFrom" $ take n (ToolShed.Data.List.Splits.splitsLeftFrom index l) == take n (map (swap . (reverse *** reverse)) . ToolShed.Data.List.Splits.splitsRightFrom (length l - index) $ reverse l) where+ prop_splitsFrom i l = not (null l) ==> Test.QuickCheck.label "prop_splitsFrom" $ take n (ToolShed.Data.List.Splits.splitsLeftFrom index l) == take n (map (Data.Tuple.swap . (reverse *** reverse)) . ToolShed.Data.List.Splits.splitsRightFrom (length l - index) $ reverse l) where index = i `mod` length l n = succ index
src/ToolShed/Test/QuickCheck/Arbitrary/Array.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -28,32 +27,20 @@ module ToolShed.Test.QuickCheck.Arbitrary.Array() where -import Control.Applicative((<$>)) import qualified Data.Array.IArray+import qualified Data.Tuple import qualified Test.QuickCheck -#if MIN_VERSION_base(4,3,0)-import Data.Tuple(swap)-#else--- | Swap the components of a pair.-swap :: (a, b) -> (b, a)-swap (a, b) = (b, a)-#endif- instance (Data.Array.IArray.Ix i, Enum i, Test.QuickCheck.Arbitrary i, Test.QuickCheck.Arbitrary e) => Test.QuickCheck.Arbitrary (Data.Array.IArray.Array i e) where arbitrary = do pair <- Test.QuickCheck.arbitrary {-(i, i)-} let bounds@(lower, upper)- | uncurry (>) pair = swap pair+ | uncurry (>) pair = Data.Tuple.swap pair | otherwise = pair indices = [lower .. upper] - Data.Array.IArray.array bounds . zip indices <$> Test.QuickCheck.vector (length indices)--#if !(MIN_VERSION_QuickCheck(2,1,0))- coarbitrary = undefined --CAVEAT: stops warnings from ghc.-#endif+ (Data.Array.IArray.array bounds . zip indices) `fmap` Test.QuickCheck.vector (length indices)
src/ToolShed/Test/QuickCheck/Arbitrary/ArrayElem.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -29,15 +28,10 @@ module ToolShed.Test.QuickCheck.Arbitrary.ArrayElem() where -import Control.Applicative((<$>)) import qualified Data.Array.IArray import qualified Test.QuickCheck instance (Bounded i, Data.Array.IArray.Ix i, Enum i, Test.QuickCheck.Arbitrary e) => Test.QuickCheck.Arbitrary (Data.Array.IArray.Array i e) where- arbitrary = Data.Array.IArray.array bounds . zip [minBound .. maxBound] <$> Test.QuickCheck.vector (succ $ fromEnum (snd bounds) - fromEnum (fst bounds)) where+ arbitrary = (Data.Array.IArray.array bounds . zip [minBound .. maxBound]) `fmap` Test.QuickCheck.vector (succ $ fromEnum (snd bounds) - fromEnum (fst bounds)) where bounds = (minBound, maxBound)--#if !(MIN_VERSION_QuickCheck(2,1,0))- coarbitrary = undefined --CAVEAT: stops warnings from ghc.-#endif
src/ToolShed/Test/QuickCheck/Arbitrary/Map.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -26,14 +25,9 @@ module ToolShed.Test.QuickCheck.Arbitrary.Map() where -import Control.Applicative((<$>)) import qualified Data.Map import qualified Test.QuickCheck instance (Ord k, Test.QuickCheck.Arbitrary k, Test.QuickCheck.Arbitrary v) => Test.QuickCheck.Arbitrary (Data.Map.Map k v) where- arbitrary = Data.Map.fromList <$> Test.QuickCheck.arbitrary {-[(k, v)]-}--#if !(MIN_VERSION_QuickCheck(2,1,0))- coarbitrary = undefined --CAVEAT: stops warnings from ghc.-#endif+ arbitrary = Data.Map.fromList `fmap` Test.QuickCheck.arbitrary {-[(k, v)]-}
src/ToolShed/Test/QuickCheck/Arbitrary/Set.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -26,14 +25,9 @@ module ToolShed.Test.QuickCheck.Arbitrary.Set() where -import Control.Applicative((<$>)) import qualified Data.Set import qualified Test.QuickCheck instance (Ord k, Test.QuickCheck.Arbitrary k) => Test.QuickCheck.Arbitrary (Data.Set.Set k) where- arbitrary = Data.Set.fromList <$> Test.QuickCheck.arbitrary {-[k]-}--#if !(MIN_VERSION_QuickCheck(2,1,0))- coarbitrary = undefined --CAVEAT: stops warnings from ghc.-#endif+ arbitrary = Data.Set.fromList `fmap` Test.QuickCheck.arbitrary {-[k]-}
src/ToolShed/Test/SelfValidate.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2012 Dr. Alistair Ward+ Copyright (C) 2012-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@@ -28,7 +28,6 @@ quickChecks ) where -import Control.Applicative((<$>)) import qualified Data.Foldable import qualified Data.List import qualified Data.Map@@ -50,7 +49,7 @@ ] instance Test.QuickCheck.Arbitrary Primes where- arbitrary = MkPrimes <$> Test.QuickCheck.elements [negate limit .. limit] where limit = pred $ 7 * 7+ arbitrary = MkPrimes `fmap` Test.QuickCheck.elements [negate limit .. limit] where limit = pred $ 7 * 7 -- | Defines invariant properties. quickChecks :: IO ()
src/ToolShed/Test/System/Random.hs view
@@ -58,19 +58,19 @@ prop_shuffleDistribution = Test.QuickCheck.label "prop_shuffleDistribution" . all ( uncurry (&&) . ( (- < recip 20 {-empirically-} --The ideal value for a uniform distribution, would be zero.+ < recip 20 {-empirically-} -- The ideal value for a uniform distribution, would be zero. ) . (- / getStandardDeviation (populationSize : replicate (pred $ length testList) 0) --Normalise wrt the worst-case; which occurs when this column contains the same letter, for each test-case in the population.+ / getStandardDeviation (populationSize : replicate (pred $ length testList) 0) -- Normalise wrt the worst-case; which occurs when this column contains the same letter, for each test-case in the population. ) . getStandardDeviation &&& (- == populationSize --Confirm the size of the test-data.+ == populationSize -- Confirm the size of the test-data. ) . Data.Foldable.sum ) ) . map ( foldr ( uncurry $ Data.Map.insertWith (+) ) (- Data.Map.fromList . zip testList $ repeat (0 :: Int) --Initial value.- ) . (`zip` repeat 1) --Count the instances of each letter in this column, which for a uniform distribution, should be approximately the same.+ Data.Map.fromList . zip testList $ repeat (0 :: Int) -- Initial value.+ ) . (`zip` repeat 1) -- Count the instances of each letter in this column, which for a uniform distribution, should be approximately the same. ) . Data.List.transpose {-examine the columns-} . take populationSize . map fst {-shuffled digits-} . tail {-drop initial value-} . iterate ( Control.Arrow.first (`ToolShed.System.Random.shuffle` testList) . System.Random.split . snd ) . (,) undefined . System.Random.mkStdGen where
toolshed.cabal view
@@ -1,6 +1,6 @@---Package-properties+-- Package-properties Name: toolshed-Version: 0.15.0.0+Version: 0.15.0.1 Cabal-Version: >= 1.6 Copyright: (C) 2010-2013 Dr. Alistair Ward License: GPL@@ -11,16 +11,13 @@ Build-Type: Simple Description: An ill-defined collection of simple unrelated utilities used by other packages from <http://functionalley.eu> Category: Utils-Tested-With: GHC == 7.4+Tested-With: GHC == 7.4, GHC == 7.6, GHC == 7.10 Homepage: http://functionalley.eu Maintainer: toolshed <at> functionalley <dot> eu Bug-reports: toolshed <at> functionalley <dot> eu Extra-Source-Files: changelog, copyright, makefile -flag haveDeepSeq- Description: Import the type-class 'NFData' from module 'Control.DeepSeq' rather than 'Control.Parallel.Strategies'.- Default: True-+-- 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@@ -56,22 +53,19 @@ array, base == 4.*, containers >= 0.4.2.0,+ deepseq >= 1.1, directory, filepath, QuickCheck >= 2.2, random - GHC-options: -Wall -O2+ GHC-options: -Wall -O2 -fno-warn-tabs if impl(ghc >= 7.4.1) GHC-prof-options: -prof -fprof-auto -fprof-cafs else GHC-prof-options: -prof -auto-all -caf-all - if flag(haveDeepSeq)- Build-depends: deepseq >= 1.1- CPP-options: -DHAVE_DEEPSEQ- if impl(ghc >= 7.0) && flag(llvm) GHC-options: -fllvm @@ -94,3 +88,4 @@ Build-depends: Cabal >= 1.6 && < 2 + GHC-options: -Wall -O2 -fno-warn-tabs