[Haskell-cafe] Data.Binary Endianness

Jules Bean jules at jellybean.co.uk
Tue Sep 11 07:01:52 EDT 2007


Ketil Malde wrote:
> On Tue, 2007-09-11 at 09:10 +0200, Sven Panne wrote:
>> foo :: Binary a => ... -> a -> ..."? This should probably mean "foo is
>> using some portable (de-)serialization, but doesn't care about the
>> actual representation", 
> 
> I'm probably missing something, but:
> 
> How can the format be portable if the representation isn't unambigously
> defined?  And if it is unabmigously defined, what's wrong with using it
> for externally defined data formats?

It's portable because it works on other machines also running that exact 
version of Data.Binary, regardless of their CPU architecture (in 
particular, word size or endianness). That is the precise sense of 
'portable' used here.

The actual format used by Data.Binary is not explicitly described in any 
standard (although in most cases it's moderately obvious, and anyone can 
read the code), and it's not formally guaranteed that it will never 
change in a later version (although the maintainers will no doubt try 
very hard to ensure it doesn't); nor does it contain any automatic 
support for version-stamping to ensure backwards compatibility in the 
face of later unlooked-for format changes.

For these reasons, although it is very cool, I don't think it can be 
recommended as a basis for long-term file format definitions.

(All of the above speaks of the 'high-level' Data.Binary not the 
'low-level'.)

Jules


More information about the Haskell-Cafe mailing list