From fbbe544c91020da143160bb8c68ee890d214a69e Mon Sep 17 00:00:00 2001
From: "Edward Z. Yang" <ezyang@cs.stanford.edu>
Date: Mon, 13 Mar 2017 03:13:10 -0700
Subject: Render signature module tree separately from modules.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
(cherry picked from commit 2067a2d0afa9cef381d26fb7140b67c62f433fc0)
---
 haddock-api/src/Haddock/Backends/Xhtml.hs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 65b427f9..34911b11 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -263,13 +263,20 @@ ppHtmlContents dflags odir doctitle _maybe_package
   themes mathjax_url maybe_index_url
   maybe_source_url maybe_wiki_url ifaces showPkgs prologue debug qual = do
   let tree = mkModuleTree dflags showPkgs
-         [(instMod iface, toInstalledDescription iface) | iface <- ifaces]
+         [(instMod iface, toInstalledDescription iface)
+         | iface <- ifaces
+         , not (instIsSig iface)]
+      sig_tree = mkModuleTree dflags showPkgs
+         [(instMod iface, toInstalledDescription iface)
+         | iface <- ifaces
+         , instIsSig iface]
       html =
         headHtml doctitle Nothing themes mathjax_url +++
         bodyHtml doctitle Nothing
           maybe_source_url maybe_wiki_url
           Nothing maybe_index_url << [
             ppPrologue qual doctitle prologue,
+            ppSignatureTree qual sig_tree,
             ppModuleTree qual tree
           ]
   createDirectoryIfMissing True odir
@@ -282,7 +289,13 @@ ppPrologue qual title (Just doc) =
   divDescription << (h1 << title +++ docElement thediv (rdrDocToHtml qual doc))
 
 
+ppSignatureTree :: Qualification -> [ModuleTree] -> Html
+ppSignatureTree qual ts =
+  divModuleList << (sectionName << "Signatures" +++ mkNodeList qual [] "n" ts)
+
+
 ppModuleTree :: Qualification -> [ModuleTree] -> Html
+ppModuleTree _ [] = mempty
 ppModuleTree qual ts =
   divModuleList << (sectionName << "Modules" +++ mkNodeList qual [] "n" ts)
 
-- 
cgit v1.2.3