title: How to serialize/deserialize objects sent over the network in Haskell?
body: <p>I see that there are many ways to serialize/deserialize Haskell objects:</p>
  
  <ul>
  <li>Data.Serialize -> encode, decode functions</li>
  <li>Data.Binary <a href="http://code.haskell.org/binary/" rel="noreferrer">http://code.haskell.org/binary/</a></li>
  <li>MsgPack, JSON, BSON, etc</li>
  </ul>
  
  <p>In my application, I want to setup a simple TCP client-server, where client may send serialized Haskell record objects. How does one decide between these serialization alternatives?</p>
  
  <p>Additionally, when objects serialized into strings are sent over the network using <a href="http://hackage.haskell.org/package/network-2.6.0.2/docs/Network-Socket-ByteString.html" rel="noreferrer">Network.Socket</a>, strings are returned. Is there a slightly higher level library, that works at the level of whole TCP messages? In other words, is there a way to avoid writing parsing code on the receive end that:</p>
  
  <ul>
  <li>collects results of a sequence of recv() calls,</li>
  <li>detect that a whole object has been received, and </li>
  <li>then parse it into a haskell type?</li>
  </ul>
  
  <p>In my application, the objects are not expected to be too large (maybe about ~1MB max).</p>