Permalink
Browse files

Improved declNames internal error. Added a case to handle DocD.

  • Loading branch information...
1 parent 2deba11 commit 8ae2b7df6749d37df93a4ba5d7e3a6a2e7002b1a @rrnewton committed Nov 5, 2011
Showing with 24 additions and 3 deletions.
  1. +24 −3 src/Haddock/Interface/Create.hs
@@ -34,6 +34,8 @@ import Name
import Bag
import RdrName (GlobalRdrEnv)
+-- From GHC API:
+import Outputable(ppr, runSDoc, initSDocContext)
-- | Use a 'TypecheckedModule' to produce an 'Interface'.
-- To do this, we need access to already processed modules in the topological
@@ -263,10 +265,29 @@ declsFromClass class_ = docs ++ defs ++ sigs ++ ats
declNames :: HsDecl a -> [a]
declNames (TyClD d) = [tcdName d]
-declNames (ForD (ForeignImport n _ _ _)) = [unLoc n]
+declNames (ForD (ForeignImport n _ _)) = [unLoc n]
-- we have normal sigs only (since they are taken from ValBindsOut)
declNames (SigD sig) = sigNameNoLoc sig
-declNames _ = error "unexpected argument to declNames"
+declNames (DocD _) = []
+declNames x = error$ "unexpected argument to declNames: " ++ showHsDecl x
+
+showHsDecl x =
+ case x of
+ TyClD _ -> "TyClD" -- (TyClDecl id)
+ InstD _ -> "InstD" -- (InstDecl id)
+ DerivD _ -> "DerivD" -- (DerivDecl id)
+ ValD _ -> "ValD" -- (HsBind id)
+ SigD _ -> "SigD" -- (Sig id)
+ DefD _ -> "DefD" -- (DefaultDecl id)
+ ForD _ -> "ForD" -- (ForeignDecl id)
+ WarningD _ -> "WarningD" -- (WarnDecl id)
+ AnnD _ -> "AnnD" -- (AnnDecl id)
+ RuleD _ -> "RuleD" -- (RuleDecl id)
+ VectD _ -> "VectD" -- (VectDecl id)
+ SpliceD _ -> "SpliceD" -- (SpliceDecl id)
+ DocD _ -> "DocD" -- DocDecl
+ QuasiQuoteD _ -> "QuasiQuoteD" -- (HsQuasiQuote id)
+
-- | The top-level declarations of a module that we care about,
@@ -770,7 +791,7 @@ extractClassDecl c tvs0 (L pos (TypeSig lname ltype)) = case ltype of
_ -> L pos (TypeSig lname (noLoc (mkImplicitHsForAllTy (lctxt []) ltype)))
where
lctxt = noLoc . ctxt
- ctxt preds = nlHsTyConApp c (map toTypeNoLoc tvs0) : preds
+ ctxt preds = noLoc (HsClassP c (map toTypeNoLoc tvs0)) : preds
@waern

waern Nov 6, 2011

HsClassP is not defined in GHC HEAD, as it seems.

extractClassDecl _ _ _ = error "extractClassDecl: unexpected decl"

5 comments on commit 8ae2b7d

Owner

rrnewton replied Nov 5, 2011

I forgot to put it in the commit message but this addresses TICKET #184.

http://trac.haskell.org/haddock/ticket/184

waern replied Nov 6, 2011

Thanks for acting on this problem and for the patch! I have applied the patch and then made some further changes. However I don't understand the change on line 794, which doesn't seem to build with GHC HEAD.

Owner

rrnewton replied Nov 7, 2011

Hi David -- Ah, the benefits of code review!

This was sloppy; I must admit I have no idea where that change came from. I didn't intentionally make it. I think it must have been a glitch in my git usage of some kind? Was the changed line from somewhere in the history of the repo?

Otherwise, I must posit that gremlins changed it.

Owner

rrnewton replied Nov 7, 2011

Also, the extra import had become redundant.

I was going to fix this up but I pulled and noticed you've already overhauled it. Thanks!

waern replied Nov 7, 2011

Please sign in to comment.