[Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0
AM
agentm at themactionfaction.com
Wed Oct 19 16:59:58 CEST 2011
On Oct 19, 2011, at 7:32 AM, Ivan Lazar Miljenovic wrote:
> On 19 October 2011 22:09, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
>>
>> So it seems that (1) people have very different requirements and (2) the
>> Show instance only really matters for debugging in ghci. Here is a
>> thought. What if ghci allowed Show instances to be overridden dynamically?
>> So you could put your preferred Show instance for Vector Word8 in you
>> .ghci file and ghci would use that when displaying stuff (but not when
>> actually evaluating things). Would that solve most of the problems without
>> messing with vector's Show instances?
>
> Would this hypothetical ghci feature also work for cases where you
> have a ByteString as part of another type that derives Show and Read?
>
> I also wonder whether it would suffice to have a ByteString -> String
> function available rather than requiring Show per-se for the case of a
> ByteString on its lonesome.
Note that other programming languages have had to solve this exact problem and they usually end up with multiple functions- one for debugging, one for serialization, one for displaying how the object was constructed.
For example, in Python, look at:
http://docs.python.org/reference/datamodel.html#object.__repr__
http://docs.python.org/reference/datamodel.html#object.__str__
Cheers,
M
More information about the Haskell-Cafe
mailing list