[Git][ghc/ghc][wip/sand-witch/pattern- at a-binders] 3 commits: Equality of forall-types is visibility aware
Andrei Borzenkov (@sand-witch)
gitlab at gitlab.haskell.org
Sun Jul 16 06:21:37 UTC 2023
Andrei Borzenkov pushed to branch wip/sand-witch/pattern- at a-binders at Glasgow Haskell Compiler / GHC
Commits:
cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00
Equality of forall-types is visibility aware
This patch finally (I hope) nails the question of whether
(forall a. ty) and (forall a -> ty)
are `eqType`: they aren't!
There is a long discussion in #22762, plus useful Notes:
* Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare
* Note [Comparing visiblities] in GHC.Core.TyCo.Compare
* Note [ForAllCo] in GHC.Core.TyCo.Rep
It also establishes a helpful new invariant for ForAllCo,
and ForAllTy, when the bound variable is a CoVar:in that
case the visibility must be coreTyLamForAllTyFlag.
All this is well documented in revised Notes.
- - - - -
7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00
List and Tuple<n>: update documentation
Add the missing changelog.md entries and @since-annotations.
- - - - -
2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00
Type patterns (#22478, #18986)
Improved name resolution and type checking of type patterns in constructors:
1. HsTyPat: a new dedicated data type that represents type patterns in
HsConPatDetails instead of reusing HsPatSigType
2. rnHsTyPat: a new function that renames a type
pattern and collects its binders into three groups:
- explicitly bound type variables, excluding locally bound
variables
- implicitly bound type variables from kind signatures
(only if ScopedTypeVariables are enabled)
- named wildcards (only from kind signatures)
2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
2b. rnImplcitTvBndrs: removed because no longer needed
3. collect_pat: updated to collect type variable binders from type patterns
(this means that types and terms use the same infrastructure to detect
conflicting bindings, unused variables and name shadowing)
3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
collection of type variables
4. tcHsTyPat: a new function that typechecks type patterns, capable of
handling polymorphic kinds.
See Note [Type patterns: binders and unifiers]
Examples of code that is now accepted:
f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing
g :: forall a. Proxy a -> ...
g (P @a) = ... -- also triggers -Wname-shadowing
h (P @($(TH.varT (TH.mkName "t")))) = ...
-- t is bound at splice time
j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected
data T where
MkT :: forall (f :: forall k. k -> Type).
f Int -> f Maybe -> T
k :: T -> ()
k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
-- f :: forall k. k -> Type
Examples of code that is rejected with better error messages:
f (Left @a @a _) = ...
-- new message:
-- • Conflicting definitions for ‘a’
-- Bound at: Test.hs:1:11
-- Test.hs:1:14
Examples of code that is now rejected:
{-# OPTIONS_GHC -Werror=unused-matches #-}
f (P @a) = ()
-- Defined but not used: type variable ‘a’
- - - - -
30 changed files:
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion.hs-boot
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Reduction.hs
- compiler/GHC/Core/TyCo/Compare.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/FVs.hs-boot
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Rename.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/Types.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5edc52ff461662864e160484cacd9a2b4c73b868...2afbddb0f24df20cfc42279bb8695f91bbd3c1e0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5edc52ff461662864e160484cacd9a2b4c73b868...2afbddb0f24df20cfc42279bb8695f91bbd3c1e0
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230716/f7114b2f/attachment.html>
More information about the ghc-commits
mailing list