Add suggestion for PatternSynonyms parse error (fixes #12429)
[ghc.git] / compiler / parser / HaddockUtils.hs
1
2 module HaddockUtils where
3
4 import HsSyn
5 import SrcLoc
6
7 import Control.Monad
8
9 -- -----------------------------------------------------------------------------
10 -- Adding documentation to record fields (used in parsing).
11
12 addFieldDoc :: LConDeclField a -> Maybe LHsDocString -> LConDeclField a
13 addFieldDoc (L l fld) doc
14 = L l (fld { cd_fld_doc = cd_fld_doc fld `mplus` doc })
15
16 addFieldDocs :: [LConDeclField a] -> Maybe LHsDocString -> [LConDeclField a]
17 addFieldDocs [] _ = []
18 addFieldDocs (x:xs) doc = addFieldDoc x doc : xs
19
20
21 addConDoc :: LConDecl a -> Maybe LHsDocString -> LConDecl a
22 addConDoc decl Nothing = decl
23 addConDoc (L p c) doc = L p ( c { con_doc = con_doc c `mplus` doc } )
24
25 addConDocs :: [LConDecl a] -> Maybe LHsDocString -> [LConDecl a]
26 addConDocs [] _ = []
27 addConDocs [x] doc = [addConDoc x doc]
28 addConDocs (x:xs) doc = x : addConDocs xs doc
29
30 addConDocFirst :: [LConDecl a] -> Maybe LHsDocString -> [LConDecl a]
31 addConDocFirst [] _ = []
32 addConDocFirst (x:xs) doc = addConDoc x doc : xs