
On 05.09.2010 22:02, Don Stewart wrote:
For strict, checked binary parsing, use the cereal package. For lazy binary parsing with async errors, use binary.
Unfortunately cereal is too slow. I got ~5x slowdown with cereal and had to patch binary in order to incorporated error handling (essentially same as in cereal but simpler).
They're the main two points in the design space. The other is to tag the lazy stream, and insert failure tags in the structure.
It won't help againist "not enough input" errors. Sometimes fragments of data I process are damaged they are too short, some bits are flipped etc. There is no way to guard againist beforementioned errors but to constantly check that there is enough data in stream. Also error handling is very useful in signalling that data is malformed. It's possible to use cereal but it's too slow and it's inconvenient to have both Binary and Serialize instances. Also beginnig from 0.5.0.2 Get monad is strict and consume all required input at once. And therefore isn't suitable for lazy parsing unless lazyness is introduced manually.