[Haskell-cafe] ANNOUNCE: vector-bytestring-

Michael Snoyman michael at snoyman.com
Thu Oct 20 21:43:06 CEST 2011

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
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.


More information about the Haskell-Cafe mailing list