[Haskell-cafe] How to define Show [MyType] ?

Henning Thielemann schlepptop at henning-thielemann.de
Fri Dec 5 12:01:25 EST 2008

Jules Bean schrieb:
> Dmitri O.Kondratiev wrote:
>> I am trying to define instance Show[MyType] so
>> show (x:xs :: MyType) would return a single string where substrings
>> corresponding to list elements will be separated by "\n".
>> This would allow pretty printing of MyType list in several lines
>> instead of one, as default Show does for lists.
> You're doing it wrong.
> Show is not for pretty-printing.


> Show is for the production of haskell syntax for debugging and
> copy-pasting into test cases, as well as for use with 'Read'.
> If you want to pretty print, use a different function name.

Maybe related:

More information about the Haskell-Cafe mailing list