darcs patch: Implementation of aton and ntoa outside the IO monad

Robert Marlow bobstopper at bobturf.org
Mon Sep 25 04:09:13 EDT 2006

I think HostAddresses are probably good how they are now. It seems a bit
too much work to convert a HostAddresses endianness everytime it's used.
If the problem is how it appears (which along with PortAddress can be
confusing) perhaps it just needs a different show implementation.

I've attached some Byte utilities. I don't know if this would be
considered useful to the Haskell libraries or not, but I find it useful
for doing things like outputing raw binary and messing with endianness.
It's poorly documented, but I can fix that if it's considered useful.

On Sun, 2006-09-24 at 11:42 +0200, Tomasz Zielonka wrote:
> I was thinking about it before. As of now, Network libraries just
> put bits in network order into values of type HostAddress = Word32. But
> Word32 is interpreted in host order by Haskell, so the same IP address
> will be seen as a different number on little and big endian platforms.
> The best would be to have an endianness independent representation for
> IP4 addresses, by converting IP addresses to host order. This way things
> are simple - the most significant octet of IP address with be the most
> significant 8-bits of HostAddress, etc.
> Conversion to/from network order could be done around calls to various
> system calls. Yes, it adds an (small) additional cost (on little endian
> machines), but I think it's worth it. With current design you sometimes
> can't avoid impure and/or inelegant code.
> Best regards
> Tomasz
Robert Marlow <bobstopper at bobturf.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Byte.hs
Type: text/x-haskell
Size: 1993 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20060925/1f536539/Byte.bin

More information about the Libraries mailing list