[commit: haddock] master: Print kind signatures on GADTs (bd134c7)
git at git.haskell.org
git at git.haskell.org
Mon Mar 31 04:35:12 UTC 2014
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/bd134c7b2a6880bf3858fd8c27fa16ab946d7718
>---------------------------------------------------------------
commit bd134c7b2a6880bf3858fd8c27fa16ab946d7718
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date: Mon Mar 31 05:34:36 2014 +0100
Print kind signatures on GADTs
>---------------------------------------------------------------
bd134c7b2a6880bf3858fd8c27fa16ab946d7718
CHANGES | 2 +
html-test/ref/AdvanceTypes.html | 2 +-
html-test/ref/{Ticket253_2.html => Bug85.html} | 86 +++++++++++++++---------
html-test/src/Bug85.hs | 15 +++++
src/Haddock/Backends/Xhtml/Decl.hs | 16 +++--
5 files changed, 83 insertions(+), 38 deletions(-)
diff --git a/CHANGES b/CHANGES
index be2de82..31851e5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ Changes in version 2.15.0
* Always read in prologue files as UTF8 (#286 and Cabal #1721)
+ * Print kind signatures GADTs (#85)
+
Changes in version 2.14.1
* Render * and -> with their UnicodeSyntax equivalents if -U is enabled
diff --git a/html-test/ref/AdvanceTypes.html b/html-test/ref/AdvanceTypes.html
index ab37fe6..b918a22 100644
--- a/html-test/ref/AdvanceTypes.html
+++ b/html-test/ref/AdvanceTypes.html
@@ -50,7 +50,7 @@ window.onload = function () {pageLoad();setSynopsis("mini_AdvanceTypes.html");};
>data</span
> <a name="t:Pattern" class="def"
>Pattern</a
- > <span class="keyword"
+ > :: [*] -> * <span class="keyword"
>where</span
></p
><div class="subs constructors"
diff --git a/html-test/ref/Ticket253_2.html b/html-test/ref/Bug85.html
similarity index 58%
copy from html-test/ref/Ticket253_2.html
copy to html-test/ref/Bug85.html
index 2e20f6b..bb1f03a 100644
--- a/html-test/ref/Ticket253_2.html
+++ b/html-test/ref/Bug85.html
@@ -3,13 +3,13 @@
><head
><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/><title
- >Ticket253_2</title
+ >Bug85</title
><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
/><script src="haddock-util.js" type="text/javascript"
></script
><script type="text/javascript"
>//<![CDATA[
-window.onload = function () {pageLoad();setSynopsis("mini_Ticket253_2.html");};
+window.onload = function () {pageLoad();setSynopsis("mini_Bug85.html");};
//]]>
</script
></head
@@ -39,41 +39,35 @@ window.onload = function () {pageLoad();setSynopsis("mini_Ticket253_2.html");};
></tr
></table
><p class="caption"
- >Ticket253_2</p
- ></div
- ><div id="synopsis"
- ><p id="control.syn" class="caption expander" onclick="toggleSection('syn')"
- >Synopsis</p
- ><ul id="section.syn" class="hide" onclick="toggleSection('syn')"
- ><li class="src short"
- ><a href=""
- >bar</a
- > :: <a href=""
- >Int</a
- ></li
- ><li class="src short"
- ><span class="keyword"
- >data</span
- > <a href=""
- >Baz</a
- > = <a href=""
- >Baz</a
- ></li
- ></ul
+ >Bug85</p
></div
><div id="interface"
><h1
>Documentation</h1
><div class="top"
><p class="src"
- ><a name="v:bar" class="def"
- >bar</a
- > :: <a href=""
- >Int</a
+ ><span class="keyword"
+ >data</span
+ > <a name="t:Foo" class="def"
+ >Foo</a
+ > :: (* -> *) -> * -> * <span class="keyword"
+ >where</span
></p
- ><div class="doc"
- ><p
- >Comment</p
+ ><div class="subs constructors"
+ ><p class="caption"
+ >Constructors</p
+ ><table
+ ><tr
+ ><td class="src"
+ ><a name="v:Bar" class="def"
+ >Bar</a
+ > :: f x -> <a href=""
+ >Foo</a
+ > f (f x)</td
+ ><td class="doc empty"
+ > </td
+ ></tr
+ ></table
></div
></div
><div class="top"
@@ -82,6 +76,8 @@ window.onload = function () {pageLoad();setSynopsis("mini_Ticket253_2.html");};
>data</span
> <a name="t:Baz" class="def"
>Baz</a
+ > :: * <span class="keyword"
+ >where</span
></p
><div class="subs constructors"
><p class="caption"
@@ -89,7 +85,9 @@ window.onload = function () {pageLoad();setSynopsis("mini_Ticket253_2.html");};
><table
><tr
><td class="src"
- ><a name="v:Baz" class="def"
+ ><a name="v:Baz-39-" class="def"
+ >Baz'</a
+ > :: <a href=""
>Baz</a
></td
><td class="doc empty"
@@ -98,6 +96,32 @@ window.onload = function () {pageLoad();setSynopsis("mini_Ticket253_2.html");};
></table
></div
></div
+ ><div class="top"
+ ><p class="src"
+ ><span class="keyword"
+ >data</span
+ > <a name="t:Qux" class="def"
+ >Qux</a
+ > <span class="keyword"
+ >where</span
+ ></p
+ ><div class="subs constructors"
+ ><p class="caption"
+ >Constructors</p
+ ><table
+ ><tr
+ ><td class="src"
+ ><a name="v:Quux" class="def"
+ >Quux</a
+ > :: <a href=""
+ >Qux</a
+ ></td
+ ><td class="doc empty"
+ > </td
+ ></tr
+ ></table
+ ></div
+ ></div
></div
></div
><div id="footer"
diff --git a/html-test/src/Bug85.hs b/html-test/src/Bug85.hs
new file mode 100644
index 0000000..9c5b768
--- /dev/null
+++ b/html-test/src/Bug85.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE GADTs, KindSignatures #-}
+{-# OPTIONS_HADDOCK use-unicode #-}
+module Bug85 where
+
+-- explicitly stated non-trivial kind
+data Foo :: (* -> *) -> * -> * where
+ Bar :: f x -> Foo f (f x)
+
+-- Just kind * but explicitly written
+data Baz :: * where
+ Baz' :: Baz
+
+-- No kind signature written down at all
+data Qux where
+ Quux :: Qux
diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs
index 2dc1e0e..8884f69 100644
--- a/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/src/Haddock/Backends/Xhtml/Decl.hs
@@ -39,7 +39,6 @@ import GHC.Exts
import Name
import BooleanFormula
-
ppDecl :: Bool -> LinksInfo -> LHsDecl DocName
-> DocForDecl DocName -> [DocInstance DocName] -> [(DocName, Fixity)]
-> [(DocName, DocForDecl DocName)] -> Splice -> Unicode -> Qualification -> Html
@@ -312,7 +311,6 @@ ppDataBinderWithVars :: Bool -> TyClDecl DocName -> Html
ppDataBinderWithVars summ decl =
ppAppDocNameNames summ (tcdName decl) (tyvarNames $ tcdTyVars decl)
-
--------------------------------------------------------------------------------
-- * Type applications
--------------------------------------------------------------------------------
@@ -726,17 +724,23 @@ ppShortField summary unicode qual (ConDeclField (L _ name) ltype _)
-- | Print the LHS of a data\/newtype declaration.
-- Currently doesn't handle 'data instance' decls or kind signatures
ppDataHeader :: Bool -> TyClDecl DocName -> Unicode -> Qualification -> Html
-ppDataHeader summary decl@(DataDecl { tcdDataDefn = HsDataDefn { dd_ND = nd
- , dd_ctxt = ctxt } })
+ppDataHeader summary decl@(DataDecl { tcdDataDefn =
+ HsDataDefn { dd_ND = nd
+ , dd_ctxt = ctxt
+ , dd_kindSig = ks } })
unicode qual
= -- newtype or data
- (case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }) <+>
+ (case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" })
+ <+>
-- context
ppLContext ctxt unicode qual <+>
-- T a b c ..., or a :+: b
ppDataBinderWithVars summary decl
-ppDataHeader _ _ _ _ = error "ppDataHeader: illegal argument"
+ <+> case ks of
+ Nothing -> mempty
+ Just (L _ x) -> dcolon unicode <+> ppKind unicode qual x
+ppDataHeader _ _ _ _ = error "ppDataHeader: illegal argument"
--------------------------------------------------------------------------------
-- * Types and contexts
More information about the ghc-commits
mailing list