-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Haskell binding to MessagePack -- @package msgpack @version 0.2.2 -- | Feeders for Stream Deserializers module Data.MessagePack.Feed -- | Feeder returns Just ByteString when bytes remains, otherwise Nothing. type Feeder = IO (Maybe ByteString) -- | Feeder from Handle feederFromHandle :: Handle -> IO Feeder -- | Feeder from File feederFromFile :: FilePath -> IO Feeder -- | Feeder from ByteString feederFromString :: ByteString -> IO Feeder -- | Low Level Interface to MessagePack C API module Data.MessagePack.Base type SimpleBuffer = ForeignPtr () -- | Create a new Simple Buffer. It will be deleted automatically. newSimpleBuffer :: IO SimpleBuffer -- | Get data of Simple Buffer. simpleBufferData :: SimpleBuffer -> IO ByteString type Packer = ForeignPtr () -- | Create new Packer. It will be deleted automatically. newPacker :: SimpleBuffer -> IO Packer packU8 :: Packer -> Word8 -> IO Int packU16 :: Packer -> Word16 -> IO Int packU32 :: Packer -> Word32 -> IO Int packU64 :: Packer -> Word64 -> IO Int packS8 :: Packer -> Int8 -> IO Int packS16 :: Packer -> Int16 -> IO Int packS32 :: Packer -> Int32 -> IO Int packS64 :: Packer -> Int64 -> IO Int packTrue :: Packer -> IO Int packFalse :: Packer -> IO Int -- | Pack an integral data. packInt :: Integral a => Packer -> a -> IO Int -- | Pack a double data. packDouble :: Packer -> Double -> IO Int -- | Pack a nil. packNil :: Packer -> IO Int -- | Pack a bool data. packBool :: Packer -> Bool -> IO Int -- | packArray p n starts packing an array. Next n -- data will consist this array. packArray :: Packer -> Int -> IO Int -- | packMap p n starts packing a map. Next n -- pairs of data (2*n data) will consist this map. packMap :: Packer -> Int -> IO Int -- | packRAW p n starts packing a byte sequence. Next total -- n bytes of packRAWBody call will consist this -- sequence. packRAW :: Packer -> Int -> IO Int -- | Pack a byte sequence. packRAWBody :: Packer -> ByteString -> IO Int -- | Pack a single byte stream. It calls packRAW and -- packRAWBody. packRAW' :: Packer -> ByteString -> IO Int type Unpacker = ForeignPtr () defaultInitialBufferSize :: Int -- | newUnpacker initialBufferSize creates a new Unpacker. -- It will be deleted automatically. newUnpacker :: Int -> IO Unpacker -- | unpackerReserveBuffer up size reserves at least -- size bytes of buffer. unpackerReserveBuffer :: Unpacker -> Int -> IO Bool -- | Get a pointer of unpacker buffer. unpackerBuffer :: Unpacker -> IO (Ptr CChar) -- | Get size of allocated buffer. unpackerBufferCapacity :: Unpacker -> IO Int -- | unpackerBufferConsumed up size notices that writed -- size bytes to buffer. unpackerBufferConsumed :: Unpacker -> Int -> IO () -- | Write byte sequence to Unpacker. It is utility funciton, calls -- unpackerReserveBuffer, unpackerBuffer and -- unpackerBufferConsumed. unpackerFeed :: Unpacker -> ByteString -> IO () -- | Execute deserializing. It returns 0 when buffer contains not enough -- bytes, returns 1 when succeeded, returns negative value when it -- failed. unpackerExecute :: Unpacker -> IO Int -- | Returns a deserialized object when unpackerExecute returned 1. unpackerData :: Unpacker -> IO Object -- | Release memory zone. The returned zone must be freed by calling -- freeZone. unpackerReleaseZone :: Unpacker -> IO Zone -- | Free memory zone used by Unapcker. unpackerResetZone :: Unpacker -> IO () -- | Reset Unpacker state except memory zone. unpackerReset :: Unpacker -> IO () -- | Returns number of bytes of sequence of deserializing object. unpackerMessageSize :: Unpacker -> IO Int -- | Object Representation of MessagePack data. data Object ObjectNil :: Object ObjectBool :: Bool -> Object ObjectInteger :: Int -> Object ObjectDouble :: Double -> Object ObjectRAW :: ByteString -> Object ObjectArray :: [Object] -> Object ObjectMap :: [(Object, Object)] -> Object -- | Pack a Object. packObject :: Packer -> Object -> IO () data UnpackReturn -- | not enough bytes to unpack object UnpackContinue :: UnpackReturn -- | got invalid bytes UnpackParseError :: UnpackReturn -- | other error UnpackError :: UnpackReturn -- | Unpack a single MessagePack object from byte sequence. unpackObject :: Zone -> ByteString -> IO (Either UnpackReturn (Int, Object)) type Zone = Ptr () -- | Create a new memory zone. It must be freed manually. newZone :: IO Zone -- | Free a memory zone. freeZone :: Zone -> IO () -- | Create a memory zone, then execute argument, then free memory zone. withZone :: (Zone -> IO a) -> IO a instance Show Object instance Eq UnpackReturn instance Show UnpackReturn -- | Serializing Haskell values to and from MessagePack Objects. module Data.MessagePack.Class -- | The class of types serializable to and from MessagePack object class OBJECT a toObject :: OBJECT a => a -> Object fromObject :: OBJECT a => Object -> Result a -- | A type for parser results type Result a = Either String a -- | Pack a serializable Haskell value. pack :: OBJECT a => Packer -> a -> IO () instance [incoherent] OBJECT a => OBJECT (Maybe a) instance [incoherent] (OBJECT a, OBJECT b) => OBJECT [(a, b)] instance [incoherent] OBJECT a => OBJECT [a] instance [incoherent] OBJECT String instance [incoherent] OBJECT ByteString instance [incoherent] OBJECT Double instance [incoherent] OBJECT Bool instance [incoherent] OBJECT Int instance [incoherent] OBJECT () instance [incoherent] OBJECT Object -- | Monadic Stream Serializers and Deserializers module Data.MessagePack.Monad class Monad m => MonadPacker m put :: (MonadPacker m, OBJECT a) => a -> m () class Monad m => MonadUnpacker m get :: (MonadUnpacker m, OBJECT a) => m a -- | Serializer Type newtype PackerT m r PackerT :: (Packer -> m r) -> PackerT m r runPackerT :: PackerT m r -> Packer -> m r -- | Deserializer type newtype UnpackerT m r UnpackerT :: (Unpacker -> Feeder -> m r) -> UnpackerT m r runUnpackerT :: UnpackerT m r -> Unpacker -> Feeder -> m r -- | Execute given serializer and returns byte sequence. packToString :: MonadIO m => PackerT m r -> m ByteString -- | Execute given serializer and write byte sequence to Handle. packToHandle :: MonadIO m => Handle -> PackerT m r -> m () -- | Execute given serializer and write byte sequence to file. packToFile :: MonadIO m => FilePath -> PackerT m r -> m () -- | Execute deserializer using given feeder. unpackFrom :: MonadIO m => Feeder -> UnpackerT m r -> m r -- | Execute deserializer from given byte sequence. unpackFromString :: MonadIO m => ByteString -> UnpackerT m r -> m r -- | Execute deserializer using given handle. unpackFromHandle :: MonadIO m => Handle -> UnpackerT m r -> m r -- | Execute deserializer using given file content. unpackFromFile :: MonadIO m => FilePath -> UnpackerT m r -> m r instance MonadIO m => MonadUnpacker (UnpackerT m) instance MonadIO m => MonadIO (UnpackerT m) instance MonadTrans UnpackerT instance Monad m => Monad (UnpackerT m) instance MonadIO m => MonadPacker (PackerT m) instance MonadIO m => MonadIO (PackerT m) instance MonadTrans PackerT instance Monad m => Monad (PackerT m) -- | Lazy Stream Serializers and Deserializers module Data.MessagePack.Stream -- | Unpack objects using given feeder. unpackObjects :: Feeder -> IO [Object] -- | Unpack objects from file. unpackObjectsFromFile :: FilePath -> IO [Object] -- | Unpack objects from handle. unpackObjectsFromHandle :: Handle -> IO [Object] -- | Unpack oobjects from given byte sequence. unpackObjectsFromString :: ByteString -> IO [Object] -- | Simple interface to pack and unpack MessagePack data. module Data.MessagePack -- | Pack Haskell data to MessagePack string. packb :: OBJECT a => a -> IO ByteString -- | Unpack MessagePack string to Haskell data. unpackb :: OBJECT a => ByteString -> IO (Result a) -- | Pure version of packb. packb' :: OBJECT a => a -> ByteString -- | Pure version of unpackb. unpackb' :: OBJECT a => ByteString -> Result a