Skip to content
  • Vladislav Zavialov's avatar
    Pretty-printing of the * kind · 3354c68e
    Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
    Before this patch, GHC always printed the * kind unparenthesized.
    
    This led to two issues:
    
    1. Sometimes GHC printed invalid or incorrect code.
       For example, GHC would print:  type F @*   x = x
             when it meant to print:  type F @(*) x = x
       In the former case, instead of a kind application we were getting a
       type operator (@*).
    
    2. Sometimes GHC printed kinds that were correct but hard to read.
       Should  Either * Int  be read as  Either (*) Int
                                  or as  (*) Either Int  ?
       This depends on whether -XStarIsType is enabled, but it would be
       easier if we didn't have to check for the flag when reading the code.
    
    We can solve both problems by assigning (*) a different precedence. Note
    that Haskell98 kinds are not affected:
    
      ((* -> *) -> *) -> *  does NOT become  (((*) -> (*)) -> (*)) -> (*)
    
    The parentheses are added when (*) is used in a function argument
    position:
    
       F * * *   becomes  F (*) (*) (*)
       F A * B   becomes  F A (*) B
       Proxy *   becomes  Proxy (*)
       a * -> *  becomes  a (*) -> *
    3354c68e