[commit: ghc] wip/T11028-2: Refactor ConDecl (b43b6b0)

git at git.haskell.org git at git.haskell.org
Sat Dec 5 16:09:58 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T11028-2
Link       : http://ghc.haskell.org/trac/ghc/changeset/b43b6b0c97e9f88331d04224e80b9a659606db4c/ghc

>---------------------------------------------------------------

commit b43b6b0c97e9f88331d04224e80b9a659606db4c
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Mon Nov 23 22:59:27 2015 +0200

    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


>---------------------------------------------------------------

b43b6b0c97e9f88331d04224e80b9a659606db4c
 compiler/deSugar/DsMeta.hs                         |  98 ++++++++---
 compiler/hsSyn/Convert.hs                          |  22 ++-
 compiler/hsSyn/HsDecls.hs                          | 152 +++++++---------
 compiler/hsSyn/HsLit.hs                            |   1 -
 compiler/hsSyn/HsTypes.hs                          |   4 +-
 compiler/hsSyn/HsUtils.hs                          |  26 ++-
 compiler/parser/Parser.y                           |  12 +-
 compiler/parser/RdrHsSyn.hs                        |  73 +++-----
 compiler/rename/RnEnv.hs                           |   4 +-
 compiler/rename/RnNames.hs                         |  13 +-
 compiler/rename/RnSource.hs                        | 120 +++++--------
 compiler/rename/RnTypes.hs                         |  22 ++-
 compiler/typecheck/TcHsType.hs                     |   9 +-
 compiler/typecheck/TcRnDriver.hs                   |   2 +-
 compiler/typecheck/TcTyClsDecls.hs                 | 193 +++++++++++++++------
 testsuite/tests/ghc-api/annotations/T10399.stdout  |   2 -
 testsuite/tests/ghc-api/annotations/all.T          |   2 +-
 testsuite/tests/ghc-api/landmines/landmines.stdout |   2 +-
 testsuite/tests/rename/should_compile/T5331.stderr |   2 +-
 testsuite/tests/rename/should_fail/T7943.stderr    |   6 +-
 utils/haddock                                      |   2 +-
 21 files changed, 427 insertions(+), 340 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc b43b6b0c97e9f88331d04224e80b9a659606db4c


More information about the ghc-commits mailing list