[GHC] #14529: Refactor ConDecl
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The `ConDeclGADT` constructor in `ConDecl` is awful; all the information is buried. Refactor it. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Agreed, but don't use `LHsQTyVars`. This is used in `ConDeclH98`, but it shouldn't be. It should be a `[LHsTyVarBndr p]`. I've actually refactored this locally, but it's all tied up with my other very slowly-moving work. I haven't touched `ConDeclGADT` though, so by all means go ahead. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Here's what I have {{{ data ConDecl pass = ConDeclGADT { con_names :: [Located (IdP pass)] -- The next four fields describe the type after the '::' -- See Note [GADT abstract syntax] , con_forall :: Bool -- ^ True <=> explicit forall -- False => hsq_explicit is empty , con_qvars :: LHsQTyVars pass , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. } | ConDeclH98 { con_name :: Located (IdP pass) , con_forall :: Bool -- ^ True <=> explicit user-written forall -- e.g. data T a = forall b. MkT b (b->a) -- con_qvars = {b} -- False => hsq_implicit, hsq_explicit both empty , con_qvars :: LHsQTyVars pass -- Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) , con_args :: HsConDeclDetails pass -- ^ Arguments , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. } }}} `LHsQTYVars` seems right to me. I need those implicit binders. But not, I grant you, in the H98 case, because we never bind implicit variables there. I can change that too. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): The problem with `LHsQTyVars` is that every other instance of that type stores the user-written tyvars of a tycon declaration. Thus, the `kcHsTyVarBndrs` function that checks them asks for information about CUSKs, etc., which is utterly wrong for data constructors. (The reason I refactored this is that I've had to make some changes to `kcHsTyVarBndrs` in my type-level implication constraints patch, such that it no longer works at all for datacons.) Really, the right type for GADT constructors is `HsImplicitBndrs`. The problem is that you'd then have to have a tiered structure, where a `ConDeclGADT` stores an `HsImplicitBndrs` wrapped around a `ConDeclGADTDetails` or some such. It's a bit ugly. But the structure would be just right. Alternatives would be to have a `con_implicit_qvars :: [IdP pass], con_explicit_qvars :: [LHsTyVarBndr pass]`, or a new function to consume a `LHsQTyVars` from a datacon (instead of `kcHsTyVarBndrs`). Also, why change the `Maybe ...` to a `Bool` (with an invariant) to say whether or not there's a forall? The `Maybe` seems closer to the truth. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"fa29df02a1b0b926afb2525a258172dcbf0ea460/ghc" fa29df02/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="fa29df02a1b0b926afb2525a258172dcbf0ea460" Refactor ConDecl: Trac #14529 This patch refactors HsDecls.ConDecl. Specifically * ConDeclGADT was horrible, with all the information hidden inside con_res_ty. Now it's kept separate, as it should be. * ConDeclH98: use [LHsTyVarBndr] instead of LHsQTyVars for the existentials. There is no implicit binding here. * Add a field con_forall to both ConDeclGADT and ConDeclH98 which says if there is an explicit user-written forall. * Field renamings in ConDecl con_cxt to con_mb_cxt con_details to con_args There is an accompanying submodule update to Haddock. Also the following change turned out to remove a lot of clutter: * add a smart constructor for HsAppsTy, namely mkHsAppsTy, and use it consistently. This avoids a lot of painful pattern matching for the common singleton case. Two api-annotation tests (T10278, and T10399) are broken, hence marking them as expect_broken(14529). Alan is going to fix them, probably by changing the con_forall field to con_forall :: Maybe SrcSpan instead of Bool }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: alanz (added) * owner: (none) => alanz Comment: OK Alan, over to you for the `con_forall` api-annotation fix. Thanks! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * milestone: => 8.6.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * status: new => patch -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Great. But where is the patch? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4867 Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * differential: => Phab:D4867 Comment: Oops, updated the ticket -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4867 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Alan Zimmerman <alan.zimm@…>): In [changeset:"676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9/ghc" 676c575/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9" Fix API Annotations for GADT constructors Summary: This patch completes the work for #14529 by making sure that all API Annotations end up attached to a SrcSpan that appears in the final ParsedSource. Updates Haddock submodule Test Plan: ./validate Reviewers: goldfire, bgamari Subscribers: rwbarton, thomie, mpickering, carter GHC Trac Issues: #14529 Differential Revision: https://phabricator.haskell.org/D4867 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4867 Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): @bgamari, this is already on the ghc-8.6 branch? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: merge Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4867 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: 8.8.1 => 8.6.1 Comment: Not yet. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14529: Refactor ConDecl -------------------------------------+------------------------------------- Reporter: simonpj | Owner: alanz Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4867 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Correction, yes it is. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14529#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC