bytestring 0.10.0.1 → 0.10.0.2
raw patch · 7 files changed
+37/−23 lines, 7 filesdep ~directoryPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: directory
API changes (from Hackage documentation)
Files
- Data/ByteString.hs +14/−14
- Data/ByteString/Char8.hs +3/−0
- Data/ByteString/Lazy.hs +0/−1
- Data/ByteString/Lazy/Builder/ASCII.hs +6/−0
- Data/ByteString/Lazy/Builder/Internal.hs +3/−3
- Data/ByteString/Lazy/Char8.hs +4/−2
- bytestring.cabal +7/−3
Data/ByteString.hs view
@@ -270,7 +270,7 @@ import GHC.IO.Handle.Types import GHC.IO.Buffer import GHC.IO.BufferedIO as Buffered-import GHC.IO (unsafePerformIO)+import GHC.IO (unsafePerformIO, unsafeDupablePerformIO) import Data.Char (ord) import Foreign.Marshal.Utils (copyBytes) #else@@ -300,6 +300,10 @@ hWaitForInput _ _ = return () #endif +#ifndef __GLASGOW_HASKELL__+unsafeDupablePerformIO = unsafePerformIO+#endif+ -- ----------------------------------------------------------------------------- -- -- Useful macros, until we have bang patterns@@ -472,9 +476,9 @@ -- Transformations -- | /O(n)/ 'map' @f xs@ is the ByteString obtained by applying @f@ to each--- element of @xs@. This function is subject to array fusion.+-- element of @xs@. map :: (Word8 -> Word8) -> ByteString -> ByteString-map f (PS fp s len) = inlinePerformIO $ withForeignPtr fp $ \a ->+map f (PS fp s len) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> create len $ map_ 0 (a `plusPtr` s) where map_ :: Int -> Ptr Word8 -> Ptr Word8 -> IO ()@@ -514,8 +518,6 @@ -- the left-identity of the operator), and a ByteString, reduces the -- ByteString using the binary operator, from left to right. ----- This function is subject to array fusion.--- foldl :: (a -> Word8 -> a) -> a -> ByteString -> a foldl f v (PS x s l) = inlinePerformIO $ withForeignPtr x $ \ptr -> lgo v (ptr `plusPtr` s) (ptr `plusPtr` (s+l))@@ -559,7 +561,6 @@ -- | 'foldl1' is a variant of 'foldl' that has no starting value -- argument, and thus must be applied to non-empty 'ByteStrings'.--- This function is subject to array fusion. -- An exception will be thrown in the case of an empty ByteString. foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 foldl1 f ps@@ -665,7 +666,7 @@ -- passing an accumulating parameter from left to right, and returning a -- final value of this accumulator together with the new list. mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)-mapAccumL f acc (PS fp o len) = inlinePerformIO $ withForeignPtr fp $ \a -> do+mapAccumL f acc (PS fp o len) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> do gp <- mallocByteString len acc' <- withForeignPtr gp $ \p -> mapAccumL_ acc 0 (a `plusPtr` o) p return $! (acc', PS gp 0 len)@@ -685,7 +686,7 @@ -- passing an accumulating parameter from right to left, and returning a -- final value of this accumulator together with the new ByteString. mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)-mapAccumR f acc (PS fp o len) = inlinePerformIO $ withForeignPtr fp $ \a -> do+mapAccumR f acc (PS fp o len) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> do gp <- mallocByteString len acc' <- withForeignPtr gp $ \p -> mapAccumR_ acc (len-1) (a `plusPtr` o) p return $! (acc', PS gp 0 len)@@ -714,7 +715,7 @@ -- scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString -scanl f v (PS fp s len) = inlinePerformIO $ withForeignPtr fp $ \a ->+scanl f v (PS fp s len) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> create (len+1) $ \q -> do poke q v scanl_ v 0 (a `plusPtr` s) (q `plusPtr` 1)@@ -745,7 +746,7 @@ -- | scanr is the right-to-left dual of scanl. scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString-scanr f v (PS fp s len) = inlinePerformIO $ withForeignPtr fp $ \a ->+scanr f v (PS fp s len) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> create (len+1) $ \q -> do poke (q `plusPtr` len) v scanr_ v (len-1) (a `plusPtr` s) q@@ -1256,7 +1257,7 @@ -- | /O(n)/ 'filter', applied to a predicate and a ByteString, -- returns a ByteString containing those characters that satisfy the--- predicate. This function is subject to array fusion.+-- predicate. filter :: (Word8 -> Bool) -> ByteString -> ByteString filter k ps@(PS x s l) | null ps = ps@@ -1498,7 +1499,7 @@ -- performed on the result of zipWith. -- zipWith' :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString -> ByteString-zipWith' f (PS fp s l) (PS fq t m) = inlinePerformIO $+zipWith' f (PS fp s l) (PS fq t m) = unsafeDupablePerformIO $ withForeignPtr fp $ \a -> withForeignPtr fq $ \b -> create len $ zipWith_ 0 (a `plusPtr` s) (b `plusPtr` t)@@ -1957,8 +1958,7 @@ -- | Read an entire file strictly into a 'ByteString'. This is far more -- efficient than reading the characters into a 'String' and then using -- 'pack'. It also may be more efficient than opening the file and--- reading it using hGet. Files are read using 'binary mode' on Windows,--- for 'text mode' use the Char8 version of this function.+-- reading it using 'hGet'. -- readFile :: FilePath -> IO ByteString readFile f = bracket (openBinaryFile f ReadMode) hClose
Data/ByteString/Char8.hs view
@@ -192,6 +192,9 @@ useAsCStringLen, -- :: ByteString -> (CStringLen -> IO a) -> IO a -- * I\/O with 'ByteString's+ -- | ByteString I/O uses binary mode, without any character decoding+ -- or newline conversion. The fact that it does not respect the Handle+ -- newline mode is considered a flaw and may be changed in a future version. -- ** Standard input and output getLine, -- :: IO ByteString
Data/ByteString/Lazy.hs view
@@ -482,7 +482,6 @@ -- | 'foldl1' is a variant of 'foldl' that has no starting value -- argument, and thus must be applied to non-empty 'ByteStrings'.--- This function is subject to array fusion. foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 foldl1 _ Empty = errorEmptyList "foldl1" foldl1 f (Chunk c cs) = foldl f (S.unsafeHead c) (Chunk (S.unsafeTail c) cs)
Data/ByteString/Lazy/Builder/ASCII.hs view
@@ -90,6 +90,12 @@ ------------------ -- | Decimal encoding of an 'Int8' using the ASCII digits.+--+-- e.g.+--+-- > toLazyByteString (int8Dec 42) = "42"+-- > toLazyByteString (int8Dec (-1)) = "-1"+-- {-# INLINE int8Dec #-} int8Dec :: Int8 -> Builder int8Dec = E.encodeWithB E.int8Dec
Data/ByteString/Lazy/Builder/Internal.hs view
@@ -27,7 +27,7 @@ -- We achieve (2) by requiring that every 'Builder' is implemented by a -- 'BuildStep' that takes a continuation 'BuildStep', which it calls with the -- updated 'BufferRange' after it is done. Therefore, only two pointers have--- to be passed in a function call to implement concatentation of 'Builder's.+-- to be passed in a function call to implement concatenation of 'Builder's. -- Moreover, many 'Builder's are completely inlined, which enables the compiler -- to sequence them without a function call and with no boxing at all. --@@ -38,7 +38,7 @@ -- comments of the 'builder' and 'put' functions for further information. -- Note that there are /no safety belts/ at all, when implementing a 'Builder' -- using an 'IO' action: you are writing code that might enable the next--- buffer-overlow attack on a Haskell server!+-- buffer-overflow attack on a Haskell server! -- module Data.ByteString.Lazy.Builder.Internal ( @@ -428,7 +428,7 @@ -- -- 1. GHC.IO.Handle.Internals mentions in "Note [async]" that -- we should never do any side-effecting operations before- -- an interuptible operation that may raise an async. exception+ -- an interruptible operation that may raise an async. exception -- as long as we are inside 'wantWritableHandle' and the like. -- We possibly run the interuptible 'flushWriteBuffer' right at -- the start of 'fillHandle', hence entering it a second time is
Data/ByteString/Lazy/Char8.hs view
@@ -166,6 +166,9 @@ readInteger, -- * I\/O with 'ByteString's+ -- | ByteString I/O uses binary mode, without any character decoding+ -- or newline conversion. The fact that it does not respect the Handle+ -- newline mode is considered a flaw and may be changed in a future version. -- ** Standard input and output getContents, -- :: IO ByteString@@ -844,8 +847,7 @@ end n c cs = let c' = chunk c cs in c' `seq` (n, c') --- | Read an entire file /lazily/ into a 'ByteString'. Use 'text mode'--- on Windows to interpret newlines+-- | Read an entire file /lazily/ into a 'ByteString'. readFile :: FilePath -> IO ByteString readFile f = openFile f ReadMode >>= hGetContents
bytestring.cabal view
@@ -1,5 +1,5 @@ Name: bytestring-Version: 0.10.0.1+Version: 0.10.0.2 Synopsis: Fast, compact, strict and lazy byte strings with a list interface Description: An efficient compact, immutable byte string type (both strict and lazy)@@ -16,7 +16,7 @@ * Strict 'ByteString's keep the string as a single large array. This makes them convenient for passing data between C and Haskell. .- * Lazy 'ByteStrings' use a lazy list of strict chunks which makes it+ * Lazy 'ByteString's use a lazy list of strict chunks which makes it suitable for I\/O streaming tasks. . The @Char8@ modules provide a character-based view of the same@@ -24,6 +24,10 @@ binary and 8-bit character content (which is common in many file formats and network protocols). .+ The 'Builder' module provides an efficient way to build up 'ByteString's+ in an ad-hoc way by repeated concatenation. This is ideal for fast+ serialisation or pretty printing.+ . 'ByteString's are not designed for Unicode. For Unicode strings you should use the 'Text' type from the @text@ package. .@@ -146,7 +150,7 @@ QuickCheck >= 2.4 && < 3, byteorder == 1.0.*, dlist == 0.5.*,- directory >= 1.0 && < 1.2,+ directory, mtl >= 2.0 && < 2.2 ghc-options: -Wall -fwarn-tabs