[Haskell-cafe] Endian conversion
tomasz.zielonka at gmail.com
Mon Oct 3 02:35:04 EDT 2005
On 10/3/05, Joel Reymont <joelr1 at gmail.com> wrote:
> Are there any endian conversion routines for Haskell? I'm looking to
> build binary packets on top of NewBinary.Binary but my data is coming
> in little-endian whereas I'll need to send it out big endian.
>From your question I assume you want functions like htonl / ntohl.
I think the cleanest approach is to always have yours Ints, etc in host
order, and place
the endianness stuff in serialization / deserialization code, ie. on the
Number <-> Byte
Having htonl/ntohl as pure functions in Haskell would be a bit ugly, because
they would be defined differently on different platforms, and putting them
IO monad would make them barely usable.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe