Vladislav Zavialov pushed to branch wip/int-index/curried-ctxts at Glasgow Haskell Compiler / GHC Commits: 9ac162b8 by Vladislav Zavialov at 2026-11-01T12:32:26+01:00 Curried contexts in prefix GADT constructors (#27424) Prefix GADT constructor declarations now accept multiple consecutive contexts, equivalent to a single conjoined context: data G a where MkCurried :: C a => (D a, E a) => G a MkConjoined :: (C a, D a, E a) => G a This is a step towards GHC Proposal #402 "Stable GADT constructor syntax". To represent multiple contexts, the `con_mb_cxt` field of `ConDeclGADT` has been replaced by `con_cxts`, which stores a list instead of a Maybe: - con_mb_cxt :: Maybe (LHsContext pass) + con_cxts :: [LHsContext pass] The rest of this patch follows from this change. Note that in ConDeclH98, the optional context is still stored as a Maybe. To accommodate this difference, a few helper functions were generalised over a Foldable container `t`: hsConDeclTheta :: Foldable t => t (LHsContext ...) -> [LHsType ...] pprLHsContext :: (Foldable t, ...) => t (LHsContext ...) -> SDoc repContexts :: Foldable t => t (LHsContext GhcRn) -> MetaM (Core (M TH.Cxt)) tcHsContext :: Foldable t => t (LHsContext GhcRn) -> TcM [PredType] In practice, the instantiations of `t` are either `Maybe` or `[]`. Record-style GADT constructors continue to accept at most one context. `splitLHsGadtTy` accounts for this by splitting off only the first context if it detects record syntax, leaving the offending part of the type in the body for the renamer to reject later on. Test cases: T12087a T27424a T27424b T27424c T27424d GadtConSigs_th_dump1 - - - - - 42 changed files: - changelog.d/allow-gadt-prefix-con-parens - + changelog.d/gadt-curried-contexts-27424 - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Decls.hs - compiler/Language/Haskell/Syntax/Type.hs - docs/users_guide/exts/gadt_syntax.rst - − testsuite/tests/gadt/T12087.stderr - + testsuite/tests/gadt/T12087a.hs - testsuite/tests/gadt/T12087.hs → testsuite/tests/gadt/T12087b.hs - + testsuite/tests/gadt/T12087b.stderr - + testsuite/tests/gadt/T27424a.hs - + testsuite/tests/gadt/T27424b.hs - + testsuite/tests/gadt/T27424b.stderr - testsuite/tests/gadt/all.T - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/Makefile - testsuite/tests/printer/T18791.stderr - + testsuite/tests/printer/T27424c.hs - testsuite/tests/printer/all.T - testsuite/tests/th/GadtConSigs_th_dump1.hs - testsuite/tests/th/GadtConSigs_th_dump1.stderr - + testsuite/tests/th/T27424d.hs - + testsuite/tests/th/T27424d.stderr - testsuite/tests/th/all.T - utils/check-exact/ExactPrint.hs - utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs - utils/haddock/haddock-api/src/Haddock/Convert.hs - utils/haddock/haddock-api/src/Haddock/GhcUtils.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/9ac162b800ba6face9a1b4d6f2c7e9ee... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ac162b800ba6face9a1b4d6f2c7e9ee... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help