packages feed

RefSerialize 0.3.1.2 → 0.3.1.3

raw patch · 2 files changed

+37/−9 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Data.RefSerialize.Serialize: myToStrict :: ByteString -> ByteString

Files

Data/RefSerialize/Serialize.hs view
@@ -1,9 +1,10 @@-{-# OPTIONS -XOverlappingInstances-            -XTypeSynonymInstances-            -XFlexibleInstances-            -XUndecidableInstances-            -XOverloadedStrings-            -XNoMonomorphismRestriction+{-# LANGUAGE OverlappingInstances+            ,TypeSynonymInstances+            ,FlexibleInstances+            ,UndecidableInstances+            ,OverloadedStrings+            ,NoMonomorphismRestriction+            ,BangPatterns               #-} module Data.RefSerialize.Serialize where import GHC.Exts@@ -20,7 +21,29 @@ import Data.Ord import Data.Monoid +-- All this for myToStrict for compatibility with older versions of bytestring that+-- lack a "toStrict" call+import qualified Data.ByteString        as S  -- S for strict (hmm...)+import qualified Data.ByteString.Internal as S+import qualified Data.ByteString.Unsafe as S+import Data.ByteString.Lazy.Internal+import Foreign.ForeignPtr       (withForeignPtr)+import Foreign.Ptr ++myToStrict :: ByteString -> S.ByteString+myToStrict Empty           = S.empty+myToStrict (Chunk c Empty) = c+myToStrict cs0 = S.unsafeCreate totalLen $ \ptr -> go cs0 ptr+  where+    totalLen = foldlChunks (\a c -> a + S.length c) 0 cs0++    go Empty                        !_       = return ()+    go (Chunk (S.PS fp off len) cs) !destptr =+      withForeignPtr fp $ \p -> do+        S.memcpy destptr (p `plusPtr` off) (fromIntegral len)+        go cs (destptr `plusPtr` len)+ type MFun=  Char -- usafeCoherced to char to store simply the address of the function type VarName = String data ShowF= Expr ByteString | Var Int  deriving Show@@ -82,7 +105,7 @@  readContext :: ByteString -> ByteString -> (ByteString, ByteString) readContext pattern str=-  let (s1,s2)= breakOn (toStrict pattern) str+  let (s1,s2)= breakOn (myToStrict pattern) str   in  (s1, B.drop (fromIntegral $ B.length pattern) s2)  --readContext pattern str= readContext1  mempty str where
RefSerialize.cabal view
@@ -1,5 +1,5 @@ name:                RefSerialize-version:             0.3.1.2+version:             0.3.1.3 synopsis:            Write to and read from ByteStrings maintaining internal memory references description:                      Read, Show and Binary instances do not check for internal data references to the same address.@@ -9,8 +9,13 @@                      data is very typical in a pure language such is Haskell, this means that the resulting data loose the beatiful                      economy of space and processing time that referential transparency permits.                      .-                     In this release deserialization is much, much faster by using the stringsearch package+                     In this release:                      .+                     Compatibility with older versions of bytestring that have no 'toStrict' call+                     .+                     deserialization is much, much faster by using the stringsearch package+                     .+                      See "Data.RefSerialize" for details