RefSerialize 0.3.1.0 → 0.3.1.1
raw patch · 3 files changed
+12/−12 lines, 3 filesdep +hashtables
Dependencies added: hashtables
Files
- Data/RefSerialize.hs +2/−2
- Data/RefSerialize/Serialize.hs +8/−8
- RefSerialize.cabal +2/−2
Data/RefSerialize.hs view
@@ -239,7 +239,7 @@ return $ runWC (c,"") f `append` showContext c True -- | serialize x witn a given context and the parser-runWC ::(Context, ByteString) -> STW () -> ByteString+runWC :: (Context, ByteString) -> STW () -> ByteString runWC (c,vars) (STW f) = let (StatW(c',str,_), _) = f (StatW(c,[],vars))@@ -366,7 +366,7 @@ trytofindEntireObject x c= case Data.RefSerialize.Serialize.lookup hash c of Nothing -> Nothing- Just(x,y,z,n) -> insert hash (x,y,z,n+1) `seq` Just varname+ Just(x,y,z,n) -> insert hash (x,y,z,n+1) c `seq` Just varname
Data/RefSerialize/Serialize.hs view
@@ -15,15 +15,15 @@ import System.IO.Unsafe import Control.Monad (MonadPlus(..)) import Data.ByteString.Lazy.Char8 as B-import qualified Data.HashTable as HT-+--import qualified Data.HashTable as HT+import qualified Data.HashTable.IO as HT import Data.Ord 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-type Context = HT.HashTable Int ( StableName MFun, MFun,[ShowF],Int)+type Context = HT.BasicHashTable Int ( StableName MFun, MFun,[ShowF],Int) data Error= Error String data StatW= StatW (Context, [ShowF], ByteString)@@ -45,12 +45,12 @@ -- HT to map-empty = HT.new (==) HT.hashInt+empty = HT.new -- (==) HT.hashInt assocs = sortBy (comparing fst) . unsafePerformIO . HT.toList -insert k v ht= unsafePerformIO $! HT.update ht k v >> return ht+insert k v ht= unsafePerformIO $! HT.insert ht k v >> return ht @@ -63,7 +63,7 @@ toList = unsafePerformIO . HT.toList -fromList = unsafePerformIO . HT.fromList HT.hashInt+fromList = unsafePerformIO . HT.fromList -- HT.hashInt -- | return a unique hash identifier for an object -- the context assures that no StableName used in addrStr is garbage collected,@@ -74,9 +74,9 @@ addrHash c x = case Data.RefSerialize.Serialize.lookup hash c of Nothing -> addc [Var hash] c >> return (Left hash)- Just (x,y,z,n) -> HT.update c hash (x,y,z,n+1) >> return (Right hash)+ Just (x,y,z,n) -> HT.insert c hash (x,y,z,n+1) >> return (Right hash) where- addc str c= HT.update c hash (st,unsafeCoerce x, str,1)+ addc str c= HT.insert c hash (st,unsafeCoerce x, str,1) (hash,st) = hasht x readContext :: ByteString -> ByteString -> (ByteString, ByteString)
RefSerialize.cabal view
@@ -1,5 +1,5 @@ name: RefSerialize-version: 0.3.1.0+version: 0.3.1.1 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.@@ -22,7 +22,7 @@ maintainer: agocorona@gmail.com Tested-With: GHC == 6.8.2 Build-Type: Simple-build-Depends: binary,bytestring, base >=4 && <5,containers+build-Depends: binary,bytestring, base >=4 && <5,containers, hashtables exposed-modules: Data.RefSerialize, Data.RefSerialize.Parser, Data.RefSerialize.Serialize