[Haskell-cafe] ANNOUNCE: vector-bytestring-

Christian Maeder Christian.Maeder at dfki.de
Fri Oct 21 11:58:58 CEST 2011

Am 20.10.2011 21:43, schrieb Michael Snoyman:
> On Wed, Oct 19, 2011 at 9:29 PM, Ketil Malde<ketil at malde.org>  wrote:
>> Michael Snoyman<michael at snoyman.com>  writes:
>>> sense to try and pursue something like what you're suggesting, but I
>>> think the default Show (Vector Word8) should be the one most useful,
>>> most of the time, and I think the general consensus seems to be the
>>> current ByteString instance fits that role.
>> Hm.  I think it is slightly weird to display a numeric value (Word8) as
>> a Char.  Also, I would prefer a representation making the type explicit
>> (but unlike ByteString, vector seems to add a type annotation.)  Would
>> you still support the truncating behavior for 'read' and values above 255?
>> (ByteString has two interfaces, ByteString and .Char8, but as there can
>> be only one Show instance, I see why it works the way it does.)
> Perhaps the correct semantic approach would be to have:
>      newtype Char8 = Char8 Word8
> But I think that will break far too many applications to try to get it

would a new Word8 type be better to stay compatible?

        newtype Word8 = C8 Data.Word.Word8


> implemented. In an ideal world, I agree with both points: displaying a
> numeric value as a Char doesn't make sense, and there are definitely
> issues with the Read instance. However, I still think current behavior
> is the least of all available evils. Show/Read work properly as a pair
> and can encode/decode any ByteString, and there's never any
> presumption that all input to read is valid.
> Michael

More information about the Haskell-Cafe mailing list