aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2014-03-15 15:15:44 +0100
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-03-15 18:20:24 +0000
commit48f45676f7c6c79b249b51dde9a6791393860676 (patch)
tree3dd1b9c92fac4f817b0c9158d5ee008098198b6a
parent76bafc9e873ea0a75c2ad40b74310cecad89e245 (diff)
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.
-rw-r--r--html-test/ref/DeprecatedClass.html16
-rw-r--r--html-test/ref/Hash.html8
-rw-r--r--html-test/ref/Test.html8
-rw-r--r--html-test/ref/Ticket61.html8
-rw-r--r--html-test/src/Minimal.hs40
-rw-r--r--src/Haddock/Backends/Xhtml/Decl.hs7
6 files changed, 46 insertions, 41 deletions
diff --git a/html-test/ref/DeprecatedClass.html b/html-test/ref/DeprecatedClass.html
index 76c0c173..c8799bf2 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 e0abc7f6..eff422f7 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 5d738a54..fcad8657 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 bc0f0c0c..5a181e0c 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 00000000..cd2df930
--- /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 39276441..67185bff 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"