Refactor ConDecl
Summary: The ConDecl type in HsDecls is an uneasy compromise. For the most part, HsSyn directly reflects the syntax written by the programmer; and that gives just the right "pegs" on which to hang Alan's API annotations. But ConDecl doesn't properly reflect the syntax of Haskell-98 and GADT-style data type declarations. To be concrete, here's a draft new data type data ConDecl name | ConDeclGADT { con_names :: [Located name] , con_type :: LHsSigType name -- The type after the ‘::’ , con_doc :: Maybe LHsDocString } | ConDeclH98 { con_name :: Located name , con_qvars :: Maybe (LHsQTyVars name) -- User-written forall (if any), and its implicit -- kind variables -- Non-Nothing needs -XExistentialQuantification , con_cxt :: Maybe (LHsContext name) -- ^ User-written context (if any) , con_details :: HsConDeclDetails name -- ^ Arguments , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. } deriving (Typeable) Note that For GADTs, just keep a type. That's what the user writes. NB:HsType can represent records on the LHS of an arrow: { x:Int,y:Bool} -> T con_qvars and con_cxt are both Maybe because they are both optional (the forall and the context of an existential data type For ConDeclGADT the type variables of the data type do not scope over the con_type; whereas for ConDeclH98 they do scope over con_cxt and con_details. Test Plan: ./validate Reviewers: simonpj, austin, goldfire, bgamari Subscribers: goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1558 GHC Trac Issues: #11028
Showing
- compiler/deSugar/DsMeta.hs 77 additions, 21 deletionscompiler/deSugar/DsMeta.hs
- compiler/hsSyn/Convert.hs 15 additions, 7 deletionscompiler/hsSyn/Convert.hs
- compiler/hsSyn/HsDecls.hs 63 additions, 89 deletionscompiler/hsSyn/HsDecls.hs
- compiler/hsSyn/HsLit.hs 0 additions, 1 deletioncompiler/hsSyn/HsLit.hs
- compiler/hsSyn/HsTypes.hs 2 additions, 2 deletionscompiler/hsSyn/HsTypes.hs
- compiler/hsSyn/HsUtils.hs 22 additions, 4 deletionscompiler/hsSyn/HsUtils.hs
- compiler/parser/Parser.y 5 additions, 7 deletionscompiler/parser/Parser.y
- compiler/parser/RdrHsSyn.hs 20 additions, 53 deletionscompiler/parser/RdrHsSyn.hs
- compiler/rename/RnEnv.hs 3 additions, 1 deletioncompiler/rename/RnEnv.hs
- compiler/rename/RnNames.hs 12 additions, 1 deletioncompiler/rename/RnNames.hs
- compiler/rename/RnSource.hs 40 additions, 80 deletionscompiler/rename/RnSource.hs
- compiler/rename/RnTypes.hs 17 additions, 5 deletionscompiler/rename/RnTypes.hs
- compiler/typecheck/TcHsType.hs 5 additions, 4 deletionscompiler/typecheck/TcHsType.hs
- compiler/typecheck/TcRnDriver.hs 1 addition, 1 deletioncompiler/typecheck/TcRnDriver.hs
- compiler/typecheck/TcTyClsDecls.hs 136 additions, 57 deletionscompiler/typecheck/TcTyClsDecls.hs
- testsuite/tests/ghc-api/annotations/T10399.stdout 0 additions, 2 deletionstestsuite/tests/ghc-api/annotations/T10399.stdout
- testsuite/tests/ghc-api/annotations/all.T 1 addition, 1 deletiontestsuite/tests/ghc-api/annotations/all.T
- testsuite/tests/ghc-api/landmines/landmines.stdout 1 addition, 1 deletiontestsuite/tests/ghc-api/landmines/landmines.stdout
- testsuite/tests/rename/should_compile/T5331.stderr 1 addition, 1 deletiontestsuite/tests/rename/should_compile/T5331.stderr
- testsuite/tests/rename/should_fail/T7943.stderr 5 additions, 1 deletiontestsuite/tests/rename/should_fail/T7943.stderr
Loading
Please register or sign in to comment