diff --git a/CHANGES b/CHANGES
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,13 @@
+Changes in version 2.14.2
+
+ * Always drop --split-objs GHC flag for performance reasons (#292)
+
+ * Print kind signatures GADTs (#85)
+
+ * Drop single leading whitespace when reasonable from @-style blocks (#201)
+
+ * Fix crashes associated with exporting data family record selectors (#294)
+
 Changes in version 2.14.1
 
  * Render * and -> with their UnicodeSyntax equivalents if -U is enabled
@@ -96,7 +106,7 @@
 
  * Improved --qual option (no crashes, proper error messages)
 
- * A new --qual option "aliased" which qualifies identifers by the module alias
+ * A new --qual option "aliased" which qualifies identifiers by the module alias
    used in the source code
 
  * The Haddock API restores GHC's static flags after invocation
@@ -275,7 +285,7 @@
 
   * Add --use-unicode flag for displaying prettier versions of common symbols
 
-  * Mutiple verbosity levels: remove --verbose and add --verbosity=n
+  * Multiple verbosity levels: remove --verbose and add --verbosity=n
 
 -----------------------------------------------------------------------------
 
@@ -304,7 +314,7 @@
 
   * Do not indicate that a constructor argument is unboxed
 
-  * Fix problem with with non-working links to ghc-prim
+  * Fix problem with non-working links to ghc-prim
 
   * Allow referring to a specific section within a module in a module link
     (#65)
@@ -400,7 +410,7 @@
   * Haddock can generate documentation for some of the language extensions
     in GHC 6.8.2
 
-  * Format of module attributes has changed. The only way of specifiying
+  * Format of module attributes has changed. The only way of specifying
     module attributes is via a new OPTIONS_HADDOCK pragma. Example:
     {-# OPTIONS_HADDOCK hide, prune #-}
 
diff --git a/haddock.cabal b/haddock.cabal
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,5 +1,5 @@
 name:                 haddock
-version:              2.14.1
+version:              2.14.2
 synopsis:             A documentation-generation tool for Haskell libraries
 description:          Haddock is a documentation-generation tool for Haskell
                       libraries
@@ -228,7 +228,10 @@
     , vendor/attoparsec-0.10.4.0
 
   other-modules:
+      Helper
       Haddock.ParserSpec
+      Haddock.Utf8Spec
+      Haddock.Parser.UtilSpec
 
   build-depends:
       base
diff --git a/html-test/ref/A.html b/html-test/ref/A.html
--- a/html-test/ref/A.html
+++ b/html-test/ref/A.html
@@ -172,7 +172,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/AdvanceTypes.html b/html-test/ref/AdvanceTypes.html
--- a/html-test/ref/AdvanceTypes.html
+++ b/html-test/ref/AdvanceTypes.html
@@ -50,7 +50,7 @@
 	    >data</span
 	    > <a name="t:Pattern" class="def"
 	    >Pattern</a
-	    > <span class="keyword"
+	    > :: [*] -&gt; * <span class="keyword"
 	    >where</span
 	    ></p
 	  ><div class="subs constructors"
@@ -90,7 +90,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/B.html b/html-test/ref/B.html
--- a/html-test/ref/B.html
+++ b/html-test/ref/B.html
@@ -164,7 +164,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bold.html b/html-test/ref/Bold.html
--- a/html-test/ref/Bold.html
+++ b/html-test/ref/Bold.html
@@ -92,7 +92,7 @@
     ><p
       >Produced by <a href="http://www.haskell.org/haddock/"
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug1.html b/html-test/ref/Bug1.html
--- a/html-test/ref/Bug1.html
+++ b/html-test/ref/Bug1.html
@@ -95,7 +95,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug195.html b/html-test/ref/Bug195.html
--- a/html-test/ref/Bug195.html
+++ b/html-test/ref/Bug195.html
@@ -172,7 +172,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug2.html b/html-test/ref/Bug2.html
--- a/html-test/ref/Bug2.html
+++ b/html-test/ref/Bug2.html
@@ -58,7 +58,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug201.html b/html-test/ref/Bug201.html
new file mode 100644
--- /dev/null
+++ b/html-test/ref/Bug201.html
@@ -0,0 +1,102 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><title
+    >Bug201</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_Bug201.html");};
+//]]>
+</script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><ul class="links" id="page-menu"
+      ><li
+	><a href=""
+	  >Contents</a
+	  ></li
+	><li
+	><a href=""
+	  >Index</a
+	  ></li
+	></ul
+      ><p class="caption empty"
+      >&nbsp;</p
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug201</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=""
+	    >f</a
+	    > :: ()</li
+	  ><li class="src short"
+	  ><a href=""
+	    >g</a
+	    > :: ()</li
+	  ></ul
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a name="v:f" class="def"
+	    >f</a
+	    > :: ()</p
+	  ><div class="doc"
+	  ><pre
+	    >This leading whitespace
+should be dropped
+</pre
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a name="v:g" class="def"
+	    >g</a
+	    > :: ()</p
+	  ><div class="doc"
+	  ><pre
+	    > But this one
+ should not
+</pre
+	    ><pre
+	    >this should
+be dropped</pre
+	    ><pre
+	    >and so should this
+because there's a space before closing @
+</pre
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ><p
+      >Produced by <a href=""
+	>Haddock</a
+	> version 2.14.2</p
+      ></div
+    ></body
+  ></html
+>
diff --git a/html-test/ref/Bug294.html b/html-test/ref/Bug294.html
new file mode 100644
--- /dev/null
+++ b/html-test/ref/Bug294.html
@@ -0,0 +1,165 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><title
+    >Bug294</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_Bug294.html");};
+//]]>
+</script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><ul class="links" id="page-menu"
+      ><li
+	><a href=""
+	  >Contents</a
+	  ></li
+	><li
+	><a href=""
+	  >Index</a
+	  ></li
+	></ul
+      ><p class="caption empty"
+      >&nbsp;</p
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug294</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a name="t:A" class="def"
+	    >A</a
+	    ></p
+	  ><div class="subs instances"
+	  ><p id="control.i:A" class="caption collapser" onclick="toggleSection('i:A')"
+	    >Instances</p
+	    ><div id="section.i:A" class="show"
+	    ><table
+	      ><tr
+		><td class="src"
+		  ><span class="keyword"
+		    >data</span
+		    > <a href=""
+		    >DP</a
+		    > <a href=""
+		    >A</a
+		    > = <a name="v:ProblemCtor-39-" class="def"
+		    >ProblemCtor'</a
+		    > <a href=""
+		    >A</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td class="src"
+		  ><span class="keyword"
+		    >data</span
+		    > TP <a href=""
+		    >A</a
+		    > = <a name="v:ProblemCtor" class="def"
+		    >ProblemCtor</a
+		    > <a href=""
+		    >A</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		></table
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a name="v:problemField" class="def"
+	    >problemField</a
+	    > :: TO <a href=""
+	    >A</a
+	    > -&gt; <a href=""
+	    >A</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a name="v:problemField-39-" class="def"
+	    >problemField'</a
+	    > :: DO <a href=""
+	    >A</a
+	    > -&gt; <a href=""
+	    >A</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a name="v:gadtField" class="def"
+	    >gadtField</a
+	    > :: GADT <a href=""
+	    >A</a
+	    > -&gt; <a href=""
+	    >A</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a name="t:DP" class="def"
+	    >DP</a
+	    > t :: *</p
+	  ><div class="subs instances"
+	  ><p id="control.i:DP" class="caption collapser" onclick="toggleSection('i:DP')"
+	    >Instances</p
+	    ><div id="section.i:DP" class="show"
+	    ><table
+	      ><tr
+		><td class="src"
+		  ><span class="keyword"
+		    >data</span
+		    > <a href=""
+		    >DP</a
+		    > <a href=""
+		    >A</a
+		    > = <a name="v:ProblemCtor-39-" class="def"
+		    >ProblemCtor'</a
+		    > <a href=""
+		    >A</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		></table
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ><p
+      >Produced by <a href=""
+	>Haddock</a
+	> version 2.14.2</p
+      ></div
+    ></body
+  ></html
+>
diff --git a/html-test/ref/Bug3.html b/html-test/ref/Bug3.html
--- a/html-test/ref/Bug3.html
+++ b/html-test/ref/Bug3.html
@@ -75,7 +75,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug4.html b/html-test/ref/Bug4.html
--- a/html-test/ref/Bug4.html
+++ b/html-test/ref/Bug4.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug6.html b/html-test/ref/Bug6.html
--- a/html-test/ref/Bug6.html
+++ b/html-test/ref/Bug6.html
@@ -322,7 +322,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug7.html b/html-test/ref/Bug7.html
--- a/html-test/ref/Bug7.html
+++ b/html-test/ref/Bug7.html
@@ -161,7 +161,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug8.html b/html-test/ref/Bug8.html
--- a/html-test/ref/Bug8.html
+++ b/html-test/ref/Bug8.html
@@ -132,7 +132,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bug85.html b/html-test/ref/Bug85.html
new file mode 100644
--- /dev/null
+++ b/html-test/ref/Bug85.html
@@ -0,0 +1,135 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><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_Bug85.html");};
+//]]>
+</script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><ul class="links" id="page-menu"
+      ><li
+	><a href=""
+	  >Contents</a
+	  ></li
+	><li
+	><a href=""
+	  >Index</a
+	  ></li
+	></ul
+      ><p class="caption empty"
+      >&nbsp;</p
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug85</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a name="t:Foo" class="def"
+	    >Foo</a
+	    > :: (* -&gt; *) -&gt; * -&gt; * <span class="keyword"
+	    >where</span
+	    ></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 -&gt; <a href=""
+		  >Foo</a
+		  > f (f x)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a name="t:Baz" class="def"
+	    >Baz</a
+	    > :: * <span class="keyword"
+	    >where</span
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a name="v:Baz-39-" class="def"
+		  >Baz'</a
+		  > ::  <a href=""
+		  >Baz</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></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"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ><p
+      >Produced by <a href=""
+	>Haddock</a
+	> version 2.14.2</p
+      ></div
+    ></body
+  ></html
+>
diff --git a/html-test/ref/BugDeprecated.html b/html-test/ref/BugDeprecated.html
--- a/html-test/ref/BugDeprecated.html
+++ b/html-test/ref/BugDeprecated.html
@@ -182,7 +182,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/BugExportHeadings.html b/html-test/ref/BugExportHeadings.html
--- a/html-test/ref/BugExportHeadings.html
+++ b/html-test/ref/BugExportHeadings.html
@@ -198,7 +198,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Bugs.html b/html-test/ref/Bugs.html
--- a/html-test/ref/Bugs.html
+++ b/html-test/ref/Bugs.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedClass.html b/html-test/ref/DeprecatedClass.html
--- a/html-test/ref/DeprecatedClass.html
+++ b/html-test/ref/DeprecatedClass.html
@@ -148,7 +148,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedData.html b/html-test/ref/DeprecatedData.html
--- a/html-test/ref/DeprecatedData.html
+++ b/html-test/ref/DeprecatedData.html
@@ -182,7 +182,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedFunction.html b/html-test/ref/DeprecatedFunction.html
--- a/html-test/ref/DeprecatedFunction.html
+++ b/html-test/ref/DeprecatedFunction.html
@@ -100,7 +100,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedFunction2.html b/html-test/ref/DeprecatedFunction2.html
--- a/html-test/ref/DeprecatedFunction2.html
+++ b/html-test/ref/DeprecatedFunction2.html
@@ -76,7 +76,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedFunction3.html b/html-test/ref/DeprecatedFunction3.html
--- a/html-test/ref/DeprecatedFunction3.html
+++ b/html-test/ref/DeprecatedFunction3.html
@@ -76,7 +76,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedModule.html b/html-test/ref/DeprecatedModule.html
--- a/html-test/ref/DeprecatedModule.html
+++ b/html-test/ref/DeprecatedModule.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedModule2.html b/html-test/ref/DeprecatedModule2.html
--- a/html-test/ref/DeprecatedModule2.html
+++ b/html-test/ref/DeprecatedModule2.html
@@ -68,7 +68,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedNewtype.html b/html-test/ref/DeprecatedNewtype.html
--- a/html-test/ref/DeprecatedNewtype.html
+++ b/html-test/ref/DeprecatedNewtype.html
@@ -148,7 +148,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedReExport.html b/html-test/ref/DeprecatedReExport.html
--- a/html-test/ref/DeprecatedReExport.html
+++ b/html-test/ref/DeprecatedReExport.html
@@ -117,7 +117,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedRecord.html b/html-test/ref/DeprecatedRecord.html
--- a/html-test/ref/DeprecatedRecord.html
+++ b/html-test/ref/DeprecatedRecord.html
@@ -140,7 +140,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedTypeFamily.html b/html-test/ref/DeprecatedTypeFamily.html
--- a/html-test/ref/DeprecatedTypeFamily.html
+++ b/html-test/ref/DeprecatedTypeFamily.html
@@ -98,7 +98,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/DeprecatedTypeSynonym.html b/html-test/ref/DeprecatedTypeSynonym.html
--- a/html-test/ref/DeprecatedTypeSynonym.html
+++ b/html-test/ref/DeprecatedTypeSynonym.html
@@ -106,7 +106,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Examples.html b/html-test/ref/Examples.html
--- a/html-test/ref/Examples.html
+++ b/html-test/ref/Examples.html
@@ -167,7 +167,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Extensions.html b/html-test/ref/Extensions.html
--- a/html-test/ref/Extensions.html
+++ b/html-test/ref/Extensions.html
@@ -82,7 +82,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/FunArgs.html b/html-test/ref/FunArgs.html
--- a/html-test/ref/FunArgs.html
+++ b/html-test/ref/FunArgs.html
@@ -160,7 +160,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/GADTRecords.html b/html-test/ref/GADTRecords.html
--- a/html-test/ref/GADTRecords.html
+++ b/html-test/ref/GADTRecords.html
@@ -224,7 +224,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Hash.html b/html-test/ref/Hash.html
--- a/html-test/ref/Hash.html
+++ b/html-test/ref/Hash.html
@@ -317,7 +317,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/HiddenInstances.html b/html-test/ref/HiddenInstances.html
--- a/html-test/ref/HiddenInstances.html
+++ b/html-test/ref/HiddenInstances.html
@@ -156,7 +156,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/HiddenInstancesB.html b/html-test/ref/HiddenInstancesB.html
--- a/html-test/ref/HiddenInstancesB.html
+++ b/html-test/ref/HiddenInstancesB.html
@@ -132,7 +132,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Hyperlinks.html b/html-test/ref/Hyperlinks.html
--- a/html-test/ref/Hyperlinks.html
+++ b/html-test/ref/Hyperlinks.html
@@ -80,7 +80,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/IgnoreExports.html b/html-test/ref/IgnoreExports.html
--- a/html-test/ref/IgnoreExports.html
+++ b/html-test/ref/IgnoreExports.html
@@ -92,7 +92,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/ImplicitParams.html b/html-test/ref/ImplicitParams.html
--- a/html-test/ref/ImplicitParams.html
+++ b/html-test/ref/ImplicitParams.html
@@ -104,7 +104,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Minimal.html b/html-test/ref/Minimal.html
--- a/html-test/ref/Minimal.html
+++ b/html-test/ref/Minimal.html
@@ -266,7 +266,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/ModuleWithWarning.html b/html-test/ref/ModuleWithWarning.html
--- a/html-test/ref/ModuleWithWarning.html
+++ b/html-test/ref/ModuleWithWarning.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/NamedDoc.html b/html-test/ref/NamedDoc.html
--- a/html-test/ref/NamedDoc.html
+++ b/html-test/ref/NamedDoc.html
@@ -60,7 +60,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Nesting.html b/html-test/ref/Nesting.html
--- a/html-test/ref/Nesting.html
+++ b/html-test/ref/Nesting.html
@@ -287,7 +287,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/NoLayout.html b/html-test/ref/NoLayout.html
--- a/html-test/ref/NoLayout.html
+++ b/html-test/ref/NoLayout.html
@@ -78,7 +78,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/NonGreedy.html b/html-test/ref/NonGreedy.html
--- a/html-test/ref/NonGreedy.html
+++ b/html-test/ref/NonGreedy.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Operators.html b/html-test/ref/Operators.html
--- a/html-test/ref/Operators.html
+++ b/html-test/ref/Operators.html
@@ -450,7 +450,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/PatternSyns.html b/html-test/ref/PatternSyns.html
--- a/html-test/ref/PatternSyns.html
+++ b/html-test/ref/PatternSyns.html
@@ -234,7 +234,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Properties.html b/html-test/ref/Properties.html
--- a/html-test/ref/Properties.html
+++ b/html-test/ref/Properties.html
@@ -84,7 +84,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/PruneWithWarning.html b/html-test/ref/PruneWithWarning.html
--- a/html-test/ref/PruneWithWarning.html
+++ b/html-test/ref/PruneWithWarning.html
@@ -63,7 +63,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/QuasiExpr.html b/html-test/ref/QuasiExpr.html
--- a/html-test/ref/QuasiExpr.html
+++ b/html-test/ref/QuasiExpr.html
@@ -214,7 +214,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/QuasiQuote.html b/html-test/ref/QuasiQuote.html
--- a/html-test/ref/QuasiQuote.html
+++ b/html-test/ref/QuasiQuote.html
@@ -58,7 +58,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/SpuriousSuperclassConstraints.html b/html-test/ref/SpuriousSuperclassConstraints.html
--- a/html-test/ref/SpuriousSuperclassConstraints.html
+++ b/html-test/ref/SpuriousSuperclassConstraints.html
@@ -114,7 +114,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TH.html b/html-test/ref/TH.html
--- a/html-test/ref/TH.html
+++ b/html-test/ref/TH.html
@@ -56,7 +56,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TH2.html b/html-test/ref/TH2.html
--- a/html-test/ref/TH2.html
+++ b/html-test/ref/TH2.html
@@ -56,7 +56,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Test.html b/html-test/ref/Test.html
--- a/html-test/ref/Test.html
+++ b/html-test/ref/Test.html
@@ -2142,7 +2142,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Ticket112.html b/html-test/ref/Ticket112.html
--- a/html-test/ref/Ticket112.html
+++ b/html-test/ref/Ticket112.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Ticket253_1.html b/html-test/ref/Ticket253_1.html
--- a/html-test/ref/Ticket253_1.html
+++ b/html-test/ref/Ticket253_1.html
@@ -84,7 +84,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Ticket253_2.html b/html-test/ref/Ticket253_2.html
--- a/html-test/ref/Ticket253_2.html
+++ b/html-test/ref/Ticket253_2.html
@@ -104,7 +104,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Ticket61.html b/html-test/ref/Ticket61.html
--- a/html-test/ref/Ticket61.html
+++ b/html-test/ref/Ticket61.html
@@ -72,7 +72,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Ticket75.html b/html-test/ref/Ticket75.html
--- a/html-test/ref/Ticket75.html
+++ b/html-test/ref/Ticket75.html
@@ -108,7 +108,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TitledPicture.html b/html-test/ref/TitledPicture.html
--- a/html-test/ref/TitledPicture.html
+++ b/html-test/ref/TitledPicture.html
@@ -102,7 +102,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TypeFamilies.html b/html-test/ref/TypeFamilies.html
--- a/html-test/ref/TypeFamilies.html
+++ b/html-test/ref/TypeFamilies.html
@@ -1046,7 +1046,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TypeFamilies2.html b/html-test/ref/TypeFamilies2.html
--- a/html-test/ref/TypeFamilies2.html
+++ b/html-test/ref/TypeFamilies2.html
@@ -222,7 +222,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/TypeOperators.html b/html-test/ref/TypeOperators.html
--- a/html-test/ref/TypeOperators.html
+++ b/html-test/ref/TypeOperators.html
@@ -166,7 +166,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Unicode.html b/html-test/ref/Unicode.html
--- a/html-test/ref/Unicode.html
+++ b/html-test/ref/Unicode.html
@@ -74,7 +74,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/ref/Visible.html b/html-test/ref/Visible.html
--- a/html-test/ref/Visible.html
+++ b/html-test/ref/Visible.html
@@ -60,7 +60,7 @@
     ><p
       >Produced by <a href=""
 	>Haddock</a
-	> version 2.14.1</p
+	> version 2.14.2</p
       ></div
     ></body
   ></html
diff --git a/html-test/src/Bug201.hs b/html-test/src/Bug201.hs
new file mode 100644
--- /dev/null
+++ b/html-test/src/Bug201.hs
@@ -0,0 +1,28 @@
+-- We test that leading whitespace gets properly dropped (or not!)
+-- from codeblocks
+module Bug201 where
+
+-- |
+-- @
+-- This leading whitespace
+-- should be dropped
+-- @
+f :: ()
+f = ()
+
+{-|
+@
+ But this one
+ should not
+@
+
+> this should
+> be dropped
+
+@
+ and so should this
+ because there's a space before closing @
+ @
+-}
+g :: ()
+g = ()
diff --git a/html-test/src/Bug294.hs b/html-test/src/Bug294.hs
new file mode 100644
--- /dev/null
+++ b/html-test/src/Bug294.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE TypeFamilies, FlexibleInstances, GADTs #-}
+-- This tests that we are able to extract record selectors for
+-- associated types when the type itself is not exported. Making this
+-- bug exhibit is very simple: simply mention a record field defined
+-- inside of the associated type anywhere in the export list.
+--
+-- Note: ProblemCtor only shows up when T or A are exported but PolyCtor
+-- only shows up when the class is exported as well, since it's polymorphic.
+module Bug294 ( A, problemField, problemField', gadtField
+              , TP(ProblemCtor), DP(ProblemCtor'), TO'(PolyCtor)) where
+
+data A
+
+class T t where
+  data TO t :: *
+  data TP t :: *
+
+  t :: t
+
+instance T A where
+  data TO A = TA { problemField :: A }
+  data TP A = ProblemCtor A
+
+data family DO t :: *
+data family DP t :: *
+
+data instance DO A = DA { problemField' :: A }
+data instance DP A = ProblemCtor' A
+
+data GADT :: * -> * where
+  Ctor :: { gadtField :: A } -> GADT A
+
+class T' t where
+  data TO' t :: *
+
+instance T' a where
+  data TO' a = PolyCtor
diff --git a/html-test/src/Bug85.hs b/html-test/src/Bug85.hs
new file mode 100644
--- /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.hs b/src/Haddock.hs
--- a/src/Haddock.hs
+++ b/src/Haddock.hs
@@ -314,22 +314,20 @@
 -- | Start a GHC session with the -haddock flag set. Also turn off
 -- compilation and linking. Then run the given 'Ghc' action.
 withGhc :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
-withGhc libDir flags ghcActs = do
-  runGhc (Just libDir) $ do
-    dynflags  <- getSessionDynFlags
-    let dynflags' = gopt_set dynflags Opt_Haddock
-    let dynflags'' = dynflags' {
-        hscTarget = HscNothing,
-        ghcMode   = CompManager,
-        ghcLink   = NoLink
-      }
-    dynflags''' <- parseGhcFlags dynflags''
-    defaultCleanupHandler dynflags''' $ do
-        -- ignore the following return-value, which is a list of packages
-        -- that may need to be re-linked: Haddock doesn't do any
-        -- dynamic or static linking at all!
-        _ <- setSessionDynFlags dynflags'''
-        ghcActs dynflags'''
+withGhc libDir flags ghcActs = runGhc (Just libDir) $ do
+  dynflags  <- getSessionDynFlags
+  dynflags' <- parseGhcFlags (gopt_set dynflags Opt_Haddock) {
+    hscTarget = HscNothing,
+    ghcMode   = CompManager,
+    ghcLink   = NoLink
+    }
+  let dynflags'' = gopt_unset dynflags' Opt_SplitObjs
+  defaultCleanupHandler dynflags'' $ do
+      -- ignore the following return-value, which is a list of packages
+      -- that may need to be re-linked: Haddock doesn't do any
+      -- dynamic or static linking at all!
+      _ <- setSessionDynFlags dynflags''
+      ghcActs dynflags''
   where
     parseGhcFlags :: MonadIO m => DynFlags -> m DynFlags
     parseGhcFlags dynflags = do
diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs
--- a/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/src/Haddock/Backends/Xhtml/Decl.hs
@@ -39,7 +39,6 @@
 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 summ decl =
   ppAppDocNameNames summ (tcdName decl) (tyvarNames $ tcdTyVars decl)
 
-
 --------------------------------------------------------------------------------
 -- * Type applications
 --------------------------------------------------------------------------------
@@ -726,17 +724,23 @@
 -- | 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
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -767,21 +767,33 @@
   | name `elem` getMainDeclBinder (unLoc decl) = decl
   | otherwise  =
     case unLoc decl of
-      TyClD d | isClassDecl d ->
+      TyClD d@ClassDecl {} ->
         let matches = [ sig | sig <- tcdSigs d, name `elem` sigName sig,
                         isVanillaLSig sig ] -- TODO: document fixity
         in case matches of
-          [s0] -> let (n, tyvar_names) = name_and_tyvars d
+          [s0] -> let (n, tyvar_names) = (tcdName d, getTyVars d)
                       L pos sig = extractClassDecl n tyvar_names s0
                   in L pos (SigD sig)
-          _ -> error "internal: extractDecl"
-      TyClD d | isDataDecl d ->
-        let (n, tyvar_names) = name_and_tyvars d
-            L pos sig = extractRecSel name mdl n tyvar_names (dd_cons (tcdDataDefn d))
-        in L pos (SigD sig)
+          _ -> error "internal: extractDecl (ClassDecl)"
+      TyClD d@DataDecl {} ->
+        let (n, tyvar_names) = (tcdName d, map toTypeNoLoc $ getTyVars d)
+        in SigD <$> extractRecSel name mdl n tyvar_names (dd_cons (tcdDataDefn d))
+      InstD (DataFamInstD DataFamInstDecl { dfid_tycon = L _ n
+                                          , dfid_pats = HsWB { hswb_cts = tys }
+                                          , dfid_defn = defn }) ->
+        SigD <$> extractRecSel name mdl n tys (dd_cons defn)
+      InstD (ClsInstD ClsInstDecl { cid_datafam_insts = insts }) ->
+        let matches = [ d | L _ d <- insts
+                          , L _ ConDecl { con_details = RecCon rec } <- dd_cons (dfid_defn d)
+                          , ConDeclField { cd_fld_name = L _ n } <- rec
+                          , n == name
+                      ]
+        in case matches of
+          [d0] -> extractDecl name mdl (noLoc . InstD $ DataFamInstD d0)
+          _ -> error "internal: extractDecl (ClsInstD)"
       _ -> error "internal: extractDecl"
   where
-    name_and_tyvars d = (tcdName d, hsLTyVarLocNames (tyClDeclTyVars d))
+    getTyVars = hsLTyVarLocNames . tyClDeclTyVars
 
 
 toTypeNoLoc :: Located Name -> LHsType Name
@@ -799,7 +811,7 @@
 extractClassDecl _ _ _ = error "extractClassDecl: unexpected decl"
 
 
-extractRecSel :: Name -> Module -> Name -> [Located Name] -> [LConDecl Name]
+extractRecSel :: Name -> Module -> Name -> [LHsType Name] -> [LConDecl Name]
               -> LSig Name
 extractRecSel _ _ _ _ [] = error "extractRecSel: selector not found"
 
@@ -810,7 +822,9 @@
     _ -> extractRecSel nm mdl t tvs rest
  where
   matching_fields flds = [ f | f@(ConDeclField n _ _) <- flds, unLoc n == nm ]
-  data_ty = foldl (\x y -> noLoc (HsAppTy x y)) (noLoc (HsTyVar t)) (map toTypeNoLoc tvs)
+  data_ty
+    | ResTyGADT ty <- con_res con = ty
+    | otherwise = foldl' (\x y -> noLoc (HsAppTy x y)) (noLoc (HsTyVar t)) tvs
 
 
 -- | Keep export items with docs.
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -2,6 +2,7 @@
 {-# LANGUAGE StandaloneDeriving
              , FlexibleInstances, UndecidableInstances
              , IncoherentInstances #-}
+{-# LANGUAGE LambdaCase #-}
 -- |
 -- Module      :  Haddock.Parser
 -- Copyright   :  (c) Mateusz Kowalczyk 2013,
@@ -21,7 +22,7 @@
 import           Data.Attoparsec.ByteString.Char8 hiding (parse, take, endOfLine)
 import qualified Data.ByteString.Char8 as BS
 import           Data.Char (chr, isAsciiUpper)
-import           Data.List (stripPrefix, intercalate)
+import           Data.List (stripPrefix, intercalate, unfoldr)
 import           Data.Maybe (fromMaybe)
 import           Data.Monoid
 import           DynFlags
@@ -59,7 +60,8 @@
     p :: Parser (Doc RdrName)
     p = mconcat <$> paragraph d `sepBy` many (skipHorizontalSpace *> "\n")
 
--- | Parse a text paragraph.
+-- | Parse a text paragraph. Actually just a wrapper over 'parseStringBS' which
+-- drops leading whitespace and encodes the string to UTF8 first.
 parseString :: DynFlags -> String -> Doc RdrName
 parseString d = parseStringBS d . encodeUtf8 . dropWhile isSpace
 
@@ -366,8 +368,31 @@
 -- for markup.
 codeblock :: DynFlags -> Parser (Doc RdrName)
 codeblock d =
-  DocCodeBlock . parseStringBS d <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
+  DocCodeBlock . parseStringBS d . dropSpaces
+  <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
   where
+    dropSpaces xs =
+      let rs = decodeUtf8 xs
+      in case splitByNl rs of
+        [] -> xs
+        ys -> case last ys of
+          ' ':_ -> case mapM dropSpace ys of
+            Nothing -> xs
+            Just zs -> encodeUtf8 $ intercalate "\n" zs
+          _ -> xs
+
+    -- This is necessary because ‘lines’ swallows up a trailing newline
+    -- and we lose information about whether the last line belongs to @ or to
+    -- text which we need to decide whether we actually want to be dropping
+    -- anything at all.
+    splitByNl = unfoldr (\case '\n':s -> Just (span (/= '\n') s)
+                               _ -> Nothing)
+                . ('\n' :)
+
+    dropSpace "" = Just ""
+    dropSpace (' ':xs) = Just xs
+    dropSpace _ = Nothing
+
     block' = scan False p
       where
         p isNewline c
diff --git a/test/Haddock/Parser/UtilSpec.hs b/test/Haddock/Parser/UtilSpec.hs
new file mode 100644
--- /dev/null
+++ b/test/Haddock/Parser/UtilSpec.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Haddock.Parser.UtilSpec (main, spec) where
+
+import           Test.Hspec
+import           Data.Either
+
+import           Data.Attoparsec.ByteString.Char8
+import           Haddock.Parser.Util
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = do
+  describe "takeUntil" $ do
+    it "takes everything until a specified byte sequence" $ do
+      parseOnly (takeUntil "end") "someend" `shouldBe` Right "some"
+
+    it "requires the end sequence" $ do
+      parseOnly (takeUntil "end") "someen" `shouldSatisfy` isLeft
+
+    it "takes escaped bytes unconditionally" $ do
+      parseOnly (takeUntil "end") "some\\endend" `shouldBe` Right "some\\end"
diff --git a/test/Haddock/ParserSpec.hs b/test/Haddock/ParserSpec.hs
--- a/test/Haddock/ParserSpec.hs
+++ b/test/Haddock/ParserSpec.hs
@@ -432,12 +432,34 @@
           ] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n"
 
       it "accepts horizontal space before the @" $ do
+        unlines [ "     @"
+                , "foo"
+                , ""
+                , "bar"
+                , "@"
+                ] `shouldParseTo` DocCodeBlock "foo\n\nbar\n"
+
+      it "strips a leading space from a @ block if present" $ do
         unlines [ " @"
-                , " foo"
+                , " hello"
+                , " world"
+                , " @"
+                ] `shouldParseTo` DocCodeBlock "hello\nworld\n"
+
+        unlines [ " @"
+                , " hello"
                 , ""
-                , " bar"
+                , " world"
                 , " @"
-                ] `shouldParseTo` DocCodeBlock " foo\n\n bar\n "
+                ] `shouldParseTo` DocCodeBlock "hello\n\nworld\n"
+
+      it "only drops whitespace if there's some before closing @" $ do
+        unlines [ "@"
+                , "    Formatting"
+                , "        matters."
+                , "@"
+                ]
+          `shouldParseTo` DocCodeBlock "    Formatting\n        matters.\n"
 
       it "accepts unicode" $ do
         "@foo 灼眼のシャナ bar@" `shouldParseTo` DocCodeBlock "foo 灼眼のシャナ bar"
diff --git a/test/Haddock/Utf8Spec.hs b/test/Haddock/Utf8Spec.hs
new file mode 100644
--- /dev/null
+++ b/test/Haddock/Utf8Spec.hs
@@ -0,0 +1,15 @@
+module Haddock.Utf8Spec (main, spec) where
+
+import           Test.Hspec
+import           Test.QuickCheck
+
+import           Haddock.Utf8
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = do
+  describe "decodeUtf8" $ do
+    it "is inverse to encodeUtf8" $ do
+      property $ \xs -> (decodeUtf8 . encodeUtf8) xs `shouldBe` xs
diff --git a/test/Helper.hs b/test/Helper.hs
new file mode 100644
--- /dev/null
+++ b/test/Helper.hs
@@ -0,0 +1,183 @@
+module Helper where
+import           DynFlags (Settings(..), DynFlags, defaultDynFlags)
+import           Platform
+import           PlatformConstants
+
+dynFlags :: DynFlags
+dynFlags = defaultDynFlags settings
+  where
+    settings = Settings {
+        sTargetPlatform = platform
+      , sGhcUsagePath = error "Haddock.ParserSpec.sGhcUsagePath"
+      , sGhciUsagePath = error "Haddock.ParserSpec.sGhciUsagePath"
+      , sTopDir = error "Haddock.ParserSpec.sTopDir"
+      , sTmpDir = error "Haddock.ParserSpec.sTmpDir"
+      , sRawSettings = []
+      , sExtraGccViaCFlags = error "Haddock.ParserSpec.sExtraGccViaCFlags"
+      , sSystemPackageConfig = error "Haddock.ParserSpec.sSystemPackageConfig"
+      , sPgm_L = error "Haddock.ParserSpec.sPgm_L"
+      , sPgm_P = error "Haddock.ParserSpec.sPgm_P"
+      , sPgm_F = error "Haddock.ParserSpec.sPgm_F"
+      , sPgm_c = error "Haddock.ParserSpec.sPgm_c"
+      , sPgm_s = error "Haddock.ParserSpec.sPgm_s"
+      , sPgm_a = error "Haddock.ParserSpec.sPgm_a"
+      , sPgm_l = error "Haddock.ParserSpec.sPgm_l"
+      , sPgm_dll = error "Haddock.ParserSpec.sPgm_dll"
+      , sPgm_T = error "Haddock.ParserSpec.sPgm_T"
+      , sPgm_sysman = error "Haddock.ParserSpec.sPgm_sysman"
+      , sPgm_windres = error "Haddock.ParserSpec.sPgm_windres"
+      , sPgm_libtool = error "Haddock.ParserSpec.sPgm_libtool"
+      , sPgm_lo = error "Haddock.ParserSpec.sPgm_lo"
+      , sPgm_lc = error "Haddock.ParserSpec.sPgm_lc"
+      , sOpt_L = []
+      , sOpt_P = []
+      , sOpt_F = []
+      , sOpt_c = []
+      , sOpt_a = []
+      , sOpt_l = []
+      , sOpt_windres = []
+      , sOpt_lo = []
+      , sOpt_lc = []
+      , sLdSupportsCompactUnwind = error "Haddock.ParserSpec.sLdSupportsCompactUnwind"
+      , sLdSupportsBuildId  = error "Haddock.ParserSpec.sLdSupportsBuildId "
+      , sLdSupportsFilelist  = error "Haddock.ParserSpec.sLdSupportsFilelist "
+      , sLdIsGnuLd = error "Haddock.ParserSpec.sLdIsGnuLd"
+      , sPlatformConstants = platformConstants
+      }
+    platform = Platform {
+        platformArch = ArchUnknown
+      , platformOS = OSUnknown
+      , platformWordSize = 64
+      , platformHasGnuNonexecStack = False
+      , platformHasIdentDirective = False
+      , platformHasSubsectionsViaSymbols = False
+      , platformUnregisterised = error "Haddock.ParserSpec.platformUnregisterised"
+      }
+
+    platformConstants = PlatformConstants {
+        pc_platformConstants = ()
+      , pc_STD_HDR_SIZE = 0
+      , pc_PROF_HDR_SIZE = 0
+      , pc_BLOCK_SIZE = 0
+      , pc_BLOCKS_PER_MBLOCK = 0
+      , pc_OFFSET_StgRegTable_rR1 = 0
+      , pc_OFFSET_StgRegTable_rR2 = 0
+      , pc_OFFSET_StgRegTable_rR3 = 0
+      , pc_OFFSET_StgRegTable_rR4 = 0
+      , pc_OFFSET_StgRegTable_rR5 = 0
+      , pc_OFFSET_StgRegTable_rR6 = 0
+      , pc_OFFSET_StgRegTable_rR7 = 0
+      , pc_OFFSET_StgRegTable_rR8 = 0
+      , pc_OFFSET_StgRegTable_rR9 = 0
+      , pc_OFFSET_StgRegTable_rR10 = 0
+      , pc_OFFSET_StgRegTable_rF1 = 0
+      , pc_OFFSET_StgRegTable_rF2 = 0
+      , pc_OFFSET_StgRegTable_rF3 = 0
+      , pc_OFFSET_StgRegTable_rF4 = 0
+      , pc_OFFSET_StgRegTable_rF5 = 0
+      , pc_OFFSET_StgRegTable_rF6 = 0
+      , pc_OFFSET_StgRegTable_rD1 = 0
+      , pc_OFFSET_StgRegTable_rD2 = 0
+      , pc_OFFSET_StgRegTable_rD3 = 0
+      , pc_OFFSET_StgRegTable_rD4 = 0
+      , pc_OFFSET_StgRegTable_rD5 = 0
+      , pc_OFFSET_StgRegTable_rD6 = 0
+      , pc_OFFSET_StgRegTable_rXMM1 = 0
+      , pc_OFFSET_StgRegTable_rXMM2 = 0
+      , pc_OFFSET_StgRegTable_rXMM3 = 0
+      , pc_OFFSET_StgRegTable_rXMM4 = 0
+      , pc_OFFSET_StgRegTable_rXMM5 = 0
+      , pc_OFFSET_StgRegTable_rXMM6 = 0
+      , pc_OFFSET_StgRegTable_rL1 = 0
+      , pc_OFFSET_StgRegTable_rSp = 0
+      , pc_OFFSET_StgRegTable_rSpLim = 0
+      , pc_OFFSET_StgRegTable_rHp = 0
+      , pc_OFFSET_StgRegTable_rHpLim = 0
+      , pc_OFFSET_StgRegTable_rCCCS = 0
+      , pc_OFFSET_StgRegTable_rCurrentTSO = 0
+      , pc_OFFSET_StgRegTable_rCurrentNursery = 0
+      , pc_OFFSET_StgRegTable_rHpAlloc = 0
+      , pc_OFFSET_stgEagerBlackholeInfo = 0
+      , pc_OFFSET_stgGCEnter1 = 0
+      , pc_OFFSET_stgGCFun = 0
+      , pc_OFFSET_Capability_r = 0
+      , pc_OFFSET_bdescr_start = 0
+      , pc_OFFSET_bdescr_free = 0
+      , pc_OFFSET_bdescr_blocks = 0
+      , pc_SIZEOF_CostCentreStack = 0
+      , pc_OFFSET_CostCentreStack_mem_alloc = 0
+      , pc_REP_CostCentreStack_mem_alloc = 0
+      , pc_OFFSET_CostCentreStack_scc_count = 0
+      , pc_REP_CostCentreStack_scc_count = 0
+      , pc_OFFSET_StgHeader_ccs = 0
+      , pc_OFFSET_StgHeader_ldvw = 0
+      , pc_SIZEOF_StgSMPThunkHeader = 0
+      , pc_OFFSET_StgEntCounter_allocs = 0
+      , pc_REP_StgEntCounter_allocs = 0
+      , pc_OFFSET_StgEntCounter_allocd = 0
+      , pc_REP_StgEntCounter_allocd = 0
+      , pc_OFFSET_StgEntCounter_registeredp = 0
+      , pc_OFFSET_StgEntCounter_link = 0
+      , pc_OFFSET_StgEntCounter_entry_count = 0
+      , pc_SIZEOF_StgUpdateFrame_NoHdr = 0
+      , pc_SIZEOF_StgMutArrPtrs_NoHdr = 0
+      , pc_OFFSET_StgMutArrPtrs_ptrs = 0
+      , pc_OFFSET_StgMutArrPtrs_size = 0
+      , pc_SIZEOF_StgArrWords_NoHdr = 0
+      , pc_OFFSET_StgTSO_cccs = 0
+      , pc_OFFSET_StgTSO_stackobj = 0
+      , pc_OFFSET_StgStack_sp = 0
+      , pc_OFFSET_StgStack_stack = 0
+      , pc_OFFSET_StgUpdateFrame_updatee = 0
+      , pc_SIZEOF_StgFunInfoExtraRev = 0
+      , pc_MAX_SPEC_SELECTEE_SIZE = 0
+      , pc_MAX_SPEC_AP_SIZE = 0
+      , pc_MIN_PAYLOAD_SIZE = 0
+      , pc_MIN_INTLIKE = 0
+      , pc_MAX_INTLIKE = 0
+      , pc_MIN_CHARLIKE = 0
+      , pc_MAX_CHARLIKE = 0
+      , pc_MUT_ARR_PTRS_CARD_BITS = 0
+      , pc_MAX_Vanilla_REG = 0
+      , pc_MAX_Float_REG = 0
+      , pc_MAX_Double_REG = 0
+      , pc_MAX_Long_REG = 0
+      , pc_MAX_XMM_REG = 0
+      , pc_MAX_Real_Vanilla_REG = 0
+      , pc_MAX_Real_Float_REG = 0
+      , pc_MAX_Real_Double_REG = 0
+      , pc_MAX_Real_XMM_REG = 0
+      , pc_MAX_Real_Long_REG = 0
+      , pc_RESERVED_C_STACK_BYTES = 0
+      , pc_RESERVED_STACK_WORDS = 0
+      , pc_AP_STACK_SPLIM = 0
+      , pc_WORD_SIZE = 0
+      , pc_DOUBLE_SIZE = 0
+      , pc_CINT_SIZE = 0
+      , pc_CLONG_SIZE = 0
+      , pc_CLONG_LONG_SIZE = 0
+      , pc_BITMAP_BITS_SHIFT = 0
+      , pc_TAG_BITS = 0
+      , pc_WORDS_BIGENDIAN = False
+      , pc_DYNAMIC_BY_DEFAULT = False
+      , pc_LDV_SHIFT = 0
+      , pc_ILDV_CREATE_MASK = 0
+      , pc_ILDV_STATE_CREATE = 0
+      , pc_ILDV_STATE_USE = 0
+      , pc_OFFSET_StgRegTable_rYMM1 = 0
+      , pc_OFFSET_StgRegTable_rYMM2 = 0
+      , pc_OFFSET_StgRegTable_rYMM3 = 0
+      , pc_OFFSET_StgRegTable_rYMM4 = 0
+      , pc_OFFSET_StgRegTable_rYMM5 = 0
+      , pc_OFFSET_StgRegTable_rYMM6 = 0
+      , pc_OFFSET_StgRegTable_rZMM1 = 0
+      , pc_OFFSET_StgRegTable_rZMM2 = 0
+      , pc_OFFSET_StgRegTable_rZMM3 = 0
+      , pc_OFFSET_StgRegTable_rZMM4 = 0
+      , pc_OFFSET_StgRegTable_rZMM5 = 0
+      , pc_OFFSET_StgRegTable_rZMM6 = 0
+      , pc_OFFSET_StgFunInfoExtraFwd_arity = 0
+      , pc_REP_StgFunInfoExtraFwd_arity = 0
+      , pc_OFFSET_StgFunInfoExtraRev_arity = 0
+      , pc_REP_StgFunInfoExtraRev_arity = 0
+      }
