extra 1.6 → 1.6.1
raw patch · 8 files changed
+42/−30 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Extra: newTempDirWithin :: FilePath -> IO (FilePath, IO ())
+ Extra: newTempFileWithin :: FilePath -> IO (FilePath, IO ())
+ System.IO.Extra: newTempDirWithin :: FilePath -> IO (FilePath, IO ())
+ System.IO.Extra: newTempFileWithin :: FilePath -> IO (FilePath, IO ())
Files
- CHANGES.txt +3/−0
- Generate.hs +3/−1
- extra.cabal +2/−2
- src/Data/List/Extra.hs +1/−1
- src/Extra.hs +2/−2
- src/System/IO/Extra.hs +12/−5
- test/TestCustom.hs +1/−2
- test/TestUtil.hs +18/−17
CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for Extra +1.6.1+ Add newTempFileWithin and newTempDirWithin+ Mark the Extra module as deprecated, used for documentation only 1.6 #23, delete subtractTime Require QuickCheck-2.10
Generate.hs view
@@ -5,6 +5,7 @@ import Data.List.Extra import System.IO.Extra+import Control.Exception import Control.Monad.Extra import System.FilePath import System.Directory@@ -33,7 +34,7 @@ ,"--" ,"-- Most users should import the specific modules (e.g. @\"Data.List.Extra\"@), which" ,"-- also reexport their non-@Extra@ modules (e.g. @\"Data.List\"@)."- ,"module Extra("] +++ ,"module Extra {-# DEPRECATED \"This module is provided as documentation of all new functions, you should import the more specific modules directly.\" #-} ("] ++ concat [ [" -- * " ++ mod ," -- | Extra functions available in @" ++ show mod ++ "@." ," " ++ unwords (map (++",") funs)]@@ -60,6 +61,7 @@ writeFileBinaryChanged :: FilePath -> String -> IO () writeFileBinaryChanged file x = do+ evaluate $ length x -- ensure we don't write out files with _|_ in them old <- ifM (doesFileExist file) (Just <$> readFileBinary' file) (return Nothing) when (Just x /= old) $ writeFileBinary file x
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: extra-version: 1.6+version: 1.6.1 license: BSD3 license-file: LICENSE category: Development@@ -15,7 +15,7 @@ The module "Extra" documents all functions provided by this library. Modules such as "Data.List.Extra" provide extra functions over "Data.List" and also reexport "Data.List". Users are recommended to replace "Data.List" imports with "Data.List.Extra" if they need the extra functionality. homepage: https://github.com/ndmitchell/extra#readme bug-reports: https://github.com/ndmitchell/extra/issues-tested-with: GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2+tested-with: GHC==8.2.1, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 extra-doc-files: CHANGES.txt
src/Data/List/Extra.hs view
@@ -425,7 +425,7 @@ -- The first element of the returned tuple -- is the prefix of @haystack@ before @needle@ is matched. The second -- is the remainder of @haystack@, starting with the match.--- If you want the remainder /without/ the patch, use 'stripInfix'.+-- If you want the remainder /without/ the match, use 'stripInfix'. -- -- > breakOn "::" "a::b::c" == ("a", "::b::c") -- > breakOn "/" "foobar" == ("foobar", "")
src/Extra.hs view
@@ -5,7 +5,7 @@ -- -- Most users should import the specific modules (e.g. @"Data.List.Extra"@), which -- also reexport their non-@Extra@ modules (e.g. @"Data.List"@).-module Extra(+module Extra {-# DEPRECATED "This module is provided as documentation of all new functions, you should import the more specific modules directly." #-} ( -- * Control.Concurrent.Extra -- | Extra functions available in @"Control.Concurrent.Extra"@. getNumCapabilities, setNumCapabilities, withNumCapabilities, forkFinally, once, onceFork, Lock, newLock, withLock, withLockTry, Var, newVar, readVar, writeVar, modifyVar, modifyVar_, withVar, Barrier, newBarrier, signalBarrier, waitBarrier, waitBarrierMaybe,@@ -47,7 +47,7 @@ isWindows, isMac, -- * System.IO.Extra -- | Extra functions available in @"System.IO.Extra"@.- captureOutput, withBuffering, readFileEncoding, readFileUTF8, readFileBinary, readFile', readFileEncoding', readFileUTF8', readFileBinary', writeFileEncoding, writeFileUTF8, writeFileBinary, withTempFile, withTempDir, newTempFile, newTempDir, fileEq,+ captureOutput, withBuffering, readFileEncoding, readFileUTF8, readFileBinary, readFile', readFileEncoding', readFileUTF8', readFileBinary', writeFileEncoding, writeFileUTF8, writeFileBinary, withTempFile, withTempDir, newTempFile, newTempDir, newTempFileWithin, newTempDirWithin, fileEq, -- * System.Process.Extra -- | Extra functions available in @"System.Process.Extra"@. system_, systemOutput, systemOutput_,
src/System/IO/Extra.hs view
@@ -16,6 +16,7 @@ writeFileEncoding, writeFileUTF8, writeFileBinary, -- * Temporary files withTempFile, withTempDir, newTempFile, newTempDir,+ newTempFileWithin, newTempDirWithin, -- * File comparison fileEq, ) where@@ -158,13 +159,16 @@ -- temporary file. Most users should use 'withTempFile' which -- combines these operations. newTempFile :: IO (FilePath, IO ())-newTempFile = do+newTempFile = newTempFileWithin =<< getTemporaryDirectory++-- | Like 'newTempFile' but using a custom temporary directory.+newTempFileWithin :: FilePath -> IO (FilePath, IO ())+newTempFileWithin tmpdir = do file <- create del <- once $ ignore $ removeFile file return (file, del) where create = do- tmpdir <- getTemporaryDirectory val <- tempUnique (file, h) <- retryBool (\(_ :: IOError) -> True) 5 $ openTempFile tmpdir $ "extra-file-" ++ show val ++ "-" hClose h@@ -189,8 +193,11 @@ -- temporary directory. Most users should use 'withTempDir' which -- combines these operations. newTempDir :: IO (FilePath, IO ())-newTempDir = do- tmpdir <- getTemporaryDirectory+newTempDir = newTempDirWithin =<< getTemporaryDirectory++-- | Like 'newTempDir' but using a custom temporary directory.+newTempDirWithin :: FilePath -> IO (FilePath, IO ())+newTempDirWithin tmpdir = do dir <- retryBool (\(_ :: IOError) -> True) 5 $ create tmpdir del <- once $ ignore $ removeDirectoryRecursive dir return (dir, del)@@ -221,7 +228,7 @@ foreign import ccall unsafe "string.h memcmp" memcmp :: Ptr CUChar -> Ptr CUChar -> CSize -> IO CInt --- | Returs 'True' when the contents of both files is the same.+-- | Returns 'True' when the contents of both files is the same. sameContent :: Handle -> Handle -> IO Bool sameContent h1 h2 = sameSize h1 h2 &&^ withb (\b1 -> withb $ \b2 -> eq b1 b2) where eq b1 b2 = do
test/TestCustom.hs view
@@ -6,8 +6,7 @@ import System.IO.Extra import Data.IORef import TestUtil--import Extra as X+import Data.Typeable.Extra as X testCustom :: IO ()
test/TestUtil.hs view
@@ -1,39 +1,40 @@ {-# LANGUAGE ScopedTypeVariables, CPP, FlexibleInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} -- OK because a test module module TestUtil (runTests ,testGen, testRaw ,erroneous, erroneousIO- ,(====)+ ,(====), (==>) ,ASCIIString(..) ,module X ) where import Test.QuickCheck import Test.QuickCheck.Test-import Control.Exception.Extra-import Data.Either.Extra-import System.IO.Extra-import Data.Version.Extra-import Data.IORef import System.IO.Unsafe import Text.Show.Functions() -import Extra as X import Control.Applicative as X-import Control.Monad as X-import Data.Function as X-import Data.List as X+import Control.Concurrent.Extra as X+import Control.Exception.Extra as X+import Control.Monad.Extra as X import Data.Char as X+import Data.Either.Extra as X+import Data.Function as X+import Data.IORef.Extra as X+import Data.List.Extra as X import Data.Monoid as X-import Data.Tuple as X-import Data.Typeable as X-import Data.Version as X-import System.Directory as X+import Data.Tuple.Extra as X+import Data.Typeable.Extra as X+import Data.Version.Extra as X+import Numeric.Extra as X+import System.Directory.Extra as X import System.FilePath as X-import System.Info as X-import Control.Exception as X-import Test.QuickCheck as X((==>))+import System.Info.Extra as X+import System.IO.Extra as X+import System.Process.Extra as X+import System.Time.Extra as X {-# NOINLINE testCount #-}