Admin message

Due to a large amount of spam we do not allow new users to create repositories, they are "external" users. If you are a new user and want to create a repository, for example for forking GHC, open a new issue on ghc/ghc using the "get-verified" issue template

Atrocious parenthesization in -ddump-deriv output
The next installment in "RyanGlScott finds parenthesization bugs". This time, we're featuring `-ddump-deriv`. Just look at this garbage: ``` $ /opt/ghc/8.2.2/bin/ghci GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> import Data.Ix λ> import Language.Haskell.TH.Syntax λ> import Data.Data λ> :set -ddump-deriv -XDeriveLift -XDeriveDataTypeable λ> data Foo = Foo Int Int deriving (Show, Lift, Data, Eq, Ord, Ix) ==================== Derived instances ==================== Derived class instances: instance GHC.Show.Show Ghci1.Foo where GHC.Show.showsPrec a_a6me Ghci1.Foo b1_a6mf b2_a6mg = GHC.Show.showParen (a_a6me GHC.Classes.>= 11) ((GHC.Base..) (GHC.Show.showString "Foo ") ((GHC.Base..) (GHC.Show.showsPrec 11 b1_a6mf) ((GHC.Base..) GHC.Show.showSpace (GHC.Show.showsPrec 11 b2_a6mg)))) GHC.Show.showList = GHC.Show.showList__ (GHC.Show.showsPrec 0) instance Language.Haskell.TH.Syntax.Lift Ghci1.Foo where Language.Haskell.TH.Syntax.lift Ghci1.Foo a1_a6mh a2_a6mi = Language.Haskell.TH.Lib.appE (Language.Haskell.TH.Lib.appE (Language.Haskell.TH.Lib.conE (Language.Haskell.TH.Syntax.mkNameG_d "interactive" "Ghci1" "Foo")) (Language.Haskell.TH.Syntax.lift a1_a6mh)) (Language.Haskell.TH.Syntax.lift a2_a6mi) instance Data.Data.Data Ghci1.Foo where Data.Data.gfoldl k_a6mj z_a6mk Ghci1.Foo a1_a6ml a2_a6mm = ((z_a6mk Ghci1.Foo `k_a6mj` a1_a6ml) `k_a6mj` a2_a6mm) Data.Data.gunfold k_a6mn z_a6mo _ = k_a6mn (k_a6mn (z_a6mo Ghci1.Foo)) Data.Data.toConstr Ghci1.Foo _ _ = Ghci1.$cFoo Data.Data.dataTypeOf _ = Ghci1.$tFoo instance GHC.Classes.Eq Ghci1.Foo where (GHC.Classes.==) (Ghci1.Foo a1_a6mp a2_a6mq) (Ghci1.Foo b1_a6mr b2_a6ms) = (((a1_a6mp GHC.Classes.== b1_a6mr)) GHC.Classes.&& ((a2_a6mq GHC.Classes.== b2_a6ms))) (GHC.Classes./=) a_a6mt b_a6mu = GHC.Classes.not ((GHC.Classes.==) a_a6mt b_a6mu) instance GHC.Classes.Ord Ghci1.Foo where GHC.Classes.compare a_a6mv b_a6mw = case a_a6mv of { Ghci1.Foo a1_a6mx a2_a6my -> case b_a6mw of { Ghci1.Foo b1_a6mz b2_a6mA -> case (GHC.Classes.compare a1_a6mx b1_a6mz) of GHC.Types.LT -> GHC.Types.LT GHC.Types.EQ -> (a2_a6my `GHC.Classes.compare` b2_a6mA) GHC.Types.GT -> GHC.Types.GT } } (GHC.Classes.<) a_a6mB b_a6mC = case a_a6mB of { Ghci1.Foo a1_a6mD a2_a6mE -> case b_a6mC of { Ghci1.Foo b1_a6mF b2_a6mG -> case (GHC.Classes.compare a1_a6mD b1_a6mF) of GHC.Types.LT -> GHC.Types.True GHC.Types.EQ -> (a2_a6mE GHC.Classes.< b2_a6mG) GHC.Types.GT -> GHC.Types.False } } (GHC.Classes.<=) a_a6mH b_a6mI = GHC.Classes.not ((GHC.Classes.<) b_a6mI a_a6mH) (GHC.Classes.>) a_a6mJ b_a6mK = (GHC.Classes.<) b_a6mK a_a6mJ (GHC.Classes.>=) a_a6mL b_a6mM = GHC.Classes.not ((GHC.Classes.<) a_a6mL b_a6mM) instance GHC.Arr.Ix Ghci1.Foo where GHC.Arr.range (Ghci1.Foo a1_a6mN a2_a6mO, Ghci1.Foo b1_a6mP b2_a6mQ) = [Ghci1.Foo c1_a6mR c2_a6mS | c1_a6mR <- GHC.Arr.range (a1_a6mN, b1_a6mP), c2_a6mS <- GHC.Arr.range (a2_a6mO, b2_a6mQ)] GHC.Arr.unsafeIndex (Ghci1.Foo a1_a6mT a2_a6mU, Ghci1.Foo b1_a6mV b2_a6mW) Ghci1.Foo c1_a6mX c2_a6mY = (GHC.Arr.unsafeIndex (a2_a6mU, b2_a6mW) c2_a6mY GHC.Num.+ (GHC.Arr.unsafeRangeSize (a2_a6mU, b2_a6mW) GHC.Num.* GHC.Arr.unsafeIndex (a1_a6mT, b1_a6mV) c1_a6mX)) GHC.Arr.inRange (Ghci1.Foo a1_a6oj a2_a6ok, Ghci1.Foo b1_a6ol b2_a6om) Ghci1.Foo c1_a6on c2_a6oo = (GHC.Arr.inRange (a1_a6oj, b1_a6ol) c1_a6on GHC.Classes.&& GHC.Arr.inRange (a2_a6ok, b2_a6om) c2_a6oo) Ghci1.$con2tag_Hv18APskVh1Gg9kT3PCwD2 :: Ghci1.Foo -> GHC.Prim.Int# Ghci1.$con2tag_Hv18APskVh1Gg9kT3PCwD2 Ghci1.Foo _ _ = 0# Ghci1.$tFoo :: Data.Data.DataType Ghci1.$cFoo :: Data.Data.Constr Ghci1.$tFoo = Data.Data.mkDataType "Foo" [Ghci1.$cFoo] Ghci1.$cFoo = Data.Data.mkConstr Ghci1.$tFoo "Foo" [] Data.Data.Prefix ``` There are several lines where `Foo` must be surrounded with parentheses to typecheck, but aren't. They are: - In the `Show` instance: ` GHC.Show.showsPrec a_a8sa Ghci11.Foo b1_a8sb b2_a8sc ` - In the `Lift` instance: ` Language.Haskell.TH.Syntax.lift Ghci11.Foo a1_a8sd a2_a8se ` - In the `Data` instance: ` Data.Data.gfoldl k_a8sf z_a8sg Ghci11.Foo a1_a8sh a2_a8si ... Data.Data.toConstr Ghci11.Foo _ _ = Ghci11.$cFoo ` - In the auxiliary bindings (technically, these aren't legal definitions in the first place, but it does look jarring): ` Ghci11.$con2tag_GrjBmXmdiewCS4g3vLeGMg :: Ghci11.Foo -> GHC.Prim.Int# Ghci11.$con2tag_GrjBmXmdiewCS4g3vLeGMg Ghci11.Foo _ _ = 0# ` <details><summary>Trac metadata</summary> | Trac field | Value | | ---------------------- | ------------ | | Version | 8.2.2 | | Type | Bug | | TypeOfFailure | OtherFailure | | Priority | normal | | Resolution | Unresolved | | Component | Compiler | | Test case | | | Differential revisions | | | BlockedBy | | | Related | | | Blocking | | | CC | | | Operating system | | | Architecture | | </details> <!-- {"blocked_by":[],"summary":"Atrocious parenthesization in -ddump-deriv output","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["deriving"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The next installment in \"RyanGlScott finds parenthesization bugs\". This time, we're featuring `-ddump-deriv`. Just look at this garbage:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.2/bin/ghci\r\nGHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\nλ> import Data.Ix\r\nλ> import Language.Haskell.TH.Syntax\r\nλ> import Data.Data\r\nλ> :set -ddump-deriv -XDeriveLift -XDeriveDataTypeable \r\nλ> data Foo = Foo Int Int deriving (Show, Lift, Data, Eq, Ord, Ix)\r\n\r\n==================== Derived instances ====================\r\nDerived class instances:\r\n instance GHC.Show.Show Ghci1.Foo where\r\n GHC.Show.showsPrec a_a6me Ghci1.Foo b1_a6mf b2_a6mg\r\n = GHC.Show.showParen\r\n (a_a6me GHC.Classes.>= 11)\r\n ((GHC.Base..)\r\n (GHC.Show.showString \"Foo \")\r\n ((GHC.Base..)\r\n (GHC.Show.showsPrec 11 b1_a6mf)\r\n ((GHC.Base..) GHC.Show.showSpace (GHC.Show.showsPrec 11 b2_a6mg))))\r\n GHC.Show.showList = GHC.Show.showList__ (GHC.Show.showsPrec 0)\r\n \r\n instance Language.Haskell.TH.Syntax.Lift Ghci1.Foo where\r\n Language.Haskell.TH.Syntax.lift Ghci1.Foo a1_a6mh a2_a6mi\r\n = Language.Haskell.TH.Lib.appE\r\n (Language.Haskell.TH.Lib.appE\r\n (Language.Haskell.TH.Lib.conE\r\n (Language.Haskell.TH.Syntax.mkNameG_d \"interactive\" \"Ghci1\" \"Foo\"))\r\n (Language.Haskell.TH.Syntax.lift a1_a6mh))\r\n (Language.Haskell.TH.Syntax.lift a2_a6mi)\r\n \r\n instance Data.Data.Data Ghci1.Foo where\r\n Data.Data.gfoldl k_a6mj z_a6mk Ghci1.Foo a1_a6ml a2_a6mm\r\n = ((z_a6mk Ghci1.Foo `k_a6mj` a1_a6ml) `k_a6mj` a2_a6mm)\r\n Data.Data.gunfold k_a6mn z_a6mo _\r\n = k_a6mn (k_a6mn (z_a6mo Ghci1.Foo))\r\n Data.Data.toConstr Ghci1.Foo _ _ = Ghci1.$cFoo\r\n Data.Data.dataTypeOf _ = Ghci1.$tFoo\r\n \r\n instance GHC.Classes.Eq Ghci1.Foo where\r\n (GHC.Classes.==)\r\n (Ghci1.Foo a1_a6mp a2_a6mq)\r\n (Ghci1.Foo b1_a6mr b2_a6ms)\r\n = (((a1_a6mp GHC.Classes.== b1_a6mr))\r\n GHC.Classes.&& ((a2_a6mq GHC.Classes.== b2_a6ms)))\r\n (GHC.Classes./=) a_a6mt b_a6mu\r\n = GHC.Classes.not ((GHC.Classes.==) a_a6mt b_a6mu)\r\n \r\n instance GHC.Classes.Ord Ghci1.Foo where\r\n GHC.Classes.compare a_a6mv b_a6mw\r\n = case a_a6mv of {\r\n Ghci1.Foo a1_a6mx a2_a6my\r\n -> case b_a6mw of {\r\n Ghci1.Foo b1_a6mz b2_a6mA\r\n -> case (GHC.Classes.compare a1_a6mx b1_a6mz) of\r\n GHC.Types.LT -> GHC.Types.LT\r\n GHC.Types.EQ -> (a2_a6my `GHC.Classes.compare` b2_a6mA)\r\n GHC.Types.GT -> GHC.Types.GT } }\r\n (GHC.Classes.<) a_a6mB b_a6mC\r\n = case a_a6mB of {\r\n Ghci1.Foo a1_a6mD a2_a6mE\r\n -> case b_a6mC of {\r\n Ghci1.Foo b1_a6mF b2_a6mG\r\n -> case (GHC.Classes.compare a1_a6mD b1_a6mF) of\r\n GHC.Types.LT -> GHC.Types.True\r\n GHC.Types.EQ -> (a2_a6mE GHC.Classes.< b2_a6mG)\r\n GHC.Types.GT -> GHC.Types.False } }\r\n (GHC.Classes.<=) a_a6mH b_a6mI\r\n = GHC.Classes.not ((GHC.Classes.<) b_a6mI a_a6mH)\r\n (GHC.Classes.>) a_a6mJ b_a6mK = (GHC.Classes.<) b_a6mK a_a6mJ\r\n (GHC.Classes.>=) a_a6mL b_a6mM\r\n = GHC.Classes.not ((GHC.Classes.<) a_a6mL b_a6mM)\r\n \r\n instance GHC.Arr.Ix Ghci1.Foo where\r\n GHC.Arr.range\r\n (Ghci1.Foo a1_a6mN a2_a6mO, Ghci1.Foo b1_a6mP b2_a6mQ)\r\n = [Ghci1.Foo c1_a6mR c2_a6mS |\r\n c1_a6mR <- GHC.Arr.range (a1_a6mN, b1_a6mP),\r\n c2_a6mS <- GHC.Arr.range (a2_a6mO, b2_a6mQ)]\r\n GHC.Arr.unsafeIndex\r\n (Ghci1.Foo a1_a6mT a2_a6mU, Ghci1.Foo b1_a6mV b2_a6mW)\r\n Ghci1.Foo c1_a6mX c2_a6mY\r\n = (GHC.Arr.unsafeIndex (a2_a6mU, b2_a6mW) c2_a6mY\r\n GHC.Num.+\r\n (GHC.Arr.unsafeRangeSize (a2_a6mU, b2_a6mW)\r\n GHC.Num.* GHC.Arr.unsafeIndex (a1_a6mT, b1_a6mV) c1_a6mX))\r\n GHC.Arr.inRange\r\n (Ghci1.Foo a1_a6oj a2_a6ok, Ghci1.Foo b1_a6ol b2_a6om)\r\n Ghci1.Foo c1_a6on c2_a6oo\r\n = (GHC.Arr.inRange (a1_a6oj, b1_a6ol) c1_a6on\r\n GHC.Classes.&& GHC.Arr.inRange (a2_a6ok, b2_a6om) c2_a6oo)\r\n \r\n Ghci1.$con2tag_Hv18APskVh1Gg9kT3PCwD2 :: Ghci1.Foo -> GHC.Prim.Int#\r\n Ghci1.$con2tag_Hv18APskVh1Gg9kT3PCwD2 Ghci1.Foo _ _ = 0#\r\n Ghci1.$tFoo :: Data.Data.DataType\r\n Ghci1.$cFoo :: Data.Data.Constr\r\n Ghci1.$tFoo = Data.Data.mkDataType \"Foo\" [Ghci1.$cFoo]\r\n Ghci1.$cFoo\r\n = Data.Data.mkConstr Ghci1.$tFoo \"Foo\" [] Data.Data.Prefix\r\n}}}\r\n\r\nThere are several lines where `Foo` must be surrounded with parentheses to typecheck, but aren't. They are:\r\n\r\n* In the `Show` instance:\r\n {{{\r\n GHC.Show.showsPrec a_a8sa Ghci11.Foo b1_a8sb b2_a8sc\r\n }}}\r\n* In the `Lift` instance:\r\n {{{\r\n Language.Haskell.TH.Syntax.lift Ghci11.Foo a1_a8sd a2_a8se\r\n }}}\r\n* In the `Data` instance:\r\n {{{\r\n Data.Data.gfoldl k_a8sf z_a8sg Ghci11.Foo a1_a8sh a2_a8si\r\n ...\r\n Data.Data.toConstr Ghci11.Foo _ _ = Ghci11.$cFoo\r\n }}}\r\n* In the auxiliary bindings (technically, these aren't legal definitions in the first place, but it does look jarring):\r\n {{{\r\n Ghci11.$con2tag_GrjBmXmdiewCS4g3vLeGMg :: Ghci11.Foo -> GHC.Prim.Int#\r\n Ghci11.$con2tag_GrjBmXmdiewCS4g3vLeGMg Ghci11.Foo _ _ = 0#\r\n }}}","type_of_failure":"OtherFailure","blocking":[]} -->
issue