Discussion: Why is inet_addr in IO?

Thomas DuBuisson thomas.dubuisson at gmail.com
Thu Aug 28 15:28:41 UTC 2014


-1

I'd be in favor of a more drastic change, such as removing inet_addr
entirely .  Largely because `inet_addr("255.255.255.255") ~
inet_addr("foobar")` as noted by the inet_addr man page.  Let's add an
`inet_aton :: String -> m String` for some `m`.

I'd be enthusiastic if the full proposal was even more drastic,
including changing `inet_ntoa` into a pure function (which means
re-implementing it instead of using  C due to the static buffer
problem).

On Thu, Aug 28, 2014 at 7:41 AM, Edward Kmett <ekmett at gmail.com> wrote:
> inet_addr doesn't do any lookups, it is basically a glorified parsing
> problem converting from a string to a host address.
>
> http://hackage.haskell.org/package/network-2.6.0.1/docs/src/Network-Socket.html#inet_addr
>
> Why, beyond the obvious implementation details, does it live in IO?
>
> Given that the current version lives in IO, should there be a version that
> is obviously made pure so that folks who want to use it directly can do so
> without having to bury it behind an unsafePerformIO?
>
> This isn't a concrete proposal at this time, but more an attempt to sound
> out if such a proposal should be formed.
>
> -Edward
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>


More information about the Libraries mailing list