[Git][ghc/ghc][wip/int-index/conpat-one-list] One list in ConPat (part of #25127)
Vladislav Zavialov (@int-index)
gitlab at gitlab.haskell.org
Thu Mar 6 23:32:36 UTC 2025
Vladislav Zavialov pushed to branch wip/int-index/conpat-one-list at Glasgow Haskell Compiler / GHC
Commits:
640080a9 by Vladislav Zavialov at 2025-03-07T02:30:51+03:00
One list in ConPat (part of #25127)
This patch changes PrefixCon to use one list instead of two:
-data HsConDetails tyarg arg rec
- = PrefixCon [tyarg] [arg]
+data HsConDetails arg rec
+ = PrefixCon [arg]
| RecCon rec
| InfixCon arg arg
The [tyarg] list is now gone. To understand the effect of this change,
recall that there are three instantiations of HsConDetails:
1. type HsConPatDetails p =
HsConDetails (HsConPatTyArg (NoGhcTc p)) -- tyarg
(LPat p) -- arg
(HsRecFields p (LPat p)) -- rec
2. type HsConDeclH98Details pass =
HsConDetails Void -- tyarg
(HsScaled pass (LBangType pass)) -- arg
(XRec pass [LConDeclField pass]) -- rec
3. type HsPatSynDetails pass =
HsConDetails Void -- tyarg
(LIdP pass) -- arg
[RecordPatSynField pass] -- rec
In cases (2) and (3), tyarg was instantiated to Void, so the [tyarg]
list was always empty. Its removal is basically a no-op.
The interesting case is (1), which is used in ConPat to represent
pattern matching of the form (MkE @tp1 @tp2 p1 p2).
With this patch, its representation is changed as follows:
ConPat "MkE" [tp1, tp2] [p1, p2] -- old
ConPat "MkE" [InvisP tp1, InvisP tp2, p1, p2] -- new
The new mixed-list representation is consintent with lambdas, where
InvisP is already used to deal with \ @tp1 tp2 p1 p2 -> body.
The immediate effect of the new representation is an improvement to
error messages. Consider the pattern (Con x @t y). Previously it
resulted in a parse error because @t could not occur after x. Now it is
reported as [GHC-14964]. Test case: TyAppPat_MisplacedApplication.
In the long term, this is intended as preparation for #18389 and #25127,
which would make (Con x @t y) potentially valid, e.g. if its type is
Con :: forall a -> forall b. (a, b) -> T
The TH AST is left unchanged for the moment to avoid breakage.
- - - - -
54 changed files:
- compiler/GHC/Hs/Binds.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/Docs.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Constructor.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/GREInfo.hs
- compiler/Language/Haskell/Syntax/Binds.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Pat.hs
- compiler/Language/Haskell/Syntax/Type.hs
- testsuite/tests/ghc-api/exactprint/Test20239.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/parser/should_compile/T20452.stderr
- testsuite/tests/printer/Test24533.stdout
- testsuite/tests/rename/should_fail/T22478b.stderr
- testsuite/tests/rename/should_fail/T22478e.stderr
- testsuite/tests/rename/should_fail/T22478f.stderr
- testsuite/tests/typecheck/should_fail/T19109.stderr
- testsuite/tests/typecheck/should_fail/T23776.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_MisplacedApplication.hs
- testsuite/tests/typecheck/should_fail/TyAppPat_MisplacedApplication.stderr
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/640080a9e85c12934fea655ec6f0d70c936e30d0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/640080a9e85c12934fea655ec6f0d70c936e30d0
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/20250306/87291f72/attachment.html>
More information about the ghc-commits
mailing list