[commit: bytestring] master: Add a proper Show and Read instance for lazy bytestrings (abded1d)
Ian Lynagh
igloo at earth.li
Wed Feb 22 21:57:22 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/abded1d6d891933b2d1afc849401c3025b95a0e6
>---------------------------------------------------------------
commit abded1d6d891933b2d1afc849401c3025b95a0e6
Author: Duncan Coutts <duncan at community.haskell.org>
Date: Sun Nov 6 16:58:51 2011 +0000
Add a proper Show and Read instance for lazy bytestrings
Previous one was derived which was silly.
>---------------------------------------------------------------
Data/ByteString/Lazy/Internal.hs | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Data/ByteString/Lazy/Internal.hs b/Data/ByteString/Lazy/Internal.hs
index 0f77e47..356b670 100644
--- a/Data/ByteString/Lazy/Internal.hs
+++ b/Data/ByteString/Lazy/Internal.hs
@@ -62,16 +62,21 @@ import Data.Generics (Data)
-- Instances of Eq, Ord, Read, Show, Data, Typeable
--
data ByteString = Empty | Chunk {-# UNPACK #-} !S.ByteString ByteString
- deriving (Show, Read
+
#if defined(__GLASGOW_HASKELL__)
- ,Data, Typeable
+ deriving (Data, Typeable)
#endif
- )
instance NFData ByteString where
rnf Empty = ()
rnf (Chunk _ b) = rnf b
+instance Show ByteString where
+ showsPrec p ps r = showsPrec p (unpackChars ps) r
+
+instance Read ByteString where
+ readsPrec p str = [ (packChars x, y) | (x, y) <- readsPrec p str ]
+
------------------------------------------------------------------------
-- Packing and unpacking from lists
More information about the Cvs-libraries
mailing list