messagepack 0.4.0 → 0.5.0
raw patch · 4 files changed
+24/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.MessagePack: ObjectUInt :: Word64 -> Object
Files
- CHANGELOG +4/−0
- Data/MessagePack.hs +18/−13
- messagepack.cabal +1/−1
- tests/Main.hs +1/−0
CHANGELOG view
@@ -1,3 +1,7 @@+2015-08-07 Will Sewell <will@pusher.com>++ * Add ObjectUInt constructor for messagepack unsigned ints+ 2015-05-07 Mike Pye <mike@pusher.com> * Remove coercion of msgpack String type to haskell Text
Data/MessagePack.hs view
@@ -21,10 +21,14 @@ import Data.Int import Data.MessagePack.Spec import Data.Serialize+import Data.Word import qualified Data.ByteString as BS import qualified Data.Map as M data Object = ObjectNil+ -- | Unsigned integers from the MsgPack protocol: uint 8, uint 16, uint 32, uint 64+ | ObjectUInt Word64+ -- | Signed integers and fixnums from the MsgPack protocol: positive fixnum, negative fixnum, int 8, int 16, int 32, int 64 | ObjectInt Int64 | ObjectBool Bool | ObjectFloat Float@@ -37,19 +41,20 @@ deriving (Eq, Ord, Show) instance Serialize Object where-- put (ObjectInt i)- | i >= 0 && i <= 127 = putWord8 $ fromIntegral i- | i >= -32 && i <= -1 = putWord8 $ fromIntegral i+ put (ObjectUInt i) | i >= 0 && i < 0x100 = putWord8 uint8 >> putWord8 (fromIntegral i) | i >= 0 && i < 0x10000 = putWord8 uint16 >> putWord16be (fromIntegral i) | i >= 0 && i < 0x100000000 = putWord8 uint32 >> putWord32be (fromIntegral i)- | i >= 0 = putWord8 uint64 >> putWord64be (fromIntegral i)- | i >= -0x80 = putWord8 int8 >> putWord8 (fromIntegral i)- | i >= -0x8000 = putWord8 int16 >> putWord16be (fromIntegral i)- | i >= -0x80000000 = putWord8 int32 >> putWord32be (fromIntegral i)- | otherwise = putWord8 int64 >> putWord64be (fromIntegral i)+ | otherwise = putWord8 uint64 >> putWord64be (fromIntegral i) + put (ObjectInt i)+ | i >= 0 && i <= 127 = putWord8 $ fromIntegral i+ | i >= -32 && i <= -1 = putWord8 $ fromIntegral i+ | i >= -0x80 && i < 0x80 = putWord8 int8 >> putWord8 (fromIntegral i)+ | i >= -0x8000 && i < 0x8000 = putWord8 int16 >> putWord16be (fromIntegral i)+ | i >= -0x80000000 && i < 0x80000000 = putWord8 int32 >> putWord32be (fromIntegral i)+ | otherwise = putWord8 int64 >> putWord64be (fromIntegral i)+ put ObjectNil = putWord8 nil put (ObjectBool b) = putWord8 $ if b then true else false@@ -128,10 +133,10 @@ | k .&. posFixintMask == posFixint = return $ ObjectInt $ fromIntegral k | k .&. negFixintMask == negFixint = return $ ObjectInt $ fromIntegral (fromIntegral k :: Int8)- | k == uint8 = ObjectInt <$> fromIntegral <$> getWord8- | k == uint16 = ObjectInt <$> fromIntegral <$> getWord16be- | k == uint32 = ObjectInt <$> fromIntegral <$> getWord32be- | k == uint64 = ObjectInt <$> fromIntegral <$> getWord64be+ | k == uint8 = ObjectUInt <$> fromIntegral <$> getWord8+ | k == uint16 = ObjectUInt <$> fromIntegral <$> getWord16be+ | k == uint32 = ObjectUInt <$> fromIntegral <$> getWord32be+ | k == uint64 = ObjectUInt <$> getWord64be | k == int8 = ObjectInt <$> fromIntegral <$> (get :: Get Int8) | k == int16 = ObjectInt <$> fromIntegral <$> (get :: Get Int16) | k == int32 = ObjectInt <$> fromIntegral <$> (get :: Get Int32)
messagepack.cabal view
@@ -1,5 +1,5 @@ name : messagepack-version : 0.4.0+version : 0.5.0 synopsis : Serialize instance for Message Pack Object description : Serialize instance for Message Pack Object homepage : https://github.com/rodrigosetti/messagepack
tests/Main.hs view
@@ -15,6 +15,7 @@ instance Arbitrary Object where arbitrary = sized $ \n -> oneof [ return ObjectNil+ , ObjectUInt <$> arbitrary , ObjectInt <$> arbitrary , ObjectBool <$> arbitrary , ObjectFloat <$> arbitrary