diff options
Diffstat (limited to 'src/Haddock/Backends')
-rw-r--r-- | src/Haddock/Backends/Hoogle.hs | 4 | ||||
-rw-r--r-- | src/Haddock/Backends/LaTeX.hs | 37 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Decl.hs | 36 |
3 files changed, 35 insertions, 42 deletions
diff --git a/src/Haddock/Backends/Hoogle.hs b/src/Haddock/Backends/Hoogle.hs index 44e83d64..adf95636 100644 --- a/src/Haddock/Backends/Hoogle.hs +++ b/src/Haddock/Backends/Hoogle.hs @@ -143,10 +143,10 @@ ppClass x = out x{tcdSigs=[]} : addContext (TypeSig name (L l sig)) = TypeSig name (L l $ f sig) addContext _ = error "expected TypeSig" - f (HsForAllTy a b con d) = HsForAllTy a b (reL $ context : unL con) d + f (HsForAllTy a b con d) = HsForAllTy a b (reL (context : unLoc con)) d f t = HsForAllTy Implicit [] (reL [context]) (reL t) - context = reL $ HsClassP (unL $ tcdLName x) + context = nlHsTyConApp (unL $ tcdLName x) (map (reL . HsTyVar . hsTyVarName . unL) (tcdTyVars x)) diff --git a/src/Haddock/Backends/LaTeX.hs b/src/Haddock/Backends/LaTeX.hs index 27f6bd5e..d6a71f27 100644 --- a/src/Haddock/Backends/LaTeX.hs +++ b/src/Haddock/Backends/LaTeX.hs @@ -24,7 +24,7 @@ import GHC import OccName import Name ( isTyConName, nameOccName ) import RdrName ( rdrNameOcc, isRdrTc ) -import BasicTypes ( IPName(..), Boxity(..) ) +import BasicTypes ( ipNameName ) import Outputable ( Outputable, ppr, showSDoc ) import FastString ( unpackFS, unpackLitString ) @@ -450,7 +450,7 @@ rDoc = maybeDoc . fmap latexStripTrailingWhitespace ------------------------------------------------------------------------------- -ppClassHdr :: Bool -> Located [LHsPred DocName] -> DocName +ppClassHdr :: Bool -> Located [LHsType DocName] -> DocName -> [Located (HsTyVarBndr DocName)] -> [Located ([DocName], [DocName])] -> Bool -> LaTeX ppClassHdr summ lctxt n tvs fds unicode = @@ -473,7 +473,7 @@ ppClassDecl :: [DocInstance DocName] -> SrcSpan -> Maybe (Doc DocName) -> [(DocName, DocForDecl DocName)] -> TyClDecl DocName -> Bool -> LaTeX ppClassDecl instances loc mbDoc subdocs - (ClassDecl lctxt lname ltyvars lfds lsigs _ ats _) unicode + (ClassDecl lctxt lname ltyvars lfds lsigs _ ats at_defs _) unicode = declWithDoc classheader (if null body then Nothing else Just (vcat body)) $$ instancesBit where @@ -486,8 +486,8 @@ ppClassDecl instances loc mbDoc subdocs body = catMaybes [fmap docToLaTeX mbDoc, body_] body_ - | null lsigs, null ats = Nothing - | null ats = Just methodTable + | null lsigs, null ats, null at_defs = Nothing + | null ats, null at_defs = Just methodTable --- | otherwise = atTable $$ methodTable | otherwise = error "LaTeX.ppClassDecl" @@ -771,7 +771,7 @@ ppContextNoArrow [] _ = empty ppContextNoArrow cxt unicode = pp_hs_context (map unLoc cxt) unicode -ppContextNoLocs :: [HsPred DocName] -> Bool -> LaTeX +ppContextNoLocs :: [HsType DocName] -> Bool -> LaTeX ppContextNoLocs [] _ = empty ppContextNoLocs cxt unicode = pp_hs_context cxt unicode <+> darrow unicode @@ -780,17 +780,10 @@ ppContext :: HsContext DocName -> Bool -> LaTeX ppContext cxt unicode = ppContextNoLocs (map unLoc cxt) unicode -pp_hs_context :: [HsPred DocName] -> Bool -> LaTeX +pp_hs_context :: [HsType DocName] -> Bool -> LaTeX pp_hs_context [] _ = empty -pp_hs_context [p] unicode = ppPred unicode p -pp_hs_context cxt unicode = parenList (map (ppPred unicode) cxt) - - -ppPred :: Bool -> HsPred DocName -> LaTeX -ppPred unicode (HsClassP n ts) = ppAppNameTypes n (map unLoc ts) unicode -ppPred unicode (HsEqualP t1 t2) = ppLType unicode t1 <> text "~" <> ppLType unicode t2 -ppPred unicode (HsIParam (IPName n) t) - = char '?' <> ppDocName n <> dcolon unicode <> ppLType unicode t +pp_hs_context [p] unicode = ppType unicode p +pp_hs_context cxt unicode = parenList (map (ppType unicode) cxt) ------------------------------------------------------------------------------- @@ -807,9 +800,9 @@ ppBang HsNoBang = empty ppBang _ = char '!' -- Unpacked args is an implementation detail, -tupleParens :: Boxity -> [LaTeX] -> LaTeX -tupleParens Boxed = parenList -tupleParens Unboxed = ubxParenList +tupleParens :: HsTupleSort -> [LaTeX] -> LaTeX +tupleParens (HsBoxyTuple _) = parenList +tupleParens HsUnboxedTuple = ubxParenList ------------------------------------------------------------------------------- @@ -878,12 +871,16 @@ ppr_mono_ty _ (HsTupleTy con tys) u = tupleParens con (map (ppLType u) t ppr_mono_ty _ (HsKindSig ty kind) u = parens (ppr_mono_lty pREC_TOP ty u <+> dcolon u <+> ppKind kind) ppr_mono_ty _ (HsListTy ty) u = brackets (ppr_mono_lty pREC_TOP ty u) ppr_mono_ty _ (HsPArrTy ty) u = pabrackets (ppr_mono_lty pREC_TOP ty u) -ppr_mono_ty _ (HsPredTy p) u = parens (ppPred u p) +ppr_mono_ty _ (HsIParamTy n ty) u = brackets (ppDocName (ipNameName n) <+> dcolon u <+> ppr_mono_lty pREC_TOP ty u) ppr_mono_ty _ (HsSpliceTy {}) _ = error "ppr_mono_ty HsSpliceTy" ppr_mono_ty _ (HsQuasiQuoteTy {}) _ = error "ppr_mono_ty HsQuasiQuoteTy" ppr_mono_ty _ (HsRecTy {}) _ = error "ppr_mono_ty HsRecTy" ppr_mono_ty _ (HsCoreTy {}) _ = error "ppr_mono_ty HsCoreTy" +ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) unicode + = maybeParen ctxt_prec pREC_OP $ + ppr_mono_lty pREC_OP ty1 unicode <+> char '~' <+> ppr_mono_lty pREC_OP ty2 unicode + ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) unicode = maybeParen ctxt_prec pREC_CON $ hsep [ppr_mono_lty pREC_FUN fun_ty unicode, ppr_mono_lty pREC_CON arg_ty unicode] diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs index add926ab..28132046 100644 --- a/src/Haddock/Backends/Xhtml/Decl.hs +++ b/src/Haddock/Backends/Xhtml/Decl.hs @@ -32,9 +32,9 @@ import qualified Data.Map as Map import Data.Maybe import Text.XHtml hiding ( name, title, p, quote ) -import BasicTypes ( IPName(..), Boxity(..) ) import GHC import Name +import BasicTypes ( ipNameName ) import Outputable ( ppr, showSDoc, Outputable ) @@ -301,7 +301,7 @@ ppContextNoArrow [] _ _ = noHtml ppContextNoArrow cxt unicode qual = pp_hs_context (map unLoc cxt) unicode qual -ppContextNoLocs :: [HsPred DocName] -> Bool -> Qualification -> Html +ppContextNoLocs :: [HsType DocName] -> Bool -> Qualification -> Html ppContextNoLocs [] _ _ = noHtml ppContextNoLocs cxt unicode qual = pp_hs_context cxt unicode qual <+> darrow unicode @@ -311,18 +311,10 @@ ppContext :: HsContext DocName -> Bool -> Qualification -> Html ppContext cxt unicode qual = ppContextNoLocs (map unLoc cxt) unicode qual -pp_hs_context :: [HsPred DocName] -> Bool -> Qualification-> Html +pp_hs_context :: [HsType DocName] -> Bool -> Qualification-> Html pp_hs_context [] _ _ = noHtml -pp_hs_context [p] unicode qual = ppPred unicode qual p -pp_hs_context cxt unicode qual = parenList (map (ppPred unicode qual) cxt) - - -ppPred :: Bool -> Qualification -> HsPred DocName -> Html -ppPred unicode qual (HsClassP n ts) = ppAppNameTypes n (map unLoc ts) unicode qual -ppPred unicode qual (HsEqualP t1 t2) = ppLType unicode qual t1 <+> toHtml "~" - <+> ppLType unicode qual t2 -ppPred unicode qual (HsIParam (IPName n) t) - = toHtml "?" +++ ppDocName qual n <+> dcolon unicode <+> ppLType unicode qual t +pp_hs_context [p] unicode qual = ppType unicode qual p +pp_hs_context cxt unicode qual = parenList (map (ppType unicode qual) cxt) ------------------------------------------------------------------------------- @@ -330,7 +322,7 @@ ppPred unicode qual (HsIParam (IPName n) t) ------------------------------------------------------------------------------- -ppClassHdr :: Bool -> Located [LHsPred DocName] -> DocName +ppClassHdr :: Bool -> Located [LHsType DocName] -> DocName -> [Located (HsTyVarBndr DocName)] -> [Located ([DocName], [DocName])] -> Bool -> Qualification -> Html ppClassHdr summ lctxt n tvs fds unicode qual = @@ -352,7 +344,7 @@ ppFds fds unicode qual = ppShortClassDecl :: Bool -> LinksInfo -> TyClDecl DocName -> SrcSpan -> [(DocName, DocForDecl DocName)] -> Bool -> Qualification -> Html -ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _) loc +ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _ _) loc subdocs unicode qual = if null sigs && null ats then (if summary then id else topDeclElem links loc [nm]) hdr @@ -381,7 +373,7 @@ ppClassDecl :: Bool -> LinksInfo -> [DocInstance DocName] -> SrcSpan -> Maybe (Doc DocName) -> [(DocName, DocForDecl DocName)] -> TyClDecl DocName -> Bool -> Qualification -> Html ppClassDecl summary links instances loc mbDoc subdocs - decl@(ClassDecl lctxt lname ltyvars lfds lsigs _ ats _) unicode qual + decl@(ClassDecl lctxt lname ltyvars lfds lsigs _ ats _ _) unicode qual | summary = ppShortClassDecl summary links decl loc subdocs unicode qual | otherwise = classheader +++ maybeDocSection qual mbDoc +++ atBit +++ methodBit +++ instancesBit @@ -653,9 +645,9 @@ ppBang _ = toHtml "!" -- Unpacked args is an implementation detail, -- so we just show the strictness annotation -tupleParens :: Boxity -> [Html] -> Html -tupleParens Boxed = parenList -tupleParens Unboxed = ubxParenList +tupleParens :: HsTupleSort -> [Html] -> Html +tupleParens (HsBoxyTuple _) = parenList +tupleParens HsUnboxedTuple = ubxParenList -------------------------------------------------------------------------------- @@ -724,7 +716,7 @@ ppr_mono_ty _ (HsKindSig ty kind) u q = parens (ppr_mono_lty pREC_TOP ty u q <+> dcolon u <+> ppKind kind) ppr_mono_ty _ (HsListTy ty) u q = brackets (ppr_mono_lty pREC_TOP ty u q) ppr_mono_ty _ (HsPArrTy ty) u q = pabrackets (ppr_mono_lty pREC_TOP ty u q) -ppr_mono_ty _ (HsPredTy p) u q = parens (ppPred u q p) +ppr_mono_ty _ (HsIParamTy n ty) u q = brackets (ppDocName q (ipNameName n) <+> dcolon u <+> ppr_mono_lty pREC_TOP ty u q) ppr_mono_ty _ (HsSpliceTy {}) _ _ = error "ppr_mono_ty HsSpliceTy" #if __GLASGOW_HASKELL__ == 612 ppr_mono_ty _ (HsSpliceTyOut {}) _ _ = error "ppr_mono_ty HsQuasiQuoteTy" @@ -734,6 +726,10 @@ ppr_mono_ty _ (HsQuasiQuoteTy {}) _ _ = error "ppr_mono_ty HsQuasiQuoteT ppr_mono_ty _ (HsRecTy {}) _ _ = error "ppr_mono_ty HsRecTy" ppr_mono_ty _ (HsCoreTy {}) _ _ = error "ppr_mono_ty HsCoreTy" +ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) unicode qual + = maybeParen ctxt_prec pREC_OP $ + ppr_mono_lty pREC_OP ty1 unicode qual <+> char '~' <+> ppr_mono_lty pREC_OP ty2 unicode qual + ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) unicode qual = maybeParen ctxt_prec pREC_CON $ hsep [ppr_mono_lty pREC_FUN fun_ty unicode qual, ppr_mono_lty pREC_CON arg_ty unicode qual] |