streaming-with 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+156/−8 lines, 4 filesdep +temporaryPVP ok
version bump matches the API change (PVP)
Dependencies added: temporary
API changes (from Hackage documentation)
+ Streaming.With: withSystemTempDirectory :: (MonadIO m, MonadMask m) => String -> (FilePath -> m a) -> m a
+ Streaming.With: withSystemTempFile :: (MonadIO m, MonadMask m) => String -> ((FilePath, Handle) -> m r) -> m r
+ Streaming.With: withTempDirectory :: (MonadMask m, MonadIO m) => FilePath -> String -> (FilePath -> m a) -> m a
+ Streaming.With: withTempFile :: (MonadIO m, MonadMask m) => FilePath -> String -> ((FilePath, Handle) -> m r) -> m r
+ Streaming.With.Lifted: withSystemTempDirectory :: (Withable w) => String -> w FilePath
+ Streaming.With.Lifted: withSystemTempFile :: (Withable w) => String -> w (FilePath, Handle)
+ Streaming.With.Lifted: withTempDirectory :: (Withable w) => FilePath -> String -> w FilePath
+ Streaming.With.Lifted: withTempFile :: (Withable w) => FilePath -> String -> w (FilePath, Handle)
Files
- ChangeLog.md +12/−1
- src/Streaming/With.hs +67/−5
- src/Streaming/With/Lifted.hs +75/−1
- streaming-with.cabal +2/−1
ChangeLog.md view
@@ -1,5 +1,16 @@ # Revision history for streaming-with -## 0.1.0.0 -- 2017-06-30+## 0.1.1.0 -- 2017-07-07++* Add support for the [temporary] package, specifically the functions:++ * `withSystemTempFile`+ * `withTempFile`+ * `withSystemTempDirectory`+ * `withTempDirectory`++ [temporary]: http://hackage.haskell.org/package/temporary++## 0.1.0.0 -- 2017-06-30 * First release.
src/Streaming/With.hs view
@@ -16,7 +16,14 @@ , writeBinaryFile , appendBinaryFile , withBinaryFileContents- -- ** Re-exports+ -- ** Temporary files+ , withSystemTempFile+ , withTempFile+ -- *** Re-exports+ -- $tempreexports+ , withSystemTempDirectory+ , withTempDirectory+ -- * Re-exports -- $reexports , MonadMask , bracket@@ -25,10 +32,13 @@ import Data.ByteString.Streaming (ByteString) import qualified Data.ByteString.Streaming as B -import Control.Monad.Catch (MonadMask, bracket)-import Control.Monad.IO.Class (MonadIO, liftIO)-import System.IO (Handle, IOMode(..), hClose, openBinaryFile,- openFile)+import Control.Monad.Catch (MonadMask, bracket)+import Control.Monad.IO.Class (MonadIO, liftIO)+import System.IO (Handle, IOMode(..), hClose,+ openBinaryFile, openFile)+import System.IO.Temp (withSystemTempDirectory,+ withTempDirectory)+import qualified System.IO.Temp as T -------------------------------------------------------------------------------- @@ -59,6 +69,58 @@ withBinaryFileContents :: (MonadMask m, MonadIO m, MonadIO n) => FilePath -> (ByteString n () -> m r) -> m r withBinaryFileContents fp f = withBinaryFile fp ReadMode (f . B.hGetContents)++--------------------------------------------------------------------------------++-- | /This is 'T.withSystemTempFile' from the @temporary@ package with+-- the continuation re-structured to only take one argument./+--+-- Create and use a temporary file in the system standard temporary+-- directory.+--+-- Behaves exactly the same as 'withTempFile', except that the+-- parent temporary directory will be that returned by+-- 'T.getCanonicalTemporaryDirectory'.+--+-- @since 0.1.1.0+withSystemTempFile :: (MonadIO m, MonadMask m)+ => String -- ^ File name template. See 'T.openTempFile'+ -> ((FilePath, Handle) -> m r)+ -> m r+withSystemTempFile template = T.withSystemTempFile template . curry++-- | /This is 'T.withTempFile' from the @temporary@ package with+-- the continuation re-structured to only take one argument./+--+-- Use a temporary filename that doesn't already exist.+--+-- Creates a new temporary file inside the given directory, making+-- use of the template. The temp file is deleted after use. For+-- example:+--+-- > withTempFile "src" "sdist." $ \(tmpFile, hFile) -> ...+--+-- The @tmpFile@ will be file in the given directory, e.g.+-- @src/sdist.342@.+--+-- @since 0.1.1.0+withTempFile :: (MonadIO m, MonadMask m)+ => FilePath -- ^ Temp dir to create the file in+ -> String -- ^ File name template. See+ -- 'T.openTempFile'.+ -> ((FilePath, Handle) -> m r)+ -> m r+withTempFile dir template = T.withTempFile dir template . curry++{- $tempreexports++These functions are re-exported from the+<http://hackage.haskell.org/package/temporary temporary> package as-is+as their structure already matches those found here.++@since 0.1.1.0++-} --------------------------------------------------------------------------------
src/Streaming/With/Lifted.hs view
@@ -44,7 +44,12 @@ , writeBinaryFile , appendBinaryFile , withBinaryFileContents- -- ** Re-exports+ -- ** Temporary files+ , withSystemTempFile+ , withTempFile+ , withSystemTempDirectory+ , withTempDirectory+ -- * Re-exports -- $reexports , MonadMask , bracket@@ -122,6 +127,75 @@ -- required output type (e.g. remove transformer). withBinaryFileContents :: (Withable w, MonadIO n) => FilePath -> w (ByteString n ()) withBinaryFileContents fp = liftWith (W.withBinaryFileContents fp)++--------------------------------------------------------------------------------++-- | Create and use a temporary file in the system standard temporary+-- directory.+--+-- Behaves exactly the same as 'withTempFile', except that the+-- parent temporary directory will be that returned by+-- 'System.IO.Temp.getCanonicalTemporaryDirectory'.+--+-- @since 0.1.1.0+withSystemTempFile :: (Withable w)+ => String -- ^ File name template. See+ -- 'System.IO.Temp.openTempFile'.+ -> w (FilePath, Handle)+withSystemTempFile template = liftWith (W.withSystemTempFile template)++-- | Use a temporary filename that doesn't already exist.+--+-- Creates a new temporary file inside the given directory, making+-- use of the template. The temp file is deleted after use. For+-- example:+--+-- > withTempFile "src" "sdist." >>= \(tmpFile, hFile) -> ...+--+-- The @tmpFile@ will be file in the given directory, e.g.+-- @src/sdist.342@.+--+-- @since 0.1.1.0+withTempFile :: (Withable w)+ => FilePath -- ^ Temp dir to create the file in+ -> String -- ^ File name template. See+ -- 'System.IO.Temp.openTempFile'.+ -> w (FilePath, Handle)+withTempFile dir template = liftWith (W.withTempFile dir template)++-- | Create and use a temporary directory in the system standard+-- temporary directory.+--+-- Behaves exactly the same as 'withTempDirectory', except that the+-- parent temporary directory will be that returned by+-- 'System.IO.Temp.getCanonicalTemporaryDirectory'.+--+-- @since 0.1.1.0+withSystemTempDirectory :: (Withable w)+ => String -- ^ Directory name template. See+ -- 'System.IO.Temp.openTempFile'.+ -> w FilePath+withSystemTempDirectory template = liftWith (W.withSystemTempDirectory template)++-- | Create and use a temporary directory.+--+-- Creates a new temporary directory inside the given directory,+-- making use of the template. The temp directory is deleted after+-- use. For example:+--+-- > withTempDirectory "src" "sdist." >>= \tmpDir -> ...+--+-- The @tmpDir@ will be a new subdirectory of the given directory, e.g.+-- @src/sdist.342@.+--+-- @since 0.1.1.0+withTempDirectory :: (Withable w)+ => FilePath -- ^ Temp directory to create the+ -- directory in+ -> String -- ^ Directory name template. See+ -- 'System.IO.Temp.openTempFile'.+ -> w FilePath+withTempDirectory dir template = liftWith (W.withTempDirectory dir template) --------------------------------------------------------------------------------
streaming-with.cabal view
@@ -1,5 +1,5 @@ name: streaming-with-version: 0.1.0.0+version: 0.1.1.0 synopsis: with/bracket-style idioms for use with streaming description: This package provides the foundations for a continuation-based@@ -26,6 +26,7 @@ , exceptions >= 0.6 && < 0.9 , managed == 1.0.* , streaming-bytestring >= 0.1.0.3 && < 0.2+ , temporary >= 1.2.1 && < 1.3 , transformers hs-source-dirs: src default-language: Haskell2010