-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Write to and read from Strings maintaining internal memory references -- -- Read, Show and Data.Binary do not check for pointers to the same -- address as a result, the data is duplicated when serialized. This is a -- waste of space in the filesystem and also a waste of serialization -- time. but the worst consequence is that, when the serialized data is -- read, it allocates multiple copies for the same object referenced -- multiple times. Because multiple referenced 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. This package allows the -- serialization and deserialization of large data structures without -- duplication of data, with the result of optimized performance and -- memory usage. It is also useful for debugging purposes. There are -- automatic derived instances for instances of Read/Show. Lists of -- non-chars have its own instance. The deserializer contains a subset of -- Parsec.Token for defining deserializing parsers. Every instance of -- Show/Read is also a instance of Data.RefSerialize the serialized -- string has the form expr( var1, ...varn) where -- var1=value1,..valn=valueN so that the string can ve EVALuated. So -- the entire deserialization can be substituted by eval. See demo.hs and -- tutorial. I presumably will add a entry in haskell-web.blogspot.com To -- develop: -derived instances for Data.Binary -serialization to/from -- ByteStings @package RefSerialize @version 0.2.2 module Data.Serialize type MFun = Char type VarName = String type ShowF = String type Context = Map Int (MFun, ShowF) data Error Error :: String -> Error data Stat Stat :: (Context, String, String) -> Stat numVar :: String -> Int module Data.Parser data ST a ST :: (Stat -> Either Error (Stat, a)) -> ST a () :: ST a -> String -> ST a (<|>) :: ST a -> ST a -> ST a char :: Char -> ST Char anyChar :: ST Char string :: [Char] -> ST [Char] upper :: ST Char space :: ST Char digit :: ST Char sepBy :: ST a -> ST sep -> ST [a] between :: (Monad m) => m a -> m a1 -> m b -> m b choice :: [ST a] -> ST a option :: a -> ST a -> ST a notFollowedBy :: (Show t) => ST t -> ST () many :: ST a -> ST [a] bool :: ST Bool charLiteral :: ST Char stringLiteral :: ST [Char] natural :: ST Integer integer :: ST Integer float :: ST Double naturalOrFloat :: ST (Either Integer Double) decimal :: ST Integer hexadecimal :: ST Integer octal :: ST Integer symbol :: [Char] -> ST [Char] lexeme :: ST b -> ST b whiteSpace :: ST () parens :: ST a -> ST a braces :: ST a -> ST a angles :: ST a -> ST a brackets :: ST a -> ST a semi :: ST [Char] comma :: ST [Char] colon :: ST [Char] dot :: ST [Char] semiSep :: ST a -> ST [a] semiSep1 :: ST a -> ST [a] commaSep :: ST a -> ST [a] commaSep1 :: ST a -> ST [a] instance MonadPlus ST instance Monad ST module Data.RefSerialize class Serialize c showp :: (Serialize c) => c -> ST String readp :: (Serialize c) => ST c rshowp :: (Serialize c) => c -> ST String rreadp :: (Serialize c) => ST c rShow :: (Serialize c) => c -> String rRead :: (Serialize c) => String -> c -- | insert a variable at this position. and the expression value in the -- where part. runW rshowp (1::Int) -> 1 runW (insertVar -- rshowp) (1::Int) -> v1 where { v1=1} This is useful when the object -- is referenced many times insertVar :: (a -> ST String) -> a -> ST String readVar :: (Serialize c) => ST c -> ST c varName :: a -> [Char] runR :: ST a -> String -> a runW :: ST String -> String instance [overlap ok] (Show a, Read a) => Serialize a instance [overlap ok] (Serialize a) => Serialize [a]