[commit: haddock] 2.17.3.1-spanfix, alexbiehl-patch-1, ghc-8.0, ghc-8.0-facebook, ghc-head, ghc-head1, haddock-quick, headdock-library-1.4.5, ie_avails, issue-303, issue-475, master, pr-filter-maps, pr/cabal-desc, travis, v2.16, v2.17, v2.17.3, v2.18, wip-located-module-as, wip/D2418, wip/T11080-open-data-kinds, wip/T11258, wip/T11430, wip/T12105, wip/T12105-2, wip/T12942, wip/T13163, wip/T14529, wip/T3384, wip/embelleshed-rdr, wip/new-tree-one-param, wip/rae, wip/remove-frames, wip/remove-frames1, wip/revert-ttg-2017-11-20, wip/ttg-2017-10-13, wip/ttg-2017-10-31, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13, wip/ttg6-unrevert-2017-11-22: Hook type specialization logic with HTML pretty-printer. (d6741ee)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:34:32 UTC 2017


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

On branches: 2.17.3.1-spanfix,alexbiehl-patch-1,ghc-8.0,ghc-8.0-facebook,ghc-head,ghc-head1,haddock-quick,headdock-library-1.4.5,ie_avails,issue-303,issue-475,master,pr-filter-maps,pr/cabal-desc,travis,v2.16,v2.17,v2.17.3,v2.18,wip-located-module-as,wip/D2418,wip/T11080-open-data-kinds,wip/T11258,wip/T11430,wip/T12105,wip/T12105-2,wip/T12942,wip/T13163,wip/T14529,wip/T3384,wip/embelleshed-rdr,wip/new-tree-one-param,wip/rae,wip/remove-frames,wip/remove-frames1,wip/revert-ttg-2017-11-20,wip/ttg-2017-10-13,wip/ttg-2017-10-31,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13,wip/ttg6-unrevert-2017-11-22
Link       : http://git.haskell.org/haddock.git/commitdiff/d6741ee8d407a8ac3c16e5bbddb657cab442a14c

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

commit d6741ee8d407a8ac3c16e5bbddb657cab442a14c
Author: Ɓukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Wed Jul 15 18:28:17 2015 +0200

    Hook type specialization logic with HTML pretty-printer.


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

d6741ee8d407a8ac3c16e5bbddb657cab442a14c
 haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 28 +++++++++++++++-----------
 haddock-api/src/Haddock/Types.hs               |  6 ++++++
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index 22b3422..2a82053 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -22,6 +22,7 @@ module Haddock.Backends.Xhtml.Decl (
 import Haddock.Backends.Xhtml.DocMarkup
 import Haddock.Backends.Xhtml.Layout
 import Haddock.Backends.Xhtml.Names
+import Haddock.Backends.Xhtml.Specialize
 import Haddock.Backends.Xhtml.Types
 import Haddock.Backends.Xhtml.Utils
 import Haddock.GhcUtils
@@ -493,32 +494,33 @@ ppClassDecl summary links instances fixities loc d subdocs
     ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a+++" | "+++b) $ map (ppMinimal False) fs
       where wrap | p = parens | otherwise = id
 
-    instancesBit = ppInstances links instances (Just sigs) nm splice unicode qual
+    instSpec = Just $ InstSpec { ispecSigs = sigs, ispecTyVars = ltyvars }
+    instancesBit = ppInstances links instances instSpec nm splice unicode qual
 
 ppClassDecl _ _ _ _ _ _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"
 
 
 ppInstances :: LinksInfo
-            -> [DocInstance DocName] -> Maybe [Sig DocName] -> DocName
+            -> [DocInstance DocName] -> Maybe (InstSpec DocName) -> DocName
             -> Splice -> Unicode -> Qualification
             -> Html
-ppInstances links instances msigs baseName splice unicode qual
+ppInstances links instances mspec baseName splice unicode qual
   = subInstances qual instName links True (zipWith instDecl [1..] instances)
   -- force Splice = True to use line URLs
   where
     instName = getOccString $ getName baseName
     instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName)
     instDecl iid (inst, maybeDoc,l) =
-        ((ppInstHead links splice unicode qual msigs iid inst, maybeDoc, []),l)
+        ((ppInstHead links splice unicode qual iid mspec inst, maybeDoc, []),l)
 
 
 ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification
-           -> Maybe [Sig DocName] -> Int -> InstHead DocName
+           -> Int -> Maybe (InstSpec DocName) -> InstHead DocName
            -> Html
-ppInstHead links splice unicode qual msigs iid (InstHead {..}) =
+ppInstHead links splice unicode qual iid mspec ihead@(InstHead {..}) =
     case ihdInstType of
-        ClassInst cs | Just sigs <- msigs ->
-            subClsInstance (nameStr ++ "-" ++ show iid) hdr (mets sigs)
+        ClassInst cs | Just spec <- mspec ->
+            subClsInstance (nameStr ++ "-" ++ show iid) hdr (mets spec ihead)
           where
             hdr = ppContextNoLocs cs unicode qual <+> typ
             mets = ppInstanceSigs links splice unicode qual
@@ -533,12 +535,14 @@ ppInstHead links splice unicode qual msigs iid (InstHead {..}) =
 
 
 ppInstanceSigs :: LinksInfo -> Splice -> Unicode -> Qualification
-              -> [Sig DocName]
+              -> InstSpec DocName -> InstHead DocName
               -> [Html]
-ppInstanceSigs links splice unicode qual sigs = do
-    TypeSig lnames (L sspan typ) _ <- sigs
+ppInstanceSigs links splice unicode qual (InstSpec {..}) (InstHead {..}) = do
+    TypeSig lnames (L sspan typ) _ <- ispecSigs
     let names = map unLoc lnames
-    return $ ppFunSig False links sspan noDocForDecl names typ [] splice unicode qual
+    let typ' = specializeTyVarBndrs ispecTyVars ihdTypes typ
+    return $ ppFunSig False links sspan noDocForDecl names typ' []
+        splice unicode qual
 
 
 lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs
index 5a03af6..76164b5 100644
--- a/haddock-api/src/Haddock/Types.hs
+++ b/haddock-api/src/Haddock/Types.hs
@@ -328,6 +328,12 @@ data InstHead name = InstHead
     , ihdInstType :: InstType name
     }
 
+-- | Instance details used for printing specialized method signatures.
+data InstSpec name = InstSpec
+    { ispecTyVars :: LHsTyVarBndrs name
+    , ispecSigs :: [Sig name]
+    }
+
 -----------------------------------------------------------------------------
 -- * Documentation comments
 -----------------------------------------------------------------------------



More information about the ghc-commits mailing list