extra 0.7 → 0.8
raw patch · 7 files changed
+19/−5 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- Generate.hs +1/−1
- README.md +1/−1
- extra.cabal +1/−1
- src/Control/Monad/Extra.hs +3/−0
- src/System/IO/Extra.hs +7/−1
- test/TestGen.hs +4/−1
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Extra +0.8+ Fix a bug in writeFileEncoding/writeFileUTF8 0.7 Fix for missing case in withNumCapabilities 0.6
Generate.hs view
@@ -36,7 +36,7 @@ ,""] ++ ["import " ++ x | x <- mods] writeFileBinaryChanged "test/TestGen.hs" $ unlines $- ["{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables #-}"+ ["{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables, ViewPatterns #-}" ,"module TestGen(tests) where" ,"import TestUtil" ,"default(Maybe Bool,Int,Double,Maybe (Maybe Bool),Maybe (Maybe Char))"
README.md view
@@ -7,7 +7,7 @@ * `Control.Exception.Extra.retry` provides a function that retries an `IO` action a number of times. * `System.Environment.Extra.lookupEnv` is a functional available in GHC 7.6 and above. On GHC 7.6 and above this package reexports the version from `System.Environment` while on GHC 7.4 and below it defines an equivalent version. -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.+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. ## Which functions?
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.10 build-type: Simple name: extra-version: 0.7+version: 0.8 license: BSD3 license-file: LICENSE category: Development
src/Control/Monad/Extra.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} -- | Extra functions for "Control.Monad". -- These functions provide looping, list operations and booleans.@@ -16,7 +17,9 @@ ) where import Control.Monad+#if __GLASGOW_HASKELL__ < 709 import Control.Applicative+#endif import Data.Maybe -- General utilities
src/System/IO/Extra.hs view
@@ -53,6 +53,8 @@ -- | A strict version of 'readFile'. When the string is produced, the entire -- file will have been read into memory and the file handle will have been closed. -- Closing the file handle does not rely on the garbage collector.+--+-- > \(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \file -> do writeFile file s; readFile' file readFile' :: FilePath -> IO String readFile' file = withFile file ReadMode $ \h -> do s <- hGetContents h@@ -82,15 +84,19 @@ -- | Write a file with a particular encoding. writeFileEncoding :: TextEncoding -> FilePath -> String -> IO ()-writeFileEncoding enc file x = withFile x WriteMode $ \h -> do+writeFileEncoding enc file x = withFile file WriteMode $ \h -> do hSetEncoding h enc hPutStr h x -- | Write a file with the 'utf8' encoding.+--+-- > \s -> withTempFile $ \file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file writeFileUTF8 :: FilePath -> String -> IO () writeFileUTF8 = writeFileEncoding utf8 -- | Write a binary file.+--+-- > \s -> withTempFile $ \file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file writeFileBinary :: FilePath -> String -> IO () writeFileBinary file x = withBinaryFile file WriteMode $ \h -> hPutStr h x
test/TestGen.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables #-}+{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables, ViewPatterns #-} module TestGen(tests) where import TestUtil default(Maybe Bool,Int,Double,Maybe (Maybe Bool),Maybe (Maybe Char))@@ -172,6 +172,9 @@ testGen "listTest (listFilesInside $ return . not . isPrefixOf \".\" . takeFileName) [\"bar.txt\",\"foo\" </> \"baz.txt\",\".foo\" </> \"baz2.txt\", \"zoo\"] [\"bar.txt\",\"zoo\",\"foo\" </> \"baz.txt\"]" $ listTest (listFilesInside $ return . not . isPrefixOf "." . takeFileName) ["bar.txt","foo" </> "baz.txt",".foo" </> "baz2.txt", "zoo"] ["bar.txt","zoo","foo" </> "baz.txt"] testGen "listTest (listFilesInside $ const $ return False) [\"bar.txt\"] []" $ listTest (listFilesInside $ const $ return False) ["bar.txt"] [] testGen "isWindows == (os == \"mingw32\")" $ isWindows == (os == "mingw32")+ testGen "\\(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \\file -> do writeFile file s; readFile' file" $ \(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \file -> do writeFile file s; readFile' file+ testGen "\\s -> withTempFile $ \\file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file" $ \s -> withTempFile $ \file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file+ testGen "\\s -> withTempFile $ \\file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file" $ \s -> withTempFile $ \file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file testGen "captureOutput (print 1) == return (\"1\\n\",())" $ captureOutput (print 1) == return ("1\n",()) testGen "withTempFile doesFileExist == return True" $ withTempFile doesFileExist == return True testGen "(doesFileExist =<< withTempFile return) == return False" $ (doesFileExist =<< withTempFile return) == return False