Skip to content

GHC 8.4.1 regression: rank-n types no longer parenthesized when pretty-printed

Take this file:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where

import Language.Haskell.TH

$([d| f :: (forall a. a) -> Int
      f _ = undefined |])

In GHC 8.2.2, -ddump-splices behaves as you'd expect:

$ /opt/ghc/8.2.2/bin/ghci Bug.hs
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Bug.hs:(8,3)-(9,24): Splicing declarations
    [d| f_a1zL :: (forall a_a1zM. a_a1zM) -> Int
        f_a1zL _ = undefined |]
  ======>
    f_a49Z :: (forall a_a4a0. a_a4a0) -> Int
    f_a49Z _ = undefined
Ok, one module loaded.

But in GHC 8.4.1-alpha (and HEAD), the GHC pretty-printer incorrectly leaves off the parentheses around the type (forall a. a):

$ /opt/ghc/8.4.1/bin/ghci Bug.hs
GHCi, version 8.4.0.20171222: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Bug.hs:(8,3)-(9,24): Splicing declarations
    [d| f_a1EF :: (forall a_a1EG. a_a1EG) -> Int
        f_a1EF _ = undefined |]
  ======>
    f_a4ap :: forall a_a4aq. a_a4aq -> Int
    f_a4ap _ = undefined
Ok, one module loaded.
Trac metadata
Trac field Value
Version 8.4.1-alpha1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component GHC API
Test case
Differential revisions
BlockedBy
Related
Blocking
CC alanz
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information