
Einar Karttunen
I am trying to figure out the best interface to binary parser and pretty printing combinators for network protocols.
2) Using better combinators
packet = w32be <> w32be <> w32be <> lengthPrefixList w32be (lengthPrefixList w32be bytes) Has anyone used combinators like this before and how did it work?
Yes, the nhc98 Binary library has a "<<" combinator, in very much the style you outline. It is only used in pure code, but it permits some very concise descriptions of the binary layout. The library is described here: ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html but unfortunately that paper has only the tiniest examples of the usage of "<<". However, in my experience the style worked well and was pleasant to use. Regards, Malcolm