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

Jules Bean jules at jellybean.co.uk
Fri Dec 5 05:59:02 EST 2008

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.


More information about the Haskell-Cafe mailing list