diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-02-13 17:15:49 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-27 09:53:52 -0500 |
commit | 5bc195b1fe788e9a900a15fbe473967850517c3e (patch) | |
tree | 83844589096791edb049f719a990004756e02114 /testsuite/tests/partial-sigs/should_compile | |
parent | 4dbacba5d2831bc80c48f3986e59b1a1c91cc620 (diff) | |
download | haskell-5bc195b1fe788e9a900a15fbe473967850517c3e.tar.gz |
Treat kind/type variables identically, demolish FKTV
Implements GHC Proposal #24: .../ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst
Fixes Trac #16334, Trac #16315
With this patch, scoping rules for type and kind variables have been
unified: kind variables no longer receieve special treatment. This
simplifies both the language and the implementation.
User-facing changes
-------------------
* Kind variables are no longer implicitly quantified when an explicit
forall is used:
p :: Proxy (a :: k) -- still accepted
p :: forall k a. Proxy (a :: k) -- still accepted
p :: forall a. Proxy (a :: k) -- no longer accepted
In other words, now we adhere to the "forall-or-nothing" rule more
strictly.
Related function: RnTypes.rnImplicitBndrs
* The -Wimplicit-kind-vars warning has been deprecated.
* Kind variables are no longer implicitly quantified in constructor
declarations:
data T a = T1 (S (a :: k) | forall (b::k). T2 (S b) -- no longer accepted
data T (a :: k) = T1 (S (a :: k) | forall (b::k). T2 (S b) -- still accepted
Related function: RnTypes.extractRdrKindSigVars
* Implicitly quantified kind variables are no longer put in front of
other variables:
f :: Proxy (a :: k) -> Proxy (b :: j)
f :: forall k j (a :: k) (b :: j). Proxy a -> Proxy b -- old order
f :: forall k (a :: k) j (b :: j). Proxy a -> Proxy b -- new order
This is a breaking change for users of TypeApplications. Note that
we still respect the dpendency order: 'k' before 'a', 'j' before 'b'.
See "Ordering of specified variables" in the User's Guide.
Related function: RnTypes.rnImplicitBndrs
* In type synonyms and type family equations, free variables on the RHS
are no longer implicitly quantified unless used in an outermost kind
annotation:
type T = Just (Nothing :: Maybe a) -- no longer accepted
type T = Just Nothing :: Maybe (Maybe a) -- still accepted
The latter form is a workaround due to temporary lack of an explicit
quantification method. Ideally, we would write something along these
lines:
type T @a = Just (Nothing :: Maybe a)
Related function: RnTypes.extractHsTyRdrTyVarsKindVars
* Named wildcards in kinds are fixed (Trac #16334):
x :: (Int :: _t) -- this compiles, infers (_t ~ Type)
Related function: RnTypes.partition_nwcs
Implementation notes
--------------------
* One of the key changes is the removal of FKTV in RnTypes:
- data FreeKiTyVars = FKTV { fktv_kis :: [Located RdrName]
- , fktv_tys :: [Located RdrName] }
+ type FreeKiTyVars = [Located RdrName]
We used to keep track of type and kind variables separately, but
now that they are on equal footing when it comes to scoping, we
can put them in the same list.
* extract_lty and family are no longer parametrized by TypeOrKind,
as we now do not distinguish kind variables from type variables.
* PatSynExPE and the related Note [Pattern synonym existentials do not scope]
have been removed (Trac #16315). With no implicit kind quantification,
we can no longer trigger the error.
* reportFloatingKvs and the related Note [Free-floating kind vars]
have been removed. With no implicit kind quantification,
we can no longer trigger the error.
Diffstat (limited to 'testsuite/tests/partial-sigs/should_compile')
7 files changed, 15 insertions, 4 deletions
diff --git a/testsuite/tests/partial-sigs/should_compile/T15039a.stderr b/testsuite/tests/partial-sigs/should_compile/T15039a.stderr index 1563a2eb23..d07ce73230 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039a.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039a.stderr @@ -27,7 +27,7 @@ T15039a.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Dict (a ~~ b)’ Where: ‘a’, ‘k’, ‘b’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict (a ~~ b) -> () + ex3 :: forall a k (b :: k). Dict (a ~~ b) -> () at T15039a.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ diff --git a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr index c28b94879b..8f9c2c8a45 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr @@ -28,7 +28,7 @@ T15039b.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] standing for ‘Dict ((a :: *) ~~ (b :: k))’ Where: ‘a’, ‘k’, ‘b’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () + ex3 :: forall a k (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () at T15039b.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ diff --git a/testsuite/tests/partial-sigs/should_compile/T15039c.stderr b/testsuite/tests/partial-sigs/should_compile/T15039c.stderr index 40c126f061..261a82e91a 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039c.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039c.stderr @@ -27,7 +27,7 @@ T15039c.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘Dict (a ~~ b)’ Where: ‘a’, ‘k’, ‘b’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict (a ~~ b) -> () + ex3 :: forall a k (b :: k). Dict (a ~~ b) -> () at T15039c.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ diff --git a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr index cca94416b8..8548356001 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr @@ -29,7 +29,7 @@ T15039d.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] standing for ‘Dict ((a :: *) ~~ (b :: k))’ Where: ‘a’, ‘k’, ‘b’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () + ex3 :: forall a k (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () at T15039d.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ diff --git a/testsuite/tests/partial-sigs/should_compile/T16334.hs b/testsuite/tests/partial-sigs/should_compile/T16334.hs new file mode 100644 index 0000000000..c01ef5cc16 --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T16334.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE NamedWildCards, PartialTypeSignatures, PolyKinds, NoStarIsType #-} + +module T16334 where + +k :: (Int :: _t) +k = 42 diff --git a/testsuite/tests/partial-sigs/should_compile/T16334.stderr b/testsuite/tests/partial-sigs/should_compile/T16334.stderr new file mode 100644 index 0000000000..83429e0d33 --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T16334.stderr @@ -0,0 +1,4 @@ + +T16334.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)] + • Found type wildcard ‘_t’ standing for ‘Type’ + • In the type signature: k :: (Int :: _t) diff --git a/testsuite/tests/partial-sigs/should_compile/all.T b/testsuite/tests/partial-sigs/should_compile/all.T index d6eaa7727a..3e62552a20 100644 --- a/testsuite/tests/partial-sigs/should_compile/all.T +++ b/testsuite/tests/partial-sigs/should_compile/all.T @@ -89,3 +89,4 @@ test('T15039b', normal, compile, ['-fprint-explicit-kinds']) test('T15039c', normal, compile, ['-fprint-equality-relations']) test('T15039d', normal, compile, ['-fprint-explicit-kinds -fprint-equality-relations']) +test('T16334', normal, compile, ['']) |