Pretty-printing of the * kind
Before this patch, GHC always printed the *
kind unparenthesized.
This led to two issues:
-
Sometimes GHC printed invalid or incorrect code. For example, GHC would print
type F @* x = x
when it meant to printtype F @(*) x = x
. In the former case, instead of a kind application we were getting a type operator(@*)
. -
Sometimes GHC printed kinds that were correct but hard to read. Should
Either * Int
be read asEither (*) 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 * * *
becomesF (*) (*) (*)
-
F A * B
becomesF A (*) B
-
Proxy *
becomesProxy (*)
-
a * -> *
becomesa (*) -> *