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

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Sep 26 09:48:57 EDT 2006

On Tue, Sep 26, 2006 at 09:00:33AM -0400, Samuel Bronson wrote:
> How often do you need to do comparisons on addresses for anything but
> equality (which doesn't require flipping to test)?

I may want to see if a HostAddresses is in a certain range of addresses
- for example, a range assigned by an one of internet registries. Here
it's actually important what ordering relation we use. The current one
is useless.

I may want to use (Map HostAddress something) or (Set HostAddress).

I may want to sort HostAddresses to remove duplicates.

> >The problem is everything that gives different results on platforms with
> >different byte-orders. Show is one example, but there are also arithmetic
> >operations, Ord, etc.
> ... How often do you need to do arithmatic?

Additions, multiplications... rather not.
But Data.Bits operations can be useful to manipulate netmasks and
network addresses.

> Oh, btw, there are ntoh*/hton* functions for converting between host
> and network byte orders regardless of how crazy the host byte-order
> is...

Why not do it better?

Network byte order is meant to be used over the *network*. It is
unfortunate that BSD sockets don't hide that detail from the programmer.
I think Haskell should be a bit above the level of IP frames.

Do you have any good reasons to keep the current status besides:
- "we don't want additional conversions"
- "that's how it's done in C"
- "you don't need it"

Best regards

More information about the Libraries mailing list