Skip to content

Commit

Permalink
Improved declNames internal error. Added a case to handle DocD.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrnewton committed Nov 5, 2011
1 parent 2deba11 commit 8ae2b7d
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/Haddock/Interface/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@waern

waern Nov 6, 2011

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

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


Expand Down

5 comments on commit 8ae2b7d

@rrnewton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

@waern
Copy link

@waern waern commented on 8ae2b7d Nov 6, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rrnewton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rrnewton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@waern waern commented on 8ae2b7d Nov 7, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.