[Haskell-cafe] Show me

Andrew Coppin andrewcoppin at btinternet.com
Wed Aug 6 14:06:44 EDT 2008


Jonathan Cast wrote:
> instance Show x => Show (Foo x) where
>   showsPrec n foo = ("list_foo "++) . shows (foo_list foo)
>
> You use the n parameter if you've got an infix operator in your syntax
> and you want to put parentheses around an instance of it if n has the
> wrong value (either too high or too low, I can never remember).
>   

OK. So... should the call to shows actually be showsPrec? Or does it not 
matter in this case?

Actually, now that I think of it, my *next* problem is going to be 
writing a matching Read instance...



More information about the Haskell-Cafe mailing list