[Haskell-cafe] type/class question: toString

Graham Fawcett graham.fawcett at gmail.com
Tue Nov 6 09:18:24 EST 2007


Hi folks,

Is there a way to declare a 'toString' function, such that

toString x | <x is a String> = x
toString x | <x's type is an instance of Show> = show x

Perhaps, in the type system, there's a way to declare a ToString
class, and somehow "inherit" all instances of Show as ToString
instances?

Thanks,
Graham


More information about the Haskell-Cafe mailing list