TokTok / hs-msgpack-binary

Haskell implementation of MessagePack / msgpack.org
http://msgpack.org/
Other
16 stars 10 forks source link

This implementation doesn't fully follow the MessagePack spec #15

Closed SX91 closed 7 years ago

SX91 commented 7 years ago

https://github.com/msgpack/msgpack/blob/master/spec.md#types-limitation

a value of an Integer object is limited from -(2^63) upto (2^64)-1

This implementation stores it in Int64, which won't adequately represent Unsigned Integers, which are greater than (2^63) - 1.

SX91 commented 7 years ago

Ideally we need to separate Signed and Unsigned integers in Object (make two constructors instead of one) and encode Signed as msgpack's negative (value < 0) and unsigned as msgpack positive (value >= 0) ints. This way positives would be easily converted to Int (with checking) and Word; negatives would convert to Int only. It's done this way in many MessagePack implementations (C one, for example).

SX91 commented 7 years ago

For example: Try packing 0xFFFFFFFFFFFFFFFF by data-msgpack and any other (correct) implementation. On Python you'll get b'\xcf\xff\xff\xff\xff\xff\xff\xff\xff', on Haskell: "\255".