diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2015-12-07 12:40:38 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-07 13:09:17 +0100 |
commit | 51a5e68db887adb3565ff2f077267e2b513be562 (patch) | |
tree | 62a44143c3b5ddb6f42170dc057ec8f3292fbf1e /testsuite/tests/ghc-api | |
parent | 700c42b5e0ffd27884e6bdfa9a940e55449cff6f (diff) | |
download | haskell-51a5e68db887adb3565ff2f077267e2b513be562.tar.gz |
Refactor ConDecl
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
```lang=hs
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.
Updates haddock submodule.
Test Plan: ./validate
Reviewers: simonpj, erikd, hvr, goldfire, austin, bgamari
Subscribers: erikd, goldfire, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1558
GHC Trac Issues: #11028
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10399.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/landmines/landmines.stdout | 2 |
3 files changed, 2 insertions, 4 deletions
diff --git a/testsuite/tests/ghc-api/annotations/T10399.stdout b/testsuite/tests/ghc-api/annotations/T10399.stdout index 58a4093aae..612ecfd734 100644 --- a/testsuite/tests/ghc-api/annotations/T10399.stdout +++ b/testsuite/tests/ghc-api/annotations/T10399.stdout @@ -44,9 +44,7 @@ ((Test10399.hs:15:45-46,AnnBang), [Test10399.hs:15:45]), ((Test10399.hs:15:45-46,AnnRarrow), [Test10399.hs:15:48-49]), ((Test10399.hs:15:45-64,AnnRarrow), [Test10399.hs:15:48-49]), -((Test10399.hs:(16,5)-(17,69),AnnCloseP), [Test10399.hs:17:69]), ((Test10399.hs:(16,5)-(17,69),AnnDcolon), [Test10399.hs:16:12-13]), -((Test10399.hs:(16,5)-(17,69),AnnOpenP), [Test10399.hs:16:27]), ((Test10399.hs:(16,15)-(17,69),AnnDot), [Test10399.hs:16:25]), ((Test10399.hs:(16,15)-(17,69),AnnForall), [Test10399.hs:16:15-20]), ((Test10399.hs:(16,27)-(17,69),AnnCloseP), [Test10399.hs:17:69]), diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T index 4104bceebf..c7c8542a11 100644 --- a/testsuite/tests/ghc-api/annotations/all.T +++ b/testsuite/tests/ghc-api/annotations/all.T @@ -16,7 +16,7 @@ test('T10358', normal, run_command, ['$MAKE -s --no-print-directory T10358' test('T10278', normal, run_command, ['$MAKE -s --no-print-directory T10278']) test('T10354', normal, run_command, ['$MAKE -s --no-print-directory T10354']) test('T10396', normal, run_command, ['$MAKE -s --no-print-directory T10396']) -test('T10399', expect_broken(11028), run_command, ['$MAKE -s --no-print-directory T10399']) +test('T10399', normal, run_command, ['$MAKE -s --no-print-directory T10399']) test('T10313', normal, run_command, ['$MAKE -s --no-print-directory T10313']) test('T11018', normal, run_command, ['$MAKE -s --no-print-directory T11018']) test('bundle-export', normal, run_command, ['$MAKE -s --no-print-directory bundle-export']) diff --git a/testsuite/tests/ghc-api/landmines/landmines.stdout b/testsuite/tests/ghc-api/landmines/landmines.stdout index db0b651dfa..551b2cf8d7 100644 --- a/testsuite/tests/ghc-api/landmines/landmines.stdout +++ b/testsuite/tests/ghc-api/landmines/landmines.stdout @@ -1,4 +1,4 @@ (12,12,7) -(66,62,0) +(63,63,0) (13,13,7) (10,10,7) |