python-pickle-0.2.3: Serialization/deserialization using Python Pickle format.

Safe HaskellNone
LanguageHaskell98

Language.Python.Pickle

Description

Very partial implementation of the Python Pickle Virtual Machine (protocol 2): i.e. parses pickled data into opcodes, then executes the opcodes to construct a (Haskell representation of a) Python object.

Synopsis

Documentation

parse :: ByteString -> Either String [OpCode] Source #

Parse a pickled object to a list of opcodes.

unpickle :: ByteString -> Either String Value Source #

Unpickle (i.e. deserialize) a Python object. Protocols 0, 1, and 2 are supported.

pickle :: Value -> ByteString Source #

Pickle (i.e. serialize) a Python object. Protocol 2 is used.

type Stack = [Value] Source #

executeTuple :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo) Source #

executeDict :: Monad m => [(Value, Value)] -> Stack -> Memo -> m ([Value], Memo) Source #

executeList :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo) Source #

executeSetitems :: Monad m => [(Value, Value)] -> Stack -> Memo -> m ([Value], Memo) Source #

executeAppends :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo) Source #

newtype Pickler a Source #

Constructors

Pickler 

Fields

Instances

Monad Pickler Source # 

Methods

(>>=) :: Pickler a -> (a -> Pickler b) -> Pickler b #

(>>) :: Pickler a -> Pickler b -> Pickler b #

return :: a -> Pickler a #

fail :: String -> Pickler a #

Functor Pickler Source # 

Methods

fmap :: (a -> b) -> Pickler a -> Pickler b #

(<$) :: a -> Pickler b -> Pickler a #

Applicative Pickler Source # 

Methods

pure :: a -> Pickler a #

(<*>) :: Pickler (a -> b) -> Pickler a -> Pickler b #

(*>) :: Pickler a -> Pickler b -> Pickler b #

(<*) :: Pickler a -> Pickler b -> Pickler a #

MonadWriter [OpCode] Pickler Source # 

Methods

writer :: (a, [OpCode]) -> Pickler a #

tell :: [OpCode] -> Pickler () #

listen :: Pickler a -> Pickler (a, [OpCode]) #

pass :: Pickler (a, [OpCode] -> [OpCode]) -> Pickler a #

MonadState (Map Value Int) Pickler Source # 

Methods

get :: Pickler (Map Value Int) #

put :: Map Value Int -> Pickler () #

state :: (Map Value Int -> (a, Map Value Int)) -> Pickler a #