#2530: deriving Show adds extra parens for constructor with record syntax
-----------------------+----------------------------------------------------
    Reporter:  spl     |       Owner:          
        Type:  bug     |      Status:  new     
    Priority:  normal  |   Component:  Compiler
     Version:  6.8.3   |    Severity:  normal  
    Keywords:          |    Testcase:          
Architecture:  x86     |          Os:  MacOS X 
-----------------------+----------------------------------------------------
 Since record construction binds more tightly than function application, no
 parentheses are needed when passing a constructor with record syntax to a
 function constructor. As a result, we can pass {{{Just A {x = 5}}}} as
 shown below.

 {{{
 module Main where

 data A = A {x :: Int} deriving (Show)

 main :: IO ()
 main = print $ Just A {x = 5}
 }}}

 But we get the result in the GHCi session below:

 {{{
 *Main> main
 Just (A {x = 5})
 }}}

 I tried looking through {{{TcGenDeriv}}}, but didn't figure out quite
 where the parenifying was done. {{{nested_compose_Expr}}}?
 {{{show_thingies}}}?

 I just wanted to make a ticket for general knowledge. Of course, this is
 not a real bug. Perhaps you could reclassify it as a feature. Either way,
 it would be nice to have.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2530>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to