[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

#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

#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