[Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0
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.
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.
> 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://firstname.lastname@example.org\">v.dijk.bas at gmail.com</a></p>\n\n<p>Nick
> on IRC:<tt>basvandijk</tt></p>\n\n<a
> 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
> 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
> So what do other people think about this?
More information about the Haskell-Cafe