[Haskell] [ANNOUNCE] network-address-0.2.0

Ben Millwood haskell at benmachine.co.uk
Thu Sep 8 17:27:46 CEST 2011


On Thu, Sep 8, 2011 at 3:23 PM, Sebastian Nowicki <sebnow at gmail.com> wrote:
>
> I don't know if it's generally accepted to provide Read/Show instances
> which don't parse/print Haskell syntax.
>

It's quite common, and several "standard" libraries do it. Handle for
example has a (fairly useless) Show instance. Whether it's a good idea
or not is another question :)

>>> Planned for the next release:
>>>
>>>  * Support for parsing IPv4 notation embedded in IPv6 (e.g. "::192.168.1.1")
>>
>> is the result a value of type IPv4 or IPv6? For an IPv4-Compatible
>> address I'd expect the result to be IPv4. It might also be useful to
>> add a conversion function to turn an IPv4 address into an IPv4-Mapped
>> IPv6 address.
>
> Technically it's an IPv6 address, "::192.168.1.1" isn't a valid IPv4
> string (hence parsing should fail). You can convert from one address
> to another using toAddress . fromAddress, i.e.:
>
>    (toAddress . fromAddress $ (readAddress "192.168.1.1" :: IPv4)) :: IPv6
>

If these sorts of type coercions are often necessary, maybe you should
just expose read(s)IPv4 and toIPv6 and friends?



More information about the Haskell mailing list