[commit: haddock] v2.16: Fix orphan instance collapsing (718c083)

git at git.haskell.org git at git.haskell.org
Mon Nov 20 20:59:55 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branch  : v2.16
Link       : http://git.haskell.org/haddock.git/commitdiff/718c0830ba961562bddcfd9dbe3262c660fc7b9a

>---------------------------------------------------------------

commit 718c0830ba961562bddcfd9dbe3262c660fc7b9a
Author: Oleg Grenrus <oleg.grenrus at iki.fi>
Date:   Mon Sep 28 16:37:44 2015 +0300

    Fix orphan instance collapsing


>---------------------------------------------------------------

718c0830ba961562bddcfd9dbe3262c660fc7b9a
 haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index 031b40e..6fed2e1 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -545,7 +545,7 @@ ppInstances links origin instances splice unicode qual
     instName = getOccString origin
     instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName)
     instDecl no (inst, mdoc, loc) =
-        ((ppInstHead links splice unicode qual mdoc origin no inst), loc)
+        ((ppInstHead links splice unicode qual mdoc origin False no inst), loc)
 
 
 ppOrphanInstances :: LinksInfo
@@ -560,14 +560,17 @@ ppOrphanInstances links instances splice unicode qual
 
     instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName)
     instDecl no (inst, mdoc, loc) =
-        ((ppInstHead links splice unicode qual mdoc (instOrigin inst) no inst), loc)
+        ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst), loc)
 
 
 ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification
            -> Maybe (MDoc DocName)
-           -> InstOrigin DocName -> Int -> InstHead DocName
+           -> InstOrigin DocName
+           -> Bool -- ^ Is instance orphan
+           -> Int  -- ^ Normal
+           -> InstHead DocName
            -> SubDecl
-ppInstHead links splice unicode qual mdoc origin no ihd@(InstHead {..}) =
+ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) =
     case ihdInstType of
         ClassInst { .. } ->
             ( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual <+> typ
@@ -575,7 +578,7 @@ ppInstHead links splice unicode qual mdoc origin no ihd@(InstHead {..}) =
             , [subInstDetails iid ats sigs]
             )
           where
-            iid = instanceId origin no ihd
+            iid = instanceId origin no orphan ihd
             sigs = ppInstanceSigs links splice unicode qual clsiSigs
             ats = ppInstanceAssocTys links splice unicode qual clsiAssocTys
         TypeInst rhs ->
@@ -614,8 +617,9 @@ lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2
 lookupAnySubdoc n = fromMaybe noDocForDecl . lookup n
 
 
-instanceId :: InstOrigin DocName -> Int -> InstHead DocName -> String
-instanceId origin no ihd = concat
+instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocName -> String
+instanceId origin no orphan ihd = concat $
+    [ "o:" | orphan ] ++
     [ qual origin
     , ":" ++ getOccString origin
     , ":" ++ (occNameString . getOccName . ihdClsName) ihd



More information about the ghc-commits mailing list