diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-12-02 23:10:33 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-12-05 16:07:49 -0500 |
commit | 3354c68ec6c90bbccc0f361aa7973eeb75ea229c (patch) | |
tree | b9c5e2f9627b25b6d7bdf745b281b6771b8d5990 /testsuite/tests/partial-sigs | |
parent | c4ca29c796fa86ad9d5cd4dfa1a5cdd4e0565fb0 (diff) | |
download | haskell-3354c68ec6c90bbccc0f361aa7973eeb75ea229c.tar.gz |
Pretty-printing of the * kind
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 (*) -> *
Diffstat (limited to 'testsuite/tests/partial-sigs')
-rw-r--r-- | testsuite/tests/partial-sigs/should_compile/T15039b.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/partial-sigs/should_compile/T15039d.stderr | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr index 8f9c2c8a45..949995ddda 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr @@ -37,21 +37,21 @@ T15039b.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () (bound at T15039b.hs:25:1) T15039b.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict (Coercible @* a b)’ + • Found type wildcard ‘_’ standing for ‘Dict (Coercible @(*) a b)’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex6 :: forall a b. Dict (Coercible @* a b) -> () + ex6 :: forall a b. Dict (Coercible @(*) a b) -> () at T15039b.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () • Relevant bindings include - ex6 :: Dict (Coercible @* a b) -> () (bound at T15039b.hs:33:1) + ex6 :: Dict (Coercible @(*) a b) -> () (bound at T15039b.hs:33:1) T15039b.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible @* a b’ + • Found type wildcard ‘_’ standing for ‘Coercible @(*) a b’ Where: ‘a’, ‘b’ are rigid type variables bound by - the inferred type of ex7 :: Coercible @* a b => Coercion @{*} a b + the inferred type of ex7 :: Coercible @(*) a b => Coercion @{*} a b at T15039b.hs:36:1-14 • In the type signature: ex7 :: _ => Coercion (a :: Type) (b :: Type) diff --git a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr index 8548356001..6e26d5a1cb 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr @@ -38,21 +38,21 @@ T15039d.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () (bound at T15039d.hs:25:1) T15039d.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict (Coercible @* a b)’ + • Found type wildcard ‘_’ standing for ‘Dict (Coercible @(*) a b)’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex6 :: forall a b. Dict (Coercible @* a b) -> () + ex6 :: forall a b. Dict (Coercible @(*) a b) -> () at T15039d.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () • Relevant bindings include - ex6 :: Dict (Coercible @* a b) -> () (bound at T15039d.hs:33:1) + ex6 :: Dict (Coercible @(*) a b) -> () (bound at T15039d.hs:33:1) T15039d.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible @* a b’ + • Found type wildcard ‘_’ standing for ‘Coercible @(*) a b’ Where: ‘a’, ‘b’ are rigid type variables bound by - the inferred type of ex7 :: Coercible @* a b => Coercion @{*} a b + the inferred type of ex7 :: Coercible @(*) a b => Coercion @{*} a b at T15039d.hs:36:1-14 • In the type signature: ex7 :: _ => Coercion (a :: Type) (b :: Type) |