diff options
| author | Sebastian Graf <sgraf1337@gmail.com> | 2019-10-17 10:52:12 +0200 | 
|---|---|---|
| committer | Alec Theriault <alec.theriault@gmail.com> | 2019-11-04 07:02:14 -0500 | 
| commit | dacaaadfac740411e66e76b1e7b9d0ecf224b0fb (patch) | |
| tree | 4d6a3b5eb15e60c7ff4fb35306efa2490c536db5 /haddock-api/src/Haddock | |
| parent | 25991b19d75a5ddda29ee8d4815a162ed7a96ba2 (diff) | |
Define `XRec` for location information and get rid of `HasSrcSpan`
In https://gitlab.haskell.org/ghc/ghc/merge_requests/1970 I propose a
simpler way to encode location information into the GHC and Haddock AST
while incurring no cost for e.g. TH which doesn't need location
information.
These are just changes that have to happen in lock step.
Diffstat (limited to 'haddock-api/src/Haddock')
| -rw-r--r-- | haddock-api/src/Haddock/Types.hs | 19 | 
1 files changed, 3 insertions, 16 deletions
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs index c03ab385..b5659038 100644 --- a/haddock-api/src/Haddock/Types.hs +++ b/haddock-api/src/Haddock/Types.hs @@ -668,6 +668,8 @@ instance MonadIO ErrMsgGhc where  -- * Pass sensitive types  ----------------------------------------------------------------------------- +type instance XRec DocNameI f = Located (f DocNameI) +  type instance XForAllTy        DocNameI = NoExtField  type instance XQualTy          DocNameI = NoExtField  type instance XTyVar           DocNameI = NoExtField @@ -748,19 +750,4 @@ type instance XHsQTvs        DocNameI = NoExtField  type instance XConDeclField  DocNameI = NoExtField  type instance XXConDeclField DocNameI = NoExtCon -type instance XXPat DocNameI = Located (Pat DocNameI) - -type instance SrcSpanLess (LPat DocNameI) = Pat DocNameI -instance HasSrcSpan (LPat DocNameI) where -  -- NB: The following chooses the behaviour of the outer location -  --     wrapper replacing the inner ones. -  composeSrcSpan (L sp p) =  if sp == noSrcSpan -                             then p -                             else XPat (L sp (stripSrcSpanPat p)) -   -- NB: The following only returns the top-level location, if any. -  decomposeSrcSpan (XPat (L sp p)) = L sp (stripSrcSpanPat p) -  decomposeSrcSpan p               = L noSrcSpan  p - -stripSrcSpanPat :: LPat DocNameI -> Pat DocNameI -stripSrcSpanPat (XPat (L _ p)) = stripSrcSpanPat p -stripSrcSpanPat p              = p +type instance XXPat DocNameI = NoExtCon  | 
