python-pickle-0.3.0: Serialization/deserialization using Python Pickle format.
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

data Value Source #

Instances

Instances details
Show Value Source # 
Instance details

Defined in Language.Python.Pickle

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Eq Value Source # 
Instance details

Defined in Language.Python.Pickle

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Ord Value Source # 
Instance details

Defined in Language.Python.Pickle

Methods

compare :: Value -> Value -> Ordering #

(<) :: Value -> Value -> Bool #

(<=) :: Value -> Value -> Bool #

(>) :: Value -> Value -> Bool #

(>=) :: Value -> Value -> Bool #

max :: Value -> Value -> Value #

min :: Value -> Value -> Value #

MonadState (Map Value Int) Pickler Source # 
Instance details

Defined in Language.Python.Pickle

Methods

get :: Pickler (Map Value Int) #

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

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

type Stack = [Value] Source #

newtype Pickler a Source #

Constructors

Pickler 

Fields

Instances

Instances details
Applicative Pickler Source # 
Instance details

Defined in Language.Python.Pickle

Methods

pure :: a -> Pickler a #

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

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

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

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

Functor Pickler Source # 
Instance details

Defined in Language.Python.Pickle

Methods

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

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

Monad Pickler Source # 
Instance details

Defined in Language.Python.Pickle

Methods

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

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

return :: a -> Pickler a #

MonadWriter [OpCode] Pickler Source # 
Instance details

Defined in Language.Python.Pickle

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 # 
Instance details

Defined in Language.Python.Pickle

Methods

get :: Pickler (Map Value Int) #

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

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

class FromValue a where Source #

Methods

fromVal :: Value -> Maybe a Source #

Instances

Instances details
FromValue ByteString Source # 
Instance details

Defined in Language.Python.Pickle

FromValue Text Source # 
Instance details

Defined in Language.Python.Pickle

FromValue Integer Source # 
Instance details

Defined in Language.Python.Pickle

FromValue Bool Source # 
Instance details

Defined in Language.Python.Pickle

FromValue Double Source # 
Instance details

Defined in Language.Python.Pickle

FromValue Int Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe Int Source #

(FromValue a, Ord a) => FromValue (Set a) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (Set a) Source #

FromValue a => FromValue [a] Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe [a] Source #

(FromValue k, FromValue v, Ord k) => FromValue (Map k v) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (Map k v) Source #

(FromValue a, FromValue b) => FromValue (a, b) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b) Source #

(FromValue a, FromValue b, FromValue c) => FromValue (a, b, c) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b, c) Source #

(FromValue a, FromValue b, FromValue c, FromValue d) => FromValue (a, b, c, d) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b, c, d) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e) => FromValue (a, b, c, d, e) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b, c, d, e) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e, FromValue f) => FromValue (a, b, c, d, e, f) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b, c, d, e, f) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e, FromValue f, FromValue g) => FromValue (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Language.Python.Pickle

Methods

fromVal :: Value -> Maybe (a, b, c, d, e, f, g) Source #