[Haskell-cafe] ANNOUNCE: vector-bytestring-

Christian Maeder Christian.Maeder at dfki.de
Mon Oct 17 10:18:39 CEST 2011

I think the cleanest solution (just from a theoretical point of view) is 
to use a newtype for your byte strings.

- it should have the same performance
- allows to make ByteString really abstract when hiding the newtype 
- is portable and supplies control over all other instances (not just Show)

I'm not sure if one could make really bad thinks to your ByteString by 
using the Vector interface, but one would want to disallow vector 
operations just for compatible with other byte strings.

It would require more work just on your side, though.

Cheers Christian

Am 15.10.2011 16:15, schrieb Bas van Dijk:
> On 15 October 2011 13:34, Roman Leshchinskiy<rl at cse.unsw.edu.au>  wrote:
>> On 15/10/2011, at 12:26, Roman Leshchinskiy wrote:
>>> On 14/10/2011, at 12:37, Bas van Dijk wrote:
>>>> If there's need for a specific Show instance for Vectors of Word8s we
>>>> can always add one directly to vector. (Roman, what are your thoughts
>>>> on this?)
>>> Personally, I think that ByteString and especially Vector Word8 aren't strings and shouldn't be treated as such. But I wouldn't be strongly against showing them as strings. However, I *am* strongly against using UndecidableInstances in vector and I don't see how to implement this without using them.
>> I meant OverlappingInstances, of course. To clarify, I would still consider it if everybody thinks it's a really good idea.
>> Roman
> I agree that you shouldn't use ByteStrings or Vectors of Word8s for
> Unicode strings. However I can imagine that for quick sessions in ghci
> it can be quite handy if they are shown as strings. For example,
> currently we have:
>> import Network.HTTP.Enumerator
>> simpleHttp "http://code.haskell.org/~basvandijk/"
> Chunk "<html>\n<head><title>Bas van
> Dijk</title></head>\n<body>\n<h1>Bas van Dijk</h1>\n\n<p>Email:<a
> href=\"mailto://v.dijk.bas@gmail.com\">v.dijk.bas at gmail.com</a></p>\n\n<p>Nick
> on IRC:<tt>basvandijk</tt></p>\n\n<a
> href=\"http://www.haskellers.com/user/basvandijk/\">\n<img
> src=\"http://www.haskellers.com/static/badge.png\" \n       alt=\"I'm
> a Haskeller\"\n       border=\"0\">\n</a>\n\n<p>See my<a
> href=\"https://github.com/basvandijk\">GitHub</a>  page for a list of
> projects I work on.</p>\n\n</body>\n</html>\n" Empty
> If ByteStrings were not shown as strings this would look like:
> Chunk ( fromList
> [60,104,116,109,108,62,10,60,104,101,97,100,62,60,116,105,116,108,101,62,66,97,115,32,118,97,110,32,68,105,106,107,60,47,116,105,116,108,101,62,60,47,104,101,97,100,62,10,60,98,111,100,121,62,10,60,104,49,62,66,97,115,32,118,97,110,32,68,105,106,107,60,47,104,49,62,10,10,60,112,62,69,109,97,105,108,58,32,60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,47,47,118,46,100,105,106,107,46,98,97,115,64,103,109,97,105,108,46,99,111,109,34,62,118,46,100,105,106,107,46,98,97,115,64,103,109,97,105,108,46,99,111,109,60,47,97,62,60,47,112,62,10,10,60,112,62,78,105,99,107,32,111,110,32,73,82,67,58,32,60,116,116,62,98,97,115,118,97,110,100,105,106,107,60,47,116,116,62,60,47,112,62,10,10,60,97,32,104,114,101,102,61,34,104,116,116,112,58,47,47,119,119,119,46,104,97,115,107,101,108,108,101,114,115,46,99,111,109,47,117,115,101,114,47,98,97,115,118,97,110,100,105,106,107,47,34,62,10,32,32,60,105,109,103,32,115,114,99,61,34,104,116,116,112,58,47,47,119,119,119,46,104,97,115,107,101,108
> Empty
> Personally, I don't work in ghci that often so I don't care that much
> if we have or don't have specialized Show instances for Vectors of
> Word8s.
> So what do other people think about this?
> Bas

More information about the Haskell-Cafe mailing list