instance overaps with lib

Serge D. Mechveliani mechvel at botik.ru
Tue Sep 5 07:44:44 EDT 2006


On Tue, Sep 05, 2006 at 12:11:20PM +0100, Ross Paterson wrote:

> [..]
> You seem to be using special instances to do two things: add spacing and
> remove extraneous parentheses.  A neater way to do the latter would be
> to use the precedence parameter of showsPrec for Term to control whether
> the parentheses are added in the first place, e.g. (untested)
> 
>   showsPrec p t = 
>     (case t 
>      of
>      VarT v         -> shows v
>      App f []  []   -> showString (name f)
>      App f []  [r]  -> showParen (p > app_prec) $
>                            showString (name f) . showChar ' ' .
>                            showsPrec (app_prec+1) r
>      ...
>     where app_prec = 10

Thank you very much. 
I have to study this. Because I always defined  Show  via showsPrec, 
and also was always missing of what is the first argument of showsPrec.



More information about the Glasgow-haskell-users mailing list