Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512)
GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted.
Showing
- compiler/GHC/Rename/HsType.hs 1 addition, 2 deletionscompiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs 25 additions, 54 deletionscompiler/GHC/Rename/Module.hs
- docs/users_guide/9.8.1-notes.rst 16 additions, 0 deletionsdocs/users_guide/9.8.1-notes.rst
- testsuite/tests/indexed-types/should_compile/T14131.hs 5 additions, 5 deletionstestsuite/tests/indexed-types/should_compile/T14131.hs
- testsuite/tests/indexed-types/should_compile/T15852.hs 1 addition, 1 deletiontestsuite/tests/indexed-types/should_compile/T15852.hs
- testsuite/tests/indexed-types/should_compile/T15852.stderr 4 additions, 4 deletionstestsuite/tests/indexed-types/should_compile/T15852.stderr
- testsuite/tests/indexed-types/should_fail/T14230.hs 1 addition, 1 deletiontestsuite/tests/indexed-types/should_fail/T14230.hs
- testsuite/tests/indexed-types/should_fail/T7938.hs 1 addition, 1 deletiontestsuite/tests/indexed-types/should_fail/T7938.hs
- testsuite/tests/indexed-types/should_fail/T7938.stderr 1 addition, 1 deletiontestsuite/tests/indexed-types/should_fail/T7938.stderr
- testsuite/tests/rename/should_compile/T23512b.hs 9 additions, 0 deletionstestsuite/tests/rename/should_compile/T23512b.hs
- testsuite/tests/rename/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/rename/should_compile/all.T
- testsuite/tests/rename/should_fail/T23512a.hs 9 additions, 0 deletionstestsuite/tests/rename/should_fail/T23512a.hs
- testsuite/tests/rename/should_fail/T23512a.stderr 6 additions, 0 deletionstestsuite/tests/rename/should_fail/T23512a.stderr
- testsuite/tests/rename/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/rename/should_fail/all.T
- testsuite/tests/typecheck/should_fail/T15797.hs 1 addition, 1 deletiontestsuite/tests/typecheck/should_fail/T15797.hs
Loading
Please register or sign in to comment