diff options
author | Ćukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-20 13:59:13 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2015-08-21 18:22:31 +0100 |
commit | 70ed9912b5400b1b2afd60cd8bd3585e3d355a5a (patch) | |
tree | a706c7741641dd8db11521a6bf3d2f006fbc6129 /haddock-api | |
parent | 8135ce02b26385a610587abb26775055c5323b31 (diff) |
Hook type renamer with instance method HTML pretty-printer.
Diffstat (limited to 'haddock-api')
-rw-r--r-- | haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 6 | ||||
-rw-r--r-- | haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | 5 |
2 files changed, 8 insertions, 3 deletions
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 |