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/polykinds | |
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/polykinds')
-rw-r--r-- | testsuite/tests/polykinds/T10503.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T11399.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T14450.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T14520.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T8566.stderr | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/testsuite/tests/polykinds/T10503.stderr b/testsuite/tests/polykinds/T10503.stderr index a47a872253..0895bdba26 100644 --- a/testsuite/tests/polykinds/T10503.stderr +++ b/testsuite/tests/polykinds/T10503.stderr @@ -13,5 +13,5 @@ T10503.hs:8:6: error: To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the type signature: h :: forall k r. - (Proxy ('KProxy :: KProxy k) ~ Proxy ('KProxy :: KProxy *) => r) + (Proxy ('KProxy :: KProxy k) ~ Proxy ('KProxy :: KProxy (*)) => r) -> r diff --git a/testsuite/tests/polykinds/T11399.stderr b/testsuite/tests/polykinds/T11399.stderr index cd78c24792..e5c9e0e37c 100644 --- a/testsuite/tests/polykinds/T11399.stderr +++ b/testsuite/tests/polykinds/T11399.stderr @@ -4,6 +4,6 @@ T11399.hs:10:32: error: When matching kinds a :: * -> * TYPE :: GHC.Types.RuntimeRep -> * - Expected kind ‘* -> *’, but ‘UhOh a’ has kind ‘a * -> *’ + Expected kind ‘* -> *’, but ‘UhOh a’ has kind ‘a (*) -> *’ • In the first argument of ‘Functor’, namely ‘(UhOh a)’ In the instance declaration for ‘Functor (UhOh a)’ diff --git a/testsuite/tests/polykinds/T14450.stderr b/testsuite/tests/polykinds/T14450.stderr index 927ae6a720..c631bade87 100644 --- a/testsuite/tests/polykinds/T14450.stderr +++ b/testsuite/tests/polykinds/T14450.stderr @@ -2,6 +2,6 @@ T14450.hs:33:3: error: • Type indexes must match class instance head Expected: Dom @k @k (IddSym0 @k) - Actual: Dom @* @* (IddSym0 @*) + Actual: Dom @(*) @(*) (IddSym0 @(*)) • In the type instance declaration for ‘Dom’ In the instance declaration for ‘Varpi (IddSym0 :: k ~> k)’ diff --git a/testsuite/tests/polykinds/T14520.stderr b/testsuite/tests/polykinds/T14520.stderr index cc7619d39b..b8a1ed1bf0 100644 --- a/testsuite/tests/polykinds/T14520.stderr +++ b/testsuite/tests/polykinds/T14520.stderr @@ -1,6 +1,6 @@ T14520.hs:15:24: error: • Expected kind ‘bat w w’, - but ‘Id’ has kind ‘XXX @a0 @* (XXX @a0 @(a0 ~>> *) kat0 b0) b0’ + but ‘Id’ has kind ‘XXX @a0 @(*) (XXX @a0 @(a0 ~>> *) kat0 b0) b0’ • In the first argument of ‘Sing’, namely ‘(Id :: bat w w)’ In the type signature: sId :: Sing w -> Sing (Id :: bat w w) diff --git a/testsuite/tests/polykinds/T8566.stderr b/testsuite/tests/polykinds/T8566.stderr index 23dddf66c7..44fae4202e 100644 --- a/testsuite/tests/polykinds/T8566.stderr +++ b/testsuite/tests/polykinds/T8566.stderr @@ -6,7 +6,7 @@ T8566.hs:34:9: error: bound by the instance declaration at T8566.hs:32:10-67 or from: 'AA t (a : as) ~ 'AA t1 as1 bound by a pattern with constructor: - A :: forall v (t :: v) (as :: [U *]) (r :: [*]). I ('AA t as) r, + A :: forall v (t :: v) (as :: [U (*)]) (r :: [*]). I ('AA t as) r, in an equation for ‘c’ at T8566.hs:34:5 The type variable ‘fs0’ is ambiguous |