aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs
index 78af98b8..38ec7d44 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs
@@ -299,7 +299,7 @@ rebindName name = do
case Map.lookup (getName name) rneCtx of
Just name' -> pure name'
Nothing | getNameRep name `Set.member` rneFV -> freshName name
- Nothing -> pure name
+ Nothing -> reuseName name
-- | Generate fresh occurrence name, put it into context and return.
@@ -316,6 +316,13 @@ freshName name = do
rep = getNameRep nname
+reuseName :: SetName name => name -> Rebind name name
+reuseName name = do
+ env@RenameEnv { .. } <- get
+ put $ env { rneCtx = Map.insert (getName name) name rneCtx }
+ return name
+
+
findFreshName :: Set NameRep -> NameRep -> NameRep
findFreshName taken =
fromJust . List.find isFresh . alternativeNames