From bd134c7b2a6880bf3858fd8c27fa16ab946d7718 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Mon, 31 Mar 2014 05:34:36 +0100 Subject: Print kind signatures on GADTs --- CHANGES | 2 + html-test/ref/AdvanceTypes.html | 2 +- html-test/ref/Bug85.html | 135 +++++++++++++++++++++++++++++++++++++ html-test/src/Bug85.hs | 15 +++++ src/Haddock/Backends/Xhtml/Decl.hs | 16 +++-- 5 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 html-test/ref/Bug85.html create mode 100644 html-test/src/Bug85.hs diff --git a/CHANGES b/CHANGES index be2de824..31851e5d 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 ab37fe61..b918a220 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 Pattern :: [*] -> * where

+Bug85
Safe HaskellSafe-Inferred

Bug85

Documentation

data Foo :: (* -> *) -> * -> * where

Constructors

Bar :: f x -> Foo f (f x) 

data Baz :: * where

Constructors

Baz' :: Baz 

data Qux where

Constructors

Quux :: Qux 
diff --git a/html-test/src/Bug85.hs b/html-test/src/Bug85.hs new file mode 100644 index 00000000..9c5b768b --- /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 2dc1e0e7..8884f69f 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 -- cgit v1.2.3