aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-07-20 03:01:49 -0700
committerSimon Jakobi <simon.jakobi@gmail.com>2018-07-20 13:39:29 +0200
commit0b50627a7ae8bfbcfe771eac71cc1975903d118e (patch)
treeb732ed4c7881ccd7659ce550159ab87f124bb1ac /haddock-api
parent990d54c4e4a119d6d3a9ceae278eb7ca9fd24fce (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 (cherry picked from commit 133e9c2c168db19c1135479f7ab144c4e33af2a4)
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs7
-rw-r--r--haddock-api/src/Haddock/Types.hs3
2 files changed, 8 insertions, 2 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 78242990..c4df2090 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
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs
index 01083afb..6da45a3b 100644
--- a/haddock-api/src/Haddock/Types.hs
+++ b/haddock-api/src/Haddock/Types.hs
@@ -28,6 +28,7 @@ module Haddock.Types (
import Control.Exception
import Control.Arrow hiding ((<+>))
import Control.DeepSeq
+import Control.Monad.IO.Class (MonadIO(..))
import Data.Typeable
import Data.Map (Map)
import Data.Data (Data)
@@ -661,6 +662,8 @@ instance Monad ErrMsgGhc where
m >>= k = WriterGhc $ runWriterGhc m >>= \ (a, msgs1) ->
fmap (second (msgs1 ++)) (runWriterGhc (k a))
+instance MonadIO ErrMsgGhc where
+ liftIO m = WriterGhc (fmap (\x -> (x, [])) (liftIO m))
-----------------------------------------------------------------------------
-- * Pass sensitive types