I'm confused by the differences between haskell and python clients for msgpack. This:
import Data.MessagePack as MP
import Data.ByteString.Lazy as BL
BL.writeFile "test_haskell" $ MP.pack (0, 2, 28, ())
and this:
import msgpack
with open("test_python", "w") as f:
f.write(msgpack.packb([0, 2, 28, []]))
give me the different files:
$ diff test_haskell test_python
Binary files test_haskell and test_python differ
Can anybody explain, what I'm doing wrong? Maybe I misunderstood something about ByteString
usage?
The empty tuple ()
in Haskell is not like empty tuple or empty list in Python. It's similar to None
in Python. (in the context of msgpack).
So to get the same result, change the haskell program as:
MP.pack (0, 2, 28, []) -- empty list
Or change the python program as:
f.write(msgpack.packb([0, 2, 28, None]))
See a demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With