
I don't think that making Show a type class was a mistake. I think
that we have long since overloaded the meaning of Show and made it
ambiguous. There are multiple distinct reasons people use Show, and
this gets confusing. It would be good if we as a community tried to
nail down these different meanings that people tend to attach to Show
and fork out new type classes that each encompass those meanings.
Text is useful and often ignored as a means of debugging, inspecting,
logging, and serializing.
Off the top of my head, I would say that the traditional meaning of
Show could be changed to Serial, where serial encompasses both Read
and Show -- possibly we could find a more efficient read function,
several have been proposed. Then a separate class could be made for
HumanReadable (or Loggable) where the point would bet that we write
something that can be read by humans without conforming to a
particular grammar that Haskell could read back in.
-- Jeff
On Fri, Dec 26, 2008 at 1:31 PM, Jonathan Cast
On Fri, 2008-12-26 at 11:51 +0000, Thomas DuBuisson wrote:
Hello cafe, This is just a small thought, but its been bugging me. We have these things called type classes for a reason (I like to think).
Type classes were invented for two reasons:
1) To imitate mathematical convention. Addition, in full, is written as
x +_{A} y
where A is a mathematical structure supplying addition. However, the convention is that the subscript may be omitted `when no ambiguity may arise'. Programming languages (generally) take this and run with it, allowing
x + y
to mean (depending on the language) pretty much anything. Type classes are an ingenious step back toward the mathematical convention, where the operation + must come from some complete structure.
2) To allow conversion from structured data into strings to be treated as a single operation. Most languages support this in some form, but I am increasingly failing to see why. There are usually several different ways in which a given piece of structured data can meaningfully be `shown'; in languages which try to do the right thing when given
print "string", 'c', (2 + 2), [true, false, :maybe]
you *still* end up defining (multiple!) special-purpose output or conversion-to-string functions so you can print the same data in multiple ways. I think making Show a type class was a mistake.
jcc
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe