toolshed 0.11.1.0 → 0.12.0.0
raw patch · 8 files changed
+123/−13 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ ToolShed.ListPlus: linearise :: [(a, a)] -> [a]
+ ToolShed.Pair: both :: (Bool, Bool) -> Bool
+ ToolShed.Pair: mirror :: (a -> b) -> (a, a) -> (b, b)
+ ToolShed.Pair: neither :: (Bool, Bool) -> Bool
+ ToolShed.TimeAction: getCPUSeconds :: Fractional seconds => IO result -> IO (seconds, result)
+ ToolShed.TimeAction: printCPUSeconds :: IO result -> IO result
- ToolShed.TimePure: getCPUSeconds :: NFData expression => expression -> IO (Double, expression)
+ ToolShed.TimePure: getCPUSeconds :: (Fractional seconds, NFData expression) => expression -> IO (seconds, expression)
Files
- changelog +4/−0
- makefile +5/−1
- src/ToolShed/Defaultable.hs +1/−0
- src/ToolShed/ListPlus.hs +6/−0
- src/ToolShed/Pair.hs +44/−0
- src/ToolShed/TimeAction.hs +49/−0
- src/ToolShed/TimePure.hs +9/−9
- toolshed.cabal +5/−3
changelog view
@@ -24,3 +24,7 @@ * Added module "ToolShed.Defaultable", and derived class 'ToolShed.Options.Options' from it. 0.11.1.0 * Added functions 'merge' and 'mergeBy' to module "ToolShed.ListPlus" and exported a new type-synonym 'ToolShed.ListPlus.ChunkLength'.+ * Uploaded to <http://hackage.haskell.org/packages/hackage.html>.+0.12.0.0+ * Added module "ToolShed.TimeAction" to measure the CPU-seconds required for an IO-action.+ * Added module "Pair".
makefile view
@@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -.PHONY: all build clean configure copy haddock help hlint install prof sdist+.PHONY: all build check clean configure copy haddock help hlint install prof sdist all: install @@ -45,8 +45,12 @@ sdist: configure runhaskell Setup.hs $@ +check: sdist+ cabal upload --check --verbose=3 dist/*.tar.gz;+ clean: runhaskell Setup.hs $@+ find src -type f \( -name '*.o' -o -name '*.hi' \) -delete help: @grep '^[a-zA-Z].*:' makefile | sed -e 's/:.*//'
src/ToolShed/Defaultable.hs view
@@ -25,6 +25,7 @@ Defaultable(..) ) where +-- | An interface to which data which have a default-value can adhere. class Defaultable a where defaultValue :: a -- ^ The default value of the data-type.
src/ToolShed/ListPlus.hs view
@@ -29,6 +29,7 @@ chunk, excise, groupComparing,+ linearise, merge, mergeBy, -- splitsFrom,@@ -83,6 +84,11 @@ -> [a] -- ^ The polymorphic input list to group. -> [[a]] -- ^ The same list split into chunks of the required length. groupComparing f = Data.List.groupBy (\a b -> f a == f b)++-- | Converts a list of /Pairs/, into a narrower list.+linearise :: [(a, a)] -> [a]+linearise [] = []+linearise ((l, r) : remainder) = l : r : linearise remainder --Recurse {- | * Merge two sorted lists, to product a single sorted list.
+ src/ToolShed/Pair.hs view
@@ -0,0 +1,44 @@+{-+ Copyright (C) 2010 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@] Miscellaneous operations on Pairs.+-}++module ToolShed.Pair(+-- * Functions+ mirror,+-- ** Predicates+ both,+ neither+) where++import Control.Arrow((***))++-- | Apply the same transformation to both halves of a /Pair/.+mirror :: (a -> b) -> (a, a) -> (b, b)+mirror f = f *** f++-- | 'True' if both halves of the /Pair/ are.+both :: (Bool, Bool) -> Bool+both = uncurry (&&)++-- | 'True' if neither half of the /Pair/ is.+neither :: (Bool, Bool) -> Bool+neither = not . uncurry (||)+
+ src/ToolShed/TimeAction.hs view
@@ -0,0 +1,49 @@+{-+ Copyright (C) 2011 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@] Determines the CPU-time, required to evaluate the specified IO-action.++-}++module ToolShed.TimeAction(+-- * Functions+ getCPUSeconds,+ printCPUSeconds+) where++import qualified System.CPUTime+import qualified System.IO++-- | Time the specified IO-action, returning the seconds and result as a 'Pair'.+getCPUSeconds :: Fractional seconds => IO result -> IO (seconds, result)+getCPUSeconds action = do+ startTime <- System.CPUTime.getCPUTime+ result <- action+ endTime <- System.CPUTime.getCPUTime++ return (fromInteger (endTime - startTime) / 1e12 {-convert from pico-seconds-}, result)++-- | Print the time required by the specified IO-action.+printCPUSeconds :: IO result -> IO result+printCPUSeconds action = do+ (cpuSeconds, result) <- getCPUSeconds action++ System.IO.hPutStrLn System.IO.stderr $ "CPU-seconds:\t" ++ show (cpuSeconds :: Double)++ return {-to IO-monad-} result
src/ToolShed/TimePure.hs view
@@ -20,11 +20,6 @@ [@DESCRIPTION@] Determines the CPU-time, required to evaluate the specified pure expression. - [@CAVEAT@]-- The function used to force evaluation of the pure expression 'rnf',- & the type-class which the polymorphic data must implement 'NFData',- have been relocated from module "Control.Parallel.Strategies" to "Control.DeepSeq". -} module ToolShed.TimePure (@@ -36,6 +31,11 @@ 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@@ -44,13 +44,13 @@ #endif {- |- * Time the specified pure expression.+ * Time the specified pure expression, returning the seconds and result as a 'Pair'. * CAVEAT: as a side-effect, the expression is /deep/ evaluated. -}-getCPUSeconds :: NFData expression+getCPUSeconds :: (Fractional seconds, NFData expression) => expression -- ^ Arbitrary polymorphic expression.- -> IO (Double, expression) -- ^ The original expression, tagged with the CPU-seconds taken.+ -> IO (seconds, expression) -- ^ The original expression, tagged with the CPU-seconds taken. getCPUSeconds expression = do start <- System.CPUTime.getCPUTime end <-@@ -72,7 +72,7 @@ printCPUSeconds expression = do (cpuSeconds, result) <- getCPUSeconds expression - System.IO.hPutStrLn System.IO.stderr $ "CPU-seconds=" ++ show cpuSeconds+ System.IO.hPutStrLn System.IO.stderr $ "CPU-seconds:\t" ++ show (cpuSeconds :: Double) return {-to IO-monad-} result
toolshed.cabal view
@@ -1,6 +1,6 @@ --Package-properties Name: toolshed-Version: 0.11.1.0+Version: 0.12.0.0 Cabal-Version: >= 1.6 Copyright: (C) 2010 Dr. Alistair Ward License: GPL@@ -18,11 +18,11 @@ Extra-Source-Files: changelog, copyright, makefile flag haveDeepSeq- Description: Use the new module 'Control.DeepSeq', where available, rather than 'Control.Parallel.Strategies'.+ Description: Import the type-class 'NFData' from module 'Control.DeepSeq' rather than 'Control.Parallel.Strategies'. Default: True flag llvm- Description: Whether the 'llvm' backend has been installed and is required for code-generation.+ Description: Whether the 'llvm' compiler-backend has been installed and is required for code-generation. manual: True default: False @@ -33,7 +33,9 @@ ToolShed.Defaultable ToolShed.ListPlus ToolShed.Options+ ToolShed.Pair ToolShed.SelfValidate+ ToolShed.TimeAction ToolShed.TimePure ToolShed.Unsafe