From 70ed9912b5400b1b2afd60cd8bd3585e3d355a5a Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Mon, 20 Jul 2015 13:59:13 +0200 Subject: Hook type renamer with instance method HTML pretty-printer. --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 6 +++++- haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'haddock-api/src/Haddock/Backends') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index f54b7c22..176180ad 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -31,6 +31,7 @@ import Haddock.Doc (combineDocumentation) import Data.List ( intersperse, sort ) import qualified Data.Map as Map +import qualified Data.Set as Set import Data.Maybe import Text.XHtml hiding ( name, title, p, quote ) @@ -540,9 +541,12 @@ ppInstanceSigs :: LinksInfo -> Splice -> Unicode -> Qualification ppInstanceSigs links splice unicode qual (InstSpec {..}) (InstHead {..}) = do TypeSig lnames (L sspan typ) _ <- ispecSigs let names = map unLoc lnames - let typ' = sugar $ specializeTyVarBndrs ispecTyVars ihdTypes typ + let typ' = rename' . sugar $ specializeTyVarBndrs ispecTyVars ihdTypes typ return $ ppFunSig False links sspan noDocForDecl names typ' [] splice unicode qual + where + fv = foldr Set.union Set.empty . map freeVariables $ ihdTypes + rename' = rename fv lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2 diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs index 4e68cb7b..3b3d95b9 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs @@ -7,6 +7,7 @@ module Haddock.Backends.Xhtml.Specialize ( specialize, specialize' , specializeTyVarBndrs , sugar, rename + , freeVariables ) where @@ -111,8 +112,8 @@ setInternalOccName occ name = nname' = mkInternalName (nameUnique nname) occ (nameSrcSpan nname) -rename :: SetName name => HsType name -> HsType name -rename = fst . evalRWS undefined Map.empty . renameType -- TODO. +rename :: SetName name => Set OccName -> HsType name -> HsType name +rename fv typ = fst $ evalRWS (renameType typ) fv Map.empty type Rename name a = RWS (Set OccName) () (Map Name name) a -- cgit v1.2.3