[commit: haddock] master: Hide minimal definition for only-method classes (48f4567)
git at git.haskell.org
git at git.haskell.org
Sat Mar 15 18:24:52 UTC 2014
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/48f45676f7c6c79b249b51dde9a6791393860676
>---------------------------------------------------------------
commit 48f45676f7c6c79b249b51dde9a6791393860676
Author: Niklas Haas <git at nand.wakku.to>
Date: Sat Mar 15 15:15:44 2014 +0100
Hide minimal definition for only-method classes
Previously this was not covered by the All xs check since here it is not
actually an All, rather a single Var n.
This also adds the previously missing html-test/src/Minimal.hs.
>---------------------------------------------------------------
48f45676f7c6c79b249b51dde9a6791393860676
html-test/ref/DeprecatedClass.html | 16 ---------------
html-test/ref/Hash.html | 8 --------
html-test/ref/Test.html | 8 --------
html-test/ref/Ticket61.html | 8 --------
html-test/src/Minimal.hs | 40 ++++++++++++++++++++++++++++++++++++
src/Haddock/Backends/Xhtml/Decl.hs | 7 ++++++-
6 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/html-test/ref/DeprecatedClass.html b/html-test/ref/DeprecatedClass.html
index 76c0c17..c8799bf 100644
--- a/html-test/ref/DeprecatedClass.html
+++ b/html-test/ref/DeprecatedClass.html
@@ -95,14 +95,6 @@ window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedClass.html")
><p
>some class</p
></div
- ><div class="subs minimal"
- ><p class="caption"
- >Minimal complete definition</p
- ><p class="src"
- ><a href="DeprecatedClass.html#v:foo"
- >foo</a
- ></p
- ></div
><div class="subs methods"
><p class="caption"
>Methods</p
@@ -135,14 +127,6 @@ window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedClass.html")
>Deprecated: SomeOtherClass</p
></div
></div
- ><div class="subs minimal"
- ><p class="caption"
- >Minimal complete definition</p
- ><p class="src"
- ><a href="DeprecatedClass.html#v:bar"
- >bar</a
- ></p
- ></div
><div class="subs methods"
><p class="caption"
>Methods</p
diff --git a/html-test/ref/Hash.html b/html-test/ref/Hash.html
index e0abc7f..eff422f 100644
--- a/html-test/ref/Hash.html
+++ b/html-test/ref/Hash.html
@@ -250,14 +250,6 @@ window.onload = function () {pageLoad();setSynopsis("mini_Hash.html");};
><p
>A class of types which can be hashed.</p
></div
- ><div class="subs minimal"
- ><p class="caption"
- >Minimal complete definition</p
- ><p class="src"
- ><a href="Hash.html#v:hash"
- >hash</a
- ></p
- ></div
><div class="subs methods"
><p class="caption"
>Methods</p
diff --git a/html-test/ref/Test.html b/html-test/ref/Test.html
index 5d738a5..fcad865 100644
--- a/html-test/ref/Test.html
+++ b/html-test/ref/Test.html
@@ -1599,14 +1599,6 @@ window.onload = function () {pageLoad();setSynopsis("mini_Test.html");};
> a <span class="keyword"
>where</span
></p
- ><div class="subs minimal"
- ><p class="caption"
- >Minimal complete definition</p
- ><p class="src"
- ><a href="Test.html#v:ff"
- >ff</a
- ></p
- ></div
><div class="subs methods"
><p class="caption"
>Methods</p
diff --git a/html-test/ref/Ticket61.html b/html-test/ref/Ticket61.html
index bc0f0c0..5a181e0 100644
--- a/html-test/ref/Ticket61.html
+++ b/html-test/ref/Ticket61.html
@@ -53,14 +53,6 @@ window.onload = function () {pageLoad();setSynopsis("mini_Ticket61.html");};
> a <span class="keyword"
>where</span
></p
- ><div class="subs minimal"
- ><p class="caption"
- >Minimal complete definition</p
- ><p class="src"
- ><a href="Ticket61.html#v:f"
- >f</a
- ></p
- ></div
><div class="subs methods"
><p class="caption"
>Methods</p
diff --git a/html-test/src/Minimal.hs b/html-test/src/Minimal.hs
new file mode 100644
index 0000000..cd2df93
--- /dev/null
+++ b/html-test/src/Minimal.hs
@@ -0,0 +1,40 @@
+-- | This tests the new MINIMAL pragma present in GHC 7.8
+module Minimal
+ ( Foo(..)
+ , Weird(..)
+ , NoMins(..)
+ , FullMin(..)
+ , PartialMin(ccc)
+ , EmptyMin(..)
+ ) where
+
+class Foo a where
+ -- | Any two of these are required...
+ foo, bar, bat :: a
+
+ -- | .. or just this
+ fooBarBat :: (a,a,a)
+
+ {-# MINIMAL (foo, bar) | (bar, bat) | (foo, bat) | fooBarBat #-}
+
+class Weird a where
+ a,b,c,d,e,f,g :: a
+
+ {-# MINIMAL ((a, b), c | (d | (e, (f | g)))) #-}
+
+class NoMins a where
+ x,y,z :: a
+
+ -- | Has a default implementation!
+ z = x
+
+class FullMin a where
+ aaa,bbb :: a
+
+class PartialMin a where
+ ccc,ddd :: a
+
+class EmptyMin a where
+ eee,fff :: a
+ eee = fff
+ fff = undefined
diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs
index 3927644..67185bf 100644
--- a/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/src/Haddock/Backends/Xhtml/Decl.hs
@@ -474,11 +474,16 @@ ppClassDecl summary links instances fixities loc d subdocs
-- type signature?
minimalBit = case [ s | L _ (MinimalSig s) <- lsigs ] of
- -- Miminal complete definition = every method
+ -- Miminal complete definition = every shown method
And xs : _ | sort [getName n | Var (L _ n) <- xs] ==
sort [getName n | L _ (TypeSig ns _) <- lsigs, L _ n <- ns]
-> noHtml
+ -- Minimal complete definition = the only shown method
+ Var (L _ n) : _ | [getName n] ==
+ [getName n' | L _ (TypeSig ns _) <- lsigs, L _ n' <- ns]
+ -> noHtml
+
-- Minimal complete definition = nothing
And [] : _ -> subMinimal $ toHtml "Nothing"
More information about the ghc-commits
mailing list