diff options
author | simonpj@microsoft.com <unknown> | 2009-07-02 09:46:57 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2009-07-02 09:46:57 +0000 |
commit | 432b9c9322181a3644083e3c19b7e240d90659e7 (patch) | |
tree | affb919c8731145d0353f2ec828f11304ff40ca0 /compiler/parser/HaddockUtils.hs | |
parent | 25cead299c5857b9142a82c917080a654be44b83 (diff) | |
download | haskell-432b9c9322181a3644083e3c19b7e240d90659e7.tar.gz |
New syntax for GADT-style record declarations, and associated refactoring
The main purpose of this patch is to fix Trac #3306, by fleshing out the
syntax for GADT-style record declraations so that you have a context in
the type. The new form is
data T a where
MkT :: forall a. Eq a => { x,y :: !a } -> T a
See discussion on the Trac ticket.
The old form is still allowed, but give a deprecation warning.
When we remove the old form we'll also get rid of the one reduce/reduce
error in the grammar. Hurrah!
While I was at it, I failed as usual to resist the temptation to do lots of
refactoring. The parsing of data/type declarations is now much simpler and
more uniform. Less code, less chance of errors, and more functionality.
Took longer than I planned, though.
ConDecl has record syntax, but it was not being used consistently, so I
pushed that through the compiler.
Diffstat (limited to 'compiler/parser/HaddockUtils.hs')
-rw-r--r-- | compiler/parser/HaddockUtils.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/parser/HaddockUtils.hs b/compiler/parser/HaddockUtils.hs index 70a5da25fe..ea73911c99 100644 --- a/compiler/parser/HaddockUtils.hs +++ b/compiler/parser/HaddockUtils.hs @@ -151,17 +151,16 @@ parseKey key toParse0 = -- ----------------------------------------------------------------------------- -- Adding documentation to record fields (used in parsing). -type Field a = ([Located a], LBangType a, Maybe (LHsDoc a)) +addFieldDoc :: ConDeclField a -> Maybe (LHsDoc a) -> ConDeclField a +addFieldDoc fld doc = fld { cd_fld_doc = cd_fld_doc fld `mplus` doc } -addFieldDoc :: Field a -> Maybe (LHsDoc a) -> Field a -addFieldDoc (a, b, c) doc = (a, b, c `mplus` doc) - -addFieldDocs :: [Field a] -> Maybe (LHsDoc a) -> [Field a] +addFieldDocs :: [ConDeclField a] -> Maybe (LHsDoc a) -> [ConDeclField a] addFieldDocs [] _ = [] addFieldDocs (x:xs) doc = addFieldDoc x doc : xs addConDoc :: LConDecl a -> Maybe (LHsDoc a) -> LConDecl a -addConDoc (L p c) doc = L p ( c { con_doc = con_doc c `mplus` doc } ) +addConDoc decl Nothing = decl +addConDoc (L p c) doc = L p ( c { con_doc = con_doc c `mplus` doc } ) addConDocs :: [LConDecl a] -> Maybe (LHsDoc a) -> [LConDecl a] addConDocs [] _ = [] |