Safe Haskell | None |
---|---|
Language | Haskell98 |
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.
- parse :: ByteString -> Either String [OpCode]
- unpickle :: ByteString -> Either String Value
- pickle :: Value -> ByteString
- opcodes :: [Parser OpCode]
- int :: Parser OpCode
- binint :: Parser OpCode
- binint1 :: Parser OpCode
- binint2 :: Parser OpCode
- long :: Parser OpCode
- long1 :: Parser OpCode
- long4 :: Parser OpCode
- string' :: Parser OpCode
- binstring :: Parser OpCode
- short_binstring :: Parser OpCode
- none :: Parser OpCode
- true :: Parser OpCode
- false :: Parser OpCode
- newtrue :: Parser OpCode
- newfalse :: Parser OpCode
- unicode :: Parser OpCode
- binunicode :: Parser OpCode
- float :: Parser OpCode
- binfloat :: Parser OpCode
- empty_list :: Parser OpCode
- append :: Parser OpCode
- appends :: Parser OpCode
- list :: Parser OpCode
- empty_tuple :: Parser OpCode
- tuple :: Parser OpCode
- tuple1 :: Parser OpCode
- tuple2 :: Parser OpCode
- tuple3 :: Parser OpCode
- empty_dict :: Parser OpCode
- dict :: Parser OpCode
- setitem :: Parser OpCode
- setitems :: Parser OpCode
- pop :: Parser OpCode
- dup :: Parser OpCode
- mark :: Parser OpCode
- popmark :: Parser OpCode
- get' :: Parser OpCode
- binget :: Parser OpCode
- long_binget :: Parser OpCode
- put' :: Parser OpCode
- binput :: Parser OpCode
- long_binput :: Parser OpCode
- ext1 :: Parser OpCode
- ext2 :: Parser OpCode
- ext4 :: Parser OpCode
- global :: Parser OpCode
- reduce :: Parser OpCode
- build :: Parser OpCode
- inst :: Parser OpCode
- obj :: Parser OpCode
- newobj :: Parser OpCode
- proto :: Parser OpCode
- stop :: Parser OpCode
- persid :: Parser OpCode
- binpersid :: Parser OpCode
- decimalInt :: Parser Int
- doubleFloat :: Parser ByteString Double
- decimalLong :: Parser Int
- decodeLong1 :: Parser Int
- decodeLong4 :: a
- stringnl :: Parser ByteString ByteString
- float8 :: Parser Double
- int4 :: Parser Int
- uint2 :: Parser Int
- serialize :: OpCode -> Put
- putFloat8 :: Double -> Put
- putUint2 :: Int -> Put
- encodeLong1 :: Int -> Put
- data OpCode
- = INT Int
- | BININT Int
- | BININT1 Int
- | BININT2 Int
- | LONG Int
- | LONG1 Int
- | LONG4 Int
- | STRING ByteString
- | BINSTRING ByteString
- | SHORT_BINSTRING ByteString
- | NONE
- | NEWTRUE
- | NEWFALSE
- | UNICODE ByteString
- | BINUNICODE ByteString
- | FLOAT Double
- | BINFLOAT Double
- | EMPTY_LIST
- | APPEND
- | APPENDS
- | LIST
- | EMPTY_TUPLE
- | TUPLE
- | TUPLE1
- | TUPLE2
- | TUPLE3
- | EMPTY_DICT
- | DICT
- | SETITEM
- | SETITEMS
- | POP
- | DUP
- | MARK
- | POP_MARK
- | GET Int
- | BINGET Int
- | LONG_BINGET Int
- | PUT Int
- | BINPUT Int
- | LONG_BINPUT Int
- | EXT1 Int
- | EXT2 Int
- | EXT4 Int
- | GLOBAL ByteString ByteString
- | REDUCE
- | BUILD
- | INST ByteString ByteString
- | OBJ
- | NEWOBJ
- | PROTO Int
- | STOP
- | PERSID ByteString
- | BINPERSID
- data Value
- unpickle' :: [OpCode] -> Either String Value
- type Stack = [Value]
- type Memo = IntMap Value
- execute :: [OpCode] -> Stack -> Memo -> Either String Value
- executePartial :: [OpCode] -> Stack -> Memo -> (Stack, Memo, [OpCode])
- executeOne :: OpCode -> Stack -> Memo -> Either String (Stack, Memo)
- executeLookup :: Int -> Stack -> Memo -> Either String (Stack, Memo)
- executeTuple :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo)
- executeDict :: Monad m => [(Value, Value)] -> Stack -> Memo -> m ([Value], Memo)
- executeList :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo)
- executeSetitem :: Monad m => Stack -> Memo -> m ([Value], Memo)
- executeSetitems :: Monad m => [(Value, Value)] -> Stack -> Memo -> m ([Value], Memo)
- executeAppend :: Monad m => Stack -> Memo -> m ([Value], Memo)
- executeAppends :: Monad m => [Value] -> Stack -> Memo -> m ([Value], Memo)
- addToDict :: [(Value, Value)] -> Value -> Value
- newtype Pickler a = Pickler {}
- runPickler :: Pickler () -> [OpCode]
- pickle' :: Value -> Pickler ()
- binput' :: Value -> Pickler ()
- pickleDict :: Map Value Value -> Pickler ()
- pickleList :: [Value] -> Pickler ()
- pickleTuple :: [Value] -> Pickler ()
- pickleBinInt :: Int -> Pickler ()
- pickleBinLong :: Int -> Pickler ()
- pickleBinFloat :: Double -> Pickler ()
- pickleBinString :: ByteString -> Pickler ()
- dictGet :: Value -> Value -> Either String (Maybe Value)
- dictGet' :: Value -> Value -> Either String Value
- dictGetString :: Value -> ByteString -> Either String ByteString
Documentation
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.
decimalInt :: Parser Int Source #
decimalLong :: Parser Int Source #
decodeLong1 :: Parser Int Source #
decodeLong4 :: a Source #
encodeLong1 :: Int -> Put Source #
runPickler :: Pickler () -> [OpCode] Source #
pickleList :: [Value] -> Pickler () Source #
pickleTuple :: [Value] -> Pickler () Source #
pickleBinInt :: Int -> Pickler () Source #
pickleBinLong :: Int -> Pickler () Source #
pickleBinFloat :: Double -> Pickler () Source #
pickleBinString :: ByteString -> Pickler () Source #
dictGetString :: Value -> ByteString -> Either String ByteString Source #