aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Interface/Create.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-07-20 03:01:49 -0700
committerAlexander Biehl <alexbiehl@gmail.com>2018-07-20 12:01:49 +0200
commit133e9c2c168db19c1135479f7ab144c4e33af2a4 (patch)
tree700465ca4106165056733fc45155f7caaaa6292a /haddock-api/src/Haddock/Interface/Create.hs
parentc3eb3f0581f69e816f9453b1747a9f2a3ba02bb9 (diff)
Preserve docs on type family instances (#867)
* Preserve docs on type family instances The only problem was that the instance location was slightly off for type family instances. * Accept output
Diffstat (limited to 'haddock-api/src/Haddock/Interface/Create.hs')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index a35e2053..ced7cae5 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -419,9 +419,12 @@ mkMaps dflags pkgName gre instances decls = do
instanceMap = M.fromList [ (getSrcSpan n, n) | n <- instances ]
names :: SrcSpan -> HsDecl GhcRn -> [Name]
- names l (InstD d) = maybeToList (M.lookup loc instanceMap) -- See note [2].
+ names _ (InstD d) = maybeToList (M.lookup loc instanceMap) -- See note [2].
where loc = case d of
- TyFamInstD _ -> l -- The CoAx's loc is the whole line, but only for TFs
+ -- The CoAx's loc is the whole line, but only for TFs. The
+ -- workaround is to dig into the family instance declaration and
+ -- get the identifier with the right location.
+ TyFamInstD (TyFamInstDecl d') -> getLoc (feqn_tycon (hsib_body d'))
_ -> getInstLoc d
names l (DerivD {}) = maybeToList (M.lookup l instanceMap) -- See note [2].
names _ decl = getMainDeclBinder decl