Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/43388cda7838a1c92789a5fd2988c3f0f9965fe9

>---------------------------------------------------------------

commit 43388cda7838a1c92789a5fd2988c3f0f9965fe9
Author: Bas van Dijk <[email protected]>
Date:   Sat Nov 5 16:50:50 2011 +0000

    Add NFData instances for strict and lazy ByteStrings

>---------------------------------------------------------------

 Data/ByteString/Internal.hs      |    4 ++++
 Data/ByteString/Lazy/Internal.hs |    6 ++++++
 bytestring.cabal                 |    4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Data/ByteString/Internal.hs b/Data/ByteString/Internal.hs
index 938f2a1..1dce1c1 100644
--- a/Data/ByteString/Internal.hs
+++ b/Data/ByteString/Internal.hs
@@ -71,6 +71,8 @@ import Foreign.Storable         (Storable(..))
 import Foreign.C.Types          (CInt(..), CSize(..), CULong(..))
 import Foreign.C.String         (CString)
 
+import Control.DeepSeq          (NFData)
+
 #ifndef __NHC__
 import Control.Exception        (assert)
 #endif
@@ -157,6 +159,8 @@ data ByteString = PS {-# UNPACK #-} !(ForeignPtr Word8) -- 
payload
     deriving (Data, Typeable)
 #endif
 
+instance NFData ByteString
+
 instance Show ByteString where
     showsPrec p ps r = showsPrec p (unpackWith w2c ps) r
 
diff --git a/Data/ByteString/Lazy/Internal.hs b/Data/ByteString/Lazy/Internal.hs
index 52ba17b..6489f6c 100644
--- a/Data/ByteString/Lazy/Internal.hs
+++ b/Data/ByteString/Lazy/Internal.hs
@@ -40,6 +40,8 @@ import qualified Data.ByteString.Internal as S
 
 import Foreign.Storable (Storable(sizeOf))
 
+import Control.DeepSeq (NFData, rnf)
+
 #if defined(__GLASGOW_HASKELL__)
 import Data.Typeable    (Typeable)
 #if __GLASGOW_HASKELL__ >= 610
@@ -61,6 +63,10 @@ data ByteString = Empty | Chunk {-# UNPACK #-} !S.ByteString 
ByteString
 #endif
              )
 
+instance NFData ByteString where
+    rnf Empty       = ()
+    rnf (Chunk _ b) = rnf b
+
 ------------------------------------------------------------------------
 
 -- | The data type invariant:
diff --git a/bytestring.cabal b/bytestring.cabal
index 8c6ee23..ec86c75 100644
--- a/bytestring.cabal
+++ b/bytestring.cabal
@@ -27,7 +27,7 @@ Cabal-Version:       >= 1.8
 extra-source-files:  README TODO
 
 library
-  build-depends:     base >= 3 && < 5
+  build-depends:     base >= 3 && < 5, deepseq
 
   if impl(ghc >= 6.10)
     build-depends:   ghc-prim, base >= 4
@@ -71,7 +71,7 @@ test-suite prop-compiled
   type:             exitcode-stdio-1.0
   main-is:          Properties.hs
   hs-source-dirs:   . tests
-  build-depends:    base, random, directory,
+  build-depends:    base, deepseq, random, directory,
                     QuickCheck >= 2.3 && < 3
   if impl(ghc >= 6.10)
     build-depends:  ghc-prim



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to